From: "koilanetroc (Oleg Tolmashov) via ruby-core" Date: 2026-11-10T09:33:32+00:00 Subject: [ruby-core:127403] [Ruby Bug#22220] Performance regression when requiring `aws-sdk-ec2` in Ruby 4.0.6 Issue #22220 has been updated by koilanetroc (Oleg Tolmashov). k0kubun (Takashi Kokubun) wrote in #note-6: > ruby_4_0 commit:faa5caf1b734f371ce0ea0b1ae544b47d865e551. Hi, may I clarify why 3.4 is marked as not needed? 3.4.11 includes the #22126 backport (commit:8a159ffbd6, merging commit:1f473ed633), which is the change this ticket fixes. Without the fix, 3.4.11 and 3.4.12 compile methods with many branches in quadratic time. We hit this in production: a method generated from a large template took 40+ seconds to compile on 3.4.12. The compile holds the GVL, so other threads in the process stopped for that whole time. We can't move to 4.0 yet and need 3.4.12 for the security fixes. Could https://github.com/ruby/ruby/pull/18181 be backported to 3.4? ---------------------------------------- Bug #22220: Performance regression when requiring `aws-sdk-ec2` in Ruby 4.0.6 https://bugs.ruby-lang.org/issues/22220#change-119849 * Author: emanuelevans (Emanuel Evans) * Status: Closed * ruby -v: 4.0.6 * Backport: 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONE ---------------------------------------- Ruby 4.0.6 introduced a large performance regression when loading `aws-sdk-ec2` (~30s on my machine, compared to <1s for ruby 4.0.5). Script to reproduce: ``` for v in 4.0.5 4.0.6; do docker run --rm ruby:$v-slim bash -c ' gem install --no-document aws-sdk-ec2 -v 1.402.0 >/dev/null 2>&1 ruby -e "t = Process.clock_gettime(Process::CLOCK_MONOTONIC) require \"aws-sdk-ec2\" printf(\"ruby %s: %.2fs\n\", RUBY_VERSION, Process.clock_gettime(Process::CLOCK_MONOTONIC) - t)"' done ``` It appears to be related to `Shape.new` and/or `Class.new` compile times; minimal reproduction: ``` for v in 4.0.5 4.0.6; do docker run --rm ruby:$v-slim ruby -e ' src = "class Shape\n def self.new(**) = nil\nend\nmodule M\n" + (1..16_000).map { |i| %( K_#{i} = Shape.new(name: "k#{i}")) }.join("\n") + "\nend\n" File.write("/tmp/bench.rb", src) t = Process.clock_gettime(Process::CLOCK_MONOTONIC) RubyVM::InstructionSequence.compile_file("/tmp/bench.rb") printf("ruby %s: %.2fs\n", RUBY_VERSION, Process.clock_gettime(Process::CLOCK_MONOTONIC) - t)' done ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/