Skip to content

chore: fix gossipsub benchmarks#3511

Open
dozyio wants to merge 8 commits into
libp2p:mainfrom
dozyio:chore-gossipsub-benchmarks
Open

chore: fix gossipsub benchmarks#3511
dozyio wants to merge 8 commits into
libp2p:mainfrom
dozyio:chore-gossipsub-benchmarks

Conversation

@dozyio
Copy link
Copy Markdown
Collaborator

@dozyio dozyio commented May 16, 2026

Description

Fix gossipsub benchmarks so that they can run

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@dozyio dozyio marked this pull request as ready for review May 16, 2026 14:31
@dozyio dozyio requested a review from a team as a code owner May 16, 2026 14:31
@dozyio
Copy link
Copy Markdown
Collaborator Author

dozyio commented May 16, 2026

Might want to migrate off benchmark.js as it hasn't been updates in a long while

@tabcat
Copy link
Copy Markdown
Member

tabcat commented May 24, 2026

i think tinybench is new standard https://github.com/tinylibs/tinybench

@dozyio
Copy link
Copy Markdown
Collaborator Author

dozyio commented May 25, 2026

Thinking to get this one in as it matches the rest of the repo and then migrate all off benchmark.js

dozyio and others added 6 commits May 25, 2026 12:58
Extract the per-file runBenchmark helper (identical except protobuf's
runsFactor, now defaulted to 1) into test/utils/benchmark.ts.
Replace the @ts-expect-error on the benchmark import with the real
types (Benchmark.Deferred, Benchmark) in the shared benchmark helper.
Use aegir's bundled mocha (no direct mocha dep) and forward --exit so
the run terminates after benchmarks leave handles open.
Times heartbeat() instead of the publish fan-out (now a one-time
warm-up), and stops the nodes so their timers don't keep the run alive.
@tabcat
Copy link
Copy Markdown
Member

tabcat commented May 26, 2026

  • Heartbeat was timing the publish, not heartbeat(). The migration folded
    the old untimed beforeEach publish into the timed fn, so it measured
    ~275 ms/op instead of ~3.66 ms/op. Moved it to a one-time warm-up so it times
    heartbeat() alone.
  • Node teardown — the 50 nodes were never stopped, so their timers kept the
    process alive and the run hung after finishing. Added stop().
  • Deduped runBenchmarktest/utils/benchmark.ts (was copied in all 4 files).
  • @types/benchmark added, dropped the @ts-expect-error.
  • mochaaegir test -t node (mocha wasn't a direct dep), kept --exit
    as a safety net.

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