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

Huge startup time with lot of files in project directory #191

Closed dmig closed 1 year ago

dmig commented 7 years ago

Timecop shows, that editorconfig is the slowest package in my installation. Startup times are always higher than 1 second: 1060-1080ms. Doesn't matter, how many files are open at startup time (mostly 2-4). But without project package load time is around 10ms. Looks like, editrconfig makes a lot of unneded file scans.

Involved .editorconfig-files

root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.py]
indent_style = space
indent_size = 4

[*.yaml]
indent_style = space

Directory structure

Can't show details, but:
...
161 directories, 1155 files
Most of them are not shown in treeview: .git contents, a lot of .gitignore'd files.

Installed packages

Built-in Atom Packages (90)
├── atom-dark-syntax@0.28.0
├── atom-dark-ui@0.53.0
├── atom-light-syntax@0.29.0
├── atom-light-ui@0.46.0
├── base16-tomorrow-dark-theme@1.5.0
├── base16-tomorrow-light-theme@1.5.0
├── one-dark-ui@1.10.3
├── one-light-ui@1.10.3
├── one-dark-syntax@1.7.1
├── one-light-syntax@1.7.1
├── solarized-dark-syntax@1.1.2
├── solarized-light-syntax@1.1.2
├── about@1.7.6
├── archive-view@0.63.2
├── autocomplete-atom-api@0.10.1
├── autocomplete-css@0.16.1
├── autocomplete-html@0.7.3
├── autocomplete-plus@2.35.3
├── autocomplete-snippets@1.11.0
├── autoflow@0.29.0
├── autosave@0.24.2
├── background-tips@0.27.0
├── bookmarks@0.44.3
├── bracket-matcher@0.85.5
├── command-palette@0.40.4
├── dalek@0.2.1
├── deprecation-cop@0.56.7
├── dev-live-reload@0.47.1
├── encoding-selector@0.23.3
├── exception-reporting@0.41.3
├── find-and-replace@0.207.5
├── fuzzy-finder@1.5.4
├── git-diff@1.3.5
├── go-to-line@0.32.0
├── grammar-selector@0.49.4
├── image-view@0.61.2
├── incompatible-packages@0.27.2
├── keybinding-resolver@0.38.0
├── line-ending-selector@0.6.3
├── link@0.31.3
├── markdown-preview@0.159.11
├── metrics@1.2.2
├── notifications@0.67.1
├── open-on-github@1.2.1
├── package-generator@1.1.1
├── settings-view@0.249.4
├── snippets@1.1.4
├── spell-check@0.71.4
├── status-bar@1.8.7
├── styleguide@0.49.6
├── symbols-view@0.115.5
├── tabs@0.105.4
├── timecop@0.36.0
├── tree-view@0.217.0-5
├── update-package-dependencies@0.11.0
├── welcome@0.36.2
├── whitespace@0.36.2
├── wrap-guide@0.40.1
├── language-c@0.57.0
├── language-clojure@0.22.2
├── language-coffee-script@0.48.6
├── language-csharp@0.14.2
├── language-css@0.42.2
├── language-gfm@0.88.1
├── language-git@0.19.0
├── language-go@0.43.1
├── language-html@0.47.2
├── language-hyperlink@0.16.1
├── language-java@0.27.0
├── language-javascript@0.126.1
├── language-json@0.19.0
├── language-less@0.32.0
├── language-make@0.22.3
├── language-mustache@0.13.1
├── language-objective-c@0.15.1
├── language-perl@0.37.0
├── language-php@0.38.0
├── language-property-list@0.9.1
├── language-python@0.45.2
├── language-ruby@0.71.0
├── language-ruby-on-rails@0.25.2
├── language-sass@0.59.0
├── language-shellscript@0.25.0
├── language-source@0.9.0
├── language-sql@0.25.4
├── language-text@0.7.2
├── language-todo@0.29.1
├── language-toml@0.18.1
├── language-xml@0.35.0
└── language-yaml@0.29.0

