Expand description
Measurement of the simulation work one solve does.
Simulating a swap is the dominant cost of solving, and that cost varies by orders of magnitude
between protocols — a constant-product pool is arithmetic, a vm:* pool runs EVM bytecode. This
records what was asked of which component, so a solve can say where its time went.
Callers go through MeteredProtocolSim::get_amount_out_metered, which wraps the panic guard
in sim_guard rather than replacing it. Counting and reporting are one decision: an
algorithm that does not bracket its solve with start_solve and report must not meter
either, or the counts pile up on the worker thread unread. water_fill and
path_frank_wolfe both bracket, which is why the shared split code they run through meters;
everything else takes the bare guard.
Counts live in a thread-local for the duration of a solve, which a worker runs start to finish
on one thread. Recording therefore needs nothing passed down to it, and the default build —
where swap-metrics is off — compiles every entry point here to nothing.
Traits§
- Metered
Protocol Sim - Extension trait adding metered, panic-guarded simulation calls to every
ProtocolSim.
Functions§
- record_
cache_ hit - Recording is compiled out. See
start_solve. - record_
interpolation - Recording is compiled out. See
start_solve. - record_
refusal_ without_ calling - Recording is compiled out. See
start_solve. - report
- There is nothing to report without
swap-metrics. - start_
solve - Recording is compiled out. The arguments are taken so the call sites read the same in either build; the optimiser drops them.
Type Aliases§
- Stage
Label - What the report calls the stage a swap was asked for.