Skip to content

feat(p4): packrat memoization ON by default — parity corpus fallback 3→0 - #51

Merged
opaopa6969 merged 1 commit into
masterfrom
feat/p4-memoize-default-on
Jun 28, 2026
Merged

feat(p4): packrat memoization ON by default — parity corpus fallback 3→0#51
opaopa6969 merged 1 commit into
masterfrom
feat/p4-memoize-default-on

Conversation

@opaopa6969

Copy link
Copy Markdown
Owner

背景(fallback=0)

#40 packrat parse メモ化が parse-equivalent と実証され、#49 で mapping 段の再マッピングも解消した今、parity corpus が legacy にフォールバックする唯一の残因は 10s parse deadline 超過(memoize が opt-in/OFF だったため)でした。実測でフォールバックしていた3式:

if((1>0|10<20)&(true)){10}else{0} -> token-ast
if(not(toUpperCase('cnjpuszn')[4:6].in(...))){1}else{0} -> deadline -> legacy
if(not(not(... 同上 ...))){1}else{0} -> deadline -> legacy

memoize ON で3式とも高速 parse → p4-typed 経路で正答(10.0 / 0.0 / 1.0)。

変更

P4PreferredAstMapper の memoize を既定 ON化(-Dtinyexpression.p4.memoize=false で opt-out)。

効果

🤖 Generated with Claude Code

Now that packrat parse memoization (unlaxer-parser #40) is proven parse-equivalent
and the mapping phase no longer re-maps subtrees (#49), the only remaining reason
the curated/extracted parity corpus fell back to the legacy parser was the 10s
parse deadline being hit (memoize was opt-in/off). Three formulas fell back:
if((1>0|10<20)&(true)){10}else{0} -> token-ast
if(not(toUpperCase('cnjpuszn')[4:6].in(...))){1}else{0} -> deadline -> legacy
if(not(not(... same ...))){1}else{0} -> deadline -> legacy
With memoize ON all three parse fast and evaluate on the p4-typed path with
correct results (10.0 / 0.0 / 1.0). Flip the default to ON (opt out with
-Dtinyexpression.p4.memoize=false).
Effect:
- ThreeExecutionBackendExtractedCorpusParityTest: 0 legacy fallbacks (was 3),
wall time 100s -> 19s.
- P4AstEvaluatorCalculatorTest (giant nested-if fraud formulas, #38/#20): ~1263s
-> ~167s.
- Full suite 633 tests green; this also fixes the last baseline failure
(TernaryExpressionTest#testTernaryInSinWithDoubleParensStillWorks), so
test-baseline.txt is now empty.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@opaopa6969