Skip to content

dash-spv: debug-build sync slowed 2–3× since X11 moved to pure-Rust dash-pow on the async peer reader #1425

Open
3 of 4 issues completed

Description

@Claudius-Maginificent

TL;DR

Since the switch to the pure-Rust X11 (dash-pow, #1214) and the network rewrite that hashes headers2 inside the peer reader (#902), dash-spv syncs testnet much more slowly in debug/test builds. A debug build that synced from genesis in about 5 minutes at aca02026 no longer finishes within 15 minutes. Release builds are not affected. Downstream test suites that sync a real chain (dash-evo-tool's migration tests) now miss their time limits.

Update 2026-11-17: the comment below adds a CPU profile, a selective opt-level fix for downstream crates and the hardware-path results, and corrects the X11 "5× slower at opt-level 3" claim (a rustc 1.92 artifact).

User story

As a developer of an app built on dash-spv, I want debug and test builds to sync about as fast as before, so that my local runs and CI tests that sync a real network stay usable.

Scenario

Base flow

Build the dash-spv binary with the default dev profile and sync testnet from genesis with 2 tokio worker threads (TOKIO_WORKER_THREADS=2).

Actual behavior

rust-dashcore dev profile, opt-level 0 dev profile, dash-pow at opt-level 3 release
aca02026 (C rs-x11-hash) 301–334 s 222–244 s 106–145 s
f6bb90cb not done at 900 s (headers 71–73%) 789–899 s 89–96 s
d85f15ac not done at 900 s (headers done at 623–712 s, filters not done) 524–550 s 76–94 s
  • In slow builds peers get kicked for request timeouts and header batches arrive twice. Neither happens at aca02026 or in any release build.
    • Request-timeout kicks at dev opt-level 0: 0 / 36–38 / 14–16 log lines.
    • no segment matched duplicate batches at dev opt-level 0: 0 / 68–87 / 11–13.
  • The dash-evo-tool migration test syncs one testnet fixture and has a 600 s limit:
    • aca02026: 114 s;
    • d85f15ac at opt-level 0: 605 s, 1 of 2 runs failed;
    • d85f15ac with dash-pow and wide at opt-level 3: 244–260 s.
  • On GitHub Actions (4 vCPU), d85f15ac fails that limit even with the opt-level 3 workaround: filter headers reached 52.2%, with 13 kicks.

Expected behavior

Debug/test sync time stays close to aca02026. The X11 work does not starve the async peer readers, so slow builds do not cause request timeouts, peer kicks or duplicate batches.

Detailed discussion

Where the time goes

  1. Unoptimized dash-pow is 17.8× slower than the C X11 it replaced. It takes 3417–3431 ms per 8000 headers at opt-level 0, against 192.5 ms for rs-x11-hash; release takes 56–58 ms for both. A full header sync is ≈199 batches of 8000 headers, so this adds ≈680 s of CPU at opt-level 0, plus 3.4 s per duplicate batch.
  2. The hashing runs on the async workers. At aca02026, headers2 was decompressed and hashed in spawn_blocking. Since refactor(dash-spv): network module rewrite #902 it runs inline in the peer reader task: dash-spv/src/network/peer.rs:757-758 at d85f15ac (process_headers_with_hashes). With 2 workers, both cores stay busy during the header phase (1.8–1.9 of 2 cores), and the timeout monitor fires on healthy peers. This matches the symptoms of dash-spv: a peer whose filter replies wait in our own backlog is kicked as stalled #1234.
  3. The workspace remedy does not reach downstream crates and only partly works.
    • [profile.dev.package.dash-pow] opt-level = 3 in the workspace Cargo.toml applies only inside this workspace, because Cargo ignores profiles of dependencies. Every downstream crate has to copy it.
    • Even at opt-level 3, X11 stays 5× slower than release (≈281 ms per 8000 headers). The reason is that dash-pow gates its inline(always) hints behind #[cfg_attr(not(debug_assertions), inline(always))], at 144 sites in 0.1.1-beta. Dev and test profiles keep debug-assertions on. Corrected: that number came from an X11 benchmark built with rustc 1.92. With rustc 1.98.1/1.99.1, dash-pow at opt-level 3 hashes 8000 headers in 69–71 ms, 1.25× release. See the comment below.
    • Setting debug-assertions = false for dash-pow restores release X11 speed (59.9 ms) but gives no measurable sync gain (554 s vs 524–550 s). After the opt-level 3 fix, X11 is no longer the bottleneck.
  4. Even with dash-pow at opt-level 3, d85f15ac dev syncs 2.1–2.5× slower than aca02026 (524–550 s vs 222–244 s with 2 workers). With 16 workers it takes 282 s, while aca02026 takes 248 s whatever the worker count. So the rest of the header and filter pipeline, compiled at opt-level 0 and running on the tokio workers, still competes with the peer readers. A later CPU profile (comment below) puts most of the time in SipHash for filter matching, emitted in dashcore, and in U256 arithmetic in bitcoin-internals for the per-header Dark Gravity Wave check. Both run at opt-level 0.
  5. Changes between f6bb90cb and d85f15ac.
    • The peer-kick and routing fixes reduce the damage: at dev opt-level 0, about 2.5× fewer kicks and 6× fewer duplicates; at dev opt-level 3, full sync drops from 789–899 s to 524–550 s.
    • X11 speed is unchanged.
    • Release builds of all three revisions are fine, and d85f15ac is the fastest of them.

Possible directions (for maintainers to judge)

  • Move headers2 decompression and X11 back off the async reader, either to spawn_blocking or to a bounded hashing pool as in feat(dash-spv): accelerate compressed header sync #950. Peer timeouts would then no longer depend on the optimization level.
  • Document the downstream profile override, or put the opt-level and debug-assertions requirement in the dashcore_hashes / dash-pow README. Today every downstream crate finds it by debugging timeouts.
  • Consider making dash-pow's inline(always) unconditional, or gating it on something other than debug_assertions. Withdrawn: on rustc 1.98.1/1.99.1 this gating costs little (see the comment below).

Hardware acceleration

All numbers above use the default x86-64 target, so dashcore_hashes selects dash-pow with portable (software AES). #1214 says most of the speedup comes from the hardware path (AES-NI/AVX2 with -C target-cpu=x86-64-v3 -C target-feature=+aes, or NEON+AES on AArch64). Results for that path are in the comment below. Note that the hardware path is selected at compile time, with no runtime detection. Distributed binaries for generic x86-64 cannot use it without dropping support for CPUs without AVX2.

Method and environment

  • Host: Intel Core Ultra 7 265K, 16 CPUs, 15 GB RAM, Linux 7.0. rustc 1.98.1 (the rust-dashcore pin) and 1.99.1 (dash-evo-tool). The host was shared, with 1-minute load between 1.2 and 12.9; load is recorded per run.
  • Sync runs: the upstream dash-spv binary with -n testnet, a fresh data dir, a random 12-word wallet with no history and default flags. Each run stops at Sync complete in … or at a 900 s cap. Revisions were interleaved, and every dev variant ran at least twice. The opt-level of each crate was verified with cargo build -v.
  • X11 micro-benchmark: 8000 distinct synthetic 80-byte headers, median of 5–7 iterations after a warm-up. All revisions produce identical hashes.
  • Downstream test: dash-evo-tool on chore: bump rust-dashcore to dev f0ddfd45 platform#5951 (rust-dashcore d85f15ac), migration matrix fixture v1.0.0-weekly.20260908-wallet-only.

The full write-up, the raw per-run table, the micro-benchmark output and source, and the harness scripts are attached below.

Full results write-up (results.md)

dash-spv sync performance: aca0202 vs f6bb90c vs d85f15a

Measured 2026-11-17 by the dash-evo-tool team.

Method

  • Revisions. rust-dashcore aca02026 (C rs-x11-hash 0.1.9, headers2 hashed in spawn_blocking), f6bb90cb (pure-Rust dash-pow 0.1.0-beta from base-sdk 89828032, wide 1.7.1, hashing inline in the reader), d85f15ac (dash-pow 0.1.1-beta from crates.io, wide 1.7.1, hashing inline at peer.rs:758, plus peer-kick fixes).

  • Upstream profile note. The workspaces of both f6bb90cb and d85f15ac already contain [profile.dev.package.dash-pow] opt-level = 3. It applies only when building inside rust-dashcore and never reaches downstream crates. The "dev O0" variant therefore forces it back to 0 with --config. cargo -v confirmed that --config overrides the manifest profile; see logs/build/*.log.

  • X11 micro-benchmark (x11-bench/). This is a standalone crate per revision with a path dependency on that revision's dashcore_hashes (x11 feature) and aca's [patch] for rs-x11-hash. It hashes 8000 distinct synthetic 80-byte headers, both whole and field by field (the way consensus encoding feeds them). Each case runs 5–7 iterations after a warm-up, and the median is reported. All revisions produce identical hashes.

  • Isolated sync. The upstream dash-spv binary (-n testnet, fresh data dir, from genesis, a random 12-word mnemonic with no history, default flags: filters, masternodes and mempool on). A run stops at Sync complete in … (sync coordinator, all managers synced) or at the 900 s cap. Each run records:

    • time to Headers sync complete, Filter header sync complete, Filter sync complete, Masternode sync complete and Sync complete, measured from Starting Dash SPV client;
    • counts of request timeout: kicked, no segment matched and PeerDisconnected events;
    • /usr/bin/time -v;
    • a 5 s CPU sampler.

    Variants:

    • dev0: dev profile, dash-pow and wide (aca: rs-x11-hash) at opt-level 0;
    • dev3: dev profile, dash-pow and wide at opt-level 3 (aca: rs-x11-hash at 3);
    • devfix: dev3 plus dash-pow.debug-assertions=false;
    • release: the upstream release profile (opt 3, no LTO).

    Workers were TOKIO_WORKER_THREADS=2 unless marked wdefault (16). Revisions were interleaved, and every dev variant ran at least twice.

  • DET end-to-end. Worktree chore/bump-platform-5951 @ 44a9ed9b77 (rust-dashcore d85f15a), migration matrix, fixture v1.0.0-weekly.20260908-wallet-only only, with MIGRATION_MATRIX_SKIP_PASSWORDS=true and TMPDIR on /data. Times are libtest's finished in and exclude compilation. The workaround was neutralised with --config profile.{dev,test}.package.{dash-pow,wide}.opt-level=0; -v confirmed that dash-pow is rebuilt without -C opt-level. No tracked file was edited.

Environment

Intel Core Ultra 7 265K, 16 CPUs, 15 GB RAM, Linux 7.0. rustc 1.98.1 (rust-dashcore toolchain pin) and 1.99.1 (DET), sccache, mold, jobs = 2. Default target CPU (x86-64), so dash-pow builds with portable. The host is shared with other sessions: 1-minute load ranged from 1.2 to 12.9 during runs and is recorded per run in logs/runs-summary.md. Testnet tip was ≈1,593,180–1,593,270.

1. X11 micro-benchmark (ms per 8000 headers, median)

Build of the X11 crate(s) aca0202 (C rs-x11-hash) f6bb90c (dash-pow 0.1.0-beta) d85f15a (dash-pow 0.1.1-beta)
release (opt 3, no debug-assertions) 56.3 58.0 56.0
dev, all opt-level 0 192.5 3417 3431
dev, rs-x11-hash at opt 3 56.5 — —
dev, dash-pow at opt 3 (= upstream's own workspace setting) — 289.6 281.2
dev, dash-pow and wide at opt 3 (= DET workaround) — 287.9 276.7
dev, dash-pow, wide and safe_arch at opt 3 — 284.5 283.2
dev, "*" at opt 3 — — 270.0
dev, dash-pow at opt 3 with debug-assertions=false — — 59.9
dev, dash-pow at opt 0 with debug-assertions and overflow-checks off — — 3284
  • At opt-level 0 dash-pow is 17.8× slower than C rs-x11-hash (3.42 s vs 0.19 s), and 61× slower than release.
  • Opt-level 3 alone leaves dash-pow 5× slower than release. The cause is that dash-pow puts its inline(always) hints behind #[cfg_attr(not(debug_assertions), inline(always))] (144 sites in 0.1.1-beta, 135 in base-sdk 89828032). Any dev or test profile keeps debug-assertions on, so these hints vanish even at opt 3. Corrected: the table above was built with rustc 1.92. With 1.98.1/1.99.1, dev with dash-pow+wide at opt 3 takes 69–71 ms (1.25× release).
    • Raising wide, safe_arch, digest or every dependency to opt 3 has no effect.
    • debug-assertions=false on dash-pow alone restores release speed.
    • Upstream's own [profile.dev.package.dash-pow] opt-level = 3 and DET's workaround have the same remaining 5× gap.
  • Raw output: logs/bench-run{1..4}.txt.

2. Isolated dash-spv sync, testnet from genesis

Seconds from start. "—" means the stage was not reached by the 900 s cap. Kicks are request timeout: kicked lines (number of kicked peers in parentheses). Per-run rows are in logs/runs-summary.md, and full logs in logs/runs/<run>/run.log.

Rev Variant Workers Runs Headers done Filter headers done Synced Kicks No-segment PeerDisc User CPU s Max RSS MB
aca0202 release 2 2 72 / 74 95 / 107 106 / 145 0 0 0 60 / 65 144 / 157
f6bb90c release 2 2 82 / 78 84 / 81 89 / 96 0 0 4 / 3 68 / 72 175 / 221
d85f15a release 2 2 67 / 82 70 / 90 76 / 94 0 0 3 / 3 46 / 47 163 / 183
aca0202 release 16 1 59 94 107 0 0 0 64 178
f6bb90c release 16 1 87 94 97 0 0 3 74 373
d85f15a release 16 1 48 79 92 0 1 4 50 305
aca0202 dev3 2 2 75 / 65 107 / 99 222 / 244 0 0 0 726 / 723 175 / 134
f6bb90c dev3 2 2 287 / 278 315 / 311 899 / 789 11 (12) / 5 (5) 9 / 0 19 / 8 1393 / 1235 1340 / 450
d85f15a dev3 2 2 316 / 307 330 / 308 524 / 550 1 (1) / 2 (2) 0 / 0 4 / 5 987 / 1012 429 / 340
f6bb90c devfix 2 1 316 317 814 4 (5) 5 14 1285 847
d85f15a devfix 2 1 327 328 554 1 (1) 0 4 1006 330
aca0202 dev3 16 1 85 98 248 0 0 1 721 —
f6bb90c dev3 16 1 267 369 446 5 (7) 5 11 1056 —
d85f15a dev3 16 1 250 265 282 3 (3) 1 7 827 —
aca0202 dev0 2 2 101 / 104 123 / 125 301 / 334 0 0 0 819 / 822 154 / 136
f6bb90c dev0 2 2 — (72.9% / 70.9% at 900 s) — (55.0% / 50.0%) cap / cap 36 (55) / 38 (51) 87 / 68 58 / 54 1624 / 1568 993 / 1139
d85f15a dev0 2 2 712 / 623 712 / 623 cap / cap (filters not done) 16 (18) / 14 (14) 13 / 11 21 / 18 1754 / 1686 579 / 618

CPU cores used during the header phase (CPU time ÷ wall time, second round only):

Variant aca0202 f6bb90c d85f15a
dev0, 2 workers 1.53 1.74 1.93
dev3, 2 workers 1.58 1.44 / 1.47 (devfix) 1.81 / 1.85 (devfix)
dev3, 16 workers 1.21 2.04 2.89
release, 2 workers 0.49 0.76 0.54

How X11 adds up over a full sync (≈199 batches of 8000 headers, ignoring duplicates):

Build X11 CPU for one full header sync
release ≈11 s
dev3 ≈56 s
aca dev0 ≈38 s
dash-pow dev0 ≈680 s
  • Duplicates. Each no segment matched duplicate costs another 3.4 s at dev0. f6bb90c dev0 logged 68–87 of them, about 230–300 s of extra CPU.
  • dev0 to dev3 on d85f15a. The header phase drops by ≈310–400 s (623–712 s to 307–327 s). That is consistent with ≈680 s of X11 shared over 2 workers.

3. DET end-to-end: migration matrix, fixture 20260908, rust-dashcore d85f15a

Variant Runs Result libtest time
as-is (dash-pow and wide at opt 3) 2 pass, pass 244.0 s, 259.9 s
+ dash-pow.debug-assertions=false 1 pass 262.5 s
workaround neutralised (opt 0) 2 pass, FAIL 605.5 s (passed just inside the gate), 605.0 s (SPV sync timed out after 600 seconds; headers 83.4%, filter headers 72.3%)

The run at 605.0 s had load 5.5 at start. The run at 605.5 s had load 12.9 at start.

Comparison with earlier runs on the same host and fixture:

Revision Workaround Result
base aca0202 none needed 114 s
f6bb90c with workaround 290 s / 279 s
f6bb90c without workaround FAIL ×3 at 600 s, filter headers 36.5–37.8%
d85f15a with workaround 244–260 s
d85f15a without workaround 605 s, 1 pass and 1 fail; filter headers 72.3% at the gate
  • Event counts are not available for the DET runs. The test prints only the last ≈40 s of det-cli stderr, and only on failure. In that tail the failing run shows 1 kick line (2 peers) and 4 no segment matched.
  • CI on 4 vCPU (dashpay/dash-evo-tool GitHub Actions, not measured here). Run 44025704453 at d85f15a with the workaround still failed the gate: filter headers 52.2%, 13 kicks, 26 no-segment.

What changed between f6bb90c and d85f15a

  • X11 speed: nothing. dash-pow 0.1.0-beta and 0.1.1-beta perform the same in every profile (±3%), and hashing is still inline in the async reader.
  • Release: no regression on any revision. All three sync from genesis in 76–145 s with 2 workers and no kicks. d85 is fastest (76/94 s) and aca slowest (106/145 s).
  • dev0, 2 workers. d85 finishes headers at 623–712 s, while f6b is still at 71–73% of headers at 900 s.
    • Kick lines: 14–16 (d85) vs 36–38 (f6b), 2.5× fewer.
    • Duplicate batches: 11–13 vs 68–87, 6× fewer.
    • Peer disconnects: 18–21 vs 54–58, 3× fewer.
    • Max RSS: 0.6 GB vs 1.0–1.1 GB.
  • dev3, 2 workers. Headers take the same time (≈280–330 s on both), but full sync is 524–550 s (d85) vs 789–899 s (f6b). The difference is almost entirely in the filter and block stage after filter headers: ≈200–240 s vs ≈475–585 s. Kicks are 1–2 vs 5–11, and RSS 0.34–0.43 GB vs 0.45–1.34 GB.
  • DET (debug test profile), same host. With the workaround: 244–260 s vs 279–290 s. Without it: at the gate edge (72% filter headers) vs a sure failure (37%).
  • Interpretation (medium confidence). The peer-kick and routing fixes roughly halve the damage. They do not remove the dev-build gap to aca0202, which is 2.1–2.5× at dev3 and more than 2.7× at dev0 (aca dev0 syncs fully in 301–334 s).

Conclusions

  1. Debug and test builds regressed severely; release builds did not (high confidence).
    • Same host, 2 workers, dev profile (dev0), full sync: aca0202 takes 301–334 s. f6bb90c does not finish headers in 900 s. d85f15a finishes headers at 623–712 s but does not finish filters in 900 s.
    • Release: all three take 76–145 s, d85 the fastest.
  2. dash-pow at opt-level 0 is 17.8× slower than the C X11 it replaced, and that alone accounts for the dev0 collapse (high confidence).
    • It costs ≈680 s of CPU per full header sync, plus 3.4 s per duplicate batch.
    • The work runs on the async workers, and kicks and duplicate batches appear only in builds where it is slow: f6b/d85 at dev0 and dev3. aca and release builds have none.
    • This confirms the prior hypothesis that inline hashing starves the timeout monitor.
  3. The opt-level 3 workaround, upstream's or DET's, does not close the gap (high confidence on the measurement, medium on the cause).
    • X11 stays 5× slower than release because dash-pow puts inline(always) behind not(debug_assertions). (rustc 1.92 artifact; 1.25× on 1.98.1/1.99.1).
    • Removing that (debug-assertions=false) gives no measurable sync gain: d85 dev3 524–550 s vs devfix 554 s, and DET 244–260 s vs 262 s.
    • So after the workaround, X11 is no longer the bottleneck. The remaining gap to aca0202 is header and filter pipeline work, compiled at opt 0, that runs on the tokio workers:
      • with 2 workers, 1.8–1.9 of 2 cores are busy during headers;
      • with 16 workers, d85 dev3 needs 282 s instead of 524–550 s;
      • aca does not change with the worker count, because it offloads to spawn_blocking.
    • Which functions are hot is not identified: perf is blocked by perf_event_paranoid=4.
    • The prior claim that more workers do not help applied to DET at dev0 with 2 → 4 workers. For the isolated binary at dev3, 2 → 16 workers roughly halves sync time.
  4. For DET specifically. d85f15a with the workaround passes locally in 244–260 s, about 2.2× base's 114 s. Without the workaround it sits at the 600 s gate (1 of 2 runs fail). Adding debug-assertions=false for dash-pow is not worth it, because it gives no gain.
  5. Upstream report. The data supports reporting it, with the numbers above. The case rests on three points:
    • the 17.8× opt-0 X11 cost now sits on async workers instead of spawn_blocking;
    • the debug_assertions-gated inlining defeats the documented opt-level 3 remedy;
    • the f6b → d85 fixes help but leave debug builds 2.1× or more behind aca0202, and CI with 4 vCPU still fails.

Not executed / limits

  • No CPU profile. perf is unavailable without sudo, so the non-X11 hot path in dev3 header and filter processing is inferred from CPU saturation, not measured.
  • DET event counts. Only the failing run's ≈40 s stderr tail was available.
  • Sample size and load. n = 1–2 per cell. Host load from other sessions varied between 1.2 and 12.9. Dev-profile repeats agreed within ≈15%, except the f6b dev3 pair (899 / 789 s). Release runs are network-bound and varied more (d85 76 / 94 s, aca 106 / 145 s). All values are recorded as measured.
  • wide override in the DET neutralised build was not separately verified (cargo reported wide as Fresh). The micro-benchmark shows wide's opt-level has no effect on X11.
  • Clean-up. The rdc-bench worktrees were removed. Target dirs were kept: /data/tmp/rdc-bench-target-* and /data/tmp/x11-bench/target-*.

Files

  • logs/runs/<rev>-<variant>-w<workers>-<ts>/: run.log (dash-spv info log), time.txt, cpu.txt, meta.txt
  • logs/runs-summary.md: every run, every metric
  • logs/det/*.log{,.meta,.time}: DET runs
  • logs/build/*.log: cargo -v build logs with the opt-level evidence
  • logs/bench-run*.txt, x11-bench/: micro-benchmark output and source
  • logs/{build.sh,run.sh,parse.py,det-run.sh}: harness
Every sync run, every metric (runs-summary.md)
run outcome hdr_s fhdr_s filters_s mn_s synced_s last Headers last FilterHeaders kick_lines kicked_peers no_seg PeerDisconnected WARN ERROR user_s sys_s maxRSS_MB wall cores_hdr_phase load1
aca0202-dev0-w2-20261117T064908 synced 100.9 122.7 301.1 112.4 301.1 Synced 1593209/1593209 (100.0%) Synced 1593209/1593209 (100.0%) 0 0 0 0 3 0 819.18 9.07 154 5:05.07 — 7.44
aca0202-dev0-w2-20261117T082408 synced 103.5 125.1 333.8 115.1 333.8 Synced 1593244/1593244 (100.0%) Synced 1593244/1593244 (100.0%) 0 0 0 0 9 0 821.84 10.31 136 5:36.90 1.53 5.32
aca0202-dev3-w2-20261117T061007 synced 75.2 107.0 221.9 89.9 221.9 Synced 1593193/1593193 (100.0%) Synced 1593193/1593193 (100.0%) 0 0 0 0 3 0 725.60 10.79 175 3:44.98 — 4.91
aca0202-dev3-w2-20261117T074158 synced 65.2 98.5 244.1 80.1 244.1 Synced 1593229/1593229 (100.0%) Synced 1593229/1593229 (100.0%) 0 0 0 0 3 0 723.37 12.79 134 4:07.93 1.58 6.76
aca0202-dev3-wdefault-20261117T090311 synced 84.6 98.1 247.8 90.8 247.8 Synced 1593262/1593262 (100.0%) Synced 1593262/1593262 (100.0%) 0 0 0 1 5 0 721.07 8.72 209 4:11.59 1.21 6.79
aca0202-release-w2-20261117T055751 synced 71.8 94.6 106.2 84.4 106.2 Synced 1593183/1593183 (100.0%) Synced 1593183/1593183 (100.0%) 0 0 0 0 3 0 60.34 6.45 144 1:49.53 — 3.44
aca0202-release-w2-20261117T084810 synced 73.5 106.5 145.3 88.5 145.3 Synced 1593255/1593255 (100.0%) Synced 1593255/1593255 (100.0%) 0 0 0 0 3 0 65.27 7.18 157 2:28.72 0.49 3.65
aca0202-release-wdefault-20261117T071352 synced 59.1 93.6 106.9 73.1 106.9 Synced 1593215/1593215 (100.0%) Synced 1593215/1593215 (100.0%) 0 0 0 0 3 0 63.50 7.31 178 1:50.39 — 1.56
d85f15a-dev0-w2-20261117T065414 cap 712.3 712.4 — 733.8 — Synced 1593215/1593215 (100.0%) Synced 1593215/1593215 (100.0%) 16 18 13 21 29 0 1754.26 4.82 579 15:02.60 — 6.46
d85f15a-dev0-w2-20261117T080904 cap 623.2 623.3 — 639.7 — Synced 1593243/1593243 (100.0%) Synced 1593243/1593243 (100.0%) 14 14 11 18 26 0 1686.21 11.32 618 15:02.58 1.93 9.46
d85f15a-dev3-w2-20261117T060118 synced 315.7 330.3 524.3 331.4 524.3 Synced 1593190/1593190 (100.0%) Synced 1593190/1593190 (100.0%) 1 1 0 4 1 0 987.44 2.87 429 8:48.17 — 1.84
d85f15a-dev3-w2-20261117T071930 synced 306.9 307.6 549.8 315.0 549.8 Synced 1593220/1593220 (100.0%) Synced 1593220/1593220 (100.0%) 2 2 0 5 2 0 1012.11 5.23 340 9:13.98 1.81 1.18
d85f15a-dev3-wdefault-20261117T085053 synced 249.5 265.3 281.9 257.5 281.9 Synced 1593258/1593258 (100.0%) Synced 1593258/1593258 (100.0%) 3 3 1 7 4 0 826.75 2.70 331 4:45.94 2.89 5.86
d85f15a-devfix-w2-20261117T074607 synced 327.2 327.5 553.5 346.3 553.5 Synced 1593233/1593233 (100.0%) Synced 1593233/1593233 (100.0%) 1 1 0 4 2 0 1005.53 4.55 330 9:17.12 1.85 9.38
d85f15a-release-w2-20261117T055557 synced 66.6 69.8 74.4 76.0 76.0 Synced 1593181/1593181 (100.0%) Synced 1593181/1593181 (100.0%) 0 0 0 3 0 0 46.47 1.75 163 1:19.93 — 7.69
d85f15a-release-w2-20261117T084630 synced 81.7 89.8 92.9 94.3 94.3 Synced 1593255/1593255 (100.0%) Synced 1593255/1593255 (100.0%) 0 0 0 3 1 0 47.37 1.71 183 1:38.12 0.54 4.24
d85f15a-release-wdefault-20261117T071544 synced 48.2 79.1 91.9 58.5 91.9 Synced 1593216/1593216 (100.0%) Synced 1593216/1593216 (100.0%) 0 0 1 4 1 0 49.84 2.32 305 1:35.10 — 3.98
f6bb90c-dev0-w2-20261117T063359 cap — — — — — Syncing 1162000/1593207 (72.9%) Syncing 876000/1593207 (55.0%) 36 55 87 58 129 0 1623.82 3.69 993 15:07.90 — 3.61
f6bb90c-dev0-w2-20261117T082945 cap — — — — — Syncing 1130000/1593253 (70.9%) Syncing 796000/1593253 (50.0%) 38 51 68 54 108 0 1568.33 5.05 1139 15:04.47 1.74 6.21
f6bb90c-dev3-w2-20261117T061353 synced 287.1 315.2 898.9 345.0 898.9 Synced 1593200/1593200 (100.0%) Synced 1593200/1593200 (100.0%) 11 12 9 19 23 0 1392.76 20.95 1340 15:02.68 — 5.30
f6bb90c-dev3-w2-20261117T072845 synced 277.6 311.4 788.5 295.6 788.5 Synced 1593225/1593225 (100.0%) Synced 1593225/1593225 (100.0%) 5 5 0 8 5 0 1235.30 16.41 450 13:12.08 1.44 7.26
f6bb90c-dev3-wdefault-20261117T085540 synced 267.4 368.5 446.3 280.5 446.3 Synced 1593260/1593260 (100.0%) Synced 1593260/1593260 (100.0%) 5 7 5 11 10 0 1055.95 11.29 584 7:29.79 2.04 8.45
f6bb90c-devfix-w2-20261117T075525 synced 316.3 317.2 813.6 334.0 813.6 Synced 1593238/1593238 (100.0%) Synced 1593238/1593238 (100.0%) 8 10 5 14 15 0 1285.11 17.64 847 13:38.63 1.47 6.53
f6bb90c-release-w2-20261117T055942 synced 82.4 84.0 89.4 89.2 89.4 Synced 1593185/1593185 (100.0%) Synced 1593185/1593185 (100.0%) 0 0 0 4 0 0 67.90 4.09 175 1:33.19 — 2.52
f6bb90c-release-w2-20261117T084450 synced 78.4 81.0 95.7 89.4 95.7 Synced 1593254/1593254 (100.0%) Synced 1593254/1593254 (100.0%) 0 0 0 3 0 0 71.98 4.07 221 1:39.26 0.76 7.66
f6bb90c-release-wdefault-20261117T071720 synced 87.2 93.7 96.8 97.0 97.0 Synced 1593217/1593217 (100.0%) Synced 1593217/1593217 (100.0%) 0 0 0 3 0 0 74.27 4.91 373 1:40.31 — 2.64
X11 micro-benchmark output, run 1
== aca02026 release
check: first-hash cf0cbdc8dcaff39f4f90f25fd98350675875cc162ede403e70e8a44eb30b8485
whole-80B: min 55.87 ms, median 56.29 ms, max 67.99 ms per 8000 headers (7 iters)
field-by-field: min 56.35 ms, median 56.49 ms, max 58.65 ms per 8000 headers (7 iters)
== f6bb90cb release
check: first-hash cf0cbdc8dcaff39f4f90f25fd98350675875cc162ede403e70e8a44eb30b8485
whole-80B: min 57.96 ms, median 58.02 ms, max 58.36 ms per 8000 headers (7 iters)
field-by-field: min 57.95 ms, median 58.24 ms, max 58.40 ms per 8000 headers (7 iters)
== d85f15ac release
check: first-hash cf0cbdc8dcaff39f4f90f25fd98350675875cc162ede403e70e8a44eb30b8485
whole-80B: min 55.85 ms, median 56.01 ms, max 59.78 ms per 8000 headers (7 iters)
field-by-field: min 56.13 ms, median 56.27 ms, max 56.74 ms per 8000 headers (7 iters)
== aca02026 debug
check: first-hash cf0cbdc8dcaff39f4f90f25fd98350675875cc162ede403e70e8a44eb30b8485
whole-80B: min 192.08 ms, median 192.52 ms, max 192.64 ms per 8000 headers (5 iters)
field-by-field: min 193.32 ms, median 193.90 ms, max 194.67 ms per 8000 headers (5 iters)
== f6bb90cb debug
check: first-hash cf0cbdc8dcaff39f4f90f25fd98350675875cc162ede403e70e8a44eb30b8485
whole-80B: min 3411.34 ms, median 3417.34 ms, max 3439.31 ms per 8000 headers (5 iters)
field-by-field: min 3418.30 ms, median 3420.86 ms, max 3422.06 ms per 8000 headers (5 iters)
== d85f15ac debug
check: first-hash cf0cbdc8dcaff39f4f90f25fd98350675875cc162ede403e70e8a44eb30b8485
whole-80B: min 3423.91 ms, median 3431.31 ms, max 3441.74 ms per 8000 headers (5 iters)
field-by-field: min 3424.63 ms, median 3426.75 ms, max 3434.14 ms per 8000 headers (5 iters)

X11 micro-benchmark output, run 2
== bins/aca02026-dev-x11o3
whole-80B: min 55.75 ms, median 56.50 ms, max 56.67 ms per 8000 headers (5 iters)
field-by-field: min 57.60 ms, median 58.19 ms, max 58.61 ms per 8000 headers (5 iters)
== bins/d85f15ac-dev-pow3
whole-80B: min 277.57 ms, median 281.16 ms, max 282.25 ms per 8000 headers (5 iters)
field-by-field: min 280.72 ms, median 281.60 ms, max 282.59 ms per 8000 headers (5 iters)
== bins/d85f15ac-dev-powwide3
whole-80B: min 275.38 ms, median 276.67 ms, max 278.06 ms per 8000 headers (5 iters)
field-by-field: min 283.58 ms, median 284.02 ms, max 285.53 ms per 8000 headers (5 iters)
== bins/d85f15ac-dev-powwidesa3
whole-80B: min 282.70 ms, median 283.16 ms, max 283.81 ms per 8000 headers (5 iters)
field-by-field: min 284.30 ms, median 284.62 ms, max 284.96 ms per 8000 headers (5 iters)
== bins/f6bb90cb-dev-pow3
whole-80B: min 286.40 ms, median 289.59 ms, max 291.77 ms per 8000 headers (5 iters)
field-by-field: min 288.15 ms, median 289.27 ms, max 293.08 ms per 8000 headers (5 iters)
== bins/f6bb90cb-dev-powwide3
whole-80B: min 287.24 ms, median 287.85 ms, max 292.21 ms per 8000 headers (5 iters)
field-by-field: min 285.53 ms, median 286.56 ms, max 286.84 ms per 8000 headers (5 iters)
== bins/f6bb90cb-dev-powwidesa3
whole-80B: min 283.44 ms, median 284.46 ms, max 285.59 ms per 8000 headers (5 iters)
field-by-field: min 281.12 ms, median 281.32 ms, max 283.30 ms per 8000 headers (5 iters)

X11 micro-benchmark output, run 3
== bins2-d85f15ac-pow-ovf-off
field-by-field: min 57.72 ms, median 59.21 ms, max 59.72 ms per 8000 headers (5 iters)
== bins2-d85f15ac-powwide+all-deps3
field-by-field: min 269.92 ms, median 270.02 ms, max 271.64 ms per 8000 headers (5 iters)
== bins2-d85f15ac-powwide+digest+hybrid3
field-by-field: min 280.83 ms, median 281.54 ms, max 281.88 ms per 8000 headers (5 iters)
== bins2-d85f15ac-powwide+hashes3
field-by-field: min 279.66 ms, median 280.65 ms, max 282.03 ms per 8000 headers (5 iters)

X11 micro-benchmark output, run 4
== bins3-d85f15ac-pow0-ovf-dbg-off
field-by-field: min 3245.46 ms, median 3283.78 ms, max 3287.14 ms per 8000 headers (5 iters)
== bins3-d85f15ac-pow3-dbgassert-off
field-by-field: min 59.77 ms, median 59.92 ms, max 62.58 ms per 8000 headers (5 iters)
== bins3-d85f15ac-pow3-hashes3
field-by-field: min 275.41 ms, median 280.96 ms, max 281.45 ms per 8000 headers (5 iters)
== bins3-d85f15ac-pow3-ovf-off
field-by-field: min 275.20 ms, median 275.48 ms, max 275.69 ms per 8000 headers (5 iters)

X11 micro-benchmark source (main.rs)
use dashcore_hashes::hash_x11;
#[allow(unused_imports)]
use dashcore_hashes::Hash as _;
#[allow(unused_imports)]
use dashcore_hashes::HashEngine as _;
use std::hint::black_box;
use std::time::Instant;

const N: usize = 8000;

fn headers() -> Vec<[u8; 80]> {
    let mut s: u64 = 0x9E37_79B9_7F4A_7C15;
    let mut next = || {
        s ^= s << 13;
        s ^= s >> 7;
        s ^= s << 17;
        s
    };
    (0..N)
        .map(|i| {
            let mut h = [0u8; 80];
            h[0..4].copy_from_slice(&0x2000_0000u32.to_le_bytes());
            for c in h[4..68].chunks_mut(8) {
                c.copy_from_slice(&next().to_le_bytes());
            }
            h[68..72].copy_from_slice(&(1_700_000_000u32 + 150 * i as u32).to_le_bytes());
            h[72..76].copy_from_slice(&0x1b0e_7256u32.to_le_bytes());
            h[76..80].copy_from_slice(&(next() as u32).to_le_bytes());
            h
        })
        .collect()
}

fn run_whole(hs: &[[u8; 80]]) -> u8 {
    let mut acc = 0u8;
    for h in hs {
        acc ^= hash_x11::Hash::hash(black_box(h)).as_byte_array()[0];
    }
    acc
}

fn run_fields(hs: &[[u8; 80]]) -> u8 {
    let mut acc = 0u8;
    for h in hs {
        let h = black_box(h);
        let mut e = hash_x11::Hash::engine();
        for f in [0..4, 4..36, 36..68, 68..72, 72..76, 76..80] {
            e.input(&h[f]);
        }
        acc ^= hash_x11::Hash::from_engine(e).as_byte_array()[0];
    }
    acc
}

fn time(name: &str, iters: usize, f: impl Fn() -> u8) {
    let _ = f();
    let mut v: Vec<f64> = (0..iters)
        .map(|_| {
            let t = Instant::now();
            black_box(f());
            t.elapsed().as_secs_f64() * 1e3
        })
        .collect();
    v.sort_by(|a, b| a.partial_cmp(b).unwrap());
    println!(
        "{name}: min {:.2} ms, median {:.2} ms, max {:.2} ms per {N} headers ({iters} iters)",
        v[0],
        v[iters / 2],
        v[iters - 1]
    );
}

fn main() {
    let iters: usize = std::env::args().nth(1).and_then(|a| a.parse().ok()).unwrap_or(7);
    let hs = headers();
    println!("check: first-hash {}", hash_x11::Hash::hash(&hs[0]));
    time("whole-80B", iters, || run_whole(&hs));
    time("field-by-field", iters, || run_fields(&hs));
}
X11 micro-benchmark Cargo.toml for aca0202
[package]
name = "x11-bench-aca02026"
version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
name = "x11-bench"
path = "../src/main.rs"

[dependencies]
dashcore_hashes = { path = "/data/git-worktrees/rdc-bench-aca02026/hashes", features = ["x11"] }

[workspace]

[patch.crates-io]
rs-x11-hash = { git = "https://github.com/dashpay/rs-x11-hash", tag = "0.1.9" }

X11 micro-benchmark Cargo.toml for f6bb90c
[package]
name = "x11-bench-f6bb90cb"
version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
name = "x11-bench"
path = "../src/main.rs"

[dependencies]
dashcore_hashes = { path = "/data/git-worktrees/rdc-bench-f6bb90cb/hashes", features = ["x11"] }

[workspace]

X11 micro-benchmark Cargo.toml for d85f15a
[package]
name = "x11-bench-d85f15ac"
version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
name = "x11-bench"
path = "../src/main.rs"

[dependencies]
dashcore_hashes = { path = "/data/git-worktrees/rdc-bench-d85f15ac/hashes", features = ["x11"] }

[workspace]

Harness: build.sh
#!/bin/bash
# build.sh <rev> <variant> ; variants: dev0 dev3 release devfix
set -o pipefail
r=$1; v=$2
W=/data/git-worktrees/rdc-bench-$r
L=/data/artifacts/dash-evo-tool/2026-11-17/spv-perf/logs/build/$r-$v.log
feat="--features cli"; [ $r = aca02026 ] && feat=""
case $v in
  dev0) prof=dev; cfg=(--config 'profile.dev.package.dash-pow.opt-level=0' --config 'profile.dev.package.wide.opt-level=0' --config 'profile.dev.package.rs-x11-hash.opt-level=0');;
  dev3) prof=dev; if [ $r = aca02026 ]; then cfg=(--config 'profile.dev.package.rs-x11-hash.opt-level=3'); else cfg=(--config 'profile.dev.package.dash-pow.opt-level=3' --config 'profile.dev.package.wide.opt-level=3'); fi;;
  devfix) prof=dev; cfg=(--config 'profile.dev.package.dash-pow.opt-level=3' --config 'profile.dev.package.wide.opt-level=3' --config 'profile.dev.package.dash-pow.debug-assertions=false');;
  release) prof=release; cfg=();;
esac
cd $W || exit 1
export CLAUDIUS_ISOLATE_TARGET=1 CARGO_TARGET_DIR=/data/tmp/rdc-bench-target-$r
start=$(date +%s)
cargo build -v -p dash-spv $feat --bin dash-spv --profile $prof "${cfg[@]}" > $L 2>&1
rc=$?
echo "rc=$rc elapsed=$(( $(date +%s)-start ))s"
grep -E 'Running `.*--crate-name (dash_pow|wide|rs_x11_hash|dashcore_hashes) ' $L | sed -E 's/.*--crate-name ([a-z_0-9]+) .*-C opt-level=([0-9]).*/\1 opt=\2/; t; s/.*--crate-name ([a-z_0-9]+) .*/\1 opt=(default 0)/' | sort -u
grep -E 'Running `.*--crate-name dash_pow ' $L | grep -o 'debug-assertions=[a-z]*' | sort -u
outdir=debug; [ $prof = release ] && outdir=release
[ $rc = 0 ] && cp $CARGO_TARGET_DIR/$outdir/dash-spv /data/tmp/spv-bench/bins/$r-$v && echo "copied $r-$v"
tail -2 $L
Harness: run.sh
#!/bin/bash
# run.sh <rev-variant> <workers: 2|default> [cap_s]
bv=$1; w=$2; cap=${3:-900}
ts=$(date -u +%Y%m%dT%H%M%S)
label=$bv-w$w-$ts
D=/data/tmp/spv-bench/runs/$label
L=/data/artifacts/dash-evo-tool/2026-11-17/spv-perf/logs/runs/$label
mkdir -p $D $L
envw=(); [ $w != default ] && envw=(TOKIO_WORKER_THREADS=$w)
echo "load_before: $(cut -d' ' -f1-3 /proc/loadavg)" > $L/meta.txt
echo "start_utc: $(date -u +%FT%T.%N)" >> $L/meta.txt
t0=$(date +%s.%N)
env "${envw[@]}" /usr/bin/time -v -o $L/time.txt /data/tmp/spv-bench/bins/$bv -n testnet -d $D --mnemonic-file /data/tmp/spv-bench/mnemonic.txt --log-dir $L > $L/stdout.txt 2>&1 &
tp=$!
sleep 1; cp=$(pgrep -P $tp | head -1)
( while kill -0 $cp 2>/dev/null; do echo "$(echo "$(date +%s.%N)-$t0" | bc) $(awk '{print $14+$15}' /proc/$cp/stat 2>/dev/null) $(ls /proc/$cp/task 2>/dev/null | wc -l)"; sleep 5; done ) > $L/cpu.txt &
smp=$!
outcome=cap
while kill -0 $tp 2>/dev/null; do
  now=$(date +%s.%N); el=$(echo "$now-$t0" | bc)
  if grep -qh 'Sync complete in' $L/*.log 2>/dev/null; then outcome=synced; sleep 3; break; fi
  if (( $(echo "$el > $cap" | bc) )); then outcome=cap; break; fi
  sleep 1
done
if ! kill -0 $tp 2>/dev/null; then outcome=exited; fi
echo "outcome: $outcome" >> $L/meta.txt
echo "wall_at_stop_s: $(echo "$(date +%s.%N)-$t0" | bc)" >> $L/meta.txt
echo "load_after: $(cut -d' ' -f1-3 /proc/loadavg)" >> $L/meta.txt
kill -INT $cp 2>/dev/null
for i in $(seq 1 30); do kill -0 $tp 2>/dev/null || break; sleep 1; done
kill -0 $tp 2>/dev/null && { kill -KILL $cp; echo "killed: yes" >> $L/meta.txt; }
wait $tp 2>/dev/null
kill $smp 2>/dev/null
du -sh $D | cut -f1 | sed 's/^/datadir_size: /' >> $L/meta.txt
rm -rf $D
echo $L
cat $L/meta.txt
Harness: parse.py
import sys, re, os, glob, datetime as dt
def ts(line):
    m = re.match(r'(\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d+)Z', line)
    return dt.datetime.fromisoformat(m.group(1)[:26]) if m else None
rows=[]
for d in sorted(sys.argv[1:]):
    logs = sorted(glob.glob(os.path.join(d,'*.log')))
    lines=[]
    for f in logs: lines += open(f, errors='replace').read().splitlines()
    meta = dict(l.split(': ',1) for l in open(os.path.join(d,'meta.txt')).read().splitlines() if ': ' in l)
    t0=None; ev={}
    pats={'hdr':'Headers sync complete at height','fh':'Filter header sync complete','flt':'Filter sync complete','mn':'Masternode sync complete','sync':'Sync complete in'}
    c={'peer_disc_ev':0,'kick_lines':0,'kicked_peers':0,'no_seg':0,'mgr_disc':0,'reader_disc':0,'aca_disc':0,'warn':0,'error':0,'timeout_any':0}
    last={'Headers':'','Filter Headers':'','Filters':''}
    for l in lines:
        t=ts(l)
        if t0 is None and 'Starting Dash SPV client' in l: t0=t
        for k,p in pats.items():
            if p in l and k not in ev and t: ev[k]=(t-t0).total_seconds()
        m=re.search(r'request timeout: kicked (\d+) peer',l)
        if m: c['kick_lines']+=1; c['kicked_peers']+=int(m.group(1))
        if 'but no segment matched' in l: c['no_seg']+=1
        if 'PeerDisconnected(' in l: c['peer_disc_ev']+=1
        if 'peer disconnected:' in l: c['mgr_disc']+=1
        if 'NETWORK: peer' in l and 'disconnected' in l: c['reader_disc']+=1
        if re.search(r'INFO .*: Peer \S+ disconnected',l): c['peer_disc_ev']+=1
        if ' WARN ' in l[:40]: c['warn']+=1
        if ' ERROR ' in l[:40]: c['error']+=1
        if re.search(r'time(d)? ?out',l,re.I): c['timeout_any']+=1
        for k in last:
            m=re.match(r'\s+'+k+r':\s+(\S+ \d+/\d+ \([\d.]+%\))',l)
            if m: last[k]=m.group(1)
    tv={}
    for l in open(os.path.join(d,'time.txt')):
        for k,p in [('user','User time'),('sys','System time'),('rss','Maximum resident'),('wall','Elapsed (wall')]:
            if p in l: tv[k]=l.rsplit(': ',1)[1].strip()
    name=os.path.basename(d)
    cores='—'
    cf=os.path.join(d,'cpu.txt')
    if os.path.exists(cf):
        smp=[tuple(map(float,x.split()[:2])) for x in open(cf) if len(x.split())>=2]
        end=ev.get('hdr')
        if smp:
            if end is None: end=smp[-1][0]
            pre=[x for x in smp if x[0]<=end+0.5]
            if pre and pre[-1][0]>5: cores=f"{pre[-1][1]/100/pre[-1][0]:.2f}"
    f=lambda k: f"{ev[k]:.1f}" if k in ev else '—'
    rows.append([name, meta.get('outcome'), f('hdr'), f('fh'), f('flt'), f('mn'), f('sync'), last['Headers'], last['Filter Headers'],
        str(c['kick_lines']), str(c['kicked_peers']), str(c['no_seg']), str(c['peer_disc_ev']), str(c['warn']), str(c['error']),
        tv.get('user'), tv.get('sys'), str(round(int(tv.get('rss','0'))/1024)), tv.get('wall'), cores, meta.get('load_before','').split()[0] if meta.get('load_before') else ''])
hdr=['run','outcome','hdr_s','fhdr_s','filters_s','mn_s','synced_s','last Headers','last FilterHeaders','kick_lines','kicked_peers','no_seg','PeerDisconnected','WARN','ERROR','user_s','sys_s','maxRSS_MB','wall','cores_hdr_phase','load1']
print('| '+' | '.join(hdr)+' |'); print('|'+'---|'*len(hdr))
for r in rows: print('| '+' | '.join(x or '' for x in r)+' |')
Harness: det-run.sh (dash-evo-tool migration test)
#!/bin/bash
# det-run.sh <label> [extra cargo args...]
lab=$1; shift
cd /data/git-worktrees/home-ubuntu-git-dash-evo-tool-bump-platform-5951 || exit 1
L=/data/artifacts/dash-evo-tool/2026-11-17/spv-perf/logs/det/$lab-$(date -u +%Y%m%dT%H%M%S).log
echo "load_before: $(cat /proc/loadavg)" > $L.meta
s=$(date +%s)
CLAUDIUS_FORCE=1 TMPDIR=/data/tmp/spv-bench-det MIGRATION_FIXTURES_DIR=/data/tmp/spv-bench/fx MIGRATION_FIXTURES_MANIFEST=/data/tmp/spv-bench/fx/manifest.json MIGRATION_MATRIX_SKIP_PASSWORDS=true timeout 3000 /usr/bin/time -v -o $L.time /home/ubuntu/.claude/plugins/cache/lklimek/claudius/12.0.0/scripts/cargo-cached.sh test --all-features "$@" --test migration-matrix -- migration_matrix --exact --nocapture > $L 2>&1
echo "rc=$? wall=$(( $(date +%s)-s ))s" >> $L.meta
echo "load_after: $(cat /proc/loadavg)" >> $L.meta
cat $L.meta; grep -E 'test result|panicked|Compiling dash-pow|Finished' $L | head; echo $L

🤖 Co-authored by Claudius the Magnificent AI Agent

Sub-issues

Sub-issues

3 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. Claudius-Maginificent commented on Nov 17, 2026

    @Claudius-Maginificent
    Author

    Follow-up: CPU profile, a selective opt-level fix, hardware path, and a correction

    TL;DR

    • In d85f15ac dev builds, nearly all the extra time is spent in two crates compiled at opt-level 0. bitcoin-internals does U256 arithmetic for the per-header Dark Gravity Wave check, and dashcore runs SipHash for filter matching. X11 is no longer a factor once dash-pow is at opt-level 3.
    • Downstream crates can fix this by putting dashcore and bitcoin-internals at opt-level 3 next to dash-pow/wide. A dev sync then takes 115–122 s, down from 524–550 s, about 2× faster than aca02026 dev. A clean build gets about 4 s slower.
    • The hardware X11 path (x86-64-v3 + AES) makes release X11 2.5× faster. It does not replace the opt-level fix, but stacks with it: 93 s.
    • Correction: the issue said X11 at opt-level 3 stays 5× slower than release. That number came from a benchmark built with rustc 1.92. With rustc 1.98.1/1.99.1 the slowdown is 1.25×. The struck-through lines in the description are fixed. All sync numbers were built with 1.98.1 and stand.

    1. CPU profile (d85f15a dev3 vs aca0202 dev3)

    perf record -F 199 --call-graph fp, 2 tokio workers, testnet from genesis. Call graphs are unusable at opt-level 0 because unwinding stops after 1–3 frames. Time is therefore attributed by self time plus the emitting crate of the v0-mangled symbol, which is the crate whose codegen unit, and so whose opt-level, produced the code.

    Code family (emitting crate) d85 headers aca headers d85 whole run aca whole run
    SipHash AVX2 + core::arch intrinsics for GCS filter matching (dashcore_hashes code emitted in dashcore) 208 s (38 %) 42 s 587 s (60 %) 377 s
    U256 ge/gt/div_rem/wrapping_shr/overflowing_* (bitcoin-internals), new in d85 220 s (40 %) 0 220 s (23 %) 0
    BIP324 ChaCha20-Poly1305 (chacha20-poly1305), new in d85 37 s 0 40 s 0
    X11 (dash-pow / C rs-x11-hash, both at opt-level 3) 15 s 25 s 15 s 41 s
    Total CPU-s / cores used 554 / 1.78 118 / 1.28 979 / 1.79 718 / 2.23

    All values are CPU-seconds. d85 hit the 540 s cap with filters unfinished: headers took 310 s, against 92 s for aca. Every top self-time symbol is opt-0 code, such as _mm256_or_si256, _mm256_xor_si256, U256::ge/gt, sip_round_avx2 and U256::div_rem. At opt-level 3 these inline to single instructions.

    • Header phase: d85's BlockHeaderValidator (dash-spv/src/validation/header.rs) calls dashcore::pow::next_work_required (DGW) for every header, while aca only checked target().is_met_by. DGW's 256-bit averaging and bit-serial U256::div_rem run in bitcoin-internals at opt-level 0.
    • Filter phase: SipHash's #[inline] AVX2 code and the intrinsics are emitted in dashcore's codegen unit. Putting dashcore_hashes alone at opt-level 3 therefore changes nothing; dashcore itself has to be at opt-level 3. d85 also does this work on the 2 tokio workers (≤1.8 cores), where aca used 2.8 cores.

    2. Selective opt-level (d85f15a, dev, 2 workers, 2 runs each)

    Every variant keeps dash-pow and wide at opt-level 3 and adds the listed packages through --config 'profile.dev.package.<pkg>.opt-level=3'. -v confirmed the opt-levels.

    Extra packages at opt-level 3 Headers s Synced s User CPU s
    none (dev3 control) 307–322 524 / 550 / cap 545 971–1012
    bitcoin-internals, chacha20-poly1305 109 / 140 512 / 466 777 / 743
    dashcore, dashcore_hashes 239 / 237 250 / 248 342 / 338
    dashcore, bitcoin-internals 104 / 104 122 / 115 155 / 150
    dashcore, dashcore_hashes, bitcoin-internals, chacha20-poly1305 89 / 147 101 / 160 94 / 88
    everything (profile.dev.opt-level = 3) 75 / 78 101 / 91 52 / 52
    reference: aca0202 dev3 65–75 222–244 723–726
    reference: d85f15a release 67–82 76–94 46–47
    • Each crate on its own fixes only its own phase. The smallest set that closes the whole gap is dashcore + bitcoin-internals.
    • Adding dashcore_hashes and chacha20-poly1305 lowers CPU further, from ~150 to ~90 s. Wall time is then bound by the network: the second run of that variant lost 50 s to 2 peer kicks.
    • Build cost, clean dash-spv build without sccache, jobs = 2: dev3 46 s, with dashcore + bitcoin-internals 50 s, everything at opt-level 3 107 s. Only dashcore grows noticeably (4.0 → ~13 s); the other three stay ≤0.2 s.
    • bitcoin-internals without a version matches all four versions in the graph (0.5.0–0.8.2; U256 is in 0.8.2).

    Downstream form (Cargo ignores profiles of dependencies, so each consumer has to add this):

    [profile.dev.package.dashcore]
    opt-level = 3
    [profile.dev.package.bitcoin-internals]
    opt-level = 3
    # plus the same under [profile.test.package.*], next to dash-pow / wide

    3. Hardware-accelerated dash-pow (x86-64-v3 + AES)

    Built with -C target-cpu=x86-64-v3 -C target-feature=+aes. cargo tree -e features -i dash-pow shows portable on for the default target and off for v3, also for -p dash-spv.

    X11 micro-benchmark, d85f15a, ms per 8000 headers (median of 7):

    Build rustc portable v3
    release 1.99.1 55.4 21.8
    release 1.98.1 55.6 22.6
    dev, all opt-level 0 1.99.1 3191 3308
    dev, dash-pow+wide at opt-level 3 1.99.1 69.3 29.7
    dev, dash-pow+wide at opt-level 3 1.98.1 70.7 29.4
    dev, dash-pow+wide at opt-level 3 1.92 281.8 234.2

    dash-spv sync, d85f15a, 2 workers, v3, one run each:

    Variant Synced (v3) Same variant, portable
    dev, all opt-level 0 headers unfinished at the 270 s cap headers 623–712 s, sync not done at 900 s
    dev3 355 s 524–550 s / cap
    dev3 + dashcore + bitcoin-internals 93 s 115–122 s
    • v3 speeds up release X11 2.5× and dev3 X11 2.4×. At opt-level 0 it does nothing.
    • The 35 % dev3 sync gain comes mostly from crates other than X11, which is only 15 CPU-s of dev3. Filter matching and DGW also run faster when compiled for v3.
    • target-cpu cannot be set per profile on stable Cargo, and there is no runtime detection. The hardware path is therefore a local developer option only. It must not reach distributed binaries, which would crash (SIGILL) on CPUs without AVX2.

    4. Correction

    The X11 micro-benchmark in the issue was built with the host's default rustc 1.92, because the bench crate had no toolchain pin. With the toolchains actually in use, dash-pow at opt-level 3 with debug-assertions on is 1.25× slower than release (69–71 ms), not 5× (≈281 ms). So gating inline(always) on debug_assertions costs little on current rustc, and I have withdrawn the suggestion to change it. The sync numbers were built with 1.98.1 and are unaffected.

    Suggestions (updated)

    • Upstream: offload headers2 decompression and hashing from the async peer reader (as before), so that peer timeouts stop depending on build settings.
    • For downstream crates: document that dashcore and bitcoin-internals (besides dash-pow/wide) need opt-level 3 in dev/test profiles, for example in the dash-spv README.
    • Optional: consider a cheaper U256 path for DGW, for example a word-based div_rem instead of the bit-serial loop. Today DGW accounts for 40 % of header-phase CPU at opt-level 0.

    🤖 Co-authored by Claudius the Magnificent AI Agent

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

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