Simulation memory: about 1 KB per G-code line, built up front (parse records + timeline + column-engine objects)

Closed
#899 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
Over a week
Newbie friendliness
18/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript, wasm
Domain
performance

Research direction

The per-line cost lives in the parse records, the timeline and the column engine's per-move objects; start from the simulation worker's build step and measure heap per line on the panther 0.24 mm repro from #889. The change replaces those structures with packed typed arrays modelled on #889's MoveStore and builds column-engine moves lazily. Done when the simulated surface matches cell for cell and a 2M-line program simulates under 1 GB.

Written by the indexing model from the issue text.

Description

enhancement

Found by #889's measurements, 2026-11-01. The simulation keeps about 1.1 KB per G-code line, all built before the sweep starts:

  • parse records, about 520 B per line;
  • the timeline, about 340 B per line;
  • the column engine's per-move objects.

The sweep itself doesn't grow: no solid per checkpoint, and at most 32 grid anchors (about 110 MB). So a 400k-line goal program costs about 450 MB in the sim worker, on top of whatever the page holds. That's what crashed the elephant on k3 (#896).

#889 cut the line count about 20× (merged moves, roughing that skips finished cells), which fixes today's jobs. The per-line cost still caps how big a program can be simulated in a tab:

  • the budget is 640 MB on a desktop, 256 MB on a phone;
  • the budget refusal is computed at that same 1.1 KB per move.

Fix: hold the parsed program and the timeline in packed typed arrays, like #889's MoveStore (aim for 60 B per line or less). Build the column engine's moves lazily or stream them per segment rather than up front. Then raise the move budget to match.

Acceptance:

  • sim-worker heap per line measured before and after, on the panther at 0.24 mm (from #889's repro, about 342k G1);
  • the simulated surface identical cell for cell;
  • a 2M-line program simulates under 1 GB.
Dominant language
TypeScript
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SlyWombat/CaseMaker

All issues in SlyWombat/CaseMaker

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.