Repository navigation
perf(app-core): speed up router dispatch - #865
Merged
Merged
Conversation
jonkwheeler
marked this pull request as ready for review
August 26, 2026 18:32
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.
Summary
Why
Changes
router-dispatchin the benchmark harness and MCP server, with same-process ratio guards against the dynamic control.Validation
pnpm format:check(not run; scoped formatting passed)pnpm typecheck(not run; scoped app-core typecheck passed)pnpm test(not run; targeted suites passed)node benchmarks/bench.mjs --quick --ratios router-dispatch— 2/2 ratio guards passedCI=true pnpm syncgit diff --checkRisk / follow-ups
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Localized hot-path optimization in route matching with explicit tests and benchmarks; dynamic matching and param decoding behavior are unchanged.
Overview
Speeds up
@octanejs/app-corerequest routing by avoiding per-candidate RegExp work on static paths and by uppercasing the HTTP method at most once permatch()call when scanning server routes.Router: Parameter-free paths compile to an exact string and compare with
pathname === pattern; routes with params or catch-alls still use capturingRegExp. Server-route method checks reuse a lazily computednormalizedMethodinstead of callingtoUpperCase()on every candidate.Regression coverage: Adds a Node-only
router-dispatchbenchmark (1,000-route tables: static hit, wrong-method miss, dynamic params) with local baselines, ratio guards vs the dynamic path, harness registration, androuter-dispatchin the Octane MCPoctane_benchmarkcatalog. New Vitest coverage locks static, param, catch-all, literal special characters, and method matching behavior.Reviewed by Cursor Bugbot for commit a51c7fd. Bugbot is set up for automated code reviews on this repo. Configure here.