Shopify / Shopify/ruby-lsp-rails
High CPU usage on ruby-lsp process
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 688
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I'm using Serena MCP which uses ruby-lsp under the hood. I saw that ruby-lsp process is constantly consuming 100% of my CPU, so I used rbspy and found that the following part of the RunnerClient is likely responsible for that:
# Responsible for transmitting notifications coming from the server to the outgoing queue, so that we can do
# things such as showing progress notifications initiated by the server
@notifier_thread = Thread.new do
until @stderr.closed?
notification = read_notification
unless @outgoing_queue.closed? || !notification
@outgoing_queue << notification
end
end
rescue IOError
# The server was shutdown and stderr is already closed
end #: Thread
Ruby version: 3.1.5
ruby-lsp-rails version: 0.4.8
Here is the rbspy output:
Time since start: 60s. Press Ctrl+C to stop.
Summary of profiling data so far:
% self % total name
98.97 98.97 gets [c function] - (unknown)
0.47 100.00 block in initialize - /home/user/.rvm/gems/ruby-3.1.5/gems/ruby-lsp-rails-0.4.8/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:119
0.29 0.29 closed? [c function] - (unknown)
0.27 99.24 read_notification - /home/user/.rvm/gems/ruby-3.1.5/gems/ruby-lsp-rails-0.4.8/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:356
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/ruby_lsp/ruby_lsp_rails/runner_client.rb, especially the notifier thread in initialize and read_notification around the reported lines. Use the supplied rbspy profile to investigate the idle CPU behavior and verify that notification forwarding still works while the ruby-lsp process no longer consumes excessive CPU.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100