Sha256: 724c8a1538ac357007ed5a0681f9fc032b2674d138461626c312a8d6118cdfae

Contents?: true

Size: 1.82 KB

Versions: 16

Compression:

Stored size: 1.82 KB

Contents

# typed: true

module Datadog
  module Core
    module Environment
      # Reports Ruby VM cache performance statistics.
      # This currently encompasses cache invalidation counters and is CRuby-specific.
      #
      # JRuby emulates some CRuby global cache statistics, but they are synthetic and don't
      # provide actionable performance information in the same way CRuby does.
      # @see https://github.com/jruby/jruby/issues/4384#issuecomment-267069314
      #
      # TruffleRuby does not have a global runtime cache invalidation cache.
      # @see http://archive.today/2021.09.10-205702/https://medium.com/graalvm/precise-method-and-constant-invalidation-in-truffleruby-4dd56c6bac1a
      module VMCache
        module_function

        # Global constant cache "generation" counter.
        #
        # Whenever a constant creation busts the global constant cache
        # this value is incremented. This has a measurable performance impact
        # and thus show be avoided after application warm up.
        def global_constant_state
          ::RubyVM.stat[:global_constant_state]
        end

        # Global method cache "generation" counter.
        #
        # Whenever a method creation busts the global method cache
        # this value is incremented. This has a measurable performance impact
        # and thus show be avoided after application warm up.
        #
        # Since Ruby 3.0, the method class is kept on a per-class basis,
        # largely mitigating global method cache busting. `global_method_state`
        # is thus not available since Ruby 3.0.
        # @see https://bugs.ruby-lang.org/issues/16614
        def global_method_state
          ::RubyVM.stat[:global_method_state]
        end

        def available?
          defined?(::RubyVM) && ::RubyVM.respond_to?(:stat)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.8.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.7.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.6.1 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.6.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.5.2 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.5.1 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.5.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.4.2 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.4.1 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.4.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.3.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.2.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.1.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.0.0 lib/datadog/core/environment/vm_cache.rb
ddtrace-1.0.0.beta2 lib/datadog/core/environment/vm_cache.rb