Skip to content

Benchmark first HTTP announces into a swarm of fixed size #2518

Closed

Description

@josecelano

Goal

Add a Criterion benchmark that times one HTTP announce of a peer that is new to its swarm, for swarms of a few fixed sizes, so that changes to peer insertion and peer-list building can be measured. Today only repeat announces are measured.

Background

Issue #2479 repaired http_tracker/announce_once/announce_once. By its maintainer decision D3, that benchmark announces the same peer on every iteration, so it times a repeat announce: the update of the only peer in a one-peer swarm, with an empty peer list in the response. Its result is a lower bound on announce cost. It does not measure inserting a new peer or building a non-empty peer list (up to max_peers_per_announce, default 74 peers).

A new peer on every iteration would not give stable numbers: Criterion runs millions of iterations with no cleanup, so the swarm would grow by one peer per iteration and the cost would drift with its size.

Scope

  • A new benchmark group in packages/http-core/benches/http_tracker_core_benchmark.rs, http_tracker/first_announce/<N>, timing one awaited AnnounceService::handle_announce with event started for a peer that is not in a swarm pre-filled with N other seeders.
  • Swarm sizes N = 0, 74, and 1000.
  • The swarm stays at exactly N peers: each iteration times only the started announce (Criterion iter_custom), and the peer leaves again with a stopped announce outside the measured time.
  • The RoutineGuard from fix(http-core): make the HTTP announce benchmark measure the announce #2479 on the new benchmark, plus an assertion that the swarm still has N peers after the run, so both failures are caught by cargo test --benches in the pre-push hook and CI.
  • Documentation in docs/benchmarking.md.

Out of scope: production-code changes, a UDP announce benchmark, the HTTP parsing and Axum server layers, and changes to the existing repeat-announce benchmark.

Decisions

The specification records three maintainer decisions with the discarded options, their pros and cons, and why each was not chosen:

  • D1 - Measure only the join with iter_custom. Discarded: timing join and leave together, Criterion iter_batched (its synchronous setup cannot await the removal), rebuilding the swarm once per sample, and a rotating pool of peers (it measures repeat announces again). Accepted cost: two clock reads per iteration inside the measured time, a constant documented with the benchmark.
  • D2 - Swarm sizes 0, 74, and 1000. Discarded: a single size, and many sizes.
  • D3 - Seeders. Peer selection only excludes the announcing peer's address, so the peer type does not change the peer-list work; seeders match the existing benchmark's sample peer.

Specification

docs/issues/open/2518-http-first-announce-benchmark/ISSUE.md (added by the spec-only pull request).

Related to #2479.

Activity

  1. added 13 commits that reference this issue on Oct 14, 2026
  2. 10 remaining items

  3. added 3 commits that reference this issue on Oct 14, 2026
  4. self-assigned this
    on Oct 21, 2026
  5. added 10 commits that reference this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions