File tree 6 files changed +39
-6
lines changed
sig/datadog/core/environment
spec/datadog/core/runtime
6 files changed +39
-6
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,16 @@ jobs:
11
11
- ' 3.2'
12
12
- ' 3.3'
13
13
# ADD NEW RUBIES HERE
14
- name : Test (${{ matrix.os }}, ${{ matrix.ruby }})
14
+ rubyopt :
15
+ - ' --yjit'
16
+ - ' --yjit --yjit-stats=quiet'
17
+ exclude :
18
+ - ruby : ' 3.2'
19
+ rubyopt : ' --yjit --yjit-stats=quiet'
20
+ name : Test YJIT (${{ matrix.os }}, ${{ matrix.ruby }} ${{ matrix.rubyopt }})
15
21
runs-on : ${{ matrix.os }}
16
22
env :
17
- RUBYOPT : " --yjit "
23
+ RUBYOPT : ${{ matrix.rubyopt }}
18
24
SKIP_SIMPLECOV : 1
19
25
DD_INSTRUMENTATION_TELEMETRY_ENABLED : false
20
26
DD_REMOTE_CONFIGURATION_ENABLED : false
Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ def yjit_alloc_size
52
52
::RubyVM ::YJIT . runtime_stats [ :yjit_alloc_size ]
53
53
end
54
54
55
+ # Ratio of YJIT-executed instructions
56
+ def ratio_in_yjit
57
+ ::RubyVM ::YJIT . runtime_stats [ :ratio_in_yjit ]
58
+ end
59
+
55
60
def available?
56
61
defined? ( ::RubyVM ::YJIT ) \
57
62
&& ::RubyVM ::YJIT . enabled? \
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ module Metrics
31
31
METRIC_YJIT_OBJECT_SHAPE_COUNT = 'runtime.ruby.yjit.object_shape_count'
32
32
METRIC_YJIT_OUTLINED_CODE_SIZE = 'runtime.ruby.yjit.outlined_code_size'
33
33
METRIC_YJIT_YJIT_ALLOC_SIZE = 'runtime.ruby.yjit.yjit_alloc_size'
34
+ METRIC_YJIT_RATIO_IN_YJIT = 'runtime.ruby.yjit.ratio_in_yjit'
34
35
35
36
TAG_SERVICE = 'service'
36
37
end
Original file line number Diff line number Diff line change @@ -181,6 +181,10 @@ def flush_yjit_stats
181
181
Core ::Runtime ::Ext ::Metrics ::METRIC_YJIT_YJIT_ALLOC_SIZE ,
182
182
Core ::Environment ::YJIT . yjit_alloc_size
183
183
)
184
+ gauge_if_not_nil (
185
+ Core ::Runtime ::Ext ::Metrics ::METRIC_YJIT_RATIO_IN_YJIT ,
186
+ Core ::Environment ::YJIT . ratio_in_yjit
187
+ )
184
188
end
185
189
end
186
190
end
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ module Datadog
11
11
def self?.code_region_size : () -> untyped
12
12
def self?.object_shape_count : () -> untyped
13
13
def self?.yjit_alloc_size : () -> untyped
14
+ def self?.ratio_in_yjit : () -> untyped
14
15
15
16
def self?.available? : () -> untyped
16
17
end
Original file line number Diff line number Diff line change 198
198
skip ( 'Test only runs on Ruby >= 3.2' ) if RUBY_VERSION < '3.2.'
199
199
end
200
200
201
- context 'with YJIT enabled and RubyVM::YJIT.stats_enabled? false ' do
201
+ context 'with YJIT enabled' do
202
202
before do
203
- unless Datadog ::Core ::Environment ::YJIT . available?
204
- skip ( 'Test only runs with YJIT enabled and RubyVM::YJIT.stats_enabled? false' )
205
- end
203
+ skip ( 'Test only runs with YJIT enabled' ) unless Datadog ::Core ::Environment ::YJIT . available?
206
204
allow ( runtime_metrics ) . to receive ( :gauge )
207
205
end
208
206
248
246
end
249
247
end
250
248
end
249
+
250
+ context 'with YJIT enabled and RubyVM::YJIT.stats_enabled? true' do
251
+ before do
252
+ skip ( 'Test only runs on Ruby >= 3.3' ) if RUBY_VERSION < '3.3.'
253
+ unless Datadog ::Core ::Environment ::YJIT . available? && ::RubyVM ::YJIT . stats_enabled?
254
+ skip ( 'Test only runs with YJIT enabled and RubyVM::YJIT.stats_enabled? true' )
255
+ end
256
+ allow ( runtime_metrics ) . to receive ( :gauge )
257
+ end
258
+
259
+ it do
260
+ flush
261
+
262
+ expect ( runtime_metrics ) . to have_received ( :gauge )
263
+ . with ( Datadog ::Core ::Runtime ::Ext ::Metrics ::METRIC_YJIT_RATIO_IN_YJIT , kind_of ( Numeric ) )
264
+ . once
265
+ end
266
+ end
251
267
end
252
268
end
253
269
You can’t perform that action at this time.
0 commit comments