Separate internal and user key comparators in BlockIter#6944
Separate internal and user key comparators in BlockIter#6944ajkr wants to merge 13 commits intofacebook:masterfrom
BlockIter#6944Conversation
fd10a11 to
2212f0b
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
2212f0b to
d3cdfd2
Compare
|
@ajkr has updated the pull request. Re-import the pull request |
d3cdfd2 to
4a01817
Compare
|
@ajkr has updated the pull request. Re-import the pull request |
1 similar comment
|
@ajkr has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
1667475 to
c87dd92
Compare
|
@ajkr has updated the pull request. Re-import the pull request |
1 similar comment
|
@ajkr has updated the pull request. Re-import the pull request |
pdillinger
left a comment
There was a problem hiding this comment.
LGTM! :)
I would request before landing: 'make check' under valgrind, and preemptively run stress test for a little while.
|
Perf note in HISTORY.md also might be warranted. Up to you. |
76b413c to
bdf25f3
Compare
|
@ajkr has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Thanks for the review!
Done, ran:
Done. The test failure (e.g., |
PR facebook#6944 transitioned `BlockIter` from using `Comparator*` to using concrete `UserComparatorWrapper` and `InternalKeyComparator`. However, adding them as instance variables to `BlockIter` was not optimal. Bloating `BlockIter` caused the `ArenaWrappedDBIter`'s arena allocator to do more heap allocations which harmed performance of `DB::NewIterator()`. This PR pushes down the concrete comparator objects to the point of usage, which forces them to be on the stack. As a result, the `BlockIter` is back to its original size prior to facebook#6944 (actually a bit smaller since there were two `Comparator*` before). Test Plan: verified our internal `DB::NewIterator()`-heavy regression test no longer reports regression.
Summary: PR #6944 transitioned `BlockIter` from using `Comparator*` to using concrete `UserComparatorWrapper` and `InternalKeyComparator`. However, adding them as instance variables to `BlockIter` was not optimal. Bloating `BlockIter` caused the `ArenaWrappedDBIter`'s arena allocator to do more heap allocations (in certain cases) which harmed performance of `DB::NewIterator()`. This PR pushes down the concrete comparator objects to the point of usage, which forces them to be on the stack. As a result, the `BlockIter` is back to its original size prior to #6944 (actually a bit smaller since there were two `Comparator*` before). Pull Request resolved: #7149 Test Plan: verified our internal `DB::NewIterator()`-heavy regression test no longer reports regression. Reviewed By: riversand963 Differential Revision: D22623189 Pulled By: ajkr fbshipit-source-id: f6d69accfe5de51e0bd9874a480b32b29909bab6
Summary: PR facebook#6944 transitioned `BlockIter` from using `Comparator*` to using concrete `UserComparatorWrapper` and `InternalKeyComparator`. However, adding them as instance variables to `BlockIter` was not optimal. Bloating `BlockIter` caused the `ArenaWrappedDBIter`'s arena allocator to do more heap allocations (in certain cases) which harmed performance of `DB::NewIterator()`. This PR pushes down the concrete comparator objects to the point of usage, which forces them to be on the stack. As a result, the `BlockIter` is back to its original size prior to facebook#6944 (actually a bit smaller since there were two `Comparator*` before). Pull Request resolved: facebook#7149 Test Plan: verified our internal `DB::NewIterator()`-heavy regression test no longer reports regression. Reviewed By: riversand963 Differential Revision: D22623189 Pulled By: ajkr fbshipit-source-id: f6d69accfe5de51e0bd9874a480b32b29909bab6
Replace
BlockIter::comparator_andIndexBlockIter::user_comparator_wrapper_with a concreteUserComparatorWrapperandInternalKeyComparator. The motivation for this change was the inconvenience of not knowing the concrete type ofBlockIter::comparator_, which prevented calling specialized internal key comparison functions to optimize comparison of keys with global seqno applied.Test Plan:
benchmark setup -- single file DBs, in-memory, no compression. "normal_db"
created by regular flush; "ingestion_db" created by ingesting a file. Both
DBs have same contents.
benchmark run command:
results: perf increased significantly for ingestion_db (enough to cover the losses in #6843) and changed negligibly for normal_db: