Chunk recoder optimization#297
Merged
Merged
Conversation
…ecoder_optimization
…ecoder_optimization
vporoshok
requested changes
Apr 28, 2026
Collaborator
vporoshok
left a comment
There was a problem hiding this comment.
Thanks for the optimization — the benchmark numbers look nice. However, there are several serious concerns plus a handful of minor ones; see inline comments.
Blockers (must be addressed before merge):
- UB through
std::variantinUniversalDecodeIterator::operator*/operator->—reinterpret_castover the variant's storage relies on stdlib implementation details. Thestatic_assertbelow only checkssample_'s offset within each alternative, not the layout ofstd::variantitself. UniversalDecodeIterator::set— same issue but with a write; the method is not even used in this PR.
Important:
- This PR adds but does not use:
seek_to,invalidate_sample,set,SeekResult::kUpdateSampleNextAndStop,UniversalDecodeIterator::Type. Better to introduce them in the PR that actually needs them. - Typo
Universalein the public concept nameAssignableFromUniversaleDecodeIterator. [[likely]]on thekUpdateSamplebranch inseekis misplaced — the hot path here isChunkRecoder, which always returnskNext.noexceptwas dropped fromUniversalDecodeIterator::operator==/operator++— no throwing handler involved there.
Nice to have:
- The LE assumption in
bstream.h::write_byte(at minimum, addstatic_assert(std::endian::native == std::endian::little), or align the style with the existingBareBones::Bit::be(...)usage). varint_bufferwithout{}-initialization inxor.h— needs a contract comment.[[likely]]on two consecutive branches inxor.h.std::ignore = timestamp_decoder_.decode();intraits.h.- The public default constructor of
UniversalDecodeIteratorcreates a "dummy" state. - The PR description should explain which technique contributes how much — in particular, whether bypassing
std::variantis actually required for the +14%. - Nit: missing trailing newline in
traits.h.
…ecoder_optimization
vporoshok
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
// Before optimization
BenchmarkChunkRecoder_min 869701624 ns
// After optimization
BenchmarkChunkRecoder_min 745188236 ns
Boost: ~14%