Skip to content

perf: reduce component route burst overhead#1523

Merged
ricardo-devis-agullo merged 1 commit into
masterfrom
perf-improvements
Jul 23, 2026
Merged

perf: reduce component route burst overhead#1523
ricardo-devis-agullo merged 1 commit into
masterfrom
perf-improvements

Conversation

@ricardo-devis-agullo

Copy link
Copy Markdown
Collaborator

Summary

  • deduplicate concurrent cold template, data-provider, and env loads while preserving hot-reload behavior
  • bound batch and nested render fan-out, reduce request/upload hot-path work, and clear provider timers
  • add targeted batch and cold-burst benchmarks with same-machine A/B results
  • confirm single-flight collapses N downstream reads to 1; the fan-out cap halves peak storage concurrency with a documented throughput trade-off

Test plan

  • npm --workspace packages/oc run build
  • npm --workspace packages/oc run test-silent (943 passing)
  • npm --workspace packages/oc-fastify-server-adapter run build
  • npm --workspace packages/oc-fastify-server-adapter run test-silent
  • npm --workspace packages/oc run bench:quick
  • NEW/OLD batch-storage A/B at 100% success
  • NEW/OLD single-flight-burst.js A/B for N=50 and N=200

Generated with Devin

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 renderComponents fan-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.

@ricardo-devis-agullo
ricardo-devis-agullo merged commit eda74fb into master Jul 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants