ReviewOS

zig-utils/zig-js

ABI: implement per-VM CPU sampling profiles

#404
Closed chris opened this 8 days ago ·
8 days ago

Parents: #140, #143 Profiles: #163, #164 Roadmap: #134

Implement the three pinned Bun CPU sampling-profiler boundaries as a real, per-VM profiler. The ABI remains revision-compatible, but the internal design must not copy upstream's process-global running state into a multi-VM engine.

Scope

  • Pin Bun 4982b91e BunCPUProfiler.zig/BunCPUProfiler.cpp, exact Chrome CPU-profile fields, Markdown sections, and Home output-layout divergence.
  • Implement Bun__setSamplingInterval with validated, atomic interval publication.
  • Implement Bun__startCPUProfiler with per-VM lifecycle, restart/idempotence rules, monotonic start time, and no cross-VM contamination.
  • Sample real executing stacks at safe interpreter/JIT checkpoints without racing frame teardown or invoking JavaScript.
  • Implement Bun__stopCPUProfiler with Chrome-compatible nodes, samples, time deltas, source positions/position ticks, and exact start/end timestamps.
  • Emit the pinned Markdown aggregate, caller/callee, and file breakdown from the same sample set.
  • Preserve distinct Home pointer and Bun by-value string output ownership, including optional JSON/text outputs and release behavior.
  • Cover nested/recursive/anonymous/async frames, source URLs and offsets, idle/no-sample profiles, interval changes, repeated start/stop, sibling realms, invalid VMs, and OOM/failure atomicity.
  • Add bounded Debug, ReleaseSafe, and TSan fixtures; refresh both inventories, README counts, docs, and roadmap evidence.
  • Close only after the exact fixing main CI job is green.

No timer thread may read mutable interpreter frames without the VM's safe publication protocol. A cooperative checkpoint sampler is preferable to an observably racy imitation of JSC's asynchronous sampler.

8 days ago

Implemented and pushed in three cohesive main commits: 57a0f776 (per-VM cooperative sampler and serializers), 342df53f (Home/Bun fixtures plus Debug/ReleaseSafe/TSan CI), and 9ab79698 (pinned contract, inventories, docs, and README counts). Local evidence is green: focused serializer/OOM unit tests; both ABI fixtures in Debug, ReleaseSafe, and TSan; Home 433/471 and Bun 424/461 audits; 32-page docs build; release matrix 7/12 with 75 private symbols pending. Keeping this issue open only for the exact fixing main CI job.

8 days ago

Exact fixing-main evidence is green: private-abi-boundary job 88476047755 passed for 9ab796987fe04331761e620b2e928b9534330a4f, including the Debug, ReleaseSafe, and TSan CPU-profile fixture matrix. All acceptance items are complete.

Sign in to comment on this issue.