Skip to content

perf(rust): a run collects while it waits for the host - #89

Merged
kommander merged 1 commit into
devfrom
perf/stack-06-gc-while-waiting
Nov 26, 2026
Merged

kommander merged 1 commit into
devfrom
perf/stack-06-gc-while-waiting

Conversation

@hearnadam

Copy link
Copy Markdown
Contributor

A long-lived run kept up to 64k slots of garbage between cycles, most of what a
small one held. The threshold while computing stays 64k slots, so a short
program still never collects. A run that stops to wait for the host collects
there, a whole cycle, once it has made 8k slots since its last one
(Vm::gc_idle): time the program was not going to use. A heap over 256k slots
keeps collecting in steps.

examples/gc_bench, 20,000 events: palette loop peak live memory 16.1 to 1.9
MB; 50 runs with 5 active 51.7 to 13.2 MB; collection time and event latency
unchanged.


Part 6 of 11 in a stack; based on perf/stack-05-shared-builtins. 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).

@hearnadam
hearnadam added this pull request to stack #95 November 26, 2026 17:17
@hearnadam
hearnadam force-pushed the perf/stack-06-gc-while-waiting branch from a15076d to 465067d Compare November 26, 2026 17:20
@kommander
kommander force-pushed the perf/stack-06-gc-while-waiting branch 3 times, most recently from 8a183ed to 4a46576 Compare November 26, 2026 22:50
Base automatically changed from perf/stack-05-shared-builtins to dev November 26, 2026 22:52
A long-lived run kept up to 64k slots of garbage between cycles, most of what a
small one held. The threshold while computing stays 64k slots, so a short
program still never collects. A run that stops to wait for the host collects
there, a whole cycle, once it has made 8k slots since its last one
(Vm::gc_idle): time the program was not going to use. A heap over 256k slots
keeps collecting in steps.

examples/gc_bench, 20,000 events: palette loop peak live memory 16.1 to 1.9
MB; 50 runs with 5 active 51.7 to 13.2 MB; collection time and event latency
unchanged.
@kommander
kommander force-pushed the perf/stack-06-gc-while-waiting branch from 4a46576 to b030497 Compare November 26, 2026 22:52
@kommander
kommander merged commit 64eeda9 into dev Nov 26, 2026
1 check passed
@kommander
kommander deleted the perf/stack-06-gc-while-waiting branch November 26, 2026 22:54
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