perf(vm): eliminate recurring stack and return allocations
This commit is contained in:
+25
@@ -67,3 +67,28 @@ String concatenation still creates a new string when the language semantics requ
|
||||
- The right performance question is often "where is the repeated cost?" rather than "where is any cost at all?"
|
||||
- Immutable payload sharing is a strong default when public semantics must remain stable and hot-path copies are the real issue.
|
||||
- Internal telemetry should help engineering decisions without silently becoming a product contract.
|
||||
|
||||
## Successful execution can allocate without materializing guest values
|
||||
|
||||
The later stack/return correction (DEC-0061) demonstrated another source of
|
||||
recurring native allocations: eager diagnostic Strings and disposable return
|
||||
storage. A warmed scalar call/return loop allocated and freed 3,000 times per
|
||||
1,000 iterations; lazy diagnostics and in-place return transfer reduced both
|
||||
counts to zero in debug and release. The original string materialization evidence
|
||||
above remains a separate observation.
|
||||
|
||||
Validate before moving owners. Rotating only the returning frame's suffix and
|
||||
then truncating locals preserves ordered logical groups, Arc identity and heap
|
||||
aliases without cloning or scratch storage. Remove the frame after transfer so
|
||||
the existing last-root safepoint sees the results. GC scratch refusal is a later
|
||||
failure boundary: transferred roots must remain intact and sweeping must not
|
||||
start after failed marking admission.
|
||||
|
||||
Account for storage that actually exists. Eliminating temporary result storage
|
||||
can make a return succeed under a zero temporary budget without changing any
|
||||
quota ceiling. A triggered collector still needs its own admitted scratch.
|
||||
|
||||
The [execution allocation qualification](../../../docs/vm-arch/execution-allocation-qualification.md)
|
||||
records instruction regions, before/after counts and limits. The
|
||||
[memory contract](../../../docs/specs/runtime/03-memory-stack-heap-and-allocation.md)
|
||||
remains normative. These measurements say nothing about gameplay throughput.
|
||||
|
||||
Reference in New Issue
Block a user