add run_with_libfunc_profile + AotWithProgram variant for ContractExecutor#1609
Open
avi-starkware wants to merge 1 commit into
Open
add run_with_libfunc_profile + AotWithProgram variant for ContractExecutor#1609avi-starkware wants to merge 1 commit into
avi-starkware wants to merge 1 commit into
Conversation
…cutor
Exposes the libfunc-profiling primitives that downstream consumers (e.g. the
blockifier in starkware-libs/sequencer) currently maintain locally. Makes the
profile-collection pattern callback-driven so the per-call key (tx hash, etc.)
stays out of cairo-native.
- `Profile` (HashMap<ConcreteLibfuncId, LibfuncProfileData>) is now public.
- `AotContractExecutor::run_with_libfunc_profile<H, F>` (gated on
`with-libfunc-profiling`) wraps `run`: allocates a unique trace ID, points
the executor's `cairo_native__profiler__profile_id` symbol at it, drains
the resulting `Profile` after `run` returns, and hands it to a caller-
supplied `FnOnce(Profile)`. A `ProfilerGuard` restores the previous trace
ID and drops the LIBFUNC_PROFILE slot 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::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).
|
❌ Code is not formatted! Please run |
This was referenced May 14, 2026
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.Important
Stacked on #1607 and #1608. Merge those first; this PR's diff will narrow once they land.
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).Test plan
--features with-libfunc-profiling--features sierra-emu,with-libfunc-profilingContext
Companion sequencer PR that adopts these APIs and drops the locally-maintained profiling code: starkware-libs/sequencer#13880.