|
| 1 | +# Analysis efficiency measurements |
| 2 | + |
| 3 | +Tracks the experiments for [#2016](https://github.com/morluto/rea/issues/2016). |
| 4 | +The production CLI/MCP contracts and defaults remain the compatibility baseline. |
| 5 | +Downloaded artifacts, runtime copies, exported Evidence, transcripts and raw |
| 6 | +measurements belong outside the checkout. |
| 7 | + |
| 8 | +## Reproduce a measurement |
| 9 | + |
| 10 | +Use the repository's pinned Node/npm and locked dependencies. Build each selected |
| 11 | +revision, then copy its `dist/`, `bridge/`, `scripts/`, `skills/`, `package.json` |
| 12 | +and `package-lock.json` to a separate runtime directory before editing production |
| 13 | +sources. That copy needs the matching locked dependencies. The initial frozen |
| 14 | +baseline is `42b0ed126df7d5b908ac369715378d5e519051b7`; this study does not |
| 15 | +silently substitute a newer `main` or the previous Code Mode experiment. |
| 16 | + |
| 17 | +The public artifacts and acquisition digests are in `corpus.json`. Supply their |
| 18 | +actual local paths and an optional JSON object of explicit provider environment |
| 19 | +settings. Do not add credentials to that file. Provider settings are inherited |
| 20 | +by the child, but the report persists only the selected settings' digest. It |
| 21 | +does not serialize the ambient environment. |
| 22 | + |
| 23 | +```sh |
| 24 | +export NODE_OPTIONS=--max-old-space-size=512 |
| 25 | +export UV_THREADPOOL_SIZE=1 |
| 26 | +export GOMAXPROCS=1 |
| 27 | +export GOMEMLIMIT=2GiB |
| 28 | +python3 experiments/analysis-efficiency/resource-run.py -- \ |
| 29 | + node experiments/analysis-efficiency/measure.mjs \ |
| 30 | + --runtime-root /absolute/frozen-runtime \ |
| 31 | + --revision 42b0ed126df7d5b908ac369715378d5e519051b7 \ |
| 32 | + --artifact obsidian.asar --path /absolute/obsidian-1.14.4.asar \ |
| 33 | + --providers /absolute/selected-providers.json \ |
| 34 | + --output /absolute/new-measurement-directory |
| 35 | +``` |
| 36 | + |
| 37 | +The wrapper requires Linux cgroup v2 and a working user systemd manager. It owns |
| 38 | +a unique transient scope, restricts the whole process tree to one CPU, caps |
| 39 | +memory at 4 GiB with no swap and 192 tasks, and samples memory/tasks/CPU every |
| 40 | +100 ms. It stops its own scope above 3 GiB or below 4 GiB host available memory; |
| 41 | +startup requires 8 GiB available. Cleanup failures retain the owned scope's |
| 42 | +identity. Run heavy builds, providers and model trials serially. Sampled peaks |
| 43 | +can miss short spikes; cgroup limit events are separately reported. |
| 44 | + |
| 45 | +## What the numbers mean |
| 46 | + |
| 47 | +`summary.json` records the selected artifact's before/after SHA-256, runtime |
| 48 | +file-table digest, dispatcher and lockfile digests, runner source digest, |
| 49 | +Node/SDK versions, catalog sizes, caller arguments and producer Evidence IDs. |
| 50 | +`runtime-files.json` identifies the exact compiled files measured. Actual |
| 51 | +provider settings and runtime files must stay fixed during a comparison. |
| 52 | + |
| 53 | +Every tool call measures three intervals at the public SDK Transport boundary: |
| 54 | + |
| 55 | +- Client work before `send`, including first-use schema preparation. |
| 56 | +- Transport/server roundtrip, including framing, I/O, server work and client |
| 57 | + JSON parsing. This interval is **not** a Ghidra-only or provider-only timer. |
| 58 | +- Client work after the parsed response reaches `onmessage`. |
| 59 | + |
| 60 | +The SDK call's total excludes the runner's subsequent encoding and disk writes. |
| 61 | +Result byte counts measure compact JSON of the parsed client result, not raw |
| 62 | +wire bytes or tokens. Progress notifications retain their actual arrival times; |
| 63 | +they do not imply more precise internal engine timings than the producer emits. |
| 64 | +Scope CPU time and aggregate process-tree memory come from the wrapper's final |
| 65 | +JSON line. Fresh processes have cold application caches; host page caches are |
| 66 | +not globally flushed. |
| 67 | + |
| 68 | +`--delivery summary` is an explicit candidate workflow, initially for artifact |
| 69 | +inventory. It must be supported by the selected server's advertised schema. |
| 70 | +The default `complete` runs the existing calls unchanged. Compare the same |
| 71 | +analyst facts and complete source Evidence before crediting a smaller response. |
| 72 | +Projection can reduce delivery bytes without reducing upstream analysis time. |
| 73 | + |
| 74 | +For a completed WASM result exceeding the MCP response budget, the runner keeps |
| 75 | +the original error, exports retained Evidence through the public tool, and |
| 76 | +authenticates the exact reported record using the selected runtime's parser. |
| 77 | +The report names this recovery; it does not relabel the oversized inline reply |
| 78 | +as successful delivery. |
| 79 | + |
| 80 | +## Initial observations and exclusions |
| 81 | + |
| 82 | +The frozen baseline has 2,326,609 bytes of complete catalog JSON, of which |
| 83 | +494,207 bytes describe names, descriptions and input schemas. One Obsidian |
| 84 | +trial spent about 21.9 s before the first request was sent, then about 0.77 s |
| 85 | +in that request's transport/server roundtrip. Other cold runs differed |
| 86 | +substantially. These single observations identify a measurement boundary; |
| 87 | +they do not establish a speedup or a distribution. |
| 88 | + |
| 89 | +The initial matrix exercised shipped Obsidian, NewPipe, ShareX, OpenWrt, SQLite |
| 90 | +WASM and jq artifacts. SQLite produced a complete result larger than the |
| 91 | +transport frame and requires an explicit recovery run. A first jq attempt hit |
| 92 | +the SDK's default 60 s timeout because the experimental runner used a superseded |
| 93 | +three-argument call signature. SDK 2.3.1 accepts request options as argument two; |
| 94 | +the corrected jq run completed real Ghidra analysis in about 265 s. That earlier |
| 95 | +driver timeout is excluded from REA regression claims. Provisional runs with |
| 96 | +different runner source digests are not one paired statistical cohort. |
| 97 | + |
| 98 | +No cross-session engine database cache, default analyzer changes, external |
| 99 | +plugin loading, or broad plugin SDK is enabled by this experiment. |
0 commit comments