Allow cross-crate inlining for BitSliceIterator - #10588
Open
connortsui20 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Contributor
|
looks good to me -- shall we perhaps add some comments explaining why the inline is needed in this case? |
alamb
approved these changes
Aug 8, 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.
Which issue does this PR close?
BitSliceIterator#10587.Rationale for this change
Downstream crates built without LTO cannot inline the
BitSliceIteratorhot path. This change also makesBitSliceIterator::nextconsistent with the annotatednextimplementations onBitIteratorandBitIndexIterator.Vortex discovered this gap while consuming
arrow-buffer58.4.0 from a separate crate.What changes are included in this PR?
Adds
#[inline]toBitSliceIterator::{new, advance_to_set_bit, next}andUnalignedBitChunk::iter.Are these changes tested?
Yes.
Instruction-count measurements
Vortex's original
arrow-buffer58.4.0 experiment measured 13,729 marginal instructions per iteration unmodified and 8,565 with fat LTO and one codegen unit. Annotating onlyBitSliceIterator::nextreduced the count to 13,151, while annotating the broader pre-bisection set reduced it to 10,026. The bisection on currentmainnarrows that set to the four methods in this PR.A local reproduction on current
mainmeasured the proposed change with a separate consumer crate:#[inline]Removing any one of the four attributes gives up part of the improvement:
#[inline]BitSliceIterator::newBitSliceIterator::advance_to_set_bitBitSliceIterator::nextUnalignedBitChunk::iterUnalignedBitChunk::newwas also tested because it constructs this path. Adding it to the four-method set increases the result from 7,584 to 8,331 instructions, or 9.8%, so this PR does not annotate it.The consumer iterates contiguous true runs over a 16,384-bit buffer at 1% density. It uses
opt-level = 3, 16 codegen units, and no LTO. Callgrind counts from runs of 1,000 and 2,000 iterations were differenced to remove startup and setup instructions.These are instruction counts, not wall-clock measurements.
On aarch64 macOS, the optimized
arrow-bufferrlib changes from 1,799,592 to 1,808,184 bytes, an increase of 8,592 bytes or 0.48%. The median release compile time across five forced builds with warm dependencies remains 1.19 seconds.Are there any user-facing changes?
No.