Perf: Memoize regex parsing in convertConditionToConditions - #1
Draft
collinversluis wants to merge 1 commit into
Draft
Perf: Memoize regex parsing in convertConditionToConditions#1collinversluis wants to merge 1 commit into
collinversluis wants to merge 1 commit into
Conversation
Phase 6 of the perf series.
The first half of convertConditionToConditions runs two regex .match() calls on
conditionName, returning four derived strings. The result depends only on the
string conditionName — not on the conditionValue, controlModel, values, or
controls arguments — yet the same names recur many times across element and
widget instances on a page ('selected_icon[value]!' once per heading-with-icon,
etc.). The user's CPU profile flagged convertConditionToConditions at 704ms
self-time on a 200-element page.
This adds a module-scoped Map cache keyed on conditionName with a 2000-entry
safety cap. No behavior change; cache miss runs the original regex work.
Not gated by an experiment flag — pure memoization with identical output, no
observable semantic change. Easy to revert via git revert if needed.
5 tasks
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
convertConditionToConditionsis called once per condition evaluation per element during editor boot. Each call re-parses the same condition strings into regex matches. Cache the parse result by raw input string.Impact
Profile-attributable savings depend on element count and condition density. On a 200-widget bench this lands a small but unconditional win (no flag to flip).
Test plan
Notes
Standalone cherry-pick from
claude/great-mayer-klkFh(perf-build fork). No dependency on any experiment. First of four planned surgical PRs from the perf branch.Generated by Claude Code