Files

2.8 KiB
Raw Permalink Blame History

Script carrier performance and memory gates

The script carrier (plugins.md, crates/plugin/src/script) is held to nine gates on call cost, live heap, and runaway stops. Each measurement runs on the carrier itself, including boundary copies and decoding into contract types.

Reproduce from packages/cli-rs:

bun run cargo test --release -p opencode-plugin --lib script::measure:: -- --ignored --nocapture --test-threads=1

Gates

Measured on an x86-64 Linux laptop, release build (--release / --profile dist), psychoscript 64d7f2c:

Gate Requirement Script Status
Render cost per update (G1) KEEP render ≤ 10 µs; quick start render ≤ 20 µs KEEP: 5.81 µs; quick start: 10.03 µs (monitored: 11.96 µs; command: 6.07 µs) holds
Output-heavy render (G2) Render of 200 rows of two spans ≤ 1.0 ms 790.8 µs holds
Input-heavy render (G3) Render handed 600 changed IDs ≤ 50 µs 23.3 µs (changed.sessions); 9.97 µs (ignoring changed); 96.3 µs (all 3 lists, 1,003 values) holds
Activation and compile time for 1 MiB (G4) New activation ≤ 1 ms; 1 MiB source compile ≤ 100 ms (off UI thread) activation: 495 µs (hello), 549 µs (1,200 lines); 1,024,097 B file: 98.8 ms cold, 93.2 ms warm holds (no margin on compile)
Idle memory per plugin (G5) Idle activation live heap ≤ 256 KB 30,248 B (hello); 30,024 B (1,200 lines) holds
Runaway stop time (G6) Runaway stopped within 125 ms (loop, regex, crossing value, built-in) loop: 106.7 ms; /(a|a)*b/: 111.3 ms; 2^22-leaf value: 27.6 ms; repeat/replace: within slice holds
Shipped binary size (G7) --profile dist, stripped, ts enabled 101.86 MiB (29.20 MiB gz): +9.60 MiB vs. 92.26 MiB baseline (+3.90 MiB without intl; 88.72 MiB ts-only) accepted with intl
Cold build time (G8) CARGO_BUILD_JOBS=4, CPUQuota=400% 494.3 s --release --workspace (423.0 s quiet vs. 385.3 s baseline); 937.1 s --profile dist --bin opencode-native accepted (+9.8%–28%)
Large session regrouping (G9) session-manager with 16,000 sessions regroups in ≤ 50 ms CPU measured in phase (c) holds

The intl feature (ICU4X locale data/formatting/collation) adds 5.68 MiB stripped (~1.70 MiB gz) so toLocale*String and localeCompare remain locale-aware. On a busy machine the 1 MiB compile read 104–109 ms cold and 96–98 ms warm while other measures stayed within 3%; compilation runs on script-compile off the UI thread.

Other carrier measures from the same release run:

  • linked: render 74 ns, command 14 ns, input-heavy 2 ns, output-heavy 40.4 µs.
  • script: kept node 8.39 µs, built node 10.17 µs, built+keep 7.92 µs; 3 reads 14.11 µs; task round-trip 20.44 µs; compile hello 1.14 ms, 1,200 lines (44.6 KB) 4.16 ms.