Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
84f0a3a
pyrex: strip a -c argument's common leading indentation
youknowone Aug 16, 2026
784a251
posix: user and group id setters, __fspath__ binding, sendfile vector…
youknowone Aug 17, 2026
cfacf88
extra_tests: cover the -c dedent and the posix behaviours this branch…
youknowone Aug 16, 2026
14fbb7b
pyrex: empty a -c argument's space-or-tab-only lines
youknowone Aug 17, 2026
4ce0615
importing: record this build's entropy source in _sysconfigdata
youknowone Aug 17, 2026
6bdb245
importing: withhold the entropy capability names from a sandbox build
youknowone Aug 17, 2026
d617080
extra_tests: cover the -c blank-line rule and the exec environment count
youknowone Aug 17, 2026
cc065a8
pyrex: leave a -c argument alone when its lines share no prefix
youknowone Aug 17, 2026
3290400
extra_tests: cover a scandir iterator closed partway through
youknowone Aug 17, 2026
2a4174b
importing: withhold the entropy capability names from a build without…
youknowone Aug 17, 2026
9bbc57a
posix: hold the scandir iterator's enumeration state in a native owner
youknowone Aug 17, 2026
14822d0
extra_tests: cover the __fspath__ return type, the environment name r…
youknowone Aug 17, 2026
8485171
posix, pyrex, importing: reword the comments this branch added
youknowone Aug 17, 2026
2c08234
posix: reject a non-mapping exec environment before snapshotting it
youknowone Aug 17, 2026
df6ce11
Fix shared interpreter state parity
youknowone Aug 18, 2026
215bd41
jit: take the eval door's hotness decision without marking the cell
youknowone Aug 18, 2026
cb569ff
Preserve inline frame identity for getframe
youknowone Aug 18, 2026
db6aa54
builtins, posix, thread: build the finalization error without an expect
youknowone Aug 18, 2026
862eb36
posix: refuse a scandir step taken while another is in progress
youknowone Aug 18, 2026
36e5d9f
posix: take the exec environment snapshot through one helper
youknowone Aug 18, 2026
ed66aaa
importing: name the entropy capability after the backend getrandom picks
youknowone Aug 18, 2026
dc976d6
posix: decide a scandir step from the open and _in_next flags together
youknowone Aug 18, 2026
c52b509
bench: re-record the jitstats this branch's JIT commits moved
youknowone Aug 18, 2026
3357548
bench: re-record getframe_inline_subwalk_multiframe, whose loop now g…
youknowone Aug 18, 2026
93d0d50
jit: attempt the multi-frame blackhole handoff for every inline-subwa…
youknowone Aug 18, 2026
cbcf4a9
posix: record why the scandir typedef publishes __del__
youknowone Aug 18, 2026
e04562c
posix: record why a disabled __fspath__ is reported as not path-like
youknowone Aug 18, 2026
9322564
baseobjspace: name the argument's own class in uint_w's type error
youknowone Aug 19, 2026
39afb77
posix: derive the scandir iterator borrow inside its serializer
youknowone Aug 19, 2026
9d1adf7
_io: revalidate an autoflusher reservation after retaking the lock
youknowone Aug 19, 2026
26512f9
bench: re-record the nine wasm jitstats baselines left at their pre-h…
youknowone Aug 19, 2026
57d085a
baseobjspace: run the index protocol in the uid_t converter
youknowone Aug 19, 2026
8c6688b
bench/synth: record what the getframe fixture's guard failures measure
youknowone Aug 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions majit/majit-metainterp/src/warmstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ impl WarmEnterState {
self.counter.tick(bucket, self.increment_threshold)
}

