Compare syntax paths directly instead of via a generic lexicographic comparator#840
Draft
jackfirth wants to merge 1 commit into
Draft
Compare syntax paths directly instead of via a generic lexicographic comparator#840jackfirth wants to merge 1 commit into
jackfirth wants to merge 1 commit into
Conversation
…comparator `syntax-path<=>` was built with `(comparator-map (lexicographic-comparator natural<=>) syntax-path-elements)`. That generic implementation drives each comparison through `sequence-generate` on both treelists and crosses a contract boundary for every individual element comparison, which is expensive enough to dominate expansion analysis: `source-analyze` stores every visited syntax object in mutable sorted maps keyed by syntax path, so this comparator runs a logarithmic number of times per observed expansion event. Writing the comparison out as a direct indexed loop over the two treelists cuts analysis time for `xrepl-lib/xrepl/xrepl.rkt` (1877 lines) from ~78 seconds to ~44 seconds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Docs preview: https://resyntax.notjack.space/preview/840/ |
Contributor
There was a problem hiding this comment.
Resyntax analyzed 1 file in this pull request and found no issues.
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.
syntax-path<=>was(comparator-map (lexicographic-comparator natural<=>) syntax-path-elements). That generic implementation drives each comparison throughsequence-generateon both treelists and crosses a contract boundary for every individual element comparison. It's hot enough to dominate expansion analysis, sincesource-analyzekeeps every visited syntax object in sorted maps keyed by syntax path.Writing the comparison out as a direct indexed loop takes analysis of
xrepl-lib/xrepl/xrepl.rkt(1877 lines) from ~71s to ~44s.raco test -p resyntaxpasses.This overlaps with #842 — both attack the cost of
syntax-path<=>, so their speedups don't add. Together they come to ~36s.Found by profiling, in the same vein as #800.
Measurement note: figures are the minimum of 3 runs after a warmup. An earlier version of this description said ~78s → ~44s; that baseline was taken on a thermally throttled machine and overstated the ratio. Repeated runs on identical code vary by up to ~6% here, so treat differences smaller than that as unresolved.