Repository navigation
Description
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 awaitedAnnounceService::handle_announcewith eventstartedfor a peer that is not in a swarm pre-filled withNother seeders. - Swarm sizes
N= 0, 74, and 1000. - The swarm stays at exactly
Npeers: each iteration times only thestartedannounce (Criterioniter_custom), and the peer leaves again with astoppedannounce outside the measured time. - The
RoutineGuardfrom fix(http-core): make the HTTP announce benchmark measure the announce #2479 on the new benchmark, plus an assertion that the swarm still hasNpeers after the run, so both failures are caught bycargo test --benchesin 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, Criterioniter_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
docs(issues): [torrust#2518] compare first-announce results only with…
docs(issues): [torrust#2518] record each run's Criterion medians in M2
docs(pr-reviews): [torrust#2518] add the PR torrust#2519 review audit
docs(issues): [torrust#2518] wire the swarm-registry events in the be…
docs(issues): [torrust#2518] state the departure from the rotating pool
docs(issues): [torrust#2518] count inserts with a maintained assertio…
docs(pr-reviews): [torrust#2518] state the F1 verification without an…
docs(issues): [torrust#2518] log the PR torrust#2519 review fixes and…
docs(pr-reviews): [torrust#2518] record the PR torrust#2519 round 2 r…
docs(issues): [torrust#2518] add specification for torrust#2518
docs(issues): [torrust#2518] compare first-announce results only with…
docs(issues): [torrust#2518] record each run's Criterion medians in M2
docs(pr-reviews): [torrust#2518] add the PR torrust#2519 review audit
10 remaining items
docs(pr-reviews): [torrust#2518] record the PR torrust#2519 round 3 r…
Merge #2519: docs(issues): [#2518] add specification for #2518
Merge #2545: refactor(statistics): [#2536] hide the statistics reposi…
docs(issues): [#2518] record maintainer answers before implementation
refactor(http-core): [#2518] let a benchmark choose its torrent repos…
feat(http-core): [#2518] benchmark first HTTP announces into a swarm …
docs(issues): [#2518] record the benchmark mutation evidence and desi…
docs(issues): [#2518] record the cargo bench results and mark T2 done
docs(benchmarking): [#2518] document the HTTP first-announce benchmark
docs(issues): [#2518] record the approval, documentation, and complet…
Merge #2611: feat(http-core): [#2518] benchmark first HTTP announces …
chore(issues): archive closed issue #2518 spec to docs/issues/closed
Merge #2615: chore(issues): archive closed issue #2518 spec to docs/i…