Repository navigation
A census of JIT and light-frame coverage without running code, and perf-step judged by it - #232
Conversation
…ithout running it Whether the method JIT or the light frames cover a method was only visible by running a program with IR_JIT_VERBOSE=1 or IR_LIGHT_FRAMES=why: it showed the methods that program happened to call, and took as long as the program. Most of both decisions is made from the syntax tree, though, the first time a method is called. IronRuby.jit_census(paths) parses the files and takes each `def' through those decisions without running anything (Runtime/Jit/JitCensus.cs): - the body's transformation, which says whether it is a light frame and why not (MethodDefinition.TransformBody now tells the census what it tells stderr), and how many of its blocks run without a scope; - JitStub.Wrap's static decision: the parameter list (ParameterShape names what refused it) and the screen. The screen asks which calls the typed body may inline; with no class to resolve them on, the census answers from the methods the files define in the same class body, then from what Object has, and takes an unknown name as IsLeafMethod takes a method not defined yet (IsLeafShape is that test on a syntax tree alone); - JitCompiler.TryCompile for parameters that are all Integers, all Floats and all objects, with no receiver profile. A method is then `never' (no profile can make it compile), `compiles' (a typed body exists without a profile) or `maybe' (the profile decides). Util/perf/census.rb prints the counts and the reasons, most frequent first, saves a census (-o), lists the methods whose verdict changed against a saved one (-d), and checks itself against the stderr of a traced run (-c). The whole standard library is 27,944 methods in 9.8 s: 64.2% light frames, 10.1% compiles, 8.2% maybe, 81.7% never. Checked with -c against traced runs: all 14 AWFY benchmarks (346 of their 391 methods called), the standard library methods those runs called (73), and an mspec run over core/array, library/stringio and library/matrix (776). Every method agreed on both the light frame and the screen, and no method a run specialized was `never'. IronRuby.Tests passes on net10.0 (1,270 tests, with the new JitCensus1); net11.0 and ruby/spec were not run. The census counts methods, not calls, and covers `def' only: not loops compiled on their own, not define_method bodies. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Each step of the perf loop measured its change on the clock - the micro table, the AWFY suite twice in both orders - and ran /perf-gate (IronRuby.Tests, ruby/spec language, the matrices in every mode) before merging it. That is most of an hour per change, needs a quiet machine, and is the same hour whether the change did anything or not. A step is now judged by Util/perf/census.rb: the worktree's census against the saved census of the unchanged build (-d), which takes ten seconds for the standard library and the AWFY benchmarks and names each method whose verdict moved. A change is kept if methods moved up (a scope to a light frame, never to maybe or compiles) and none moved down. Two things that take seconds stay: the differential matrix for the code touched, which is all a step has to say that the code computes the same, and a traced run of the benchmarks concerned checked against the census (-c) - a move from never to maybe counts only if the trace shows such methods specialized, since loosening the screen alone makes a method slower. A gap the census cannot see (how fast covered code runs) is judged by instructions per call (ab.rb -i). What a step no longer runs is owed once to the branch (step 5): /perf-gate and /perf-measure for all the steps since the last gated commit, before the branch is pushed or a pull request is opened. Until then a step's entry in the ledger says "census only, not gated", and a step does not push. Every command in the skill was run as written against this build. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
What
IronRuby.jit_census(paths)andUtil/perf/census.rb: what the method JIT and the light frames make of everydefin a set of files, found without running any of them. Each file is parsed and each method goes through the decisions its first call would take it through:JitStub.Wrap's static decision: the parameter list and the screen;JitCompiler.TryCompilefor parameters that are all Integers, all Floats and all objects, with no receiver profile.A method is then
never(no profile can make it compile),compiles(a typed body exists without a profile) ormaybe(the profile decides).-o FILEsaves a census,-d FILElists the methods whose verdict changed against a saved one,-c LOGchecks the census against the stderr of a run traced withIR_JIT_VERBOSE=1 IR_LIGHT_FRAMES=why,-llists every method.perf-step(second commit) now judges a change by the census instead of by the clock and the gate: the worktree's census against the saved census of the unchanged build, ten seconds. It keeps the differential matrix for the code touched and a traced run checked with-c, both seconds./perf-gateand/perf-measureare owed once to the branch, before it is pushed; until then a step's ledger entry says "census only, not gated" and a step does not push.Changes to the runtime
JitCensus.cs(new). The census has no class to resolve a method's calls on, so the screen's question "may the typed body inline this call?" is answered from the methods the files define in the same class body, then from whatObjecthas in the process.JitStub:ParameterShapenames what the parameter list refused (the same testsScreenmade inline),Screentakes the callee test from the census when given one, andIsLeafShapeisIsLeafMethod's test on a syntax tree alone.JitCompiler.BailandJitScreen.Nokeep their reason for the census as they do forIR_JIT_VERBOSE.MethodDefinition.TransformBodytells the census what it tells stderr underIR_LIGHT_FRAMES=why;BlockDefinitioncounts the blocks that run without a scope.Nothing changes for code that is compiled to run: the hooks are null there.
How it was checked
-cagainst traced runs: all 14 AWFY benchmarks (346 of their 391 methods called), the standard library methods those runs called (73), and an mspec run overcore/array,library/stringioandlibrary/matrix(776). Every method agreed on both the light frame and the screen verdict, and no method a run specialized wasnever.compiles: that verdict is a typed body without a profile, and the profile can still say otherwise (a nil receiver, a String argument).JitCensus1.Not run: net11.0 (this PR's CI), ruby/spec.
Limits
defonly: not loops compiled on their own, notdefine_methodbodies.perf-stepjudged by the census, a step no longer shows that a change computes the same thing beyond what its matrix probes, or that covering more was faster on the clock. That is what step 5 of the skill defers to the gate.🤖 Generated with Claude Code
Summary by CodeRabbit