Huge performance impact due to `whiteoutLeadingComments` calls
:bug: Bug Report
Affected Languages
- [ ]
TypeScriptorJavascript - [x]
Python - [ ]
Java - [ ] .NET (
C#,F#, ...) - [ ]
Go
(possibly others as well)
General Information
- JSII Version: 1.37.0 (build a6fe12f), typescript 3.9.10
- Platform: OS X
What is the problem?
Hi! I just did some CPU profiling of our cdktf get command as its execution time increased substantially over the course of the last months. The cause for this was probably the growing AWS Terraform provider – which can take up to an hour to build in CI nowadays.
It appears that calls to whiteoutLeadingComments take a lot of time:

I was able to confirm this locally by commenting out the body of whiteoutLeadingComments which brought the invocation of JSII (with Python configured) down to 90 seconds (from 1270s).
Is there a way we could e.g. introduce caching for the result of whiteoutLeadingComments or computeLineStarts to improve the performance?
Reproduce
To reproduce the long build times, clone repo and run cdktf get.
Verbose Log
This function appears to have either been renamed or rolled in elsewhere. Is this still a bottleneck?
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
I'd need to check – but I think we can close this one. All our issues that linked to this are closed by now, too. So if we revisit (i.e. profile) JSII performance at some point in the future, we'll just raise a new up-to-date issue if we find something like this again 👍
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.