ianhattendorf / autocomplete-ruby

Provides intelligent code completion for Ruby in the Atom editor. Requires RSense.
MIT License
51 stars 9 forks source link

CPU Usage spiking with package enabled #30

Closed supremebeing7 closed 7 years ago

supremebeing7 commented 7 years ago

I recently added this package on my MacbookPro, and noticed that it would spike my cpu usage every time I saved a file. This happened after starting Atom fresh, and editing and saving files both Ruby and other types. I verified it only happens when this particular package is enabled.

Watching my Activity Monitor, when I enable this package, it spawns a java process with low CPU usage. However, saving files kicks up the CPU usage for that process very quickly (> 400% in seconds) and it kept climbing to over 600% before I shut down Atom.

It may have something to do with rsense. I had received an rsense related error when first installing the package. I don't remember what steps I took to fix that error, but I believe it involved running gem install rsense in Terminal.

ianhattendorf commented 7 years ago

Interesting, the plugin selector is set to selector: '.source.ruby', and shouldn't do anything for other files...

Is ruby auto completion working for you? You'll definitely see CPU usage with ruby files, as rsense (a java program) is needed to provide the suggestions, however this shouldn't be happening for other files. I've checked on my computer and I'm not seeing this, however I don't have a mac to test it on. Could you provide a screenshot of this occurring on a file that doesn't have a .rb extension with Activity Monitor?

supremebeing7 commented 7 years ago

@ianhattendorf auto completion in ruby is working, yes. CPU usage does not seem to be spiking on non .rb files, so either that has changed or I was initially mistaken. More likely the latter... I probably was seeing the effects from the ruby files when switching to the other file types.

The only reason I posted this as an issue is that it seems to have started after I updated the package to 0.2.6. I have had Activity Monitor open in my dock for months and never noticed any issues before that, and I work in ruby files daily. Were there any changes in the new version that may have caused this?

It's also possible that I just had too many ruby files open (~10) and that was causing the autocomplete to spike memory.

Sorry if this isn't super helpful. If you have any other debugging ideas I'd be glad to try them.

ianhattendorf commented 7 years ago

No changes that would cause this AFAIK, other than maybe it just wasn't working before (hah). The majority of the recent changes have been fixing the rsense path detection as much as possible, it's possible that it wasn't configured correctly until now. If this is the case, previously you would have been seeing generic autocompletion before (such as keyword detection in the current file) and not the ruby specific autocompletion provided by this plugin (methods, classes, etc. from other files in the project).

If the cpu usage is coming from the java process, that's all due to rsense. Nothing we can do about that from the plugin, and unfortunately it's been abandoned since 2014.

supremebeing7 commented 7 years ago

Well, it's definitely just coming from the java process, so I guess we can close this and blame rsense. Which is unfortunate because it basically makes the plugin unusable on my system.

Thanks for talking through this.

ianhattendorf commented 7 years ago

No problem. If you come across another code completion provider for Ruby similar to rsense that is actively maintained, be sure to let me know as it could be possible to migrate over. I'm sure eventually rsense will just stop working for newer ruby versions.

hackhowtofaq commented 7 years ago

@ianhattendorf what about this one https://github.com/whitequark/parser/ as @Martoko mentioned in the rsense board?

ianhattendorf commented 7 years ago

Hmm interesting. We'll need someone to create an auto-complete library usable from JavaScript similar to RSense from this, that we can then tie in to. I don't have enough time at the moment to look into it further, but I'll keep an eye out for any projects that try to take this on.