Skip to content

perf(p2p): bound catalog lookup latency across multiple peers #95

Description

@catyans

Problem

IrohBlobsP2pTransport::lookup_peers currently queries candidate peers
sequentially. Each remote lookup has its own timeout (5 seconds by default), so
stale or unreachable peers at the front of the scheduler-provided list can make
catalog lookup latency grow linearly with the number of failed candidates.

The implementation already calls this out with:

// TODO: parallelize lookups to multiple peers.

This affects both scheduler-index hits and broad peer-discovery fallback.

Proposed change

Run remote catalog lookups with a small fixed concurrency bound while retaining
the scheduler-provided ordering when selecting a successful descriptor.

  • Check local/self candidates without network I/O.
  • Keep at most a bounded number of remote lookups in flight.
  • Yield results in candidate order so a slower, higher-priority peer still wins
    over a lower-priority peer in the same window.
  • Continue past misses, timeouts, and malformed/unreachable peers.
  • Avoid adding a user-facing tuning knob until measurements show one is needed.

This reduces worst-case lookup time from approximately N * lookup_timeout to
ceil(N / concurrency) * lookup_timeout without generating an unbounded
connection burst or discarding scheduler priority.

Validation

  • Unit tests for ordering, bounded concurrency, misses, and errors.
  • Existing Iroh loopback lookup/fetch tests.
  • Multi-node Lingjun experiment with failed candidates preceding a valid
    provider, comparing lookup latency before and after the change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions