mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-24 10:30:38 +00:00
This is the continuaiton of the row-cache performance improvements, this time -- the rework of clustering keys part. The goal is to solve the same set of problems: - logN eviction complexity - deep and sparse tree Unlike partitions, this cache has one big feature that makes it impossible to just use existing B+ tree: There's no copyable key at hands. The clustering key is the managed_bytes() that is not nothrow-copy-constructibe, neither it's hash-able for lookup due to prefix lookup. Thus the choice is the B-tree, which is also N-ary one, but doesn't copy keys around. B-trees are like B+, but can have key:data pairs in inner nodes, thus those nodes may be significantly bigger then B+ ones, that have data-s only in leaf trees. Not to make the memory footprint worse, the tree assumes that keys and data live on the same object (the rows_entry one), and the tree itself manages only the key pointers. Not to invalidate iterators on insert/remove the tree nodes keep pointers on keys, not the keys themselves. The tree uses tri-compare instead of less-compare. This makes the .find and .lower_bound methods do ~10% less comparisons on random insert/lookup test. Numbers: - memory_footprint: B-tree master rows_entry size: 216 232 1 row in-cache: 968 960 (because of dummy entry) in-memtable: 1006 1022 100 rows in-cache: 50774 50856 in-memtable: 50620 50918 - mutation_test: B-tree master tps.average: 891177 833896 - simple_query: B-tree master tps.median: 71807 71656 tps.maximum: 71847 71708 * xemul/clustering-cache-over-btree-4: mutation_partition: Save one keys comparison partition_snapshot_row_cursor: Remove rows pointer mutation_partition: Use B-tree insertion sugar perf-test : Print B-tree sizes mutation_partition: Switch cache of rows onto B-tree partition_snapshot_reader: Rename cmp to less for explicity mutation_partition: Make insertion bullet-proof mutation_partition: Use tri-compare in non-set places flat_mutation_reader: Use clear() in destroy_current_mutation() rows_entry: Generalize compare utils: Intrusive B-tree (with tests) tests: Generalize bptree compaction test tests: Generalize bptree stress test