07 / Benchmarks
Compute, measured.
Compute units of the compiled
token-hooks program, measured with Mollusk (one instruction) and LiteSVM (full Token-2022 transfers). Every case below ran and succeeded; each builtin is also checked to reject under a denying config, so a number is never the cost of skipping the check.01
Token-2022 transfer
mollusk-svm 0.15.1 (unit), litesvm 0.16.0 with bundled Token-2022 11.0 (transaction)| Case | CU | Over plain transfer | |
|---|---|---|---|
| transfer_checked: Token-2022, no hook | 1,790 | — | |
| transfer_checked: token-hooks, empty policy | 19,349 | +17,559 | |
| transfer_checked: token-hooks, 7 builtins | 20,188 | +18,398 |
The hook adds Token-2022's transfer-hook CPI, extra-account resolution and the policy load. Builtin evaluation itself is small next to that, as the per-builtin table shows.
02
Per builtin (token-hooks Execute)
empty stack 6,798 CU| Stack | Measured CU | Above empty | Kernel static estimate |
|---|---|---|---|
| allowlist | 6,937 | +139 | 2,500 |
| denylist | 6,943 | +145 | 300 |
| max-size | 6,915 | +117 | 300 |
| spending-limit | 6,950 | +152 | 300 |
| time-window | 6,916 | +118 | 300 |
| timelock | 6,906 | +108 | 300 |
| accounting | 6,930 | +132 | 300 |
| credential | 8,252 | +1,454 | 1,500 |
| all 8 token builtins | 9,079 | +2,281 | 5,800 |
Static estimates are deliberately conservative upper bounds used for compute budgeting before simulation.
03
Regression gate
tolerance 5%| Case | Baseline | Current | Status |
|---|---|---|---|
| execute: empty stack | 6,798 | 6,798 | unchanged |
| execute: allowlist | 6,937 | 6,937 | unchanged |
| execute: denylist | 6,943 | 6,943 | unchanged |
| execute: max-size | 6,915 | 6,915 | unchanged |
| execute: spending-limit | 6,950 | 6,950 | unchanged |
| execute: time-window | 6,916 | 6,916 | unchanged |
| execute: timelock | 6,906 | 6,906 | unchanged |
| execute: accounting | 6,930 | 6,930 | unchanged |
| execute: credential | 8,252 | 8,252 | unchanged |
| execute: all 8 token builtins | 9,079 | 9,079 | unchanged |
| transfer_checked: Token-2022, no hook | 1,790 | 1,790 | unchanged |
| transfer_checked: token-hooks, empty policy | 19,349 | 19,349 | unchanged |
| transfer_checked: token-hooks, 7 builtins | 20,188 | 20,188 | unchanged |
04
Binaries and reproduction
token_hooks.so sha256
969dd56de202ba3e740f6b6aa6875d43406aee7679c4b2522266b49d196b7e36
scripts/build_programs.sh programs/token-hooks cargo run --release -p hook-bench # writes bench/results.json and docs/benchmarks/report.md cargo test --release -p hook-bench # fails on a >5% regression against bench/baseline.json pumphooks bench --no-run # the table above, in a terminal