Fix _guessExecutionStatusRelativeToDifferentFunctions perf#14617
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52074/ |
|
Is it possible to write an unit test for this fix? |
|
It's kind of hard, I've tried stripping down the reproducible code and it still ends up being over 2000 lines. Of course I can also add a test if you think it's needed. |
JLHwung
left a comment
There was a problem hiding this comment.
Nice work. This PR improves the _guessExecutionStatusRelativeToDifferentFunctions performance dramatically via dynamic programming. The execution status is cached so that when we don't have to descend into nodes when they are queried again by recursive calls.
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
I don't like that we have to manually maintain the executionStatusCache status (undefined vs inited), because it could be easily managed just relying on the call stack and passing the map as a parameter.
However, I don't see an easy way to do so without modifying exposed functions. We should refactor this in the future, maybe Babel 8.
path._guessExecutionStatusRelativeToDifferentFunctions Sometimes extremely slow_guessExecutionStatusRelativeToDifferentFunctions perf
Accurately speaking, it will not hang infinitely, but it is extremely slow.
After applying this modification it will go from about 10 minutes to 100ms.