sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
807 stars 39 forks source link

Build 3200 using high CPU #2709

Closed pcg79 closed 5 years ago

pcg79 commented 5 years ago

Description

Since installing the most recent update (3.2 build 3200) ST3 has been consistently taking up 40-90% of my CPU. Even if I have no files/projects/folders open.

It is not currently indexing (Indexing status says "Idle").

I am editing this with new information.

Steps to reproduce

  1. Upgraded to 3.2 build 3200
  2. Open Sublime Text with no folders/projects open.
  3. CPU is very low (close to 1%).
  4. Open any folder. The one I was experimenting with had 9 text files in it (avg size of files around 1KB).
  5. CPU jumps up to ~50%.

Expected behavior

CPU goes back to reasonable levels.

Actual behavior

CPU stays this way even if I close the project window. And does not drop back down until I restart ST.

Environment

I have uninstalled all my Packages (including Package Control).

Activity Monitor: Screen Shot 2019-03-14 at 11 13 57 AM

No projects open: Screen Shot 2019-03-14 at 11 12 31 AM

Indexing status: Screen Shot 2019-03-14 at 11 13 13 AM

tomdrewes commented 5 years ago

I saw this as well. I tried disabling the new git and diff features in my settings and restarting Sublime Text: "show_git_status": false, "mini_diff": false

and the CPU utilization was normal after that. I then re-enabled both features, restarted, and the CPU utilization stayed at normal, low levels.

Maybe some kind of initialization bug in one or the other of those features?

wbond commented 5 years ago

It is normal for there to be CPU usage after starting a new release of Sublime Text. We update syntax definitions with new versions, and the syntax definitions are used by the indexer to power Goto Definition. When a syntax definition changes, we have to rescan your project with the indexer to make sure we have current information.

Some users on version 3.2 have been running into high CPU usage due to the fact that have a git repo in their home dir, or some such equivalently large directory. When there is a git repository, we watch for file changes so we can update the badges in the sidebar. If a git repo contains an entire home dir, that means we get notified about every single file write in the home dir, and when that happens, we have to rescan the entire home dir to see what has changed.

Now, some of the issues are people who have accidentally created a ~/.git repo. One person had a folder named ~/.git that did not contain a git repo. This part is a bug, and we'll be ensuring that the file monitoring is cleaned up properly in this case.

To see if a git repo is being detected in your home dir, look for messages like the following in your Console:

git: tracking working dir /Users/wbond

Since a handful of users have reported CPU usage, we may end up putting a guard in place to prevent monitoring a git dir that appears to be errant, with an override for those who really do want to monitor such a repo.

tomdrewes commented 5 years ago

I looked, and I do not have a .git folder in my home directory, nor did I see a 'git: tracking' message for my home directory in the Sublime Text console. I did see a 'git: tracking' message for the directory which contains my project. In a dependencies downloaded/built state, the project directory contains ~146000 files (the majority of these are npm dependencies and build artifacts). All of these dependencies and build artifacts are marked appropriately in .gitignore files which are included in and differ across the subdirectories in the project directory. There are ~1100 actual git-tracked files in the project.

wbond commented 5 years ago

@tomdrewes 140,000 is no issue. You said your CPU usage went back to normal, right? If so, Sublime Text was most likely indexing your node_modules folder. You can look for a percentage in the status bar to tell when indexing is happening. If you click it, a status window will appear. I believe your issue is different than the one @pcg79 is seeing.

tomdrewes commented 5 years ago

The CPU usage is normal now. I failed to look for the indexing bar, but based on your explanation it seems likely that indexing was probably the likely cause in my case. Thanks!

pcg79 commented 5 years ago

I'm going to close this. Thinking it might not be ST3 I started uninstalling packages and after I uninstalled the MarkdownPreview package, CPU usage went back to normal. I've reinstalled it and CPU usage is still normal. Still not sure what the issue was but it seems to be resolved.

Thanks all.

pcg79 commented 5 years ago

Sorry, I'm reopening this. I think there is a problem. I'm going to edit my original submission to reflect this new information. But here's what I've found over a few hours of playing.

  1. Open Sublime Text with no folders/projects open.
  2. CPU is very low (close to 1%).
  3. Open any folder. The one I was experimenting with had 9 text files in it (avg size of files around 1KB).
  4. CPU jumps up to ~50%.

CPU stays this way even if I close the project window. And does not drop back down until I restart ST.

I have uninstalled all my Packages (including Package Control).

wbond commented 5 years ago

Please post the contents of your Console

jaschaio commented 5 years ago

Got the same issue:

Since I have updated Sublime to 3.2 it is really slow when opening projects with a decent amount of files (e.G. node_modules). CPU is constantly at ~60% on a 2.9Ghz i5 MBP. I have already disabled the new git and diffing features but it still happens.

Before the update everything was fine.

It does seem to have to do something with indexing. At least I can see that an indexing process is being done:

index "project_folder" collated in 0.45s from 13580 files
index "project_folder" is using 4875776 bytes for 46232 symbols across 570655 locations
indexing [job 2]: spawning 1 workers to process 4096 / 31148 files
indexing [job 2]: indexed 4096 files
indexing [job 2]: spawning 1 workers to process 4096 / 27052 files
pcg79 commented 5 years ago

My console log.

