Skip to content

perf(rust): the fresh runtime is made once per process and copied by each run - #85

Merged
kommander merged 2 commits into
devfrom
perf/stack-02-image
Nov 26, 2026
Merged

kommander merged 2 commits into
devfrom
perf/stack-02-image

Conversation

@hearnadam

Copy link
Copy Markdown
Contributor

A run built about 290 built-in objects, 380 strings and 250 names from scratch,
whatever its program: 352k instructions, most of what a short program cost.
builtins::image() makes them once. Every compile starts from its strings
(Strings::fresh), so they have the same ids in every run, and Vm::new copies
its heap instead of running setup. A VM whose strings did not start from the
image is still set up from scratch, as the image is.

Also sizes a fresh run's arenas for what it makes (286 objects, not room for
1,024), and has the compiler note whether the program names 'constructor',
which the string table no longer says.

examples/corpus: 15.88M to 11.91M instructions; setup 352k to 100k.
return 1: 360k to 111k. Idle waiting run: 154.7 to 84.5 KB.


Part 2 of 11 in a stack; based on perf/stack-01-bench. Each part was built, linted and tested on its own (cargo test --release --workspace, the same under PSYCHOSCRIPT_GC_STRESS=1, and the conformance cases under PSYCHOSCRIPT_ROUNDTRIP=1). Numbers are instructions retired, from rust/bench/examples/corpus and mem_probe (part 1).

Base automatically changed from perf/stack-01-bench to dev November 26, 2026 17:07
@hearnadam
hearnadam added this pull request to stack #95 November 26, 2026 17:17
hearnadam and others added 2 commits November 26, 2026 23:42
…each run

A run built about 290 built-in objects, 380 strings and 250 names from scratch,
whatever its program: 352k instructions, most of what a short program cost.
builtins::image() makes them once. Every compile starts from its strings
(Strings::fresh), so they have the same ids in every run, and Vm::new copies
its heap instead of running setup. A VM whose strings did not start from the
image is still set up from scratch, as the image is.

Also sizes a fresh run's arenas for what it makes (286 objects, not room for
1,024), and has the compiler note whether the program names 'constructor',
which the string table no longer says.

examples/corpus: 15.88M to 11.91M instructions; setup 352k to 100k.
return 1: 360k to 111k. Idle waiting run: 154.7 to 84.5 KB.
… refused instead of misread

Program strings now come after the image's (Strings::fresh), so a state from an earlier build can decode a string
id as a different string while its build id still matches. The format bump changes the build id too.
@kommander
kommander merged commit 789b94f into dev Nov 26, 2026
1 check passed
@kommander
kommander deleted the perf/stack-02-image branch November 26, 2026 22:45
kommander added a commit that referenced this pull request Nov 27, 2026
Co-authored-by: OpenCode Agent <opencode-agent[bot]@users.noreply.github.com>
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.

2 participants