Skip to content

Conversation

@iliapolo
Copy link
Contributor

@iliapolo iliapolo commented Apr 29, 2025

In order to be able to run on various machine types, calculate the max number of workers based on the total memory and CPU cores available in the machine. With this calculation we get:

  • CLI Repo (64GB & 16 Cores) = Math.min(16 * 15, (64000 - 2000) / (0.7 * 500)) = Math.min(240, 177) = 177
  • CodeBuild Canary (16GB & 8 Cores) = Math.min(8 * 15, (16000 - 2000) / (0.7 * 500)) = Math.min(120, 40) = 40
  • CodeBuild Release & Main (72GB & 32 Cores) = Math.min(32 * 15, (72000 - 2000) / (0.7 * 500)) = Math.min(480, 200) = 200

Memory Data

Here is some memory usage sampling i've added to confirm our memory consumption stats:

2025-04-29T09:50:51.525Z | [pre-callback] [test] Memory RSS: 152 MB
2025-04-29T09:50:51.200Z | [pre-callback] [test] Memory RSS: 150 MB
2025-04-29T09:50:50.836Z | [pre-callback] [test] Memory RSS: 150 MB
2025-04-29T09:54:08.055Z | [post-callback] [test] Memory RSS: 122 MB
2025-04-29T09:54:08.797Z | [post-callback] [test] Memory RSS: 114 MB
2025-04-29T09:54:12.054Z | [post-callback] [test] Memory RSS: 113 MB

2025-04-29T09:53:06.601Z | [pre-tree] [app.js] Memory RSS: 49 MB
2025-04-29T09:53:10.468Z | [pre-tree] [app.js] Memory RSS: 49 MB
2025-04-29T09:54:04.682Z | [pre-tree] [app.js] Memory RSS: 49 MB
2025-04-29T09:53:07.836Z | [post-tree] [app.js] Memory RSS: 105 MB
2025-04-29T09:54:05.071Z | [post-tree] [app.js] Memory RSS: 106 MB
2025-04-29T09:53:11.895Z | [post-tree] [app.js] Memory RSS: 105 MB
2025-04-29T09:53:08.864Z | [post-synth] [app.js] Memory RSS: 139 MB
2025-04-29T09:53:13.215Z | [post-synth] [app.js] Memory RSS: 139 MB
2025-04-29T09:54:05.367Z | [post-synth] [app.js] Memory RSS: 138 MB

2025-04-29T09:53:09.219Z | [post-synth] [cli] Memory RSS: 200 MB
2025-04-29T09:53:13.359Z | [post-synth] [cli] Memory RSS: 203 MB
2025-04-29T09:54:05.437Z | [post-synth] [cli] Memory RSS: 202 MB
2025-04-29T09:53:10.358Z | [pre-synth] [cli] Memory RSS: 201 MB
2025-04-29T09:54:04.627Z | [pre-synth] [cli] Memory RSS: 183 MB

From here we see that:

  • Memory consumed by jest process: ~150MB
  • Memory consumed by CDK App subprocess: ~140MB
  • Memory consumed by CLI subprocess: ~200MB

Notes

  • These numbers suggest a total of about 500MB per worker...multiple that by 50 and you get 25GB - way above the 16GB we were running with. Stands to reason that a simple 500 X 50 multiplication doesn't accurately describe the total max memory consumption of the suite.
  • Its surprising that the memory consumed by jest after the callback finishes is less than before the callback starts.

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

@github-actions github-actions bot added the p2 label Apr 29, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team April 29, 2025 10:13
@iliapolo iliapolo marked this pull request as ready for review April 29, 2025 10:29
@codecov-commenter
Copy link

codecov-commenter commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.15%. Comparing base (4068210) to head (83cf308).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #423   +/-   ##
=======================================
  Coverage   79.15%   79.15%           
=======================================
  Files          54       54           
  Lines        6889     6889           
  Branches      773      772    -1     
=======================================
  Hits         5453     5453           
  Misses       1418     1418           
  Partials       18       18           
Flag Coverage Δ
suite.unit 79.15% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrgrain mrgrain temporarily deployed to integ-approval May 1, 2025 10:48 — with GitHub Actions Inactive
@mrgrain mrgrain added this pull request to the merge queue May 1, 2025
Merged via the queue into main with commit 302f9bc May 1, 2025
20 checks passed
@mrgrain mrgrain deleted the epolon/dynamic-max-workers-count branch May 1, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants