truffleruby icon indicating copy to clipboard operation
truffleruby copied to clipboard

Ensure code is not invalidated when a TracePoint :class event is enabled

Open eregon opened this issue 4 years ago • 1 comments

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.

eregon avatar Jun 03 '21 13:06 eregon

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.

eregon avatar Feb 08 '22 11:02 eregon