perf: reduce component route burst overhead#1523
Merged
Merged
Conversation
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces burst overhead in the OC registry component routes by deduplicating concurrent cold-cache loads (single-flight), bounding batch/nested render fan-out, and trimming per-request hot-path work, with targeted benchmarks and unit tests to validate the perf and behavioral invariants.
Changes:
- Add single-flight dedupe for cold template/data-provider/env loads and clear execution-timeout timers after completion.
- Cap concurrency (pLimit(10)) for batch POST renders and nested
renderComponentsfan-out while preserving result order. - Reduce hot-path overhead via request-event gating, multipart parsing guards (publish-only), and faster version resolution; add benchmark scenarios/harnesses and supporting tests.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| plans/README.md | Adds plan index and execution status for perf/benchmark work. |
| plans/001-component-route-performance-wins.md | Documents the intended perf changes and verification steps for component-route hot paths. |
| plans/002-benchmark-burst-and-batch-scenarios.md | Documents benchmark scenarios/results validating single-flight and bounded fan-out. |
| packages/oc/src/registry/routes/helpers/get-component.ts | Implements single-flight for cold loads, lazy header parsing, timer cleanup, and avoids allocating empty headers. |
| packages/oc/src/registry/routes/components.ts | Replaces unbounded batch rendering with pLimit(10) while preserving order. |
| packages/oc/src/registry/domain/nested-renderer.ts | Caps nested render concurrency with pLimit(10) while preserving order and error-as-result behavior. |
| packages/oc/src/registry/domain/version-handler.ts | Adds fast paths for latest/undefined and exact-version resolution before semver range work. |
| packages/oc/src/registry/domain/validators/plugins-requirements.ts | Avoids repeated Object.keys by accepting a precomputed plugin-name Set. |
| packages/oc/src/registry/middleware/index.ts | Skips request timing payload work when there are no request event listeners. |
| packages/oc/src/registry/domain/events-handler.ts | Adds hasListeners API for listener-aware gating. |
| packages/oc/src/registry/domain/http-server/express-adapter.ts | Guards multer multipart parsing so non-publish methods avoid upload parsing checks. |
| packages/oc-fastify-server-adapter/src/index.ts | Skips multipart parsing for non-PUT methods in the Fastify adapter hook. |
| packages/oc-fastify-server-adapter/test/index.test.ts | Adds regression test proving multipart parsing is skipped for non-publish methods. |
| packages/oc/tasks/benchmarks/server-benchmark.js | Adds batch POST/body support, batch-storage scenario, preflight validation, and storage concurrency reporting. |
| packages/oc/tasks/benchmarks/storage-adapter.js | Adds active/peak read tracking to support storage concurrency measurements. |
| packages/oc/tasks/benchmarks/single-flight-burst.js | Adds a fresh-process cold-burst harness to validate single-flight collapsing N downstream loads to 1. |
| packages/oc/test/unit/registry-routes-helpers-get-component.js | Adds unit coverage for single-flight dedupe and timeout timer cleanup; updates injection for clearTimeout. |
| packages/oc/test/unit/registry-routes-component.js | Makes assertions resilient to concurrency (find-by-name rather than relying on result position). |
| packages/oc/test/unit/registry-domain-version-handler.js | Adds test coverage for exact-hit and missing-exact behaviors. |
| packages/oc/test/unit/registry-domain-nested-renderer.js | Adds test coverage for order preservation and max concurrency under the new limiter. |
| packages/oc/test/unit/registry-domain-events-handler.js | Adds tests for hasListeners behavior across on/off/reset. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Test plan
npm --workspace packages/oc run buildnpm --workspace packages/oc run test-silent(943 passing)npm --workspace packages/oc-fastify-server-adapter run buildnpm --workspace packages/oc-fastify-server-adapter run test-silentnpm --workspace packages/oc run bench:quickbatch-storageA/B at 100% successsingle-flight-burst.jsA/B for N=50 and N=200Generated with Devin