CS2DemoKit Technical Blog - Part 2 - The Analysis Engine
This is Part 2. Part 1 covers the parser: how a .dem file becomes frames, messages and typed game events. If you’d like the non-technical overview of the whole project first, start with the announcement.
Part 1 ended on a number: parsing is about 21% of the time it takes to load and analyze a demo, and evaluating rules is 72 to 81%. This post is about that 72 to 81%.
What the analysis engine is
Section titled “What the analysis engine is”CS2DemoKit.Analysis takes a ParsedDemo and a set of rulesets and produces an AnalysisRun: per-player stats, per-round tables, and highlights stamped with the tick they happened on.
ParsedDemo demo = MemoryMappedDemoSource.ParseFile("match.dem");RuleConfigLoadResult rules = YamlConfigLoader.LoadShippedEmbedded();AnalysisRun run = DemoAnalysis.Run(demo, rules.Rulesets);Run is Build followed by Evaluate, and you can call them separately:
BuildResult build = DemoAnalysis.Build(demo, rules.Rulesets); // ~21 msAnalysisRun run = DemoAnalysis.Evaluate(demo, build); // ~1.4 sBuild compiles the rulesets into a graph. Evaluate walks through the demo. On a full match those took about 21 milliseconds and 1.4 seconds in our baseline measurements (evaluation has gotten faster since; more on that below). The split means an application can compile the graph, show an empty scoreboard with the right columns, and then start the slow part. It also means you can compile once and evaluate against a hundred demos.
The best way to picture it is a spreadsheet, not a loop over events. Rules compile into a graph of cells that depend on each other. When a message arrives, it marks a few cells as changed, the engine recalculates whatever depends on them, and moves on. The work per frame depends on how much actually changed, which with the built-in data sources is about one cell in a thousand.
The state graph
Section titled “The state graph”The building blocks are small and simple. An edge fires on something: a game event, a network message, or a change in entity state. A node holds a value: a counter, a captured value, a computed formula, or a flag. Conjunction (and) and disjunction (or) nodes combine other nodes. A per-player template creates a whole set of nodes for each player the first time that player appears, which is how one rule written in the singular (“count this player’s kills”) turns into ten live copies. The same idea works per side (for: each_team, two copies) and per grenade (for: each_projectile, one copy for each grenade from the throw until it’s gone).
Rule expressions aren’t interpreted while the demo runs. During Build they’re compiled into .NET code (via LINQ expression trees), and reading an event’s fields goes through cached, compiled accessors. By the time the frame loop starts, there’s nothing left to interpret.
flowchart TD A["EvaluateCore"] --> B["pipelined digest producer<br/>(runs alongside the loop)"] B --> C["reader thread cuts chunks<br/>at DEM_FullPacket checkpoints"] C --> D["worker: prime from checkpoint,<br/>build a digest per frame"] D --> E["chunks queued in order"] A --> F["per-frame loop (sequential)"] E --> G F --> G["consume digest N, fold N-1 into the pre-frame snapshot,<br/>synthesize entity-change and molotov events"] G --> H["per message: dispatch filter,<br/>edges in topological order"] H --> I["route dirty nodes:<br/>liveness, logic, live computes, snapshot bits"] I --> J["recompute logic to fixpoint"] J --> K["drain live computes<br/>(bounded: one recompute per compute per message)"] K --> L["capture the snapshot row<br/>(chunk-shared)"]
Three behaviors in the evaluator are worth explaining.
Highlights fire on a change, not a state. When a conjunction node becomes true, that’s recorded as an event on a timeline, with the tick and the player it belongs to. That’s what a highlight is, and it’s why a highlight comes with a tick you can hand straight to a clip planner, instead of a true/false value you then have to find the timestamp for.
The order of updates within one message is decided up front. Two edges reacting to the same event can read each other’s results, so the engine sorts the edges for each kind of message based on what each one writes and reads. If the sort finds a real cycle, it doesn’t fall back to file order and hope for the best. It fails, and the error tells the rule author the exact after: <stat> line that fixes it, in terms of their rules rather than the engine’s internals.
Live formulas update only when their inputs change. A formula normally evaluates at the end of a round. Marking it live: true makes it update during the round instead, but not by re-running every formula on every message. The graph knows which nodes each formula reads, so a change to any of them schedules exactly one recalculation of that formula. That limit both prevents duplicate updates and guarantees each message’s updates finish. Graphs with no live formulas take the exact same code path as before the feature existed, which is how it shipped without changing a single expected test output.
Parallelizing something that’s sequential by definition
Section titled “Parallelizing something that’s sequential by definition”The entity decoding in that diagram is the biggest single cost in evaluation. It’s also an interesting problem, because the data can’t be decoded out of order.
Entity state is sent as changes. Frame n’s entity data is meaningless without the result of frame n-1. That’s about as sequential as data gets.
The way out is that a CS2 demo regularly includes a DEM_FullPacket, a complete snapshot instead of a set of changes. A worker that starts at one of those checkpoints doesn’t need any earlier history. So a reader thread cuts the demo into chunks at checkpoint boundaries, skipping any checkpoint that can’t be used as a clean starting point, and hands each chunk to a worker. (Over a fully loaded demo, it groups them into about twice as many chunks as there are workers.) Each worker starts from its checkpoint and decodes forward on its own, while the main loop consumes finished chunks in order.
The interesting part is how we prove that’s correct.
Workers produce per-player changes, and a worker’s first frame has to re-send every value, since it has no previous frame to compare against. So the parallel output isn’t row-for-row identical to the sequential output. It has extra rows.
But the consumer folds every row into a “latest value per (data source, player)” map, and re-sending a value that’s already there changes nothing. So the rows differ, but the folded result doesn’t, and that’s what the test checks: the folded results match, not the rows. The expected outputs are byte-identical either way.
Testing for row-for-row equality would have meant either a weaker test or making workers skip their first-frame re-send, which would bring back a dependency on earlier history, the very thing we were avoiding. Proving the folded results match costs nothing and is the stronger guarantee.
Only decoding what the rules need
Section titled “Only decoding what the rules need”If no rule in your set reads entity state, you don’t pay for entity decoding. The engine works out what it needs from what the rules actually reference: older (v1) rules are scanned for the names they mention, newer (v2) rules declare exactly what they read, and the combination decides which entity fields get decoded at all. It’s dead-code elimination, applied to a demo.
DemoAnalysis.Run does this for you. If you’re running the steps yourself, for example compiling once and running against many demos, you can apply the plan explicitly:
using DemoReader reader = DemoReader.OpenFile("match.dem");BuildResult build = DemoAnalysis.Build(reader, rules.Rulesets);reader.Configure(DemoAnalysis.PlanDecode(build)); // decode only what the graph readsAnalysisRun run = DemoAnalysis.Evaluate(reader, build);This is enforced, not just a hint. Reading a data source that wasn’t planned for throws an error instead of returning a default value. Every planned data source also has its field path and type checked against this demo’s schema at the first full snapshot, so if a CS2 update moves a field, the run fails right away instead of producing plausible-looking numbers for forty minutes.
The per-player digest, and the 99.9%
Section titled “The per-player digest, and the 99.9%”For rules that do read entity state, the decoder produces a per-frame summary: for every live player, the current value of every data source the rules use.
The original version built that summary for every frame and kept the whole stream around until evaluation used it. On a 123,283-frame demo, that’s 2.7 million stored values.
Of those, only 2,874 differ from the previous frame.
The consumer was folding all 2.7 million into a “latest value” map, which means 99.9% of the work was writing a value that was already there. Sending only the values that changed produces exactly the same result.
Measured as an interleaved A/B test over fifteen demos (40 to 524 MB, thirteen maps), with three rounds per version and the order swapped each round:
| metric | median change | range | demos improved |
|---|---|---|---|
| evaluate | -22.1% | -11.6% to -33.4% | 15/15 |
| evaluate allocation | -13.0% | -4.3% to -14.5% | 15/15 |
| total load | -17.2% | -6.2% to -26.3% | 15/15 |
| parse (control) | +0.1% | ||
| retained (control) | +0.3% |
Two things about that table matter more than the numbers.
We widened the set of demos on purpose, and it changed the answer. An earlier version of this measurement reported -31.2% for evaluation and -24.9% overall. That was on five demos, three of which happened to benefit the most, and all five were within six megabytes of each other in size. A set like that can’t catch a result that only holds at one size. The wider number is the one we publish, and the narrower one stays written down next to it so nobody rediscovers it and thinks they’ve found something.
The allocation column shows why it works. The savings grow with the length of the demo: the 36,000-frame demo saves 4.3% while the 229,000-frame demos save 14.2%. If the improvement didn’t grow that way, it wouldn’t be coming from this change.
It’s a garbage-collection win, not a decoding win. Every data source is still read for every live player on every frame; what changed is how much of that is kept around to be collected later. And it depends on the built-in data sources changing rarely, which brings us to the case where that’s not true.
Position is expensive, on purpose
Section titled “Position is expensive, on purpose”Rules read a player’s world position as three separate numbers: player.pos_x, player.pos_y, player.pos_z. As Part 1 explains, there’s no position vector in the data. Position is a grid cell index plus an offset within the cell.
A moving player’s position changes every frame, which defeats the “only send what changed” approach for that column. Counting the values actually sent on the same 123,283-frame demo:
| data sources | values sent |
|---|---|
| the six built-in sources | 14,455 |
plus pos_z |
379,576 |
| plus all three axes | 1,442,280 |
One axis costs 26 times as much. All three cost 100 times as much.
Data sources are only decoded when a rule uses them, so a ruleset that reads no position pays none of this, and a ruleset that needs one axis should read only that one.
Splitting position into three numbers wasn’t our first choice, and it has a measurable cost too. The rules language only has bool, int, float, string, duration and instant, plus lists and maps of those. There’s no vector type and no way to read .z off one. A single vector-valued column would send 548,787 values instead of the split’s 1,442,280 on the same demo, because it stores one value per player per frame instead of about 2.7. So a ruleset reading all three axes pays 2.6 times as much because of the language’s type system. That’s a real cost, and we’ve written it down. Fixing it means adding a new kind of type to the checker, the normalizer and rule hashing, which isn’t worth it until position-based rules are common.
The round-end event that never fires
Section titled “The round-end event that never fires”This is our favorite finding in the whole project, and it has nothing to do with performance.
If you want per-round stats, you need to know when each round ends. The obvious answer is the round_end game event. In the Valve matchmaking demos we’ve studied, round_end fires zero times. Its sibling, round_officially_ended, does fire on those demos.
Tournament demos are where it gets tricky. ESL and BLAST record through SourceTV, so their file header has the client name SourceTV Demo, exactly identical to what Valve matchmaking writes. Nothing in the header tells them apart. And tournament demos never fire round_officially_ended; they mark rounds with cs_pre_restart instead.
The obvious fix, listening for both, doesn’t work: on Valve matchmaking demos both events fire every round. Do that and a 16-round match comes out as 26-6 across 32 “rounds”, which looks like a plausible scoreboard until you check it against what actually happened. So each recording type has to use exactly one round-end event, and picking the right type matters.
So classification happens twice. The header gives a first guess, and then the events the demo actually contains get a vote: a recording that never fires round_officially_ended but does fire cs_pre_restart is reclassified as a tournament demo. Rules don’t listen for round_end directly. They listen for a logical $round_end, which each recording type maps to whichever event it actually uses, with built-in guards on anything that must only fire once per round.
Who won the round is a separate question. Working it out from bomb state and who’s left alive gets some rounds wrong, a surrender being the obvious one. So the engine reads the server’s own verdict, the game rules’ round-win status in the entity data, and turns it into a synthesized round_decided event on the frame the round is decided. The old derivation is only a fallback for a run that has no entity data to read.
A logical event that no loaded recording type can map is a clear build error, not a silent zero, and unknown event names get “did you mean” suggestions. A related bug needed a different fix: a knife round before a match restart produced a 14-11 score across 25 rounds, because the restart needs to roll back per-match state and nothing was doing it. Now the engine saves each value’s state at the match start and restores it when the match restarts.
A note on scope: these are observations from the demos we’ve studied, not a guarantee about every CS2 recording that exists. That’s why the engine decides from the evidence in each demo, instead of from a table we maintain by hand.
Line of sight
Section titled “Line of sight”The other big piece of CS2DemoKit.Analysis is a 3D visibility engine, and it exists because the demo doesn’t contain a usable answer. The demo’s own spotted flag is coarse, decided by the server, and tied to gameplay rules. If you want to know when one player could actually see another, you have to work it out from the map geometry.
string? bake = CollisionAssetLocator.FindCollisionTris(demo.MapName);AnalysisOptions options = new(){ VisibilityEngine = bake is null ? null : VisibilityEngine.Load(bake)};The geometry comes from an offline “bake” (a list of collision triangles in world space, plus a manifest file), so at runtime you don’t need the game installed or any Valve file formats. VisibilityEngine.Load builds a bounding-volume hierarchy (BVH), a tree structure that makes ray tests fast. The engine can’t be changed after it’s built and is safe to share across every run on that map, so build it once and keep it.
Exposed is not the same as seen
Section titled “Exposed is not the same as seen”The main measurement is two durations for each pair of opposing players, in each direction, and keeping them separate is the whole design:
- exposed: there’s a clear line from this player’s eyes to some part of the other player’s body.
- could-see: exposed, and within this player’s field of view, and not blocked by smoke.
Could-see is always a subset of exposed. Smoke is modeled as a solid sphere with a 144-unit radius centered where the grenade went off, and it’s only checked for could-see. Smoke blocks sight, not bullets, and the exposure check runs against the map’s solid geometry, where smoke doesn’t exist.
So an enemy behind smoke counts as exposed but not seen. That’s intentional, and it’s why through-smoke kills happen. Having both numbers lets a rule ask about one without accidentally asking about the other.
flowchart TD
START["anchor i of up to 6, chest first"] --> FOV{"in field of view?"}
FOV --> SKIP{"already exposed and out of view,<br/>or already could-see?"}
SKIP -- yes --> NEXT["next anchor"]
SKIP -- no --> RAY["raycast eye to anchor<br/>(BVH any-hit)"]
RAY -- blocked --> NEXT
RAY -- clear --> EXP["exposed = true"]
EXP --> SMOKE{"in view and not through smoke?"}
SMOKE -- yes --> SEE["could-see = true, stop"]
SMOKE -- no --> NEXTTwo details took more thought than they might seem to.
Up to six points per target, chest first. A single line between two players’ eyes answers a different question from the one players actually experience, because a sliver of shoulder around a corner is visible long before the head is. So the target is checked at several points on the body. The chest goes first because it’s the most likely to be visible and lets the check stop early. The shoulder points are offset sideways relative to the viewer’s line of sight, which puts them where a peek around a corner would show up, instead of along a fixed map direction that would be wrong for most angles.
The field of view is a rectangle, not a cone, and the source explains why. CS2’s horizontal field of view at 16:9 is about 106 degrees, but its vertical field of view is only about 74 degrees (73.7). A cone wide enough for the horizontal figure would also claim 106 degrees vertically, which badly over-counts sightlines above and below you on maps like Nuke and Vertigo, where those fights are common. So the field of view is a box, 106 degrees wide and 74 degrees tall.
Smoke timing comes from the smoke grenade’s own lifetime in the entity data, not a hardcoded duration. Those entity tick fields use a different starting point from the frame clock, and mixing the two up is the kind of bug described in Part 3’s “Two clocks” section.
Finally, every result records which bake it was computed against: the map version (a checksum of the map’s radar, navigation and overview files) plus the version of the tool that made the bake. Bakes are picked by map name alone, so after a Valve map update, that record is the only way to tell an outdated bake from a current one. Store it with any saved results.
The visibility scan only runs when a rule asks for it
Section titled “The visibility scan only runs when a rule asks for it”Checking every fourth tick over a forty-minute demo is roughly 38,000 ticks with up to about 300 rays each: around ten million rays, which takes minutes and can be cancelled.
So it only runs when a rule needs it. The catch is that reading a visibility-based attribute isn’t the same as subscribing to the event that produces it; some rule has to actually count enemy_spotted. Get that wrong and every reader falls back to its placeholder value, which adds up to a plausible-looking number instead of an error. So the build output includes a coverage note naming the stat, the attribute, and which of the two requirements is missing.
The eight-wide tree
Section titled “The eight-wide tree”The BVH is built using a standard technique (the binned surface-area heuristic) and then reshaped so each node has eight children instead of two. Each node’s eight child bounding boxes are stored as six separate float arrays (minimum and maximum for each axis), so a CPU with SIMD instructions can test all eight children at once. Children are arranged by direction, so a ray’s nearest child is determined directly by which way it’s pointing, and the traversal visits the nearest child first.
Empty child slots hold an inside-out box, with positive infinity as the minimum and negative infinity as the maximum, which every ray misses without needing an extra check. That works well until a ray’s direction isn’t a finite number. A direction that’s infinite on all three axes turns every calculation into NaN (not a number), nothing rules out any child, and every slot is visited, empty ones included. Both traversal versions now reject a non-finite ray up front. It’s a one-line check, and it covers a whole class of input that comes from ordinary math: normalizing a direction whose length is too small to represent gives you infinities, and nothing before that point looks wrong.
Correcting our own numbers
Section titled “Correcting our own numbers”The eight-wide tree changed two things at once: the tree shape went from two children per node to eight, and the builder learned to use multiple threads. Those are two separate improvements that multiply together, and on a machine with enough cores, either one can be made to look like the whole story.
Measured separately, on a 32-thread machine, with medians of nine warm runs per version:
| bake | triangles | binary, 1 thread | wide, 1 thread | tree shape gain | wide, 32 threads | threading gain |
|---|---|---|---|---|---|---|
| de_nuke | 191,628 | 143.5 ms | 121.9 ms | 1.18x | 27.0 ms | 4.52x |
| de_dust2 | 435,649 | 391.9 ms | 337.2 ms | 1.16x | 50.7 ms | 6.64x |
| de_overpass | 713,341 | 784.4 ms | 708.2 ms | 1.11x | 88.9 ms | 7.97x |
| de_ancient | 967,742 | 1137.8 ms | 1072.9 ms | 1.06x | 126.6 ms | 8.47x |
The new tree shape is worth 1.06 to 1.18x, and less as the map gets bigger. The rest comes from using more threads.
An earlier set of figures that circulated internally claimed 5.9x to 7.9x faster builds. Those were the combined effect: a single-threaded run of the old builder against an all-cores run of the new one. That comparison credits the tree shape with the threading improvement, and it changes with the core count of whoever runs it. The same comparison on this machine gives 5.3x to 9.0x, which is how we know that’s what those numbers were.
A memory claim didn’t hold up either. The story was 182.4 MB down to 75.4 MB on the largest map. The 75.4 MB reproduces exactly, with one thread. The 182.4 MB doesn’t reproduce at any thread count: the old builder’s peak memory on that map is 96.0 MB, and its total allocation over the whole build is 169.1 MB. So the real saving is 20.6 MB (1.27x), not 107 MB.
And that saving is only temporary. The eight-wide builder’s peak memory stays within 1.7 MB of its finished size on every map, while the binary builder peaks at 2.8 to 3.5 times its finished size in temporary data. But the finished trees are 62.2 MB (binary) and 75.4 MB (eight-wide), counting the triangle data on both sides, because the binary tree points to the caller’s triangle list while the eight-wide one copies what it needs and lets the original go. The eight-wide tree is actually the larger one. The win is in the builder’s peak memory, not in what it leaves behind.
Nine runs is the minimum, and this measurement is how we learned that. At five runs, one map’s binary builder measured 674 / 1300 / 1701 / 1257 / 1425 ms, which put the tree-shape gain at 1.72x and the combined gain at 12.95x. At nine runs it settles to 1.11x and 8.82x, with every run between 670 and 801 ms. This benchmark used to take a single sample per version, and one sample can’t tell a 1.1x effect apart from that much noise.
Two things did hold up. The tree’s structure is identical with one thread and with thirty-two on all four maps, so the threaded build produces the same tree faster, not a different tree built carelessly. And we checked the memory measurement itself. Compacting the large-object heap before every memory reading turned out to make no difference on that machine. We kept it anyway, because without it, the difference between two builders that allocate large arrays differently would be partly fragmentation and partly real memory use, with no way to tell how much of each.
Highlights and clips
Section titled “Highlights and clips”A highlight is a per-round “did this happen?”, and its match-wide .count is the number of rounds it happened in. That’s the standard way to turn “this round I did X” into a match total.
Every highlight comes back on AnalysisRun.Highlights stamped with a tick, and CS2DemoKit.Analysis.Clips turns those into clip windows. It works out round boundaries, hides highlights you’ve marked as hidden, collapses related highlights down to the best one (you want the 4K, not the 4K and the three 2Ks inside it), and calculates each round’s clip windows with lead-in time and merging of overlapping clips.
A multi-kill longer than the lead-in time starts from the first kill instead of the last one. That adjustment is applied before the round-start limit, so a clip can never spill into the previous round. Merging gives the same result regardless of the order clips are processed in.
What keeps this manageable is that everything stays on one clock, the frame clock, from start to finish. Any offset a video tool needs is applied exactly once, when the clips are output, never inside the plan. Applying a tick offset twice is a very common bug in demo tools, and it produces clips that are almost, but not quite, in the right place, which is the hardest kind of wrong to notice.
How this compares to other tools
Section titled “How this compares to other tools”As Part 1 explains, our cross-parser comparison isn’t published yet. The analysis engine is a harder case, because most of it has nothing to compare against.
A rule-driven engine over a stats language isn’t something other CS2 tools have. Benchmarking it against a hand-written stats script would measure which stats each project happened to implement, not which engine is faster, and we could pick a workload that wins every time, which is why it would be worthless.
Two parts of it can be compared, and both are on the list.
End to end: demo file to a finished scoreboard. This is what a user actually waits for, and several tools do it. The tricky part is defining a common output, since two tools that both produce “a scoreboard” may calculate ADR differently. The plan is to compare only the columns that can’t be interpreted differently (kills, deaths, assists, headshots, damage) and check that they match before timing anything.
Line of sight. Visibility computed from map geometry is rare in demo tools, and where it exists it’s usually a single line between two players’ eyes. Ours checks up to six points on the body with shoulder offsets relative to the viewer, and separates exposure from vision. Those give different answers, not just different speeds, so the comparison has to report both: rays per second and how often the two approaches disagree. A faster engine answering a rougher question isn’t really faster.
Neither is measured yet. Our first comparison runs had no scoreboard workload, because none of the other parsers in them produce per-player stats out of the box. awpy, the obvious candidate, needs Python 3.11 or later, which the test machine didn’t have, and it has no per-player scoreboard function either.
When they are measured, the same rules apply as everywhere else in this project: the benchmark harness is published alongside the numbers, the losses go in the same table as the wins, and pull requests that make the comparison fairer are welcome.
Golden tests that can’t pass by accident
Section titled “Golden tests that can’t pass by accident”We got this one wrong the first time.
The whole stats stack is tested against “golden” files: one expected-output file per demo, committed to the repository and compared with zero tolerance against a fresh run of the full engine.
The original design compared two committed files. Both were produced by the same code, so they always agreed. The test suite stayed green for six weeks while a real bug was in place, because it had no way to do anything else.
The fix is about discipline more than cleverness. Only the expected file is committed. The actual output is always recalculated from a full engine run, every time. And regenerating the expected file after an intentional change ends in a skipped test, not a passing one, so a regeneration can never be mistaken for a test that actually checked something.
The same idea shows up elsewhere. Golden files for real-match demos store summary counts plus a SHA-256 hash of the full output, which locks in every value without putting real players’ names in a public repository. When we compare entity values against another parser, its readings are saved to a fixture file rather than calling it live, so it never becomes a build dependency.
A regression test only means something if one side of the comparison is computed fresh. That seems obvious now; it wasn’t while the tests were passing.
What else we check
Section titled “What else we check”Generated files are committed and tested. The rules catalog and the editor schema are generated from the engine’s own registries and committed, and a test fails the build if the committed copy is out of date.
Determinism is tested, not assumed. Multi-threaded tree builds are checked against single-threaded ones. The parallel digest results are checked against the sequential ones. The eight-wide traversal is checked against a brute-force reference, and each SIMD version is checked against the plain version on awkward inputs, like negative zero, ray origins exactly on a box face, and zero-thickness boxes.
The benchmark tool refuses to mix results that can’t be compared. It runs one process per measurement, throws away a warm-up run in each, records the machine’s one-minute load average on every result, and uses the workstation garbage collector on purpose, because the server collector would hide garbage-collection costs, and those are roughly a third of this pipeline. When we changed the result format to add the ray columns, the comparison tool started refusing to put old results next to new ones instead of quietly averaging across the change.
None of that is exciting, but it’s what let us say “this number doesn’t reproduce” with confidence.
Part 3 covers the rules language itself: what you can measure, how a YAML file becomes a compiled graph, why the new compiler reuses the old one behind the scenes, and the design choices that make a broken rule fail loudly instead of quietly producing a wrong number.
In the meantime, docs/RULES_AUTHORING.md in the repo is the hands-on guide, and docs/perf/baseline.md has every measurement quoted here with the raw results beside it.