Skip to content

fix: large amounts of metadata can break 512MB string limit#34480

Merged
mergify[bot] merged 7 commits intomainfrom
huijbers/synth-perf
Mar 6, 2026
Merged

fix: large amounts of metadata can break 512MB string limit#34480
mergify[bot] merged 7 commits intomainfrom
huijbers/synth-perf

Conversation

@rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented May 16, 2025

A large amount of stacks leads to a large body of metadata into the manifest.json file. The file can grow too large to be written to disk (>512MB), but even if it doesn't fail outright, serializing and writing and loading a large JSON file takes a lot of CPU time.

This PR splits the metadata for stacks off into a separate file which is written separately, moving it out of the hot path of working with the manifest.json file. On a tree of 256 stacks and ~40,000
constructs, this shaves off 5 seconds off of the total synthesis time.

Also in this PR:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@rix0rrr rix0rrr requested a review from a team as a code owner May 16, 2025 11:55
@aws-cdk-automation aws-cdk-automation requested a review from a team May 16, 2025 11:55
@github-actions github-actions bot added the p2 label May 16, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label May 16, 2025
@rix0rrr rix0rrr force-pushed the huijbers/synth-perf branch from 27b76dd to 046eb38 Compare May 16, 2025 11:56
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

@rix0rrr rix0rrr added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label May 16, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review May 16, 2025 11:59

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@rix0rrr rix0rrr changed the title fix: large amounts of stacks slow down synthesis fix: large amounts of stacks slows down synthesis May 16, 2025
@rix0rrr rix0rrr self-assigned this May 26, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: f04ec71
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

rix0rrr added a commit to aws/aws-cdk-cli that referenced this pull request Jun 3, 2025
When CDK apps grow extremely large (think 10-100 stacks, 1000-10000
constructs), all metadata together begins to exceed 512MB, the maximum
string size in NodeJS. People usually deal with this by disabling
metadata, but they shouldn't have to.

In addition, even for manifests that don't exceed 512MB the extremely
large size of the single JSON object slows down its writing and reading
every time, even if the metadata doesn't need to be accessed.

An effective solution is to write the metadata of an artifact to a
separate file. This PR introduces the ability for that into the Cloud
Assembly schema, and updates the CLI to read from both sources if
available.

Relates to aws/aws-cdk#34480.
github-merge-queue bot pushed a commit to aws/aws-cdk-cli that referenced this pull request Feb 9, 2026
When CDK apps grow extremely large (think 10-100 stacks, 1000-10000
constructs), all metadata together begins to exceed 512MB, the maximum
string size in NodeJS. People usually deal with this by disabling
metadata, but they shouldn't have to.

In addition, even for manifests that don't exceed 512MB the extremely
large size of the single JSON object slows down its writing and reading
every time, even if the metadata doesn't need to be accessed.

An effective solution is to write the metadata of an artifact to a
separate file. This PR introduces the ability for that into the Cloud
Assembly schema, and updates the CLI to read from both sources if
available.

Removes an unused class from the refactoring project that we found
through this project because it would have to be refactored. Rather than
refactoring, bye-bye!

Relates to aws/aws-cdk#34480.

---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license

---------

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@rix0rrr rix0rrr force-pushed the huijbers/synth-perf branch 2 times, most recently from 17e8374 to 6b989ed Compare February 13, 2026 12:55
@rix0rrr rix0rrr changed the base branch from main to huijbers/generators February 13, 2026 12:56
commit df361bb
Merge: f14a874 68bde3b
Author: Rico Huijbers <rix0rrr@gmail.com>
Date:   Fri Feb 13 13:41:58 2026 +0100

    Merge branch 'huijbers/synth-perf' of github.com:aws/aws-cdk into huijbers/synth-perf

commit f14a874
Merge: 5bbd63a ca4409b
Author: Rico Huijbers <rix0rrr@gmail.com>
Date:   Fri Feb 13 13:41:23 2026 +0100

    Merge remote-tracking branch 'origin/main' into huijbers/synth-perf

commit 68bde3b
Author: Rico Hermans <rix0rrr@gmail.com>
Date:   Mon May 26 13:16:07 2025 +0200

    Update construct-iteration.ts

    Comments were outdated

commit f04ec71
Author: Rico Hermans <rix0rrr@gmail.com>
Date:   Mon May 26 13:15:42 2025 +0200

    Naming was shyte

commit 5bbd63a
Author: Rico Huijbers <rix0rrr@gmail.com>
Date:   Fri May 16 13:57:39 2025 +0200

    MOve this code over from the other pR

commit 046eb38
Author: Rico Huijbers <rix0rrr@gmail.com>
Date:   Fri May 16 13:49:51 2025 +0200

    fix: large amounts of stacks slow down synthesis

    A large amount of stacks leads to a large body of metadata into the
    `manifest.json` file. The file can grow too large to be written to disk
    (>512MB), but even if it doesn't fail outright, serializing and writing
    and loading a large JSON file takes a lot of CPU time.

    This PR splits the metadata for stacks off into a separate file which is
    written separately, moving it out of the hot path of working with the
    `manifest.json` file. On a tree of 256 stacks and ~40,000 constructs,
    this shaves off 5 seconds off of the total synthesis time.
@rix0rrr rix0rrr force-pushed the huijbers/synth-perf branch from 6b989ed to a8aa6cb Compare February 13, 2026 12:57
@rix0rrr rix0rrr changed the base branch from huijbers/generators to main February 13, 2026 12:57
@rix0rrr rix0rrr changed the title fix: large amounts of stacks slows down synthesis fix: large amounts of metadata can 512MB string limit Mar 3, 2026
@rix0rrr rix0rrr changed the title fix: large amounts of metadata can 512MB string limit fix: large amounts of metadata can break 512MB string limit Mar 3, 2026
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Mar 5, 2026
@rix0rrr rix0rrr removed the pr/do-not-merge This PR should not be merged at this time. label Mar 6, 2026
@mergify
Copy link
Contributor

mergify bot commented Mar 6, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Contributor

mergify bot commented Mar 6, 2026

Merge Queue Status

Rule: default-squash


  • Entered queue2026-03-06 08:58 UTC
  • Checks started · in-place
  • All checks passed · ready to merge 🚀
  • ⬜ Merge

@mergify
Copy link
Contributor

mergify bot commented Mar 6, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 20c3154 into main Mar 6, 2026
16 of 17 checks passed
@mergify mergify bot deleted the huijbers/synth-perf branch March 6, 2026 10:02
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants