perf(server): skip empty middleware work - #30
Merged
Conversation
Avoid route lookups, promise continuations, monitor snapshots, and sorting when the corresponding request pipeline stage has no work. Keep handler counts in sync with registration lifecycle changes. Amp-Thread-ID: https://ampcode.com/threads/T-01a01745-cfcc-7179-a3a1-e5aa33780a0c Co-authored-by: Upd4ting <upd4ting@gmail.com>
Upd4ting
force-pushed
the
perf/http-middleware-fast-paths
branch
from
August 19, 2026 16:50
750602f to
e8d8750
Compare
This was referenced Aug 19, 2026
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
This PR intentionally does not change controller resolution or
HTTPResultconstruction/serialization.Rebase on #29
Rebased commit:
e8d87505a5912cd06dec1a9839224d71f35050acon0c212790f29a241aeb750026caea7c09de553f4a(perf(api): compile controller resolution plans (#29)).The rebase was conflict-free. The incremental diff still contains only:
src/server.tssrc/test/server-fast-paths.test.tsgit merge-base --is-ancestor 0c212790 HEADsucceeds, so #29 is preserved in full. The benchmark below measures new main including #29 against new main + #30; it does not reattribute #29's controller-resolution gains to this PR.Incremental benchmark after rebase
Method
0c212790; candidate:e8d8750; same orb22.19.0; autocannon8.0.0; loopback HTTP{ "hello": "world" }; dynamic route:/users/:id; POST uses a small JSON bodyThese direct-server scenarios isolate the middleware/monitor change. #29 is present in both artifacts but its controller plans are intentionally outside this incremental measurement.
The five paired deltas are not uniformly positive: GET c=10 includes one -9.4% run, POST one -1.4% run, and route 1,000 one -0.1% run. Their paired median changes are respectively +9.6%, +2.7%, and +7.3%. The aggregate direction is positive, but GET c=10 and route 1,000 remain noisy.
Populated pipeline
The pipeline fixture uses two prefixes, two postfixes, and one monitor.
Because three runs are near zero and one regresses, the populated-pipeline result remains directional/inconclusive. This PR claims the robust fast path only for empty or non-matching work.
Correctness
The integration test exercises an initially empty pipeline, dynamic prefix/postfix/monitor registration, priority order, monitor execution, removal, and the restored empty fast path. The existing contract suite covers HEAD, OPTIONS, errors, monitor isolation/errors/priorities, WebSocket success/error monitoring, and route lifecycle behavior. #29's controller-plan tests are also included after the rebase.
Commands run after rebase:
pnpm install --frozen-lockfilepnpm buildpnpm --package=@antelopejs/core@1.4.7 dlx ajs module test .— 126 passingpnpm lintGitHub CI and GitGuardian pass on the rebased commit. No review or inline comment is currently open.
Limits and risk