Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save on the first file get a little freeze time. #679

Closed
luunguyenbk opened this issue Nov 21, 2015 · 3 comments
Closed

Save on the first file get a little freeze time. #679

luunguyenbk opened this issue Nov 21, 2015 · 3 comments
Assignees
Milestone

Comments

@luunguyenbk
Copy link

I'm using Atom 1.2.2 on Macos Yosermite, Atom-Beautify 0.28.19. When i first open Atom and save, it seem get a little freeze about 2-3 seconds, it only happen on the first file.
When i disable Atom-beautify, it don't happen anymore.
Is this a bug on Atom-Beautify ?

@Glavin001
Copy link
Owner

Here is the applicable code for beautify on save functionality: https://github.com/Glavin001/atom-beautify/blob/master/src/beautify.coffee#L423-L467

The part that would take time and could be causing the little freeze would be here: https://github.com/Glavin001/atom-beautify/blob/master/src/beautify.coffee#L427-L444

Since you indicated that it only happens on the first file, it would suggest that subsequent requests are using a cache and therefore faster. All of the require calls would be applicable then, since they have a built-in cache.

It could be because of the activationCommands: https://github.com/Glavin001/atom-beautify/blob/master/package.json#L105-L106
When you save, this triggers Atom Beautify to activate and thus require all of its dependencies. This could take time. After the first time, everything should be processed and cached.
This would make a lot of sense.

The best way to reduce the activation time and reduce the freeze time when first activating Atom Beautify would be to look at:

And try to cut things down.
I have not run any benchmarks however I presume that constructing the beautifier at https://github.com/Glavin001/atom-beautify/blob/master/src/beautify.coffee#L10 will take a significant amount of time on load.

Beautifiers = require("./beautifiers")
beautifier = new Beautifiers()

The main Beautifier code can be found at https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/index.coffee
It probably has the most room for optimization and performance improvements.

@ypresto
Copy link

ypresto commented Mar 19, 2016

This also affects "Installed Packages" page in preferences.

@Glavin001
Copy link
Owner

I'm going to count this issue as a duplicate of #876 as #876 has some more information that I can use for debugging.
Please continue discussion of this issue over at #876. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants