release 1.15.0 makes cdk synth radically slow
:bug: Bug Report
Affected Languages
- [ ]
TypeScriptorJavascript - [x]
Python - [x]
Java - [ ] .NET (
C#,F#, ...)
General Information
- JSII Version: 1.15.1
- Platform: Python
sh-4.2# uname -a
Linux 454d0ce8e2e4 5.4.39-linuxkit #1 SMP Fri May 8 23:03:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
sh-4.2# python3 -V -V
Python 3.7.9 (default, Aug 27 2020, 21:59:41)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-9)]
What is the problem?
When upgrading to pip3 install --upgrade jsii==1.15.0 the synthesis with CDK up to 10 times slower. Some of our pipeline jobs take now 80 minutes instead of 8.
We have a complex app.py with loads of stacks and also loads of lookups to the AWS account during synthesis. Normally it takes "only" 10 seconds to synthesize the CFN scripts. However as often as I switch between jsii==1.14.1 and jsii==1.15.0 I get the same result, that the synthesis takes much much longer. This is independent from the AWS version I use (client and library).
sh-4.2# date && python3 app.py && date
Fri Nov 27 09:29:22 UTC 2020
Fri Nov 27 09:29:32 UTC 2020
sh-4.2# pip3 install --upgrade jsii
...
Successfully uninstalled jsii-1.14.1
Successfully installed jsii-1.15.0
sh-4.2# date && python3 app.py && date
Fri Nov 27 09:29:52 UTC 2020
Fri Nov 27 09:31:54 UTC 2020
Verbose Log
Because of privacy reasons I dont want to provide verbose logs. However I made a diff of both verbose logs before and after upgrading to jsii==1.15.1 and there were just a couple and no spectacular differences:
- modules workdir
- before: /tmp/jsii-kernel-7tSAAx
- after: /tmp/jsii-kernel-WXbuZ8
- the cdk.out*-directory
Both log files are of same length and same content, except the module wordir and the cdk out dir.
Hey @ThomasSteinbach - thanks for reporting this.
Can you give us a little more info on your app & environment, so we have an easier time trying to reproduce your performance issue?
- How many stacks does your app have? How many resources per stack (on average / ballpark)?
- What version of
nodeis your system using? (node -vand/ornode -p process.versions)
The delta between both releases is: v1.14.1...v1.15.0.
If I were to throw a wild guess at which changes could cause the performance issues:
- VERY LIKELY https://github.com/aws/jsii/commit/1453ed34736917b54cfc212b2fa5e381714d1654 (https://github.com/aws/jsii/pull/2238)
- In particular, the 50ms
sleepthat was introduced when recovering fromEAGAIN- https://github.com/aws/jsii/blob/1453ed34736917b54cfc212b2fa5e381714d1654/packages/%40jsii/runtime/lib/sync-stdio.ts#L56
- https://github.com/aws/jsii/blob/1453ed34736917b54cfc212b2fa5e381714d1654/packages/%40jsii/runtime/lib/sync-stdio.ts#L102
- In particular, the 50ms
- LESS LIKELY https://github.com/aws/jsii/commit/29b226281c71e62049f72a9418011925e17dc615 (https://github.com/aws/jsii/pull/2247)
Actually in light of the previous guess, I would be really interested in the output of node -p process.versions, in particular the v8 entry therein.
We should be able to easily validate my suspicion by making a new build without the sleep statements (trading time for CPU thrashing - which is effectively what we had been doing before).
Ideally, we'd want to wait for "50 ms or until the stream becomes readable, whichever happens first", but I don't know of a way to make this in the synchronous context we must stay in there...
Hi @RomainMuller , since we started with CDK 1.43 we are using node 12.13.1 as suggested in the documentation.
Within this app we have defined +100 stacks (~about, because some stacks were created depending on the number of top level elements of a yaml file) with at least 50 resources. Mostly we create ssm parameters, but due to limitations of parameters/resources per stack, we split some stacks programatically into more. Besides ssm parameters we mainly deploy plain EC2 instances (in a for-loop), A- and CNAMe-records, S3 buckets, ... nothing special.
node -p process.versions
{
node: '12.13.1',
v8: '7.7.299.13-node.16',
uv: '1.33.1',
zlib: '1.2.11',
brotli: '1.0.7',
ares: '1.15.0',
modules: '72',
nghttp2: '1.39.2',
napi: '5',
llhttp: '1.1.4',
http_parser: '2.8.0',
openssl: '1.1.1d',
cldr: '35.1',
icu: '64.2',
tz: '2019c',
unicode: '12.1'
}
Witnessing similar behavior in a java-cdk project:
node -p process.versions
{
node: '12.18.0',
v8: '7.8.279.23-node.37',
uv: '1.37.0',
zlib: '1.2.11',
brotli: '1.0.7',
ares: '1.16.0',
modules: '72',
nghttp2: '1.41.0',
napi: '6',
llhttp: '2.0.4',
http_parser: '2.9.3',
openssl: '1.1.1g',
cldr: '37.0',
icu: '67.1',
tz: '2019c',
unicode: '13.0'
}
It's running so slowly that I was convinced it was hanging or that I was offline for some reason.
Just confirming that we are seeing much slower behavior with 1.15.0--our deployment process went from 1 hour to 1.5 hours, a 50% increase. Would greatly appreciate a speedy resolution.
So #2298 removes the sleep I reckon are the cause of your problems. I'll give instructions how you can use the PR validation artifacts to verify that this indeed restores the previous performance once it's done building.
@RomainMuller that would be nice. If "the PR validation artifacts" are a installable pypi package, I should be able to easyly check the behavior within my docker container.
Happy to test the changes once you send the instructions. Thanks for jumping on this!
Here it is:
- Download the release-package.zip file.
- Unzip that
- Depending on the language
- In the
pythondirectory, you'll find a.whlpackage you should be able topip installinto your app - The
javadirectory is a Maven repository (and the JAR file is down under there if it's faster to point at it) - The
dotnetdirectory contains NuGet packages that can be installed
- In the
You can verify the above ZIP file using this signature file (it would be named release-package.zip.asc if GitHub supported the .asc extension): release-package.zip.txt
Using the gpg command, once both files are in the same directory, you can verify using gpg --verify release-package.zip.txt release-package.zip
Hello Team. we started seeing our build stages taking ~20minutes, which used to take max of 5minutes. For now, we have downgraded jsii from 1.15 to 1.14.
I can confirm that the patch resolved the performance issue in our Python CDK project.
@slotnick thank you for confirming! I'll get this merged & released as soon as possible then!
⚠️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.
Sorry @RomainMuller for the late reply, but I also confirm the performance gains.
Successfully installed jsii-1.15.0
sh-4.2# date && python3 app.py && date
Mon Dec 7 12:03:30 UTC 2020
Mon Dec 7 12:06:07 UTC 2020
...
Successfully installed jsii-1.15.1-dev.2298.0
sh-4.2# date && python3 app.py && date
Mon Dec 7 12:07:51 UTC 2020
Mon Dec 7 12:08:02 UTC 2020
The synthesis now takes in my example 11 seconds instead of 157 seconds. Thank you very much for the improvement.