Skip to content

feat: CLI send in performance profile if emitted by app#1478

Merged
aws-cdk-automation merged 9 commits into
mainfrom
huijbers/perf-counters
May 13, 2026
Merged

feat: CLI send in performance profile if emitted by app#1478
aws-cdk-automation merged 9 commits into
mainfrom
huijbers/perf-counters

Conversation

@rix0rrr
Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr commented May 6, 2026

If the CDK app emits a performance profile (a set of counters explaining where time was spent in the CDK app), the CLI will attach those to the SYNTH event.

The data itself depends on what the CDK app is going to emit (not fully written yet), but is going to look something like this (feature added here):

{
  'phase:Construction': 12154,
  'phase:Construction(cnt)': 1,
  'bundle:NodejsFunction': 12133,
  'bundle:NodejsFunction(cnt)': 2,
  'DockerImage.fromBuild': 10957,
  'DockerImage.fromBuild(cnt)': 1,
  'phase:Load': 3940,
  'phase:Load(cnt)': 1,
  'AssetBundlingBindMount.run': 1176,
  'AssetBundlingBindMount.run(cnt)': 1,
  'phase:Synthesis': 26,
  'phase:Synthesis(cnt)': 1,
  'Stack.resolve': 7,
  'Stack.resolve(cnt)': 47,
  'FileSystem.fingerprint': 1,
  'FileSystem.fingerprint(cnt)': 1,
  'FileSystem.isEmpty': 0,
  'FileSystem.isEmpty(cnt)': 1
}

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

This adds a new feature where the CDK app can emit a performance profile
to a well-known file, and the CLI will ask the user whether to send it
in as part of telemetry or not.

The question will be posed as:

```
App synthesis produced a performance profile. Send in for analysis? (Y)es (N)o (A)lways N(E)ver
```

And the user can answer "Never" to permanently record that they never
want to do this.
@rix0rrr rix0rrr requested a review from a team May 6, 2026 09:11
@aws-cdk-automation aws-cdk-automation requested a review from a team May 6, 2026 09:12
@github-actions github-actions Bot added the p2 label May 6, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 7, 2026

Codecov Report

❌ Patch coverage is 86.79245% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.11%. Comparing base (60cdf66) to head (fa724f1).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
packages/aws-cdk/lib/cli/cli.ts 0.00% 5 Missing ⚠️
packages/aws-cdk/lib/cli/util/fs-util.ts 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1478      +/-   ##
==========================================
+ Coverage   88.10%   88.11%   +0.01%     
==========================================
  Files          74       75       +1     
  Lines       10669    10721      +52     
  Branches     1457     1464       +7     
==========================================
+ Hits         9400     9447      +47     
- Misses       1241     1246       +5     
  Partials       28       28              
Flag Coverage Δ
suite.unit 88.11% <86.79%> (+0.01%) ⬆️

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.

Comment thread packages/aws-cdk/lib/cli/cli.ts Outdated
// Ask the user
let decision: boolean | undefined = undefined;
while (decision === undefined) {
const answer: Choice = await promptly.prompt(`🔍 ${chalk.cyan('Your CDK app produced a performance profile to help AWS diagnose slow synthesis. Send in for analysis?')} (Y)es (N)o (A)lways Neve(R) (V)iew`, {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not use IoHelper here?

/**
* If present, will be sent in every event
*/
permanentCounters?: Record<string, number>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How is this supposed to be used?

Comment thread packages/aws-cdk/lib/cli/cli.ts Outdated
return await main(cmd, argv);
const ret = await main(cmd, argv);

await maybeCommitPerfCounters(ioHost);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we care about performance metrics only in case of success?

Copy link
Copy Markdown
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

Main blocker for me is that when asking for "always" approve, adding to the data might be an issue. We either need to make this abundantly clear on the opt-in, or version the data schema and store the opt-in only per schema version.

Similarly, if we phrase this exclusively as performance data, we cannot reuse the same opt-in for e.g. error logs in future. This might be by design, but wanted to call this out.

Comment thread packages/aws-cdk/lib/cli/util/fs-util.ts Outdated
Comment thread packages/aws-cdk/lib/cli/telemetry/telemetry-prefs.ts Outdated
Comment thread packages/aws-cdk/lib/cli/cli.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

Looks good. Could make a note somewhere that performance-counters.json is an inherently temporary file.

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.

5 participants