sentry-ruby icon indicating copy to clipboard operation
sentry-ruby copied to clipboard

sentry-rails 5.23.0 ActiveRecord overhead

Open bubiche opened this issue 9 months ago • 3 comments

Issue Description

sentry-rails 5.23.0 seems to make active record much slower.

Reproduction Steps

I monitor things with ScoutAPM.

  • My baseline is ruby 3.1.7 with YJIT off with sentry-rails 5.12.0, my rails application's ActiveRecord time for each request is ~13ms.
  • Upgrade to ruby 3.4.2 with YJIT on, ActiveRecord time for each request is ~10ms. sentry-rails is still at 5.12.0 so stacktrace doesn't work.
  • Upgrade sentry-rails to 5.23.0, ActiveRecord time for each request is ~15ms.

I have repeated this a few times and get similar results.

Expected Behavior

Sentry doesn't add too much overhead to my application's response time.

Actual Behavior

My response time is slower with sentry-rails 5.23.0

Ruby Version

3.4.2

SDK Version

5.23.0

Integration and Its Version

Rails

Sentry Config

Sentry.init do |config|
  config.dsn = ...
  config.breadcrumbs_logger = %i[active_support_logger http_logger]
  config.include_local_variables = true
  config.send_modules = false

  config.enabled_environments = %w[staging production]

  config.excluded_exceptions += %w[SystemExit] if [1, "1", "yes", true, "true"].include?(ENV["IS_JOBS"])
  config.excluded_exceptions += %w[Google::Cloud::AbortedError]

  config.release = ENV["RELEASE_VERSION"]
end

bubiche avatar Apr 08 '25 03:04 bubiche

Thanks for reporting this issue. I'll dig into it and report back.

solnic avatar Apr 08 '25 09:04 solnic

OK I've done some perf analysis and discovered that most likely we have a significant drop in performance going from 5.16.1 to 5.17.0 - is there a chance you could see if using 5.16.1 is still performing well and then compare with 5.17.0? The benchmark I wrote shows a ~30% performance drop between these two versions but it's just a benchmark.

solnic avatar Apr 09 '25 15:04 solnic

Thank you @solnic, using 5.16.1 does give us similar performance to 5.12.0 and I'm just eyeballing but 5.17.0/5.17.3 is somewhere in between 5.16.1 and 5.23.0.

Since we need at least 5.17 for ruby 3.4 support, we are using 5.17.3 now.

bubiche avatar Apr 11 '25 07:04 bubiche