Skip to main content

Module sim_meter

Module sim_meter 

Source
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§

MeteredProtocolSim
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§

StageLabel
What the report calls the stage a swap was asked for.