perf: throttle ReplayStore.prune, deduplicate key normalization, hoist regex, simplify retry-delay narrowing#11
Merged
chrismaz11 merged 2 commits intomainfrom Mar 16, 2026
Conversation
…t regex, simplify retry-delay narrowing Co-authored-by: chrismaz11 <24700273+chrismaz11@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Identify and suggest improvements to slow code
perf: throttle ReplayStore.prune, deduplicate key normalization, hoist regex, simplify retry-delay narrowing
Mar 16, 2026
chrismaz11
approved these changes
Mar 16, 2026
Contributor
|
@copilot Trust Signal Verification Failed |
Copilot stopped work on behalf of
chrismaz11 due to an error
March 16, 2026 14:13
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.
Several small but compounding inefficiencies in hot paths — every webhook invocation triggered a full O(n) Map scan, normalized the same private key string twice, and recompiled a regex on each SHA check.
Changes
ReplayStore.prune()throttled — full O(n) expired-entry sweep was called 2–3× per webhook; now gated behind a configurable interval (default 60 s). Individual TTL checks onbegin/getStatuslookups are unaffected.Private-key normalization deduped (
config/env.ts) —normalizePrivateKey()(regex replace + trim on a 2–4 KB string) was called twice on the same value to populate bothGITHUB_PRIVATE_KEYandGITHUB_PRIVATE_KEY_PEM; normalized once and shared.looksLikeCommitSharegex hoisted (webhooks/github.ts) —/^[a-f0-9]{7,64}$/iliteral promoted to module-levelconst COMMIT_SHA_RE, compiled once at load rather than on every release-job evaluation.getRetryDelayMsnarrowing extracted (github/client.ts) — 7-level nestedtypeof/inchain replaced with a focusedgetRetryAfterHeader(error)helper that traverseserror → response → headers → "retry-after"explicitly.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.