Skip to content

ABI: implement per-VM CPU sampling profiles #404

Description

@chrisbbreuer

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions