Add cms-api base memory regression check to CI - #5944
Open
VPS-thodax wants to merge 6 commits into
Open
Conversation
VPS-thodax
force-pushed
the
ci/cms-api-memory-check
branch
3 times, most recently
from
July 1, 2026 11:03
0ffbec4 to
8a6b3c2
Compare
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
force-pushed
the
ci/cms-api-memory-check
branch
3 times, most recently
from
July 1, 2026 11:26
c2d70ad to
9d0b7b8
Compare
VPS-thodax
commented
Jul 1, 2026
…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
previously approved these changes
Jul 2, 2026
This reverts commit c9245b4.
VPS-Obi
previously approved these changes
Jul 2, 2026
VPS-thodax
force-pushed
the
ci/cms-api-memory-check
branch
2 times, most recently
from
August 14, 2026 11:50
191f5a8 to
c7ba773
Compare
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>
Contributor
Author
|
@VPS-Obi I forgot about this PR and never merged it. Now I did the dextinity renaming. Please reapprove |
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.
Problem
Importing
@dextinity/cms-apieagerly 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 likeopenaior 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-apichanges and compares the heap cost ofrequire("@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 — dynamicimport()inside the function that needs it, keeping type-only imports asimport 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
@dextinity/cms-api, and measure its base memory.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%:
(I simulated this in this PR with temporary commits I removed again)