Skip to content

Cap LT/LOAD/BRANCH/MEMW_R max_rows at 2^20#499

Merged
MauroToscano merged 3 commits into
mainfrom
perf/cap-narrow-tables-max-rows
Apr 15, 2026
Merged

Cap LT/LOAD/BRANCH/MEMW_R max_rows at 2^20#499
MauroToscano merged 3 commits into
mainfrom
perf/cap-narrow-tables-max-rows

Conversation

@gabrielbosio

Copy link
Copy Markdown
Collaborator

Tables with effective width < 42 were sized at 2^21, producing single large chunks. Capping at 2^20 produces 2x more chunks of the standard size, improving parallel throughput and keeping peak memory per chunk uniform across all tables.

Tables with effective width < 42 were sized at 2^21, producing single
large chunks. Capping at 2^20 produces 2x more chunks of the standard
size, improving parallel throughput and keeping peak memory per chunk
uniform across all tables.
@gabrielbosio

Copy link
Copy Markdown
Collaborator Author

/bench

@github-actions

Copy link
Copy Markdown

Codex Code Review

No actionable issues found in this PR diff.

Residual risk/testing gap:

  • This is a behavioral limit change (LT, LOAD, BRANCH, MEMW_R from 2^21 to 2^20 in prover/src/tables/mod.rs). I don’t see a security or logic flaw in the change itself, but it does intentionally make some previously-accepted large traces fail earlier with table-overflow. Boundary tests around 2^20 rows for those tables would be the main validation point.

Comment thread prover/src/tables/mod.rs Outdated
@claude

claude Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Review: Cap LT/LOAD/BRANCH/MEMW_R max_rows at 2^20

Overall: Clean, minimal change. The rationale is sound — capping these four narrow-width tables at 2^20 instead of the formula-derived 2^21 doubles chunk count for better parallel throughput and keeps per-chunk peak memory uniform.

One issue

[Low — Documentation] The newly added paragraph ends with:

"Programs that exceed 2^20 rows in a capped table hit a table-overflow error."

This is incorrect. These constants are chunk sizes, not absolute row limits. In trace_builder.rs they're passed to ops.chunks(max_rows), so programs exceeding 2^20 rows in a capped table just produce more chunks — no error occurs. See inline comment for a suggested correction.

Everything else looks good

  • Constants, inline comments, and doc table are all mutually consistent.
  • MaxRowsConfig::default() correctly picks up the new values.
  • No tests hardcode the old 1 << 21 for these tables.

@github-actions

Copy link
Copy Markdown

Benchmark — fib_iterative_8M (median of 3)

Table parallelism: 32 (auto = cores / 3)

Metric main PR Δ
Peak heap 221287 MB 126817 MB -94470 MB (-42.7%) 🟢
Prove time 46.408s 46.183s -0.225s (-0.5%) ⚪

🎉 Improvement detected — heap or time decreased by more than 5%.

⚠️ Prove time spread: 5.3% (44.305s / 46.736s / 46.183s)
Consider re-running /bench

Commit: d36b05b · Baseline: built from main · Runner: self-hosted bench

@gabrielbosio
gabrielbosio marked this pull request as ready for review April 15, 2026 18:02
@github-actions

Copy link
Copy Markdown

Codex Code Review

No issues found in the PR diff.

I reviewed only the changes in prover/src/tables/mod.rs, and I don’t see:

  • security vulnerabilities,
  • logic bugs,
  • significant performance issues, or
  • unnecessary complexity.

The change is a clear, intentional behavioral cap (2^21 -> 2^20) for LT, LOAD, BRANCH, and MEMW_R, and the documentation/comments were updated consistently to match.

@claude

claude Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Review: Cap LT/LOAD/BRANCH/MEMW_R max_rows at 2^20

The change is clean and well-motivated. The docs are clearly updated and the rationale is sound: narrow tables produced 2^21-row single-threaded chunks; halving to 2^20 produces standard-sized chunks that parallelize properly.

Potential bug / Breaking change

The new cap cuts the per-table row capacity in half. Programs with between 2^20 and 2^21 rows in any of LT, LOAD, BRANCH, or MEMW_R now fail with a table-overflow error where they previously succeeded. The doc comment acknowledges this (Programs that exceed 2^20 rows in a capped table hit a table-overflow error), but there's no discussion of whether any real programs or benchmarks approach these limits.

A CPU table capped at 2^19 means at most 524 288 CPU steps, so hitting 2^20 LOAD rows requires on average >2 LOAD ops per CPU step (e.g. unaligned loads that split into multiple entries). Whether that's reachable in practice is worth explicitly checking against your benchmark suite before merging.

No tests for new threshold

There are no tests that verify overflow fires at 2^20 rather than 2^21 for these tables. Given that this is a deliberate capacity reduction, a regression test covering the new boundary would be valuable.

Minor doc nit

The PR description says "Tables with effective width < 42" but LT has effective width exactly 42 (not strictly less than). Should be "≤ 42" or just list the four tables explicitly.

Comment thread prover/src/tables/mod.rs Outdated
@MauroToscano
MauroToscano enabled auto-merge April 15, 2026 20:31
@MauroToscano
MauroToscano added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit 902e102 Apr 15, 2026
10 checks passed
@MauroToscano
MauroToscano deleted the perf/cap-narrow-tables-max-rows branch April 15, 2026 20:48
jotabulacios pushed a commit that referenced this pull request Apr 16, 2026
* perf(tables): cap LT/LOAD/BRANCH/MEMW_R max_rows at 2^20

Tables with effective width < 42 were sized at 2^21, producing single
large chunks. Capping at 2^20 produces 2x more chunks of the standard
size, improving parallel throughput and keeping peak memory per chunk
uniform across all tables.

* Drop incorrect overflow claim from max_rows doc

* Drop (capped) annotations from max_rows doc

---------

Co-authored-by: diegokingston <dkingston@fi.uba.ar>
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.

3 participants