A platform for community discussion. Free, open, simple.
PERF: Stop copying the shared heap into the supervised Sidekiq (#44152)
Alan Guo Xiang Tana2d47f00483f
diff --git a/config/pitchfork.conf.rb b/config/pitchfork.conf.rbindex ea856268d89..9e79758f1bd 100644--- a/config/pitchfork.conf.rb+++ b/config/pitchfork.conf.rb@@ -81,6 +81,7 @@ after_mold_fork do |server, mold|Discourse.redis.closeDiscourseVips::Client.use_shared_workerDiscourse.before_fork+ Process.warmupendoob_gc_enabled = ENV["DISCOURSE_DISABLE_MAJOR_GC_DURING_REQUESTS"] && RUBY_VERSION >= "3.4"diff --git a/lib/demon/sidekiq.rb b/lib/demon/sidekiq.rbindex 938f055ab3b..8b26047c722 100644--- a/lib/demon/sidekiq.rb+++ b/lib/demon/sidekiq.rb@@ -134,7 +134,10 @@ class Demon::Sidekiq < ::Demon::Basecli.parse(options)load Rails.root + "config/initializers/100-sidekiq.rb"- cli.run++ # This process inherits the heap warmed by the mold.+ # Warming it again compacts it, copying every page shared with the parent.+ cli.run(warmup: false)rescue => errorlog("Error encountered while starting Sidekiq: [#{error.class}] #{error.message}\n#{error.backtrace.join("\n")}",diff --git a/lib/discourse.rb b/lib/discourse.rbindex ae47f57d0cc..7a9c22e9bea 100644--- a/lib/discourse.rb+++ b/lib/discourse.rb@@ -1060,9 +1060,6 @@ module Discourse# V8 does not support forking, make sure all contexts are disposedObjectSpace.each_object(MiniRacer::Context) { |c| c.dispose }end-- # get rid of rubbish so we don't share it- Process.warmupend# Called in web worker processes after fork to apply worker-specificdiff --git a/lib/tasks/db.rake b/lib/tasks/db.rakeindex a7e93bcb163..a8a0a2ba2cd 100644--- a/lib/tasks/db.rake+++ b/lib/tasks/db.rake@@ -196,6 +196,7 @@ task "multisite:migrate" => %w[database_shards = databases.each_slice(database_shard_size).to_aDiscourse.before_fork+ Process.warmuppids =database_shards.map do |database_shard|