Skip to content

perf(line): the asm cache is in the image, not read at the first prompt - #229

Merged
jonruttan merged 2 commits into
mainfrom
perf/line-asm-cache
Nov 10, 2026
Merged

jonruttan merged 2 commits into
mainfrom
perf/line-asm-cache

Conversation

@jonruttan

Copy link
Copy Markdown
Owner

On a terminal, python printed its banner and never drew a prompt in x-os's container. Memory climbed past 1.4 GB, and the 3.7 GB podman VM killed it after about 24 s. With piped stdin it answers in 1.3 s.

The terminal path is the difference. python/line.x makes its lexer, for painting and bracket marks, at the first prompt, and the first Lexer make in a process imports x/tool/asm-cache. Nothing imported that module where the image is written, so each terminal session read it from source under the numeric tower's reader. x-lang's Lexer doc names this cost and says to import x/tool/asm-cache where the image is written. This PR does that in python/line.x.

Companion: jonruttan/x-os#83 adds a python session to x-os's warm.exp, so the lexer's compiled states are also in the image's code cache.

Not yet measured. A local before/after (time to first >>> on a tty, peak RSS, on x-lang v0.44.0) is queued behind the host's memory gate. I'll post the numbers here when it runs.

🤖 Generated with Claude Code

jonruttan and others added 2 commits November 4, 2026 21:05
The first Lexer make in a process imports x/tool/asm-cache, and python/line
makes its lexer lazily at a terminal session's first prompt.  Nothing
imported the module where the image is written, so every terminal session
read it from source under the numeric tower's reader: in x-os's container
(a 3.7 GB podman VM) the banner printed, memory climbed past 1.4 GB, and
the session was killed with no prompt.  Piped sessions never make the
lexer and were unaffected.  x-lang's Lexer doc names this cost and this
remedy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonruttan
jonruttan merged commit 166ceb6 into main Nov 10, 2026
12 checks passed
@jonruttan
jonruttan deleted the perf/line-asm-cache branch November 10, 2026 17:39
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