mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-01 13:45:53 +00:00
managed_bytes is implemented as chain of blob_storage objects. Each blob_storage contains 24 bytes of metadata. But in the most common case -- when there is only a single element in the chain -- 16 bytes of this metadata is trivial/unused. This is regrettable waste because managed_bytes is used for every database cell in the memtables and cache. It means that every value of size >= 7 bytes (smaller ones fit in the inline storage of managed_bytes) receives 16 bytes of useless overhead. To correct that, this series adds to managed_bytes an alternative storage layout -- used for buffers small enough to fit in one fragment -- which only stores the necessary minimum of metadata. (That is: a pointer to the parent, to facilitate moving the storage during memory defragmentation). This saves 16 bytes on every cell greater than 15 bytes. Which includes e.g. every live cell with value bigger than 6 bytes, which likely applies to most cells. Before: ``` $ build/release/scylla perf-simple-query --duration 10 median 218692.88 tps ( 61.1 allocs/op, 13.1 tasks/op, 41762 insns/op, 0 errors) $ build/release/scylla perf-simple-query --duration 10 --write median 173511.46 tps ( 58.3 allocs/op, 13.2 tasks/op, 53258 insns/op, 0 errors) $ build/release/test/perf/mutation_footprint_test -c1 --row-count=20 --partition-count=100 --data-size=8 --column-count=16 - in cache: 2580222 - in memtable: 2549852 ``` After: ``` $ build/release/scylla perf-simple-query --duration 10 median 218780.89 tps ( 61.1 allocs/op, 13.1 tasks/op, 41763 insns/op, 0 errors) $ build/release/scylla perf-simple-query --duration 10 --write median 173105.78 tps ( 58.3 allocs/op, 13.2 tasks/op, 52913 insns/op, 0 errors) $ build/release/test/perf/mutation_footprint_test -c1 --row-count=20 --partition-count=100 --data-size=8 --column-count=16 - in cache: 2068238 - in memtable: 2037696 ``` Closes scylladb/scylladb#14263 * github.com:scylladb/scylladb: utils: managed_bytes: optimize memory usage for small buffers utils: managed_bytes: rewrite managed_bytes methods in terms of managed_bytes_view