fix(core): token stack traces expensively clutter --debug mode#37642
Conversation
Capturing stack traces is an expensive operation. It only happens in `--debug` mode (`CDK_DEBUG=1`) so most normal executions don't pay this cost, but we want to start using debug mode more often to get useful trace information out of CDK apps. Right now, when debug mode is enabled, stack traces will be captured at every Token creation site. A typical CDK app will create 1000s-10s of thousands of Tokens, and each creation would require capturing a stack trace that will almost certainly never be used. Deprecate and disable token stack traces. This will make normal execution sliiiightly faster (probably unnoticeably so) and make `--debug` mode execution notably faster. For heavily used tokens from the `core` library we move the allocation of the stack trace to the prototype instead of the instance, to save that additional tiny extra bit of memory allocation of a static array on every token instantiation.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
| */ | ||
| public readonly displayHint: string; | ||
| public readonly creationStack: string[]; | ||
| public readonly creationStack: string[] = ['Token stack traces are deprecated']; |
There was a problem hiding this comment.
To me "deprecated" implies it can still be used somehow but will go away in the next major version. Maybe we can update the wording here (and in the other places).
|
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). |
Merge Queue Status
This pull request spent 31 minutes 54 seconds in the queue, including 31 minutes 40 seconds running CI. Required conditions to merge
|
|
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). |
|
Comments on closed issues and PRs are hard for our team to see. |
Capturing stack traces is an expensive operation. It only happens in
--debugmode (CDK_DEBUG=1) so most normal executions don't pay this cost, but we want to start using debug mode more often to get useful trace information out of CDK apps.Right now, when debug mode is enabled, stack traces will be captured at every Token creation site. A typical CDK app will create 1000s-10s of thousands of Tokens, and each creation would require capturing a stack trace that will almost certainly never be used.
Deprecate and disable token stack traces. This will make normal execution sliiiightly faster (probably unnoticeably so) and make
--debugmode execution notably faster.For heavily used tokens from the
corelibrary we move the allocation of the stack trace to the prototype instead of the instance, to save that additional tiny extra bit of memory allocation of a static array on every token instantiation.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license