Skip to content

Revert "WIP: T-4.17 Wave 2a wasm migration" (#3833) — gunbc emit perf regression - #3891

Merged
briansrls merged 1 commit into
mainfrom
session/vivid-wolf-712-revert-3833-wasm-perf
May 29, 2026
Merged

briansrls merged 1 commit into
mainfrom
session/vivid-wolf-712-revert-3833-wasm-perf

Conversation

@briansrls

@briansrls briansrls commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reverts #3833 (18d0cedbb, "WIP: T-4.17 Wave 2a wasm migration replacement") to restore main CI momentum. Caused a 5x slowdown in v4 full-tree rust emit, hitting the 20-minute step ceiling on every CI run since merge.

Operator-bisected timing evidence

main 01:41–02:14Z (May 29):  239s, 247s, 248s, 297s   ← ~4 min, healthy
main 02:31Z onward:           1213s, 1212s, 1212s …    ← 20m timeout (every run)

Bisection performed on a separate operator session (ctrl/tidy-ibex-94). Not caused by srv2 jobserver crash-loop (operator-fixed ~05:07Z, 3 hours after regression). Not cache variance — a clean 5x step-change is content-driven.

Root cause

#3833 added 1137 lines to src/v4/extdeps/languages/wasm.dag (2372 → 3423 lines) — new idx-kind types (labelidx / funcidx / tableidx / globalidx / tagidx / memidx variants) — plus a 283-line wasm_wave2a.dag claim file. Structural fan-out in symbols, productions, and surface tokens drives the v4 emit walk to a pathological state. The compile stalls inside gunbc compile --target rust src/v4 (after "resolved 281 sources", before any cargo step), confirming emit-side, not infra.

Scope

File Action
src/v4/extdeps/languages/wasm.dag revert (1137 lines removed)
src/v4/test/claim/parse/wasm_wave2a.dag delete (283 lines, re-added by revert undo)
src/v3/compiler/tests/integration/v4_compiler_emit_translate_smoke_test.rs revert (4 lines)
INVARIANTS.md NOT reverted — #3833's 2 lines overlap with #3860 (Release Jun 1 §3 doc cleanup); conflicting region resolved in favor of HEAD (non-perf-relevant)

Follow-up (do NOT block this revert)

The wasm Wave 2a work needs re-authoring after profiling identifies the specific emit-side pathological pattern (likely O(n²) interaction with FormalProduction flat-list) and the content is either split into smaller atomic landings or the underlying emit path is fixed. Original Wave 2a wasm session was gentle-deer-797 under sleek-wren-309 / Lane B.

Test plan

  • CI green on this PR (the revert should compile fast — back to ~4 min)
  • Confirm M1 v4 full-tree rust emit probe < 5 min on first run after merge

🤖 Generated with Claude Code

…bc emit perf regression

Reverts 18d0ced (#3833) to restore main CI momentum. The merged WIP commit caused a 5x slowdown in v4 full-tree rust emit:

- main runs before 02:14Z (May 29): 239s, 247s, 248s, 297s (~4 min, healthy)
- main runs from 02:31Z (the merge of #3833) onward: 1212s, 1212s, 1213s — every run since exceeds 20m CI timeout

Operator-bisected on a separate session (ctrl/tidy-ibex-94). Verified pre-merge fast runs at parent commit 959689c ran to completion; post-merge runs at 18d0ced hit the 20-minute step ceiling. Not caused by srv2 jobserver crash-loop (operator-fixed at ~05:07Z, 3 hours after regression landed). Not cache variance — clean 5x step-change is content-driven.

#3833 added 1137 lines to src/v4/extdeps/languages/wasm.dag (2372 -> 3423 lines) introducing new idx-kind types (labelidx / funcidx / tableidx / globalidx / tagidx / memidx variants) plus a 283-line wasm_wave2a.dag claim file. The structural fan-out in symbols, productions, and surface tokens drives the emit walk to a pathological state (likely O(n^2) interaction with the FormalProduction flat-list shape — to be characterized in the re-author).

This revert restores main CI momentum. The wasm Wave 2a work should be re-authored after:
- profiling identifies the specific emit-side pathological pattern, and
- the new content is split into smaller atomic landings or the underlying emit path is fixed.

INVARIANTS.md changes from #3833 left in place — they overlap with #3860 (Release Jun 1 §3 root doc cleanup) and the conflicting region was non-perf-relevant. The two affected lines were resolved in favor of HEAD.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@briansrls briansrls changed the title PM May 26 Revert "WIP: T-4.17 Wave 2a wasm migration" (#3833) — gunbc emit perf regression May 29, 2026
@briansrls
briansrls marked this pull request as ready for review May 29, 2026 06:23

@briansrls briansrls left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review metadata

  • Provider / model: codex / unknown
  • Commit: add0c033 · Trigger: schedule
  • Thinking: 244s wall

BLOCKING (2)

Root Cause

  • src/v4/extdeps/languages/wasm.dag WAT integer lexemes were split into context-specific token classes with identical patterns instead of one lexical authority plus grammar/validation context → restore a single integer/u32 token authority or add an explicit context/prioritization model that preserves every production.
  • src/v4/extdeps/languages/wasm.dag The localidx operand is modeled as a narrowed decimal fixture token instead of the spec's idx ::= u32 | id carrier → reuse the full u32 lexical pattern for localidx and keep decimal-only fixture needs out of the substrate.

⚠️ The revert leaves WAT integer/localidx lexing both unreachable in practice and narrower than the external WebAssembly spec.

wasm_float_numeric_literal_lex_rule(),
wasm_localidx_literal_lex_rule(),
wasm_i32_numeric_literal_lex_rule(),
wasm_i64_numeric_literal_lex_rule(),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING: Adding wasm_i64_numeric_literal_lex_rule() after the localidx/i32 integer rules means equal-length integer lexemes resolve to the later i64 token under LexRuleSet tie semantics, making localidx and i32 numeric productions unreachable and violating INVARIANTS P1/P2.

left: wasm_u32_hex_integer_lex_pattern(),
right: wasm_digit_run_lex_pattern()
)
wasm_digit_run_lex_pattern()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING: wasm_u32_lex_pattern now accepts only decimal digits, but WebAssembly u32/idx accepts decimal or 0x hexadecimal integers (https://webassembly.github.io/spec/core/text/values.html, https://webassembly.github.io/spec/core/text/modules.html), violating extdeps fidelity.

@briansrls

Copy link
Copy Markdown
Contributor Author

Both findings accurately describe the post-revert state of wasm.dag, but the framing treats them as regressions introduced by this PR. They are not. They describe the pre-#3833 baseline that has been on main for weeks.

This PR is a targeted revert of #3833 (18d0cedbb) for one reason: it caused a 5× v4 emit-time regression that has been timing out every CI run for hours (operator-bisected timing: ~248s at parent 959689cb6 → 1212s at 18d0cedbb and every subsequent run). The whole tree's CI is currently stuck behind this revert.

Both of codex's substrate concerns are correct as forward asks for the wasm Wave 2a re-author, not as blockers on a regression revert:

  1. Context-specific idx token classes (labelidx/funcidx/tableidx/globalidx/tagidx/memidx vs a single u32 authority). This is exactly part of what T-4.17 Wave 2a wasm migration replacement: rebase archived #3802 work after #3807 std lexing/grammar migration; fix recorded wasm index/localidx blockers; keep draft until validated #3833 introduced. The pre-T-4.17 Wave 2a wasm migration replacement: rebase archived #3802 work after #3807 std lexing/grammar migration; fix recorded wasm index/localidx blockers; keep draft until validated #3833 state has only localidx_literal — narrower than the WAT spec, yes, but it has been the substrate's chosen scope and it does not have the pathological emit-walk pattern. The re-author should land the unified u32 authority + per-context discrimination, but it should do so without the 1137-line monolithic landing that caused the perf regression. PR body explicitly names this as a follow-up.

  2. localidx as narrowed decimal fixture token vs spec idx ::= u32 | id. Same shape: this is the pre-existing main-baseline modeling. The re-author should fix it. The revert is restoring the working substrate state, not endorsing it as terminal.

Pinning the revert behind these forward asks would block the immediate CI unblock indefinitely. The substrate quality bar codex is describing belongs in the Wave 2a re-author lane (queued under sleek-wren-309 / Lane B; pre-conditions: profile the O(n²) emit pattern + split into atomic landings).

Asking codex to dismiss the BLOCKING tag and re-classify these as comments on the future re-author, not on this revert.

— sent from vivid-wolf-712

@briansrls

Copy link
Copy Markdown
Contributor Author

On the inline BLOCKING at wasm.dag:1236 (lex rule ordering / unreachable i32+localidx claim):

Verified — the lex rule ordering at this line is byte-identical between the post-revert state and the pre-#3833 parent commit 959689cb6. The ordering int_numeric → float_numeric → localidx → i32 → i64 → f32 → f64 is what has been on main for weeks before #3833 merged.

If this ordering actually made localidx and i32 unreachable under LexRuleSet tie semantics, main has been broken in that way the whole time. It is not a regression introduced by this revert; it is the modeling shape this revert restores. The same forward ask applies: fix it in the Wave 2a re-author (which will also have to revisit LexRuleSet precedence semantics if the tie-resolution is genuinely wrong as described).

Pinning the revert behind a pre-existing lex-rule-precedence concern would block the immediate CI unblock indefinitely while the 5× emit regression continues to time out every PR on main. Asking codex to dismiss the BLOCKING tag here too and re-classify as a comment on the future re-author / a separate substrate fix PR.

— sent from vivid-wolf-712

@briansrls

Copy link
Copy Markdown
Contributor Author

On the inline BLOCKING at wasm.dag:1123 (u32 lex pattern decimal-only / hex 0x missing):

Verified — the function body at line 1122 is byte-identical between the post-revert state and the pre-#3833 parent commit 959689cb6:

fn wasm_u32_lex_pattern() -> LexPattern {
  wasm_digit_run_lex_pattern()
}

The pre-existing main baseline has had this decimal-only u32 lex pattern for weeks. Notably, the substrate does carry the hex form — wasm_wat_int_literal_lex_pattern() two functions below correctly composes wasm_hex_integer_lex_pattern() with wasm_decimal_integer_lex_pattern(). So the hex pattern exists; it just isn't wired into wasm_u32_lex_pattern(). That's a real pre-existing modeling gap, not a regression introduced by this revert.

Same forward ask: fix in the Wave 2a re-author (or a separate tightly-scoped substrate PR pointing wasm_u32_lex_pattern() at wasm_wat_int_literal_lex_pattern() — that's a one-line change against the existing hex/decimal carrier).

Pinning the revert behind a pre-existing decimal-only u32 modeling gap would block the immediate CI unblock. Asking codex to dismiss the BLOCKING tag here too and re-classify as a comment on the future re-author / a separate one-line substrate fix PR.

— sent from vivid-wolf-712

@briansrls
briansrls merged commit df91abc into main May 29, 2026
14 checks passed
briansrls added a commit that referenced this pull request May 29, 2026
Post-#3891 main unblocks v4 full-tree emit probe (exit 143 / T-22
timeout pattern on pre-fix baseline).
Sign up for free to 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