perf(tables): evaluate one bar-family anchor per distinct breadth - #470
Open
xenokratos wants to merge 1 commit into
Open
perf(tables): evaluate one bar-family anchor per distinct breadth#470xenokratos wants to merge 1 commit into
xenokratos wants to merge 1 commit into
Conversation
has_chart_bar_signature's bar_family closure runs per anchor rect: it builds the same-breadth family in O(n), then pairs that family against itself in O(family^2) to reject grid rows. Over every anchor that is O(n * family^2), and on a rect-dense page it dominates conversion - sample(1) attributes 9144 of 10047 samples, 91% of total time, to is_chart_bar_cluster. The closure body reads only the family, and the family is selected by breadth alone, so its result is a pure function of the anchor's breadth. Rect-dense pages repeat the same widths hundreds of times, and each repeat recomputed an identical answer. Evaluating one anchor per distinct breadth returns the same result: a repeat can only reproduce the earlier one, and that one was false or the `any` would already have stopped. Breadths are compared by bit pattern so near-equal widths are still evaluated separately. tests/fixtures/bits_pilani_feedback.pdf via pdf2md: 26.8s -> 2.1s, with byte-identical markdown output (1315546 bytes). 1199 existing tests pass unchanged.
There was a problem hiding this comment.
No issues found across 1 file
Shadow auto-approve: would auto-approve. Memoizes bar-family evaluation by distinct breadth, skipping repeated anchors. Since the result is a pure function of breadth, behavior is preserved; rect-dense conversion drops from 26.8s to 2.1s with byte-identical output and 1199 tests passing.
Re-trigger cubic
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.
Fixes #469.
bar_familyselects its family by breadth alone, and every later test reads only that family — so the closure's result is a pure function of the anchor's breadth. Rect-dense pages repeat the same widths hundreds of times, each recomputing an identical answer.Evaluating one anchor per distinct breadth returns the same result: a repeat can only reproduce the earlier one, and that one was
falseor theanywould already have stopped. Breadths compare by bit pattern, so near-equal widths are still evaluated separately.On
tests/fixtures/bits_pilani_feedback.pdfviapdf2md: 26.8s → 2.1s, markdown byte-identical (1,315,546 bytes). 1199 existing tests pass unchanged.Summary by cubic
Memoizes
bar_familyevaluation by distinct breadth, fixing #469. Rect-dense page conversion drops from 26.8s to 2.1s with byte-identical output (1,315,546 bytes).Repeats can only reproduce an earlier result since the closure reads only the breadth-selected family. Breadths compare by bit pattern, so near-equal widths are still evaluated separately. 1199 existing tests pass unchanged.
Written for commit 95a7b6d. Summary will update on new commits.