Repository navigation
Conversation
reduce visited every input cell through indexed() and computed the output index with result.at(idx) per cell. It now builds one lookup table per axis which maps each stored input position to an output offset, or marks it as skipped, and runs a nested strided loop over the raw storage. Skipped outer slabs are skipped as a block, so crop and pick in crop mode scale with the output size. For arithmetic dense storages, runs of input cells which land in the same output cell are summed in a local accumulator, in the same order as before. Adds pick benchmarks which mirror the boost-histogram python benchmarks, and a test with large axes which exercises the heap-backed lookup table. Assisted-by: ClaudeCode:claude-fable-5-1 ClaudeCode:claude-fable-5-1
Drop reduce_command::lut and fill the per-axis table for pick commands directly, which removes a heap allocation per picked axis and the underflow special case. Use axis::traits::extent for the axis extent and share the setup of the pick benchmarks. Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
Contributor
Author
|
The stack reduce branch saves a little time, but I don't think it's worth it (done manually, there is |
The stack buffer saved about 12 ns per call, visible only on 1D histograms with few bins. Assisted-by: ClaudeCode:claude-fable-5-1
Assisted-by: ClaudeCode:claude-opus-5-5
henryiii
marked this pull request as ready for review
November 2, 2026 15:09
This branch has not been deployed
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.
This is a follow-up to #429. This now runs faster than the numpy version of this operation in boost-histogram.
I have a followup on this followup as well that gets another performance boost for smaller growing axes (1.2-2x) and combines parts of
reduce(reduce_axis_mapandreduce_fill) andstorage_grower(multi-index loop and per-cellfor_each_axis) into a singlecell_map(roughly the same number of LoC). I can't make a stacked PR on a branch in a fork, so I will open it as a draft that depends on this PR, and can rebase it if this goes in.🤖 AI text below 🤖
reducevisited every input cell withindexed()and calledresult.at(idx)for each one, which recomputes the linear index through the axes. This PR builds one lookup table per axis, which maps each stored input position to an output offset or a skip marker, and runs a nested strided loop over raw storage. Skipped outer slabs are skipped as a block, socropandpickwithslice_mode::cropscale with the output size. For arithmetic dense storages, runs of input cells that land in the same output cell are summed in a local accumulator, in the same order as before.Tables with up to 256 entries live on the stack.Benchmark on Apple Silicon, 3 ×
category<std::string>(32) +regular(32), dense double storage:The existing rebin/shrink benchmarks improve as well: 3D dense up to 13x, 2D dense up to 7x, unlimited 3D about 3.5x, small 1D histograms 1.2x to 2.5x.
Also adds
Pick,PickCrop, andPickAndSlicebenchmarks which mirror the boost-histogram Python benchmarks, and a test with 300 × 300 bins which exercises the heap-backed lookup table. The new test passes against the old implementation too.