Eliminate redundant work in type inference - #15863
Conversation
| if (symbol) { | ||
| for (let i = 0; i < depth; i++) { | ||
| const t = stack[i]; | ||
| if (getSymbolForInference(t) === symbol) { |
There was a problem hiding this comment.
why not storing getSymbolForInference(target) on the stack directly instead of calling it on every entry when we check
|
will it be part of 2.3.3 ? |
no. this is TS 2.4 bound. |
|
I'm using Version 2.4.0-dev.20170519 and I've found that the project I shared in #15443 no longer has this issue, however I have a separate project that doesn't compile due to this memory issue. Has anyone else found the same? Will require some work to share a test case. |
|
Was the other project compiling on 2.3? |
|
Mohamed Hegazy (@mhegazy) Here is the other project that runs out of memory when compiling on 2.4.0-dev.20170519 and 2.3. https://github.com/OliverJAsh/ts-2.4-memory-issue/compare/2.4.0-dev.20170519 |
With this PR we eliminate redundant work in type inference. Previously, we would explore instantiations of the same generic type up to five levels deep in type inference (which mirrored what we do in relationship checking to detect infinitely recursive types). We now explore just one level as no further inferences will be made beyond that anyway.
This PR doesn't include a regression test as the original issue only reproduces with the fp-ts library. However, I have manually verified that the out of memory issue is fixed and the compile time for the repro is less than 1s. Also, I have verified there are no changes in the real world code suites.
Fixes #15443.