add run_with_libfunc_profile + AotWithProgram pairing#1613
add run_with_libfunc_profile + AotWithProgram pairing#1613avi-starkware wants to merge 2 commits into
Conversation
|
✅ Code is now correctly formatted. |
98ed085 to
64c12b3
Compare
474462f to
13381fa
Compare
64c12b3 to
7e5fcd7
Compare
b5e8d6b to
94bc246
Compare
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
- 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
d19f2ac to
60e4055
Compare
6f77130 to
aa4bf47
Compare
60e4055 to
a21f3f5
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed all commit messages and made 1 comment.
Reviewable status: 1 of 4 files reviewed, 1 unresolved discussion (waiting on avi-starkware, TomerStarkware, and Yoni-Starkware).
src/executor.rs line 31 at r3 (raw file):
}; use bumpalo::Bump; // Re-exported so libfunc-profiling consumers (e.g. blockifier) can refer to the
what kind of reference is expected?
if it is just as a value - since you only use is as Arc<Program> - export:
pub type ArcProgram = std::sync::Arc<cairo_lang_sierra::program::Program>;
- 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>
aa4bf47 to
e6a4ad9
Compare
a21f3f5 to
be6cb3f
Compare
e6a4ad9 to
538f655
Compare
be6cb3f to
8b6515b
Compare
538f655 to
c8ed1f7
Compare
8b6515b to
7f27488
Compare
- 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>
avi-starkware
left a comment
There was a problem hiding this comment.
@avi-starkware made 1 comment.
Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on orizi, TomerStarkware, and Yoni-Starkware).
src/executor.rs line 31 at r3 (raw file):
Previously, orizi wrote…
what kind of reference is expected?
if it is just as a value - since you only use is asArc<Program>- export:
pub type ArcProgram = std::sync::Arc<cairo_lang_sierra::program::Program>;
Done.
0b0a902 to
6640ce9
Compare
c8ed1f7 to
90cd01f
Compare
6640ce9 to
c7e5bcc
Compare
90cd01f to
a1e3635
Compare
c7e5bcc to
7107710
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 5 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on avi-starkware, TomerStarkware, and Yoni-Starkware).
src/executor/contract_executor.rs line 150 at r5 (raw file):
/// callers don't have to keep their own copy around just to resolve libfunc samples. /// For other variants this is identical to `run` and `on_profile` is never invoked. #[cfg(feature = "with-libfunc-profiling")]
following my response to the previous PR - seems to me this is basically the only interesting function.
7107710 to
0f1975e
Compare
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With the ContractExecutor enum gone, AotWithProgram exposes the same run() shape as AotContractExecutor directly, plus a profile-capturing run_with_profile(), so feature-flag builds can swap executor types without call-site changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0f1975e to
6184f7a
Compare
- 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>
|
Previously, orizi wrote…
Following my response to your response - removed this file |
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.Follows the no-enum design from #1612: there is no
ContractExecutordispatch enum; consumers pick an executor type per feature-flag build. Each step is its own commit so it can be reverted independently.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)on success. AProfilerGuardrestores the previous trace ID and drops theLIBFUNC_PROFILEslot on both the success and unwind paths; a process-wide lock plus a thread-local depth counter make concurrent and nested (contract-calls-contract) profiled runs safe.AotWithProgram { executor, program }: pairs an AOT executor with the Sierra program it was compiled from (needed to resolve libfunc samples). Exposes inherent methods:run(...)— mirrorsAotContractExecutor::run; routes through the profiling bookkeeping (the instrumented.soneeds a live profile slot) and discards the profile.run_with_profile(..., FnOnce(Profile, ArcProgram))— hands the captured profile and the paired program to the callback.pub type ArcProgram = Arc<Program>re-export so consumers can name the program handle without a directcairo-lang-sierradependency.Commits (revert points)
add run_with_libfunc_profile + AotWithProgram pairing— the profiling primitive.give AotWithProgram inherent run/run_with_profile methods— replaces the former enum dispatch; reverting this commit removes the interchangeable-call-site methods only.Stack
EmuContractExecutorrun_with_libfunc_profile+AotWithProgramTest plan
cargo check(default features) cleancargo check --features with-libfunc-profilingcleancargo check --features sierra-emu,with-libfunc-profilingcleancargo check --workspace --all-featurescleanThis change is