ruby-lsp-rails icon indicating copy to clipboard operation
ruby-lsp-rails copied to clipboard

High CPU usage on ruby-lsp process

Open pasvistelik opened this issue 2 months ago • 0 comments

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

pasvistelik avatar Oct 27 '25 10:10 pasvistelik