pub fn maybe_compile(&mut self, cell_key: u64) -> HotResult {
pub fn maybe_compile_decision(&mut self, cell_key: u64) -> HotResult {
let mut cleanup_dead_token_cell = false;
if let Some(cell) = self.cell_by_key(cell_key) {
let has_procedure_token = cell.get_procedure_token().is_some();
Expand All @@ -723,7 +723,7 @@ impl WarmEnterState {
}
if self.should_start_dont_trace_here_trace(cell_key, flags, has_seen_a_procedure_token)
{
return self.start_tracing_cell(cell_key);
return HotResult::StartTracing;
}
// A JC_DONT_TRACE_HERE cell declines here, except when it once saw a
// procedure token that has since been invalidated — that dead entry
Expand Down Expand Up @@ -752,7 +752,25 @@ impl WarmEnterState {
return HotResult::NotHot;
}

self.start_tracing_cell(cell_key)
HotResult::StartTracing
}

/// [`Self::maybe_compile_decision`] followed by the mark that
/// `warmstate.py:441` makes once the decision is taken:
/// `cell.flags |= JC_TRACING | JC_TRACING_OCCURRED`, immediately before
/// the `try:` that runs the trace.
///
/// Callers that go straight from the answer into `setup_tracing` want
/// this form. A caller that instead delegates to a tracing entry point
/// which makes its own decision — `MetaInterp::bound_reached` reaches the
/// same cell through [`Self::force_start_tracing_for_key`] — must take the
/// decision alone, or that second call reads the mark this one left and
/// answers `AlreadyTracing` for the trace it was asked to start.
pub fn maybe_compile(&mut self, cell_key: u64) -> HotResult {
match self.maybe_compile_decision(cell_key) {
HotResult::StartTracing => self.start_tracing_cell(cell_key),
other => other,
}
}

/// warmstate.py:446-511 `WarmEnterState.maybe_compile_and_run` —
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=4
fbw_blackhole_adopted_single_frame=8
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
internal_compile_panics=0
loops_aborted=4
loops_aborted=8
loops_compiled=1
retraces_compiled=0
5 changes: 3 additions & 2 deletions pyre/bench/synth/for_iter_direct_store_double.dynasm.jitstats
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=4
fbw_blackhole_adopted_single_frame=8
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
internal_compile_panics=0
loops_aborted=4
loops_aborted=8
loops_compiled=1
retraces_compiled=0
5 changes: 3 additions & 2 deletions pyre/bench/synth/for_iter_direct_store_double.wasm.jitstats
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=2
fbw_blackhole_adopted_single_frame=6
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
internal_compile_panics=0
loops_aborted=2
loops_aborted=6
loops_compiled=0
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ guard_failures=0
internal_compile_panics=0
loops_aborted=5
loops_compiled=0
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_single_frame=9
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=8948
internal_compile_panics=0
loops_aborted=15
loops_compiled=0
loops_aborted=1
loops_compiled=2
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_single_frame=9
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=8948

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not bless the per-iteration getframe guard failure

The updated dynasm baseline now accepts 8,948 guard failures and two compiled loops for a 20,000-iteration fixture whose new specification explicitly requires the PyPy shape of one loop without aborts or frame-blackhole activity. This turns the benchmark gate into approval for a hot guard exit on nearly every compiled iteration, hiding the JIT regression instead of identifying the missing upstream optimization that should recover it.

AGENTS.md reference: AGENTS.md:L295-L303

Useful? React with 👍 / 👎.

internal_compile_panics=0
loops_aborted=15
loops_compiled=0
loops_aborted=1
loops_compiled=2
retraces_compiled=0
86 changes: 35 additions & 51 deletions pyre/bench/synth/getframe_inline_subwalk_multiframe.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,45 @@
# No `max-pypy-ratio`: this fixture compiles no loop -- its jitstats record
# `loops_compiled=0` -- so a pypy ratio compares two interpreters' startup
# rather than any generated code, and reads whatever the host's process
# spawn cost happens to be that run. The jitstats baselines gate it.
# Coverage for the multi-frame blackhole build path: an INLINED callee that
# forces an outer frame through `sys._getframe(2)`.
# Frame-identity regression for two `_getframe` operations executed from an
# inlined `leaf` MIFrame. The depth-zero lookup must return `leaf`'s own red
# frame, and its `f_locals` proxy must retain that frame so reading `"x"`
# observes the live callee local. The positive-depth lookup must start from the
# same callee frame and reach `main`, where `"base"` is stored.
#
# The walker executes a residual call concretely, so that level gets a real
# frame from the interpreter's own call sequence; an inline push did not run
# that sequence, so its level had none. A force fired from the inlined body
# therefore built a frame chain that mixed the two, rooted at the intermediate
# residual frame rather than the walked frame, and
# `try_adopt_multi_frame_blackhole`'s chain-root identity gate declined it. What
# that decline wanted was the `jit.virtual_ref` emit at the inline push
# (`executioncontext.py:89`); `walker_ec_enter` / `walker_ec_leave` landed it, so
# the chain-root gate no longer fires here, and with every level resumable from
# the concrete frame it owns, the chain is adopted rather than replayed. This fixture pins the
# result across that adopt.
# Collapsing either lookup onto the portal frame changes the namespace: the
# first read loses `x`, while the second lands on the module frame and loses
# `base`. Residualizing the depth-zero lookup instead forces the published
# callee during tracing and prevents this loop from compiling. The specialized
# path therefore records the callee frame and creates its `FrameLocalsProxy`
# without forcing the outer standard virtualizable; positive-depth lookup stays
# on the established virtual-reference walk until its per-level lowering is
# available.
#
# The build wants an escape whose forced frame is the one the inline sub-walk
# PUBLISHED, so the chain has a residual level under the walked frame and an
# inlined level under that. `sys._getframe(0).f_locals` in `leaf` is that
# escape: the depth-0 call names `leaf`'s own frame, the arm declines inside a
# sub-walk, and the getset forces the published frame.
# A real PyPy run compiles one loop with no bridges, forcings, virtualizable
# forcings, or aborts. Pyre must print the same value, compile one loop, and
# report no escape abort or frame-blackhole adoption for this fixture.
#
# The `sys._getframe(2)` read below is the OUTPUT guard and is not what reaches
# the build -- `getframe` forces only the frame it returns, and two levels up is
# `main`'s, i.e. the portal, which escapes on the ordinary portal path. Without
# the depth-0 line the file still answers correctly and stops building a
# multi-frame image at all (measured: `fbw_blackhole_adopted_multi_frame` 5 ->
# 0). In the historical gate-enabled sweep with `PYRE_FBW_DEBUG_ABORT=1`, 0 of
# 310 fixtures reached `BUILT multi-frame`.
#
# The multi-frame image is built unconditionally when the latch conditions hold,
# so this is both an output guard and build-path coverage: 5 builds, 5 adopts,
# and zero declines of any kind (`PYRE_FBW_DEBUG_ABORT=1` prints every tally;
# the other 5 escapes in the run have `inline_subwalk=false` and take the
# single-frame arm, which adopts too).
#
# What the decline used to hold back, measured by lifting it before the
# execution-context push landed: the resumed chain shifted every
# `sys._getframe(n)` up exactly one level, so the read below landed on the
# module frame and raised `KeyError: 'base'`. Variants of this shape that cannot
# raise returned a wrong number instead, silently -- `f_locals.get("base", -1)`
# scored -1 for 7, `len(f_locals)` scored the module globals' 12 for this
# frame's 3, `len(f_code.co_name)` scored `<module>`'s 8 for a 9-character
# caller name. That is the failure mode this fixture still guards: every outcome
# arm was wrong, not only the one carrying a resume coordinate.
#
# Carries only a generous `# pyre-check: max-pypy-ratio=` tripwire (top of
# file), not a tight perf gate: this guards an output, and the forcing read
# makes it a poor perf subject, so the ratio is a gross-regression guard.
# The positive-depth clause has a measured cost, and the recorded counters
# encode it rather than endorse it. `leaf`'s `_getframe(2)` reaches `main`'s
# frame, which is the virtualizable of `main`'s compiled loop, and materializes
# it. `mid(i)` stays a residual `CallMayForce` in that loop, so the
# `GuardNotForced` behind it fails on every machine-code entry: `MAJIT_STATS=1`
# reports `mc_entered` equal to `guard_failures`, with `back_edge_polls=0` and
# `bridges_compiled=0`, so the compiled loop leaves for the blackhole before it
# ever crosses its back edge. The attribution is a one-run check -- a `leaf`
# holding only the depth-zero read records `guard_failures=1`, one holding only
# the `_getframe(2)` read reproduces the full count. The recorded
# `guard_failures` is therefore a known shortfall of the positive-depth walk,
# not a number to preserve; it is expected to fall once that walk gets its
# per-level lowering. `loops_compiled` counts two traces here: `main`'s loop,
# and a linear `Finish` trace for the inlined `mid` -> `leaf` chain, whose own
# four `GuardNotForced`s never fail. The wasm baseline records
# `guard_failures=1` instead because that backend always materializes the
# virtualizable, which makes `GuardNotForced` a no-op there.
import sys


def leaf(x):
sys._getframe(0).f_locals # noqa: B018 — the read itself is the force under test
return sys._getframe(2).f_locals["base"] + x
own_x = sys._getframe(0).f_locals["x"]
return sys._getframe(2).f_locals["base"] + own_x


def mid(x):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_single_frame=9
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=1
internal_compile_panics=0
loops_aborted=15
loops_compiled=0
loops_aborted=1
loops_compiled=2
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ guard_failures=1
internal_compile_panics=0
loops_aborted=1
loops_compiled=2
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ guard_failures=0
internal_compile_panics=0
loops_aborted=5
loops_compiled=0
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ guard_failures=0
internal_compile_panics=0
loops_aborted=5
loops_compiled=0
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ guard_failures=0
internal_compile_panics=0
loops_aborted=5
loops_compiled=0
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ guard_failures=0
internal_compile_panics=0
loops_aborted=5
loops_compiled=1
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=1
internal_compile_panics=0
loops_aborted=5
loops_aborted=0
loops_compiled=1
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=1
internal_compile_panics=0
loops_aborted=5
loops_aborted=0
loops_compiled=1
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=1
internal_compile_panics=0
loops_aborted=5
loops_aborted=0
loops_compiled=1
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=1
internal_compile_panics=0
loops_aborted=5
loops_aborted=0
loops_compiled=1
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=1
internal_compile_panics=0
loops_aborted=5
loops_aborted=0
loops_compiled=1
retraces_compiled=0
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ bridges_compiled=0
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=5
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=0
guard_failures=1
internal_compile_panics=0
loops_aborted=5
loops_aborted=0
loops_compiled=1
retraces_compiled=0
Loading
Loading