I\'m trying to improve the performance of a script when executed in a web worker. It\'s designed to parse large text files in the browser without crashing. Everything works pret
Tyler Ault suggested one possibility on Google+ that turned out to be very helpful.
He speculated that using FileReaderSync
in the worker thread (instead of the plain ol' async FileReader
) was not providing an opportunity for garbage collection to happen.
Changing the worker thread to use FileReader
asynchronously (which intuitively seems like a performance step backwards) accelerated the process back up to just 37 seconds, right where I would expect it to be.
I haven't heard back from Tyler yet and I'm not entirely sure I understand why garbage collection would be the culprit, but something about FileReaderSync
was drastically slowing down the code.