A better way to get profiler state from JIT - #9423
Open
abadams wants to merge 3 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9423 +/- ##
==========================================
- Coverage 70.12% 69.92% -0.21%
==========================================
Files 261 261
Lines 79462 79649 +187
Branches 19365 19415 +50
==========================================
- Hits 55724 55695 -29
- Misses 17900 18053 +153
- Partials 5838 5901 +63 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alexreinking
approved these changes
Sep 3, 2026
Pipeline::realize on a Target with the Profile feature reports and then resets the profiler after every run, so there was no way to read the profiler's statistics programmatically without hooking a trace event and snapshotting the running instance before the reset. ProfilerScope holds a Pipeline (or the Pipeline behind a Func) and, while alive, stops realize from reporting and resetting. Statistics accumulate across every run in the scope and can be read via pipeline_stats() and func_stats(). The last scope to be destroyed for a pipeline prints the report and resets, as an unscoped realize would. The lookup walks the profiler's pipeline list comparing names by string, because halide_profiler_get_pipeline_state compares by pointer and so only works from inside the JIT module. The memory profiler test now uses this instead of the trace-event hook. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GaAM5BTGYrrWUxTZ18Aya8
hl.ProfilerScope wraps a Pipeline or Func and works as a context manager; leaving the with-block reports and resets the profiler. pipeline_stats() and func_stats() return Python-owned snapshots (ProfilerPipelineStats, ProfilerFuncStats) so they remain valid after the scope exits. Also exposes the halide_profiler_func_kind enum as ProfilerFuncKind. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GaAM5BTGYrrWUxTZ18Aya8
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GaAM5BTGYrrWUxTZ18Aya8
alexreinking
force-pushed
the
abadams/jit_profile_state_access
branch
from
September 11, 2026 09:00
bba9eb4 to
b5c165e
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.
This PR takes the scoped profiler helper from f21bac0 and expands it into an object that lets you access profiler state from JIT-land programmatically. This is used to clean up the memory profiler test, which currently has a nasty hack to snapshot profiler state.