Skip to content

refactor: improve exclusive liquidity request latency - #430

Open
louise-poole wants to merge 2 commits into
mainfrom
fix/exclusive-liquidity-request-latency
Open

refactor: improve exclusive liquidity request latency#430
louise-poole wants to merge 2 commits into
mainfrom
fix/exclusive-liquidity-request-latency

Conversation

@louise-poole

Copy link
Copy Markdown
Collaborator

Optimisation: Quote ranking narrows candidates by borrow instead of cloning, removing one deep copy of every candidate's route from the request path.

Metrics: Makes the time a request spends waiting on each worker pool visible in metrics:

  • worker_router_pool_response_seconds (new) — per-pool latency as the router sees it: queue wait, readiness wait and the solve, recorded for failures as well as successes.
  • worker_pool_readiness_wait_seconds (new) — time spent waiting for derived data before solving.
  • worker_pool_solve_duration_seconds — now labelled by outcome, and recorded for every outcome rather than successes only.

🤖 Generated with Claude Code

louise-poole and others added 2 commits August 17, 2026 11:09
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@louise-poole
louise-poole force-pushed the fix/exclusive-liquidity-request-latency branch from 527a1ac to 11fd640 Compare August 17, 2026 09:21

@Troshchk Troshchk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Left a couple of qs

// Mark all remaining worker pools as timed out
let elapsed_ms = deadline.saturating_duration_since(Instant::now())
.as_millis() as u64;
let elapsed_ms = start_time.elapsed().as_millis() as u64;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix!

Comment on lines +77 to +81
Err(SolveError::NotReady(_)) => "not_ready",
Err(SolveError::Timeout { .. }) => "timeout",
Err(SolveError::NoRouteFound { .. }) => "no_route",
Err(SolveError::InsufficientLiquidity { .. }) => "insufficient_liquidity",
Err(_) => "error",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to use solver_error_label for the error matching?
Is it ok, that we wrap some errors into simple "error" string?

/// Unlike `worker_pool_solve_duration_seconds`, which a worker reports for its own successful
/// solves, this covers everything the request actually waits for — queue wait, readiness wait,
/// and the solve — and is recorded for failures too (`outcome`). The gap between the two is
/// what a request pays for a worker pool beyond its algorithm's own working time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add that the pools are worker pools?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants