add run_with_libfunc_profile + AotWithProgram variant for ContractExecutor#1613
Open
avi-starkware wants to merge 1 commit into
Open
Conversation
|
✅ Code is now correctly formatted. |
98ed085 to
64c12b3
Compare
474462f to
13381fa
Compare
64c12b3 to
7e5fcd7
Compare
b5e8d6b to
94bc246
Compare
orizi
reviewed
May 17, 2026
Collaborator
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 3 files and all commit messages.
Reviewable status: 3 of 4 files reviewed, all discussions resolved (waiting on TomerStarkware and Yoni-Starkware).
7e5fcd7 to
4176352
Compare
94bc246 to
24984b5
Compare
4176352 to
7af0508
Compare
24984b5 to
78bf3e4
Compare
7af0508 to
38c5f2f
Compare
78bf3e4 to
5b13906
Compare
38c5f2f to
81093b3
Compare
5b13906 to
de234b8
Compare
81093b3 to
4f53f27
Compare
74aab36 to
d19f2ac
Compare
avi-starkware
added a commit
to starkware-libs/sequencer
that referenced
this pull request
May 19, 2026
- Drop unused `NativeCompiledClassV1::new_from_emu`; it had no in-tree callers, and the sierra-emu construction path will be re-added when the benchmarking/replay tool that needs it lands. - Revert `process_compilation_request`'s `.map(...)` shape to a direct `match`, moving `casm` into `NativeCompiledClassV1::new(_with_program)` in the `Ok` arm at zero cost instead of cloning it. - Bump pinned cairo-native rev to pick up `cargo fmt` fix on starkware-libs/cairo_native#1613. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4f53f27 to
6f77130
Compare
…cutor
Exposes the libfunc-profiling primitives that downstream consumers (e.g.
the blockifier in starkware-libs/sequencer) currently maintain locally.
The profile-collection pattern is callback-driven so the per-call key
(tx hash, etc.) stays out of cairo-native.
- metadata::profiler::Profile is now pub (was a private type alias).
- AotContractExecutor::run_with_libfunc_profile<H, F> (gated on
with-libfunc-profiling, in new file src/executor/libfunc_profile.rs)
wraps run with the bookkeeping the runtime needs:
1. Acquires a process-wide PROFILE_LOCK so concurrent profile calls
serialize on the global trace-id symbol. The lock is recovered
if poisoned.
2. Looks up the profile-id symbol before touching any global state.
Absent symbol -> typed Error::UnexpectedValue rather than panic.
3. Allocates a trace ID, inserts a slot in LIBFUNC_PROFILE, points
the global at the new ID.
4. Calls run; on success drains the slot and hands the Profile to
on_profile. On failure the callback is not invoked.
5. A ProfilerGuard restores the previous trace ID on success and
unwind.
- ContractExecutor::AotWithProgram(AotWithProgram { executor, program })
is a new variant that bundles an AOT executor with the Sierra program
it was built from. From<AotWithProgram> is provided.
- ContractExecutor::run dispatches the new variant via
run_with_libfunc_profile with a no-op profile callback.
- ContractExecutor::run_with_profile<H, F> is the profile-capturing
counterpart of run; for non-AotWithProgram variants it falls through
to run (callback never fires).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
d19f2ac to
60e4055
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
Exposes the libfunc-profiling primitives that downstream consumers (e.g. the blockifier in
starkware-libs/sequencer) currently maintain locally. The profile-collection pattern is callback-driven so the per-call key (tx hash, etc.) stays out of cairo-native.Replaces #1599 / #1609.
Changes
metadata::profiler::Profileis nowpub(was a private type alias).AotContractExecutor::run_with_libfunc_profile<H, F>(gated onwith-libfunc-profiling, in new filesrc/executor/libfunc_profile.rs) wrapsrun: allocates a unique trace ID, points the executor'scairo_native__profiler__profile_idsymbol at it, drains the resultingProfileafterrunreturns, and hands it to a caller-suppliedFnOnce(Profile). AProfilerGuardrestores the previous trace ID and drops theLIBFUNC_PROFILEslot on both the success and unwind paths.ContractExecutor::AotWithProgram(AotWithProgram { executor, program })is a new variant that bundles an AOT executor with the Sierra program it was built from.From<AotWithProgram>is provided.ContractExecutor::rundispatches the new variant viarun_with_libfunc_profilewith a no-op profile callback.ContractExecutor::run_with_profile<H, F>is the profile-capturing counterpart ofrun; for non-AotWithProgramvariants it falls through torun(callback never fires).Stack
ContractExecutor(supersedes add ContractExecutor dispatch enum (Aot + Emu) #1598 / add ContractExecutor dispatch enum (Aot + Emu) #1608)run_with_libfunc_profile+AotWithProgram(supersedes add run_with_libfunc_profile + AotWithProgram variant for ContractExecutor #1599 / add run_with_libfunc_profile + AotWithProgram variant for ContractExecutor #1609)Test plan
cargo check(default features) cleancargo check --features with-libfunc-profilingcleancargo check --features sierra-emu,with-libfunc-profilingcleancargo check --workspace --all-featurescleanThis change is