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

FileStatusManager.getStatus is slow after installing the plugin #415

Closed
nicity opened this issue Aug 11, 2017 · 4 comments

Comments

@nicity
Copy link
Member

commented Aug 11, 2017

IDE calls getStatus very-very often, e.g. for every icon rendered in project view so the method should be really fast.

In CPU snapshot attached to https://youtrack.jetbrains.com/issue/IDEA-176946 (private customer issue) 20s of getStatus calculation is spent in
mobi.hsz.idea.gitignore.vcs.IgnoreFileStatusProvider.getFileStatus(VirtualFile).

There are several problems with the method according the snapshot:

  • There is disk access for IgnoreFilesIndex.getKeys(myProject) (10s) and it is called for every isIgnored calculation. The (short term) suggestion is to cache the same value.
  • There is disk access for IgnoreFilesIndex.getEntries(Project, IgnoreFileType) (4s), I suspect that some entries are not relevant to the project and proper set of ignore files for project can be calculated once and cached as well
  • There is 2s in java.util.regex.Matcher.matches(), there is O(N) number of .gitignore patterns (probably some char trie can help)
  • Also there is 1.5s in getOuterFiles(Project)

@hsz hsz added the bug label Aug 11, 2017

@hsz hsz added this to the v2.0.5 milestone Aug 11, 2017

hsz added a commit that referenced this issue Aug 19, 2017

@hsz

This comment has been minimized.

Copy link
Collaborator

commented Aug 19, 2017

@nicity How can I access those memory snapshots? Can you please provide me URLs?

hsz added a commit that referenced this issue Aug 19, 2017

@nicity

This comment has been minimized.

Copy link
Member Author

commented Aug 19, 2017

Merged callees

+-------------------------------------------------------------------------------------------------------------------------------------------+-----------------+-----------------+
|                                                             Merged Call Tree                                                              |    Time (ms)    |  Own Time (ms)  |
+-------------------------------------------------------------------------------------------------------------------------------------------+-----------------+-----------------+
|  +---mobi.hsz.idea.gitignore.IgnoreManager.isFileIgnored(VirtualFile) IgnoreManager.java                                                  |  20,717  100 %  |            190  |
|    |                                                                                                                                      |                 |                 |
|    +---mobi.hsz.idea.gitignore.indexing.IgnoreFilesIndex.getKeys(Project) IgnoreFilesIndex.java                                           |  10,913   53 %  |              0  |
|    |                                                                                                                                      |                 |                 |
|    +---mobi.hsz.idea.gitignore.indexing.IgnoreFilesIndex.getEntries(Project, IgnoreFileType) IgnoreFilesIndex.java                        |   4,057   20 %  |              0  |
|    |                                                                                                                                      |                 |                 |
|    +---java.util.regex.Matcher.matches() Matcher.java                                                                                     |   2,267   11 %  |          2,267  |
|    |                                                                                                                                      |                 |                 |
|    +---mobi.hsz.idea.gitignore.lang.IgnoreLanguage.getOuterFiles(Project) IgnoreLanguage.java                                             |   1,771    9 %  |              0  |
|    |                                                                                                                                      |                 |                 |
|    +---com.intellij.dvcs.repo.VcsRepositoryManager.getRepositoryForFile(VirtualFile) VcsRepositoryManager.java                            |     671    3 %  |              0  |
|    |                                                                                                                                      |                 |                 |
|    +---com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry.getPath() VirtualFileSystemEntry.java                                  |     205    1 %  |              0  |
|    |                                                                                                                                      |                 |                 |
|    +---mobi.hsz.idea.gitignore.file.type.kind.GitExcludeFileType.getWorkingDirectory(Project, VirtualFile) GitExcludeFileType.java        |     203    1 %  |              0  |
|    |                                                                                                                                      |                 |                 |
|    +---com.intellij.openapi.project.impl.ProjectImpl.getBaseDir() ProjectImpl.java                                                        |     138    1 %  |              0  |
|    |                                                                                                                                      |                 |                 |
|    +---mobi.hsz.idea.gitignore.indexing.ExternalIndexableSetContributo

hsz added a commit that referenced this issue Aug 20, 2017

hsz added a commit that referenced this issue Aug 20, 2017

hsz added a commit that referenced this issue Aug 20, 2017

hsz added a commit that referenced this issue Aug 20, 2017

hsz added a commit that referenced this issue Aug 20, 2017

@hsz hsz modified the milestones: v2.1.0, v2.1.0-RC.1 Aug 21, 2017

@hsz

This comment has been minimized.

Copy link
Collaborator

commented Aug 21, 2017

@nicity Thanks for the call tree. I played with YourKit regarding the methods call counts, time, etc and fixed a few more things too.

From my point of view everything should be fine now - it's released with v2.1.0-RC.1 (available in eap channel (https://plugins.jetbrains.com/plugins/eap/7495) or https://github.com/hsz/idea-gitignore/releases/tag/v2.1.0-RC.1

Can you please confirm that?

Is there anything else that should be fixed before new public release?

@nicity

This comment has been minimized.

Copy link
Member Author

commented Aug 21, 2017

Great!
Lets do the release and check for users's feedback.
I'll post newer issues with profiler information if needed.

@hsz hsz closed this Aug 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.