Skip to content

Add cms-api base memory regression check to CI - #5944

Open
VPS-thodax wants to merge 6 commits into
mainfrom
ci/cms-api-memory-check
Open

Add cms-api base memory regression check to CI#5944
VPS-thodax wants to merge 6 commits into
mainfrom
ci/cms-api-memory-check

Conversation

@VPS-thodax

@VPS-thodax VPS-thodax commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Problem

Importing @dextinity/cms-api eagerly loads its whole dependency graph. This "base memory" — paid just by importing the package, before instantiating anything — dominates the API's startup memory and is paid by every consumer on boot (including the migration init container). A new eager import (e.g. a heavy dependency like openai or the mail rendering stack) inflates it for everyone, when it could be lazy-loaded instead.

Solution

Add a workflow that runs only when packages/api/cms-api changes and compares the heap cost of require("@dextinity/cms-api") on the pull request branch against the target branch. It comments when the heap grows by more than 3% (with a lazy-loading recommendation — dynamic import() inside the function that needs it, keeping type-only imports as import type) or shrinks by more than 5%. The comment updates in place across pushes and is deleted once the change returns within that band.

Advisory only — it comments and adds a warning annotation, but does not fail the pipeline or block merging.

How the measurement works

  1. Check out the pull request branch, build @dextinity/cms-api, and measure its base memory.
  2. Check out the target branch, rebuild, and measure again.
  3. Compare the two and report the heap difference.

Each measurement spawns 7 isolated worker processes (fresh module cache, forced garbage collection before and after a single import) and reports the minimum across samples, not an average: noise can only inflate a sample, never shrink it, so the lowest one is the truest reading of the fixed load cost.

Screenshots

Comment when the base memory increased by more than 3%:

Bildschirmfoto 2026-07-01 um 13 21 45

(I simulated this in this PR with temporary commits I removed again)

@VPS-thodax
VPS-thodax force-pushed the ci/cms-api-memory-check branch 3 times, most recently from 0ffbec4 to 8a6b3c2 Compare July 1, 2026 11:03
Importing @comet/cms-api eagerly loads its dependency graph, which dominates the
API's startup memory and time. Add a workflow that runs only when cms-api changes,
measures require("@comet/cms-api") heap on the PR vs. the base branch (min of N
isolated, forced-GC samples), and comments on the PR with a lazy-loading
recommendation if base memory grows by more than 3%.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@VPS-thodax
VPS-thodax force-pushed the ci/cms-api-memory-check branch 3 times, most recently from c2d70ad to 9d0b7b8 Compare July 1, 2026 11:26
@VPS-thodax VPS-thodax changed the title Draft: ci: Add cms-api base memory regression check Add cms-api base memory regression check to CI Jul 1, 2026
Comment thread scripts/measure-cms-api-memory.cjs
@VPS-thodax
VPS-thodax marked this pull request as ready for review July 1, 2026 11:38
@github-actions
github-actions Bot requested a review from VPS-Obi July 1, 2026 11:38
…comments

Comment on a heap increase over 3% or a decrease over 5%, and delete the
comment once the change returns within that band instead of leaving a stale
note. Report heap only, since RSS noise exceeds the threshold.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
VPS-Obi
VPS-Obi previously approved these changes Jul 2, 2026
Comment thread .github/workflows/cms-api-memory.yml
@VPS-Obi
VPS-Obi dismissed their stale review July 2, 2026 06:00

I wanted to comment, not approve

@VPS-thodax
VPS-thodax requested a review from VPS-Obi July 2, 2026 08:32
VPS-Obi
VPS-Obi previously approved these changes Jul 2, 2026
@VPS-thodax
VPS-thodax force-pushed the ci/cms-api-memory-check branch 2 times, most recently from 191f5a8 to c7ba773 Compare August 14, 2026 11:50
VPS-thodax and others added 2 commits August 14, 2026 13:50
Main renamed the package. `pnpm --filter` exits 0 when no project matches, so the
build steps would have passed without building anything, and the measurement would
then fail on the missing `lib` directory.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@VPS-thodax
VPS-thodax requested a review from VPS-Obi August 14, 2026 11:54
@VPS-thodax

Copy link
Copy Markdown
Contributor Author

@VPS-Obi I forgot about this PR and never merged it. Now I did the dextinity renaming. Please reapprove

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