stock-bot/design/development/architecture/benchmarks.md
2026-11-27 00:12:48 -05:00

38 lines
2.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Benchmark plan: staged measurement, one small harness
P01 starts with available code. No application benchmark was run during this planning review.
## Stage0: available now
Extend [benchmark-dataset.ts](../../../scripts/benchmark-dataset.ts) and add a small research driver:
- Fresh process/addon startup; existing native load/run/result parse.
- Single asset at1k/10k/100k bars; multi-asset fixture with equal-time events.
- Several repeated parameter trials using an existing supported native strategy.
- Dataset preparation/repeated prepared-object handoff measured separately from native/IPC work.
Record host/runtime/source/native-binary hash, seed, dataset/config identity, raw elapsed samples, returned bytes and RSS. Fresh-process and reused-input results are different; neither implies cross-trial resident data. Report startup/load/run/parse phases only where observable. DB/queue/allocations/TS-callback metrics are explicitly unavailable until their owning tasks instrument them.
Use deterministic fixtures and an economic-field hash excluding UUIDs, logs and wall time. Existing bad economics remain labelled limitations; benchmark parity does not validate alpha or accounting.
## Extend when the capability exists
| Owner | Added workload/counter |
| --- | --- |
| F06 |1k/10k/100k replay scaling; tie-order/hash equality; logging cost |
| F07/S01 | Tagged-step and real TS decisions; crossings, context bytes, decision time |
| R06 | Summary/result storage/query latency and batch queue wait |
| P04 |1/2/4 isolated workers; trials/s, tail latency, total RSS and hash equality |
| P03, if justified | Load-count reduction and resident dataset state-reset/lifetime |
| D04, if justified | Same-feature request count and incremental/batch parity |
| A02 | Restricted strategy IPC cost and timeout cleanup |
Later representative profiles:100 assets x10k observations;10 strategies over20 assets;100–1000 trials; high-turnover100k-fill result. Run them only when those semantics exist. Do not build missing features to make P01's benchmark matrix appear complete.
## Protocol
Short measurements: warmups plus repeated raw samples, medians/p95 where sample count supports them. Long sweeps: at least3 measured runs with load disclosed. Release native builds for performance; verify the actual addon hash. Cold OS/DB caches are claimed only when controlled; do not disrupt shared services to force them.
Compare equal economic/decision policies, inputs and outputs. Report bars/s for replay and end-to-end separately, trials/s, CPU time where available, RSS/bytes and parallel efficiency. Establish budgets from variance, not invented throughput targets. No timing-flaky unit tests or arbitrary dataset caps.
Optimization approval must estimate time saved across real research workloads against implementation/maintenance cost. The declarative path is optional, not a milestone every project must reach.