Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shrink size of HashSkipList buckets from 56B to 48B (#13424)
Summary: Previous order of fields in SkipList: `const uint16_t kMaxHeight_; // 2B` `const uint16_t kBranching_; // 2B` `const uint32_t kScaledInverseBranching_; // 4B` `Comparator const compare_; // 8B` `Allocator* const allocator_; // 8B` `Node* const head_; // 8B` `std::atomic<int> max_height_; // 4B` `// 4B padding added automatically for alignment` `Node** prev_; // 8B` `int32_t prev_height_; // 4B` `// 4B padding added automatically for alignment` = 56B in total. By swapping prev_ and prev_height_, we get the following: `const uint16_t kMaxHeight_; // 2B` `const uint16_t kBranching_; // 2B` `const uint32_t kScaledInverseBranching_; // 4B` `Comparator const compare_; // 8B` `Allocator* const allocator_; // 8B` `Node* const head_; // 8B` `std::atomic<int> max_height_; // 4B` `int32_t prev_height_; // 4B` `Node** prev_; // 8B` = 48B in total. So this change saves 8B per SkipList object. When allocated using AllocateAligned (as is the case for the [hash skiplist](https://github.com/facebook/rocksdb/blob/main/memtable/hash_skiplist_rep.cc#L243)) and assuming alignof(std::max_align_t) = 16, this change saves an additional 8B per SkipList object (so 16B in total). Note: this does not affect the "skiplist" memtable, which internally uses InlineSkipList Pull Request resolved: #13424 Reviewed By: cbi42 Differential Revision: D70423252 Pulled By: pdillinger fbshipit-source-id: 450dcc7f0e9e86cd3481f6930e83eea5fef78b97
- Loading branch information