Skip to content

Commit

Permalink
table cache: include tableCacheNode, tableCacheValue in size metric
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RaduBerinde committed Nov 10, 2024
1 parent 461c46d commit e0a80cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion table_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion testdata/copy_checkpoint_options
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,4 @@ copy
index_block_size=262144
target_file_size=134217728
----
----
----
2 changes: 1 addition & 1 deletion testdata/ingest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions testdata/metrics
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e0a80cd

Please sign in to comment.