aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

fix: large amounts of stacks slows down synthesis

Open rix0rrr opened this issue 6 months ago • 1 comments

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: construct tree iteration was being done in a lot of places, with function recursion and returning arrays. Moving this all into some functions that use generators. This improves performance only slightly, but it should improve memory usage by a whole lot for large construct trees.


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

rix0rrr avatar May 16 '25 11:05 rix0rrr

AWS CodeBuild CI Report

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

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

aws-cdk-automation avatar May 26 '25 11:05 aws-cdk-automation