Community Packages (81) /home/dmig/.atom/packages
├── Sublime-Style-Column-Selection@1.7.4
├── ansible-snippets@0.2.0
├── api-docs@0.0.6
├── atom-beautify@0.29.23
├── atom-bootstrap3@1.2.12
├── atom-css-unit-converter@1.1.1
├── atom-material-syntax@1.0.2
├── atom-material-syntax-dark@0.2.7
├── atom-material-syntax-light@0.4.6
├── atom-material-ui@1.3.9
├── atom-touch-events@0.23.0
├── autocomplete@0.47.0
├── autocomplete-ansible@0.1.11
├── autocomplete-paths@1.0.5
├── autocomplete-python@1.8.63
├── build@0.67.0
├── build-grunt@0.4.0
├── busy@0.7.0
├── busy-signal@1.3.0
├── chrome-color-picker@0.8.0
├── cssfmt@1.4.0
├── cursor-history@0.9.1
├── editorconfig@2.2.2
├── file-icons@2.1.3
├── git-plus@7.6.0
├── git-time-machine@1.5.9
├── grunt-runner@0.14.0
├── gz-opener@0.2.0
├── highlight-selected@0.13.1
├── hyperclick@0.0.40
├── hyperclick-markdown@0.2.2
├── intentions@1.1.2
├── js-hyperclick@1.10.1
├── language-ansible@0.2.1
├── language-apache@1.7.0
├── language-asl@1.1.0
├── language-awk@0.1.12
├── language-dots@0.0.4
├── language-lua@0.9.11
├── language-mongodb@0.3.1
├── language-patch@1.2.0
├── language-qml@1.0.0
├── language-qtpro@0.6.0
├── language-systemd@0.1.1
├── language-tmux@0.4.0
├── linter@2.1.4
├── linter-ansible-linting@1.2.3
├── linter-flake8@2.1.5
├── linter-jshint@3.0.3
├── linter-jsonlint@1.3.0
├── linter-markdown@4.0.0
├── linter-php@1.3.2
├── linter-shellcheck@1.4.4
├── linter-ui-default@1.2.3
├── local-history@4.0.1
├── markdown-preview-enhanced@0.10.12
├── minimap@4.27.1
├── minimap-autohide@0.10.1
├── minimap-bookmarks@0.4.2
├── minimap-cursorline@0.2.0
├── minimap-find-and-replace@4.5.2
├── minimap-git-diff@4.3.1
├── minimap-highlight-selected@4.6.1
├── minimap-linter@2.0.0
├── minimap-selection@4.4.0
├── nav-panel-plus@0.2.1
├── node-debugger@1.10.1
├── open-recent@5.0.0
├── path-hyperclick@0.3.0
├── pigments@0.39.1
├── pretty-json@1.6.3
├── project-manager@3.3.4
├── python-debugger@0.2.0
├── remote-edit@1.9.0
├── script@3.14.1
├── sort-lines@0.14.0
├── svn@0.0.13
├── theme-switch@0.4.0
├── todo-show@1.11.0
├── tool-bar@1.1.0
└── tool-bar-almighty@0.8.2
sindresorhus commented 7 years ago

Weird, it takes 14ms for me.

Arcanemagus commented 7 years ago

On a blank window I see editorconfig at 12 ms, however with a project open I'm seeing ~915 ms.

It looks like this time is entirely within the require('editorconfig') call transparently happening here. It looks like a majority of this time is taken up by undoing many source maps to find an original location.

image

Since you don't need the TextEditors to be observed immediately on activate, I would recommend moving the observation of the TextEditors into an idle callback. You can find an example of setting this up for a simple function here (make sure you handle early deactivation like this).

You can find a slightly more complex example that is actually observing parts of Atom here.

Arcanemagus commented 7 years ago

Note that this is essentially a duplicate of #147.

athyuttamre commented 7 years ago

+1. I see editorconfig take up nearly 92ms to startup.

screenshot 2017-04-21 02 27 37
demmer commented 7 years ago

+1 I'm also in the camp where it's close to 1s on startup.

florianb commented 7 years ago

Thanks for reporting this issue - i'll dig into it as soon as possible.

jescalan commented 7 years ago

Also getting more than 1 second consistently -- lmk if there's any way I can help with this! Editorconfig is an essential but with this issue I have to deactivate 😢

florianb commented 7 years ago

Thank you very much for your offer @jescalan. I am sorry wasn't able to fix that yet. Please feel free to help us!

As @Arcanemagus already pointed out this is for sure the implementation of the initial observation of the TextEditor (https://github.com/sindresorhus/atom-editorconfig/blob/master/index.js#L166). As explanation, we're currently embedding a dedicated editorconfig-object into each TextEditor to manage the Editorconfig-functionality. It is intended to act independent to the rest of the code.

I guess it would be the easiest thing to just detach the execution of the observeTextEditor().

However, this must be tested because even though there shouldn't be any cross-dependencies, it could be that something fails to work if the embedded editorconfig-object is not immediately available.

I'd propose the following steps to solve that:

sindresorhus commented 1 year ago

Closing as Atom is abandoned.