Repository navigation
perf(push): reuse VAPID signatures across notification sends - #199138
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Contributor
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 15, 2026
…w#199138) * perf(push): reuse VAPID signatures across notification sends * perf(push): trust a fresh loopback certificate in the web push benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Web Push fan-out repeats the same synchronous VAPID signature for every browser, adding avoidable work to the Gateway main thread.
User Impact
Notification bursts spend less time blocking other Gateway work. Payloads, delivery options, per-device authorization, subscription cleanup, and per-message encryption remain unchanged. No configuration or migration is required.
Why This Change Was Made
Reuse the dependency's VAPID headers by push-service origin, subject, public/private key and hourly expiry bucket. Tokens expire in 11–12 hours, within RFC 8292's 24-hour limit. A 64-entry FIFO bounds retained origins, identities and old buckets. The cache only reuses application-server identification; callers still authorize each delivery. Removing the mutable global VAPID setter also keeps overlapping prepared senders on their own identities.
This deliberately takes the smallest measured step. Fresh ephemeral ECDH keys and salts, HKDF, AES-GCM, request construction and HTTPS transport remain with web-push 3.6.7. Encryption is still synchronous. Production code grows by 21 lines to preserve identity separation, expiry refresh and bounded retention; no second send path, worker, dependency, schema, or config option is introduced.
Evidence
Acceptance rule declared before paired runs: realistic approval JSON (~750 bytes), 1/4/16 subscriptions, five interleaved baseline/candidate pairs, 2,000 sends per arm and shape. Accept a repeatable CPU or allocation reduction with valid ciphertext/JWT and no material delivery regression. Allocation is measured separately from untraced timing. Synthetic identities and loopback HTTPS only.
Warm-path means across five pairs, 10,000 sends per side per shape and mode (30,000 measured real HTTPS sends per side). CPU is main-thread CPU; allocation is a separate sampling pass. The HTTPS CPU includes the local mock server's equal response work.
Preparation batch p95 ranges, baseline → candidate: 1 recipient 0.186–0.368 → 0.115–0.119 ms (10,000 samples/side); 4 recipients 0.895–1.274 → 0.444–0.830 ms (2,500 samples/side); 16 recipients 2.871–3.636 → 1.776–6.391 ms (625 samples/side, 125/pair; tail is context only). Host 1-minute load was 27.2–48.1 on baseline preparation arms and 25.0–41.9 on candidate arms. One baseline send had a 188.7 ms wall outlier while that arm consumed 329 ms thread CPU across 2,000 sends; no samples were excluded. Wall-time means include contention. Per-send GC means (ms), baseline → candidate: fan-out 1: 0.001688 → 0.002643 (+0.000955); 4: 0.002769 → 0.001194 (−0.001575); 16: 0.001870 → 0.003218 (+0.001348). These tiny absolute rises on shapes 1/16 are context, not a regression verdict. No A/A rejection decision was made.
Separate instrumented dependency attribution at 16 recipients (1,600 sends): per-send key generation 20.8 µs, ECDH 49.3 µs, HKDF 9.3 µs, AES-GCM 3.9 µs, ES256 signing 36.6 µs, headers/validation/JWT encoding 15.4 µs, HTTPS request setup 10.4 µs. Encryption-inclusive cost is 95.4 µs; request-details-inclusive cost is 147.4 µs. These instrumentation timings are context, separate from untraced comparisons.
Reproduce with
node --import ./scripts/tsx.mjs scripts/perf/web-push-measure.ts --mode prepare --fanout 16 --iterations 2000; repeat withallocationandhttpsand fan-outs 1/4/16 on each revision. Baseline:794d8e7e023f33033a360a6f7b6657367e0e920d.The regression fails on main with 17 ES256 signatures for 17 sends, then passes with one. It independently decrypts all 17 aes128gcm bodies using the subscription private key, verifies ES256 signatures/claims, checks fresh per-message salts and public keys, and exercises audience, subject, identity and expiry separation across prepared senders.
Focused tests: push-web, event-web-push and approval-web-push passed (119 existing cases); new wire regression passed (49 ms test body; 133 s wrapper including worker-artifact preparation). Root script typechecks and infra test types passed. Changed-file lint/format passed. Export-name collision, eager-import closure, PR-wrapper closure, test-plan guards, push-preference/profile-read siblings and event storage-scope tests also passed (199 additional cases across six files; 224 s wrapper wall time). The test-line record covers the exact +159 test lines. Initial wire-test failure on the candidate was a future-dated test clock exceeding the dependency's expiry limit; the fixture now anchors to the current hour. No Testbox was allocated under this lane's light-local/PR-CI validation rule.
Owner measurements and real local HTTPS transport cover this duplicate-signing removal. No whole-Gateway stress campaign or live Team load was run, and no Gateway-wide CPU/list-latency claim is made. The 283 ms production sample is not reproduced as an intrinsic single-send cost on this Mac; its original contention/fan-out remains unproven.
Independent Codex autoreview (local staged candidate against
794d8e7e023f33033a360a6f7b6657367e0e920d, P0–P2) returned scoped-clean, with no accepted/actionable findings. Initial-head CI passed production/test typechecks and lint, but CodeQL flagged the benchmark'srejectUnauthorized: false. A prepared follow-up replaces it with a fresh loopback certificate and explicit CA trust. Changed-file lint and all root test/script typecheck shards pass on that repair. The final-script HTTPS smoke completed 2,000 sends at fan-out 16: 177.318 µs thread CPU/send and 2.854 ms mean batch latency, consistent with the original warm-path comparison. Certificate generation and connection warm-up precede measurement.The benchmark TLS repair is committed as
a7355f69fbf13e323f6104d5ffd65cdacf53336e. On that head, the 120 focused push tests pass (push-web, push-web.transport, event-web-push, approval-web-push), and a branch-mode Codex autoreview againstorigin/mainis scoped-clean.