From 3b862af3289eceabb64dcd82f73ba8bfcce81960 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 23 Jan 2024 20:16:27 +0000 Subject: [PATCH] sstable: capture elided prefix in a prop --- sstable/properties.go | 7 ++++++- sstable/testdata/writer | 4 +++- sstable/writer.go | 1 + testdata/event_listener | 4 ++-- testdata/ingest | 2 +- testdata/metrics | 8 ++++---- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sstable/properties.go b/sstable/properties.go index 3bbf34a8af..53932d73d2 100644 --- a/sstable/properties.go +++ b/sstable/properties.go @@ -134,6 +134,9 @@ type Properties struct { CompressionOptions string `prop:"rocksdb.compression_options"` // The total size of all data blocks. DataSize uint64 `prop:"rocksdb.data.size"` + // ElidedPrefix is the byte prefix, if any, that was elided from every key and + // key span during the construction of the sstable. + ElidedPrefix string `prop:"pebble.elided_prefix"` // The external sstable version format. Version 2 is the one RocksDB has been // using since 5.13. RocksDB only uses the global sequence number for an // sstable if this property has been set. @@ -428,7 +431,9 @@ func (p *Properties) save(tblFormat TableFormat, w *rawBlockWriter) { p.saveUvarint(m, unsafe.Offsetof(p.ValueBlocksSize), p.ValueBlocksSize) } p.saveBool(m, unsafe.Offsetof(p.WholeKeyFiltering), p.WholeKeyFiltering) - + if p.ElidedPrefix != "" { + p.saveString(m, unsafe.Offsetof(p.ElidedPrefix), p.ElidedPrefix) + } if tblFormat < TableFormatPebblev1 { m["rocksdb.column.family.id"] = binary.AppendUvarint([]byte(nil), math.MaxInt32) m["rocksdb.fixed.key.length"] = []byte{0x00} diff --git a/sstable/testdata/writer b/sstable/testdata/writer index 44236a09cb..492f9a9dc4 100644 --- a/sstable/testdata/writer +++ b/sstable/testdata/writer @@ -369,7 +369,7 @@ layout 821 footer (53) 874 EOF -build elide-prefix=foo_ +build elide-prefix=foo_ props=(elided) foo_a.SET.1:a foo_b.DEL.2: foo_c.MERGE.3:c @@ -386,3 +386,5 @@ point: [a#1,1-h#7,2] rangedel: [d#4,15-j#72057594037927935,15] rangekey: [j#9,19-m#72057594037927935,21] seqnums: [1-11] +props "elided": + pebble.elided_prefix: foo_ diff --git a/sstable/writer.go b/sstable/writer.go index 4322b062c2..08d61365f2 100644 --- a/sstable/writer.go +++ b/sstable/writer.go @@ -2303,6 +2303,7 @@ func NewWriter(writable objstorage.Writable, o WriterOptions, extraOpts ...Write w.props.MergerName = o.MergerName w.props.PropertyCollectorNames = "[]" w.props.ExternalFormatVersion = rocksDBExternalFormatVersion + w.props.ElidedPrefix = string(o.ElidePrefix) if len(o.BlockPropertyCollectors) > 0 || w.tableFormat >= TableFormatPebblev4 { var buf bytes.Buffer diff --git a/testdata/event_listener b/testdata/event_listener index ad32671e53..7684bb988f 100644 --- a/testdata/event_listener +++ b/testdata/event_listener @@ -222,7 +222,7 @@ Zombie tables: 0 (0B) Backing tables: 0 (0B) Virtual tables: 0 (0B) Block cache: 6 entries (1.1KB) hit rate: 11.1% -Table cache: 1 entries (808B) hit rate: 40.0% +Table cache: 1 entries (824B) hit rate: 40.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0 @@ -321,7 +321,7 @@ Zombie tables: 0 (0B) Backing tables: 0 (0B) Virtual tables: 0 (0B) Block cache: 12 entries (2.3KB) hit rate: 14.3% -Table cache: 1 entries (808B) hit rate: 50.0% +Table cache: 1 entries (824B) 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/ingest b/testdata/ingest index 22a7f14bd1..eab7139455 100644 --- a/testdata/ingest +++ b/testdata/ingest @@ -52,7 +52,7 @@ Zombie tables: 0 (0B) Backing tables: 0 (0B) Virtual tables: 0 (0B) Block cache: 6 entries (1.2KB) hit rate: 35.7% -Table cache: 1 entries (808B) hit rate: 50.0% +Table cache: 1 entries (824B) 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 55a1beacc1..121de6cd85 100644 --- a/testdata/metrics +++ b/testdata/metrics @@ -68,7 +68,7 @@ Zombie tables: 0 (0B) Backing tables: 0 (0B) Virtual tables: 0 (0B) Block cache: 3 entries (556B) hit rate: 0.0% -Table cache: 1 entries (808B) hit rate: 0.0% +Table cache: 1 entries (824B) hit rate: 0.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 1 @@ -201,7 +201,7 @@ Zombie tables: 1 (661B) Backing tables: 0 (0B) Virtual tables: 0 (0B) Block cache: 3 entries (556B) hit rate: 42.9% -Table cache: 1 entries (808B) hit rate: 66.7% +Table cache: 1 entries (824B) hit rate: 66.7% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 1 @@ -467,7 +467,7 @@ Zombie tables: 0 (0B) Backing tables: 0 (0B) Virtual tables: 0 (0B) Block cache: 12 entries (2.4KB) hit rate: 24.5% -Table cache: 1 entries (808B) hit rate: 60.0% +Table cache: 1 entries (824B) hit rate: 60.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0 @@ -528,7 +528,7 @@ Zombie tables: 0 (0B) Backing tables: 0 (0B) Virtual tables: 0 (0B) Block cache: 12 entries (2.4KB) hit rate: 24.5% -Table cache: 1 entries (808B) hit rate: 60.0% +Table cache: 1 entries (824B) hit rate: 60.0% Secondary cache: 0 entries (0B) hit rate: 0.0% Snapshots: 0 earliest seq num: 0 Table iters: 0