ivoanjo / gvl-tracing

Get a timeline view of Global VM Lock usage in your Ruby app
MIT License
114 stars 7 forks source link

GvlTracing.stop doesn't properly stop #11

Closed benoittgt closed 1 year ago

benoittgt commented 1 year ago

Hello

If you try to re-enable tracing after the code will break. Example with the code provided from README duplicated.

require "gvl-tracing"

def fib(n)
  return n if n <= 1
  fib(n - 1) + fib(n - 2)
end

GvlTracing.start("example1.json")
Thread.new { sleep(0.05) while true }
sleep(0.05)
3.times.map { Thread.new { fib(37) } }.map(&:join)
sleep(0.05)
GvlTracing.stop

GvlTracing.start("example2.json")
Thread.new { sleep(0.05) while true }
sleep(0.05)
3.times.map { Thread.new { fib(37) } }.map(&:join)
sleep(0.05)
GvlTracing.stop
gvl_tracing_stop.rb:20:in `start': Already started (RuntimeError)
    from gvl_tracing_stop.rb:20:in `<main>'
ivoanjo commented 1 year ago

Ooops, totally broken by a 1-character typo. Thanks for the report, fix released as 1.1.1 :)