Sublime Forum

Build 3176 high cpu usage plugin_host

#1

fresh install of 3176 build
after starting the app cpu usage goes very high because of three weird processes:

cat /dev/urandom tr -dc a-zA-Z0-9 fold -w 24
after removing “/Applications/Sublime Text.app/Contents/MacOS/plugin_host” and restarting the app those processes don’t get created, cpu is fine but half of functionality is gone.

Sweet lord what on Earth are you doing with that plugin_host?

see screenshot https://ibb.co/5xWjKVm

0 Likes

Sublime consumes cpu on Mac after update
Sublime spawning a cat /dev/urandom process taking 100% cpu (macOS)
#2

Half of the functionality is gone because you removed half of the application.

My hunch would be that you’ve got something funky in your login shell rc file. On macOS, the only way to get your environmental variables from your login shell to an application is to launch your login shell and read the output of env.

Because of the way that macOS works, GUI apps are all launched with the Dock as their parent process and by default have a stripped down and minimal env without your PATH customizations and other tweaks. This results in things like build systems not working because executables installed via things like Homebrew will never be found.

If you do a clean install and post the console output, that can help us determine if this is the issue.

Alternatively if you’ve installed any third party packages, it could be one of those.

1 Like

#3

Thanks for quick response.

yeah. It may be the case.

If you do a clean install

yep. I’ve wiped out the rm -fr ~/Library/Application\ Support/Sublime\ Text\ 3/

what do you mean by that? I didn’t get how to do that

0 Likes

#4

After you reinstall Sublime and it finishes starting up, use View > Show Console from the menu to open the console panel, and then copy and paste the contents out and share them. The console log has information on what Sublime is doing while it starts up, what packages you have installed, and such.

1 Like

#5

startup, version: 3176 osx x64 channel: stable executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text working dir: / packages path: /Users/kostyrev/Library/Application Support/Sublime Text 3/Packages state path: /Users/kostyrev/Library/Application Support/Sublime Text 3/Local zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages zip path: /Users/kostyrev/Library/Application Support/Sublime Text 3/Installed Packages ignored_packages: ["Vintage"] generating syntax summary generating meta info summary pre session restore time: 0.909165 using gpu buffer for window startup time: 0.983152 no output from shell "/bin/bash" in 1000ms 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.delete_word reloading plugin Default.detect_indentation reloading plugin Default.duplicate_line 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.swap_line reloading plugin Default.switch_file reloading plugin Default.symbol reloading plugin Default.transform reloading plugin Default.transpose reloading plugin Default.trim_trailing_white_space 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

0 Likes

#6

Ok, guys. These are the lines in my ~/.bash_profile that caused that behaviour

$ tail -6 ~/.bash_profile

if [[ -f "$(brew --prefix)/opt/mcfly/mcfly.bash" ]]; then
  source "$(brew --prefix)/opt/mcfly/mcfly.bash"
fi

That’s the utility https://github.com/cantino/mcfly

0 Likes

#7

I would wrap the McFly setup in an if with a call to tty -s to make sure the shell is connected to a TTY. http://man7.org/linux/man-pages/man1/tty.1.html

1 Like

#8

Hey, author of mcfly here. Sorry for the trouble with Sublime! Would adding [ -t 0 ] || return to mcfly.bash fix this?

(Or one of these other options?)

0 Likes

#9

Thx. Adding this fixed the sublime (tr, cat) load problem for me.

if [ -f $(brew --prefix)/opt/mcfly/mcfly.bash ]; then
[ -t 0 ] || return
. $(brew --prefix)/opt/mcfly/mcfly.bash
fi

0 Likes

#10

mcfly.bash now includes [[ -t 0 ]] || return at the top, so I believe this is fixed. It’d be great if you could confirm.

0 Likes

#11

Hi there!

I was facing the same issue here and I can confirm it works now.

Thanks!

By the way, I had to update my mcfly.bash file by hand.
Even after removing and installing mcfly again through homebrew, the version I end up with was the version without the stdin check.

Just wondering if new users/installations will still receive that version without the fix…

0 Likes

#12

Thanks! I may have failed to release it. It’s in https://github.com/cantino/mcfly/releases/tag/v0.3.4 now.

1 Like