startup, version: 3200 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/pcg79/Library/Application Support/Sublime Text 3/Packages
state path: /Users/pcg79/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/pcg79/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.268781
using gpu buffer for window
startup time: 0.382729
environment variables loaded using: /bin/zsh -l
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.detect_indentation
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin ShellScript.ShellScript
plugins loaded
using gpu buffer for window
git: tracking working dir /Users/pcg79

The very last line is what appears after I open any folder. I have no idea why it's trying to track my home dir. I realized the directory I've been using for experimentation does live (deeply) under my home dir. So I opened /tmp instead and interestingly enough the problem (and the line about git indexing my home dir) DID NOT occur.

So I assume that's the problem but I don't know how that got configured/set or how to stop it.

wbond commented 5 years ago

Do you have a folder named /Users/pcg79/.git?

The next dev build will put a guard in place to prevent this from biting people. Trying to monitor and scan an entire home dir leads to a lot of CPU usage.

pcg79 commented 5 years ago

I did. And removing it fixed it! Thanks, @wbond !

Closing as fixed. Much appreciated.

FichteFoll commented 5 years ago

2573 describes the same issue but on Linux.

RobinWest commented 5 years ago

I'm having this issue and I do not have a .git folder in my /Users/rwest directory. The console is also reporting that git is tracking the correct projects and folders.

I've tried removing my packages folder entirely and reopening the same projects and I get the same high CPU usage.

I've also tried disabling "show_git_status" and "mini_diff" as suggested to no effect.

My indexing status is idle, and it reports that it has indexed my projects in good time.

Here is my console output:

startup, version: 3200 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/rwest/Library/Application Support/Sublime Text 3/Packages
state path: /Users/rwest/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/rwest/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["MarkdownLivePreview", "Vintage"]
pre session restore time: 0.255464
using gpu buffer for window
using gpu buffer for window
using gpu buffer for window
using gpu buffer for window
using gpu buffer for window
startup time: 0.477351
environment variables loaded using: /bin/bash -l
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.detect_indentation
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin ShellScript.ShellScript
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.01-pygments
reloading plugin 0_package_control_loader.51-bs4
reloading plugin Alignment.Alignment
reloading plugin Emmet.emmet-plugin
reloading plugin LESS.less_completions
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin PackageResourceViewer.package_resource_viewer
reloading plugin PackageResourceViewer.package_resources
reloading plugin React IDE.ReactIDE
reloading plugin Sass.sass_completions
reloading plugin Babel.Babel
reloading plugin ColorPicker.sublimecp
reloading plugin TypeScript.main
2019-03-20 10:59:46,833: 4753319360: WARNING: TypeScript plugin initialized.
reloading plugin User.example
reloading plugin User.reload_all_files
reloading plugin User.run_multiple_commands
plugins loaded
lang_service_enabled: True
Path of tsserver.js: /Users/rwest/Library/Application Support/Sublime Text 3/Packages/TypeScript/tsserver/tsserver.js
Path of tsc.js: /Users/rwest/Library/Application Support/Sublime Text 3/Packages/TypeScript/tsserver/tsc.js
Trying to spawn node executable from: /usr/local/bin/node
ref view not found
Emmet: No need to update PyV8
Package Control: Skipping automatic upgrade, last run at 2019-03-20 10:16:47, next run at 2019-03-20 11:16:47 or after
using gpu buffer for window
Unable to open /Users/rwest/Library/Application Support/Sublime Text 3/Packages/Default/Preferences.sublime-settings
FichteFoll commented 5 years ago

Please see https://forum.sublimetext.com/t/sublime-consumes-cpu-on-mac-after-update/42327/53.

RobinWest commented 5 years ago

@FichteFoll much appreciated, I believe I have been through those steps (as detailed above) with no positive results.

Would it be best to create a new issue report at this point?

romberli commented 5 years ago

i'm suffering this same pb, is there any option that could disable the git thing? i want the simple st3 back...

RobinWest commented 5 years ago

You can disable the git features (noted here) but that didn't work for me. You can download the previous version here though:

https://download.sublimetext.com/Sublime%20Text%20Build%203176.dmg

romberli commented 5 years ago

You can disable the git features (noted here) but that didn't work for me. You can download the previous version here though:

https://download.sublimetext.com/Sublime%20Text%20Build%203176.dmg

thanks for your reply, but it doesn't work, i'm afraid i have to downgrade to old version...

FichteFoll commented 5 years ago

@RobinWest this issue is closed because the problem is a) solved and b) being addressed in the next build. If you are absolutely sure you went through the steps provided in the forum post and the issue still isn't resolved, you can open a new issue with as many details as possible, such as the console contents that you included earlier, your OS, your DE/WM if on Linux, how many projects you have open and the rough size of these projects.

wbond commented 5 years ago

@RobinWest @romber2001 I'd recommend reading the forum post and then posting a new issue rather than rolling back to 3176. Build 3176 won't ever see new security fixes, bug fixes or any of the new features.

There can be a number of issues. Two things I'd check for are:

  1. Make sure you don't have mcfly installed in your bashrc as some versions will get stuck in an infinite loop. The newest release of mcfly fixes that bug.
  2. Ensure you restarted Sublime Text after setting show_git_status to false. The next build of Sublime Text will include some protections to prevent errant git repositories from causing issues.

If you are still seeing problems and are on a Mac, a screenshot of the Activity Monitor with Sublime Text present would be helpful. The only thing that changed between ST 3.1 and 3.2 that is likely to be an issue is extremely large git repositories, so if that has been ruled out, it may be a plugin? The Activity Monitor info will help.