Memoise mk_prec_matrix - #2063
Open
mrichards30 wants to merge 2 commits into
Open
mrichards30 wants to merge 2 commits into
mrichards30 wants to merge 2 commits into
Conversation
Contributor
|
Can this be done by having the partial application not become stale for useless updates like defining a constant instead? |
Member
|
I think I'd prefer a world where the matrix is stored in the grammar as an option ref value. If :
then the new grammar's pointer can point to the old matrix. Otherwise, the new grammar either gets a fresh pointer with Subsequently, the If the rest 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.
Hi, I was playing around with some vibe coded profiling/flame graph tools I got Claude to put into my copy of PolyML, and found a few places when building theories that seem pretty straight forward to optimise. The first of them is that building the precedence matrix for the term parser in
mk_prec_matrixshows up a surprising amount in the flame graph.Here,
mk_prec_matrixis in pink and it's showing as 11.4% of the build.So it seems like the precedence matrix is being rebuilt a bit more often than it needs to. In this PR I've memoised it so it only re-computes when grammar rules and "specials" are changed (the only two fields
mk_prec_matrixreads). This is cutting my build time (building kernel, core_theories, and more_theories) from an average of 957s to 876s.After the change the flame graph shows
mk_prec_matrixhaving gone down to 2.1% (still in pink).