Skip to content

Commit 54584ff

Browse files
authored
Run signature blocks ahead of time and compact after indexing (#2460)
* Start running all sig blocks ahead of time * Start compacting GC after finishing indexing
1 parent 76f292e commit 54584ff

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

exe/ruby-lsp

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ require "ruby_lsp/load_sorbet"
8181
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
8282
require "ruby_lsp/internal"
8383

84+
T::Utils.run_all_sig_blocks
85+
8486
if options[:debug]
8587
if ["x64-mingw-ucrt", "x64-mingw32"].include?(RUBY_PLATFORM)
8688
$stderr.puts "Debugging is not supported on Windows"

lib/ruby_lsp/server.rb

+5
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,11 @@ def perform_initial_indexing
876876
send_message(Notification.window_show_error("Error while indexing: #{error.message}"))
877877
end
878878

879+
# Indexing produces a high number of short lived object allocations. That might lead to some fragmentation and
880+
# an unnecessarily expanded heap. Compacting ensures that the heap is as small as possible and that future
881+
# allocations and garbage collections are faster
882+
GC.compact
883+
879884
# Always end the progress notification even if indexing failed or else it never goes away and the user has no
880885
# way of dismissing it
881886
end_progress("indexing-progress")

0 commit comments

Comments
 (0)