7ute / symbols-list

An alternate symbol list sidebar for Atom.io text editor
GNU General Public License v3.0
32 stars 24 forks source link

Performance with large files #36

Closed Taeon closed 7 years ago

Taeon commented 7 years ago

I've found that switching to a pane that contains a large file with lots of methods can cause the editor to freeze for several seconds. For example, I have a JS file that's 25K lines long (yeah, I know...) and switching to it causes the editor to freeze for 2-3 seconds.

I realise there's only so much you can do in terms of performance, but is there maybe a way to make the process non-blocking (i.e. asynchronous) so that the list can be generated without bringing the editor to a halt?

Just a thought.

dnshio commented 7 years ago

+1 For this request.

I am working on a legacy python project and this plugin would help me a lot if it didn't freeze as soon as I jump to a file with around 6K lines.

I actually have to keep jumping in and out of these large files quite frequently and it appears that this plugin has to do some work each time a file comes to view.

I support @Taeon's comment about making this work async. Further performance gains could be attained with caching and invalidating the cache when the file is updated.

A quick solution would be to open/refresh symbol list on keystrokes. Because I don't need to see the symbol list all the time. I know when I want to see it and when I should refresh the symbol list.

It's an excellent looking plugin otherwise though.

7ute commented 7 years ago

I'ld like to thank both of you for you precious feedbacks and compliments. It has come to my mind previously while working on some large JS files. Unfortunately, my knowledge of atom underlaying process management is quite rudimentary. But I'll try and give it a shot soon!

johnyf commented 7 years ago

I would like to suggest a simple initial approach: to compute the hash of a file, and not update when returning to an existing pane, unless the file has changed. I do not know how well this aligns with the current internals of the symbols-list package.

7ute commented 7 years ago

This approach is fine for mid-sized files. But this bug is crippling for really heavy files ( and/or minified, ie : https://cdnjs.cloudflare.com/ajax/libs/ionic/1.3.2/js/ionic.min.js ). If some Atom expert want to try and fix this, any help is more than welcome :)

7ute commented 7 years ago

I published a first fix, preventing the freeze of the interface, by adding a timeout to the recursive parsing. The next step could be, as @johnyf said, to prevent the re-parsing on pane change, based on the checksum of the file. It might need tweaking, especially on the duration of the timeout, so feel free to use this thread to provide feedback about this fix.