Shopify / gvltools

Set of GVL instrumentation tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting zero in 3.2

mperham opened this issue · comments

I'm running Ruby 3.2. With or without YJIT, with 10, 50 or 200 threads my load testing script is always getting 0 for time waited.

% THREADS=200 LATENCY=0 bin/sidekiqload
ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin22]
THREADS: 200, LATENCY: 0, AJ: nil, PROFILE: nil
2023-01-19T16:51:49.498Z pid=27364 tid=izw ERROR: Setup RSS: 56848
2023-01-19T16:51:53.418Z pid=27364 tid=izw WARN: Created 500000 jobs in 3.917825 sec
2023-01-19T16:51:53.418Z pid=27364 tid=izw WARN: Starting warmup
2023-01-19T16:51:53.418Z pid=27364 tid=izw ERROR: Simulating 0ms of latency between Sidekiq and redis
2023-01-19T16:52:22.131Z pid=27364 tid=cqw ERROR: Done, 500000 jobs in 28.713186 sec, 17413 jobs/sec
2023-01-19T16:52:22.137Z pid=27364 tid=cqw ERROR: Ending RSS: 81424
Waited 0.0ms on the GVL

I adjusted the code to print out the raw ns value:

def gvlprofile
  begin
    require "gvltools"
  rescue LoadError
    return yield
  end
  before = GVLTools::GlobalTimer.monotonic_time
  begin
    yield
  ensure
    diff = GVLTools::GlobalTimer.monotonic_time - before
    puts "Waited #{diff}ns on the GVL"
  end
end

Still 0. I'm using macOS Ventura 13.0.1. Any ideas how to get a non-zero value?

I read the code and realized I had to add GVLTools::GlobalTimer.enable and disable before the timers would work. That should probably go in the README.