-
Notifications
You must be signed in to change notification settings - Fork 130
fix: benchmark black box handling #5558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude finished @joseph-isaacs's task —— View job
Code Review: Benchmark Black Box Handling
I've reviewed the changes to benchmark black box handling across the 5 modified files. Here's my analysis:
Summary of Changes
This PR systematically removes explicit
divan::black_box()calls from benchmark outputs and instead relies on Divan's implicit black-boxing behavior throughbench_refs()andbench_values(). The key pattern is:Before:
After:
Analysis
✅ Correct Approach
The changes are generally correct. According to Divan's documentation,
bench_refs()andbench_values()already black-box their return values automatically. The explicitblack_box()calls on outputs were redundant.✅ Input Handling Improvement
The more significant improvement is moving loop parameters into
with_inputs():This ensures loop bounds are treated as benchmark inputs and prevents the compiler from constant-folding based on knowing
lengthat compile time.Issues & Concerns
The CodSpeed report shows 11 regressions despite 31 improvements. The most notable regression is in
from_iter[Arrow<BooleanBuffer>, 128](-31.48%). This is puzzling because:from_iterbenchmark itself wasn't modified in the difffrom_iter- it never had any🔍 Specific File Review
vortex-array/benches/scalar_subtract.rs (Line 38):
✅ Correct - The result is now implicitly black-boxed by
bench_refs()vortex-buffer/benches/vortex_bitbuffer.rs (slice_arrow_buffer):
The changes to
slice_arrow_bufferat lines 147-154 are particularly relevant given the PR title mentions this benchmark:✅ Much better - Now
midis properly an input parameter rather than being captured from the outer scope. This should make measurements more stable.Recommendations
Monitor the regressions: The
from_iterregression seems unrelated to the changes and might indicate benchmark instability. Consider running benchmarks multiple times to verify stability.Consider one more optimization: In several places, you're still capturing
lengthfrom the outer scope for buffer creation:This is fine since the buffer creation happens outside the benchmark timing.
Documentation: Consider adding a comment explaining Divan's implicit black-boxing behavior so future contributors don't re-add explicit
black_box()calls.Verdict
LGTM with monitoring recommended ✅
The changes correctly remove redundant black-boxing and improve input handling. The improvements in
slice_arrow_buffer(the PR's focus) look good with +18.05% performance gains. The unrelated regressions warrant investigation but aren't necessarily caused by these changes.