justarandomgeek / vscode-factoriomod-debug

Factorio Mod Tool Kit
Other
121 stars 26 forks source link

Make plugin 6 times as fast #115

Closed JanSharp closed 7 months ago

JanSharp commented 9 months ago

Well, the title says it all. It do be a lot faster. It was just a matter of writing faster Lua patterns and reducing the amount of gmatches in total. 6 times as fast, or 500% faster, you know it sounds awesome, and it kind of is - a file that previously took 53.5ms now takes 8.7ms - except that everything else the language server is doing takes up like 99% of the time so the plugin now taking almost 50ms less time for that test file is not noticeable, and looking at the times in the log I can't even see a difference there.

The PR also contains 2 other fixes, 1 of which I also included in the changelog. The second fix is this one https://github.com/justarandomgeek/vscode-factoriomod-debug/commit/00730e181c54e0c5536901ba7481a8aa31e15131

Speaking of the changelog, those are just my suggestions, you can do with it whatever you wish. Since the performance improvement isn't noticeable it might not even make sense to include it in the changelog.

And finally some graphs because they're cool to look at. profile lines is set to false.

Before: 2024-02-23_11-21_27

After: 2024-02-23_11-25_45

Since the parse function (very left) contains way more function calls than the rest it ends up looking a lot worse than it is. But its time is also a good refernce point because it did not get changed by this PR, while everything else got significantly faster.