LorettaDevs/Loretta

Script class initialization is way too slow

Fiusen opened this issue · 2 comments

Loretta's Script class initialization of a big script takes way too long:

Time on a 20MB file:

  •   Script init: 9s
    
  •   Parse time: 0.9s
    

How to replicate:

  • Have a random script (like allopcodes-5.1.lua) and copy and paste it until ur file gets to ~20MB
var scriptParsed = new Script(ImmutableArray.Create(LuaSyntaxTree.ParseText(code)));
var root = Parsed[0].GetRoot();

SyntaxNode node = root.ChildNodes().FirstOrDefault(); // whatever

scriptParsed.GetScope(node) // long wait here

4KIgA2zjVv

After quite a bit of profiling, this is not gonna be possible without rewriting the entire scoping code.

Most of the code is being spent in unmanaged code which means that most of the time is probably being spent in array resizes of dictionaries' backing buckets and hashsets' backing buckets and/or virtual calls.

Closing this since #32 will fix this indirectly.