truffleruby
truffleruby copied to clipboard
Ensure code is not invalidated when a TracePoint :class event is enabled
See https://twitter.com/eregontp/status/1400446685113774088 and https://bugs.ruby-lang.org/issues/17881
On TruffleRuby, code compiles fine whether there are TracePoint or not, but enabling or disabling a TracePoint causes invalidations & recompilations.
For the :class event, there is no need to invalidate and we can just always check explicitly if there is an active :class TracePoint on module/class Foo since that's slow path anyway.
The :class event is used by Zeitwerk.
BTW I found that a :class TracePoint is also used in
bundler/spec/runtime/setup_spec.rb:891: TracePoint.trace(:class) do |tp|
And we found that using instrumentation for TracePoint is very heavy on memory footprint, so for :class at least we should not use instrumentation.