sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
812 stars 80 forks source link

Improve package loading performance #66

Closed abdonrd closed 8 years ago

abdonrd commented 8 years ago

I use Timecop to see the information about where time is spent while Atom loads and find this problem:

screen shot 2016-02-17 at 10 39 08

sindresorhus commented 8 years ago

Help welcome :)

florianb commented 8 years ago

I'm taking this issue. :racehorse:

florianb commented 8 years ago

Tests are implemented currently - unfortunately the measurements are significantly lower than in a production-environment. The test currently fails with a loadtime of 9-14ms depending on the run.

Unless we're able to test the real behavior i hope that our measures to tune editorconfig which then will pass the test change the production behavior as expected, too.

florianb commented 8 years ago

I created a first draft of the performance-optimization (https://github.com/florianb/atom-editorconfig/tree/iss66). Unfortunately i'm not satisfied with the results.

Strangely, when playing around with the different components i found out that having Xo as devDependency the whole load/activation-process slows down. I currently have no idea why this happens - probably @sindresorhus has?

However - i will do some further investigations. :eyeglasses:

sindresorhus commented 8 years ago

Do you happen to have atom-linter-xo installed?

You can do more advanced perf profiling in Dev Tools.

florianb commented 8 years ago

Yes, i use atom-linter-xo. I haven't used the Chrome-Dev-Profiler.. but i guess that's just something i have to learn now.. :dancers:

sindresorhus commented 8 years ago

The framegraph is your friend https://addyosmani.com/blog/devtools-flame-charts/

florianb commented 8 years ago

Great - thanks! :clap:

florianb commented 8 years ago

Okay - first riddle solved, calling workspace.observeTextEditors consumes 92% of the activation-time.

I will try to find out on which event we could try to safely rely on, in order to manage not missing any spawning editors.

florianb commented 8 years ago

Okay - i did some further tests. Relying on other events will break the functionality.

There are two facts we have to accept. At first, due to the lazy-load-mechanisms of Atom, the requirements for observerTextEditors will get into our Timecop-account as long as editorconfig is accessing that event-subscription first.

Secondly, Timecop-measurements differ from machine to machine, from environment to environment. This makes the whole issue untestable. I therefore put a upper load limit of 50ms into action. This should prevent future changes which cause long load-times.

Arcanemagus commented 8 years ago

Btw @florianb three things about load times:

tl;dr: Having xo there shouldn't affect production installs :stuck_out_tongue: