Skip to content

Commit

Permalink
Run signature blocks ahead of time and compact after indexing (#2460)
Browse files Browse the repository at this point in the history
* Start running all sig blocks ahead of time

* Start compacting GC after finishing indexing
  • Loading branch information
vinistock authored Aug 19, 2024
1 parent 76f292e commit 54584ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions exe/ruby-lsp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ require "ruby_lsp/load_sorbet"
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "ruby_lsp/internal"

T::Utils.run_all_sig_blocks

if options[:debug]
if ["x64-mingw-ucrt", "x64-mingw32"].include?(RUBY_PLATFORM)
$stderr.puts "Debugging is not supported on Windows"
Expand Down
5 changes: 5 additions & 0 deletions lib/ruby_lsp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,11 @@ def perform_initial_indexing
send_message(Notification.window_show_error("Error while indexing: #{error.message}"))
end

# Indexing produces a high number of short lived object allocations. That might lead to some fragmentation and
# an unnecessarily expanded heap. Compacting ensures that the heap is as small as possible and that future
# allocations and garbage collections are faster
GC.compact

# Always end the progress notification even if indexing failed or else it never goes away and the user has no
# way of dismissing it
end_progress("indexing-progress")
Expand Down

0 comments on commit 54584ff

Please sign in to comment.