aws-cdk-rfcs icon indicating copy to clipboard operation
aws-cdk-rfcs copied to clipboard

Faster builds

Open eladb opened this issue 5 years ago • 2 comments

PR Champion
#

Description

  • [ ] Shared build cache?

Progress

  • [x] Tracking Issue Created
  • [ ] RFC PR Created
  • [ ] Core Team Member Assigned
  • [ ] Initial Approval / Final Comment Period
  • [ ] Ready For Implementation
    • [ ] implementation issue 1
  • [ ] Resolved

eladb avatar Dec 10 '19 02:12 eladb

Some notes discovered while researching slow tests:

  • Jest hooks into the Node.js file loading mechanism (for running TS transforms and mocking and coverage), which is about doubling the time it takes to run the tests. Either switching away from Jest, or using a custom ModuleLoader (as recommended in https://github.com/facebook/jest/issues/10540) might help. (Internal reference with some more research: D19316081)
  • Synthesis is rather slow. For a complicated stack we synthesize the entire tree twice, taking about 250ms. If we do multiple expect(...).toHaveResource(...) on the same Stack object, it re-synthesizes every time (rather than re-using the same template), incurring the 250ms overhead every time.

Unfortunately it's not trivial to cache this as we also have tests that look like:

// Set up stack
expect(stack).toHaveSomething(...);

// Call a method on a construct
expect(stack).not.toHaveSomething(...);

So we DO expect the stack template to change.

OTOH we also might try to invest into caching or otherwise making resolve faster. For example, we could probably cut down on the second resolution time by keeping track of the uncached lazies and mutating the object structure returned by the first resolve() call in place (saving one full recursion cycle).

rix0rrr avatar Dec 22 '20 10:12 rix0rrr

Potentially lots of time spent in the token string concatentation as well:

image

rix0rrr avatar Dec 22 '20 10:12 rix0rrr

Marking this RFCs as stale since there has been little recent activity and it is not currently close to getting accepted as-is. We appreciate the effort that has gone into this proposal. Marking an RFCs as stale is not a one-way door. If you have made substantial changes to the proposal, please open a new issue/RFC. You might also consider raising a PR to aws/aws-cdk directly or self-publishing to Construct Hub.

mrgrain avatar Oct 27 '23 11:10 mrgrain