Module: Datadog::Core::Environment::VMCache

Defined in:
lib/datadog/core/environment/vm_cache.rb

Overview

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. TruffleRuby does not have a global runtime cache invalidation cache.

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/datadog/core/environment/vm_cache.rb', line 58

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

.constant_cache_invalidationsObject

Introduced in Ruby 3.2 to match an improved cache implementation.



47
48
49
# File 'lib/datadog/core/environment/vm_cache.rb', line 47

def constant_cache_invalidations
  ::RubyVM.stat[:constant_cache_invalidations]
end

.constant_cache_missesObject

Introduced in Ruby 3.2 to match an improved cache implementation.



54
55
56
# File 'lib/datadog/core/environment/vm_cache.rb', line 54

def constant_cache_misses
  ::RubyVM.stat[:constant_cache_misses]
end

.global_constant_stateObject

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.

This was removed in Ruby 3.2.



26
27
28
# File 'lib/datadog/core/environment/vm_cache.rb', line 26

def global_constant_state
  ::RubyVM.stat[:global_constant_state]
end

.global_method_stateObject

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.



40
41
42
# File 'lib/datadog/core/environment/vm_cache.rb', line 40

def global_method_state
  ::RubyVM.stat[:global_method_state]
end