Add experimental macOS tracing backend for Apple Silicon - #384
Open
leo-ai-for-trading wants to merge 1 commit into
Open
Add experimental macOS tracing backend for Apple Silicon#384leo-ai-for-trading wants to merge 1 commit into
leo-ai-for-trading wants to merge 1 commit into
Conversation
leo-ai-for-trading
marked this pull request as ready for review
July 25, 2026 21:51
Signed-off-by: Attilio Pittelli <attilio.pittelli@gmail.com>
leo-ai-for-trading
force-pushed
the
codex/macos-sampling-prototype
branch
from
July 25, 2026 21:55
d4f24a1 to
2244afc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds an experimental, self-contained macOS backend for Apple Silicon:
time-profileXML schema in native OCaml;xctraceid/refandsentinelcompression;The macOS implementation uses only the OCaml standard library and
unix. The C source is a benchmark/demo workload, not part of the tracing backend.Motivation
The existing backend is Linux/Intel-specific because it relies on Intel Processor Trace. This contribution provides an immediately testable Apple Silicon fallback without modifying the existing Linux backend, while establishing an OCaml software boundary and performance harness for a future hardware-backed Apple Processor Trace implementation.
Fidelity and limitations
The working M1 Pro path uses Time Profiler sampling, not hardware control-flow tracing:
The synthetic model uses an internal packet format with exact 40 ns virtual event spacing. It validates reconstruction correctness and decoder throughput only. It is not Apple's packet format and is never presented as a real target capture.
A real Apple Processor Trace capture provider, ARM64 packet decoder, image/load-address correlation, scheduling reconstruction, and hardware validation remain future work.
Validation
Focused macOS build and tests:
All macOS correctness tests pass, including XML references, sentinel reuse, sampled interval reconstruction, trace JSON, exact synthetic 40 ns call boundaries, timing anchors, deterministic checksums, and overwrite protection.
Real M1 Pro recording smoke test:
Balanced Time Profiler overhead benchmark:
Synthetic 10,000,000-event decoder benchmark:
The complete upstream
@allalias was not available in the local standalone environment because existing Linux targets require packages and tools such ascore,ppx_jane,vec,ocaml-crunch, and LLVM utilities. The new macOS targets build and test independently of those dependencies.Scope
The implementation is isolated under
macos/, with only a short root README link and trace-output ignore entries outside that directory. It does not alter the existing Linux/Intel Processor Trace behavior.