Bypass the dispatch chain for inline-value comparison#70
Open
DRMacIver wants to merge 3 commits into
Open
Conversation
UBig/IBig ordering went through as_sign_typed -> TypedReprRef::cmp, which materialises slice references even for inline (<= DoubleWord) values. Add Repr::magnitude_cmp (compares inline values as a single DoubleWord, falls through to length-then-words for heap) and Repr::signed_cmp (adds sign handling on top, using the canonical-positive-zero invariant). UBig::cmp now calls magnitude_cmp directly (capacities are always positive) and IBig::cmp calls signed_cmp. cmp_in_place gains #[inline]. The existing cmp / num_order tests exercise every branch (mixed inline/heap operands and both signs). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Directly exercises magnitude_cmp / signed_cmp on equal-scale-different-value pairs and the inline/heap boundary, for both UBig and IBig, rather than relying on incidental coverage from the existing cmp tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
|
I think this problem needs more investigation. I have written a whole bunch of |
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.
Optimisations for order comparisons that bypass expensive operations on the fast path. Gives a 22-26% speedup on some of my benchmarks.
Benchmarks (layout-sampled, K=11)
Wall-clock, dashu-only, vs the merge base, measured under 11 randomised function layouts (
ld64 -order_file) and reported as the median — to average out the ±10% code-placement noise that otherwise swamps these small-value micro-benchmarks. The untouchedubig_mulcontrol reads 0.0% ± 0.0%, confirming a clean run.ubig_cmp(all classes)ubig_min(one/two-word)ubig_mul(control)