From e0a80cdedb3f7d64baac7eb50ce94f47655db8b8 Mon Sep 17 00:00:00 2001 From: Radu Berinde Date: Sun, 10 Nov 2024 07:05:33 -0800 Subject: [PATCH] table cache: include tableCacheNode, tableCacheValue in size metric We currently only count the size of the `sstable.Reader()` in the table cache size metric. This commit adds the sizes of the `tableCacheNode` and `tableCacheValue` as well. --- table_cache.go | 2 +- testdata/copy_checkpoint_options | 2 +- testdata/ingest | 2 +- testdata/metrics | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/table_cache.go b/table_cache.go index d9cfd8a3fc..848b202361 100644 --- a/table_cache.go +++ b/table_cache.go @@ -202,7 +202,7 @@ func (c *tableCacheContainer) metrics() (CacheMetrics, FilterMetrics) { m.Hits += s.hits.Load() m.Misses += s.misses.Load() } - m.Size = m.Count * int64(unsafe.Sizeof(sstable.Reader{})) + m.Size = m.Count * int64(unsafe.Sizeof(tableCacheNode{})+unsafe.Sizeof(tableCacheValue{})+unsafe.Sizeof(sstable.Reader{})) f := c.dbOpts.readerOpts.FilterMetricsTracker.Load() return m, f } diff --git a/testdata/copy_checkpoint_options b/testdata/copy_checkpoint_options index 59818c53f4..83dfc220d6 100644 --- a/testdata/copy_checkpoint_options +++ b/testdata/copy_checkpoint_options @@ -346,4 +346,4 @@ copy index_block_size=262144 target_file_size=134217728 ---- ----- \ No newline at end of file +---- diff --git a/testdata/ingest b/testdata/ingest index 29eb2e3b9a..b902079149 100644 --- a/testdata/ingest +++ b/testdata/ingest @@ -54,7 +54,7 @@ Virtual tables: 0 (0B) Local tables size: 569B Compression types: snappy: 1 Block cache: 3 entries (1.1KB) hit rate: 18.2% -Table cache: 1 entries (760B) hit rate: 50.0% +Table cache: 1 entries (864B) hit rate: 50.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0 diff --git a/testdata/metrics b/testdata/metrics index 4d03197154..37c32771b7 100644 --- a/testdata/metrics +++ b/testdata/metrics @@ -76,7 +76,7 @@ Virtual tables: 0 (0B) Local tables size: 589B Compression types: snappy: 1 Block cache: 2 entries (716B) hit rate: 0.0% -Table cache: 1 entries (760B) hit rate: 0.0% +Table cache: 1 entries (864B) hit rate: 0.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 1 @@ -136,7 +136,7 @@ Virtual tables: 0 (0B) Local tables size: 595B Compression types: snappy: 1 Block cache: 2 entries (716B) hit rate: 33.3% -Table cache: 2 entries (1.5KB) hit rate: 66.7% +Table cache: 2 entries (1.7KB) hit rate: 66.7% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 2 @@ -183,7 +183,7 @@ Virtual tables: 0 (0B) Local tables size: 595B Compression types: snappy: 1 Block cache: 2 entries (716B) hit rate: 33.3% -Table cache: 2 entries (1.5KB) hit rate: 66.7% +Table cache: 2 entries (1.7KB) hit rate: 66.7% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 2 @@ -227,7 +227,7 @@ Virtual tables: 0 (0B) Local tables size: 595B Compression types: snappy: 1 Block cache: 2 entries (716B) hit rate: 33.3% -Table cache: 1 entries (760B) hit rate: 66.7% +Table cache: 1 entries (864B) hit rate: 66.7% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 1 @@ -510,7 +510,7 @@ Virtual tables: 0 (0B) Local tables size: 4.3KB Compression types: snappy: 7 Block cache: 8 entries (2.8KB) hit rate: 9.1% -Table cache: 1 entries (760B) hit rate: 53.8% +Table cache: 1 entries (864B) hit rate: 53.8% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0 @@ -575,7 +575,7 @@ Virtual tables: 0 (0B) Local tables size: 6.1KB Compression types: snappy: 10 Block cache: 8 entries (2.8KB) hit rate: 9.1% -Table cache: 1 entries (760B) hit rate: 53.8% +Table cache: 1 entries (864B) hit rate: 53.8% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0 @@ -853,7 +853,7 @@ Virtual tables: 0 (0B) Local tables size: 0B Compression types: snappy: 1 Block cache: 0 entries (0B) hit rate: 0.0% -Table cache: 1 entries (760B) hit rate: 0.0% +Table cache: 1 entries (864B) hit rate: 0.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0 @@ -901,7 +901,7 @@ Virtual tables: 0 (0B) Local tables size: 0B Compression types: snappy: 2 Block cache: 4 entries (1.4KB) hit rate: 0.0% -Table cache: 1 entries (760B) hit rate: 50.0% +Table cache: 1 entries (864B) hit rate: 50.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0 @@ -950,7 +950,7 @@ Virtual tables: 0 (0B) Local tables size: 589B Compression types: snappy: 3 Block cache: 4 entries (1.4KB) hit rate: 0.0% -Table cache: 1 entries (760B) hit rate: 50.0% +Table cache: 1 entries (864B) hit rate: 50.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0