perf: remove redundant explicit reverse range length - #1692
Open
samukweku wants to merge 4 commits into
Open
Conversation
Contributor
|
Collaborator
Author
|
Contract documentation is now included in this PR and its branch
An ELI5 explanation is included in the Python module docstring and |
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.
Summary
Closes the pyjanitor side of janitor-rs#107 and contributes to #23.
The Rust explicit reverse starts/ends kernels now derive their own bounded capacity hint and no longer accept a redundant
lengthargument. This change removes the corresponding Python-sideends.max() - starts.min()computation and stops passinglengthto the size kernel.ELI5: the Python layer was calculating a size estimate that Rust could calculate more safely from the actual ranges. Removing it keeps one source of truth and avoids reserving based on a potentially misleading span, especially with duplicate labels.
Performance and memory
The paired janitor-rs PR includes Criterion comparisons against the old HashMap-per-label implementation for unique and duplicate labels at n=32, 10,000, 100,000, and 1,000,000. The compact kernels are generally ~1.5–3x faster for min/max/prod/size and ~15–40% faster for sum, with broadly comparable memory and substantially lower peak live memory in representative duplicate-label cases. The benchmark records allocation count, allocated bytes, and peak live memory.
Verification
pixi-install, which was skipped because dependency resolution was unavailable due to a transient DNS failure; ruff, formatting, pydoclint, interrogate, whitespace, and file checks passed.Coordinated janitor-rs PR: branch
issue-107-explicit-ranges.