vernier 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121,7 +121,7 @@ module Vernier
121
121
  end
122
122
 
123
123
  def output(gzip: false)
124
- result = ::JSON.generate(data)
124
+ result = ::JSON.generate(data(profile.meta[:hide_anonymous_threads]))
125
125
  if gzip
126
126
  require "zlib"
127
127
  result = Zlib.gzip(result)
@@ -133,7 +133,7 @@ module Vernier
133
133
 
134
134
  attr_reader :profile
135
135
 
136
- def data
136
+ def data(hide_anonymous_threads)
137
137
  #markers_by_thread = profile.markers.group_by { |marker| marker[0] }
138
138
 
139
139
  threads = profile.threads.map do |ruby_thread_id, thread_info|
@@ -147,6 +147,12 @@ module Vernier
147
147
  )
148
148
  end
149
149
 
150
+ initially_visible_threads = if hide_anonymous_threads
151
+ threads.each_index.reject { |i| threads[i].anonymous? && !threads[i].is_main && !threads[i].is_start }.to_a
152
+ else
153
+ threads.each_index.to_a
154
+ end
155
+
150
156
  {
151
157
  meta: {
152
158
  interval: 1, # FIXME: memory vs wall
@@ -172,7 +178,7 @@ module Vernier
172
178
  }
173
179
  end,
174
180
  sourceCodeIsNotOnSearchfox: true,
175
- initialVisibleThreads: threads.each_index.to_a,
181
+ initialVisibleThreads: initially_visible_threads,
176
182
  initialSelectedThreads: Array(threads.find_index(&:is_start)),
177
183
  vernierUserMetadata: profile.meta[:user_metadata],
178
184
  extra: [
@@ -275,15 +281,17 @@ module Vernier
275
281
  2 => "Stalled"
276
282
  }.freeze
277
283
 
278
- attr_reader :profile, :is_start
284
+ attr_reader :profile, :is_start, :anonymous, :is_main
285
+ alias :anonymous? :anonymous
279
286
 
280
- def initialize(ruby_thread_id, profile, categorizer, name:, tid:, samples:, weights:, timestamps: nil, sample_categories: nil, markers:, started_at:, stopped_at: nil, allocations: nil, is_main: nil, is_start: nil)
287
+ def initialize(ruby_thread_id, profile, categorizer, name:, tid:, samples:, weights:, timestamps: nil, sample_categories: nil, markers:, started_at:, anonymous:, stopped_at: nil, allocations: nil, is_main: nil, is_start: nil)
281
288
  @ruby_thread_id = ruby_thread_id
282
289
  @profile = profile
283
290
  @categorizer = categorizer
284
291
  @tid = tid
285
292
  @name = name
286
293
  @is_main = is_main
294
+ @anonymous = anonymous
287
295
  if is_main.nil?
288
296
  @is_main = @ruby_thread_id == ::Thread.main.object_id
289
297
  end
@@ -441,7 +449,6 @@ module Vernier
441
449
  funcTable: func_table,
442
450
  nativeSymbols: {},
443
451
  samples: samples_table,
444
- jsAllocations: allocations_table,
445
452
  stackTable: stack_table,
446
453
  resourceTable: {
447
454
  length: 0,
@@ -452,7 +459,10 @@ module Vernier
452
459
  },
453
460
  markers: markers_table,
454
461
  stringArray: string_table
455
- }.compact
462
+ }.tap do |thread|
463
+ allocations = allocations_table
464
+ thread[:jsAllocations] = allocations if allocations
465
+ end
456
466
  end
457
467
 
458
468
  def markers_table
@@ -3,6 +3,7 @@ module Vernier
3
3
  class ThreadNames
4
4
  def initialize
5
5
  @names = {}
6
+ @anonymous = {}
6
7
  @tp = TracePoint.new(:thread_end) do |e|
7
8
  collect_thread(e.self)
8
9
  end
@@ -13,6 +14,10 @@ module Vernier
13
14
  @names[object_id] || "thread obj_id:#{object_id}"
14
15
  end
15
16
 
17
+ def anonymous?(object_id)
18
+ @anonymous[object_id]
19
+ end
20
+
16
21
  def finish
17
22
  collect_running
18
23
  @tp.disable
@@ -27,6 +32,7 @@ module Vernier
27
32
  end
28
33
 
29
34
  def collect_thread(th)
35
+ @anonymous[th.object_id] = !th.name
30
36
  @names[th.object_id] = pretty_name(th)
31
37
  end
32
38
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vernier
4
- VERSION = "1.11.0"
4
+ VERSION = "1.12.0"
5
5
  end
data/vernier.gemspec CHANGED
@@ -9,12 +9,12 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["john@hawthorn.email"]
10
10
 
11
11
  spec.summary = "A next generation CRuby profiler"
12
- spec.description = "Next-generation Ruby 3.2.1+ sampling profiler. Tracks multiple threads, GVL activity, GC pauses, idle time, and more."
12
+ spec.description = "Next-generation Ruby 3.3+ sampling profiler. Tracks multiple threads, GVL activity, GC pauses, idle time, and more."
13
13
  spec.homepage = "https://github.com/jhawthorn/vernier"
14
14
  spec.license = "MIT"
15
15
 
16
16
  unless ENV["IGNORE_REQUIRED_RUBY_VERSION"]
17
- spec.required_ruby_version = ">= 3.2.1"
17
+ spec.required_ruby_version = ">= 3.3.0"
18
18
  end
19
19
 
20
20
  spec.metadata["homepage_uri"] = spec.homepage
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vernier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
@@ -51,7 +51,7 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
- description: Next-generation Ruby 3.2.1+ sampling profiler. Tracks multiple threads,
54
+ description: Next-generation Ruby 3.3+ sampling profiler. Tracks multiple threads,
55
55
  GVL activity, GC pauses, idle time, and more.
56
56
  email:
57
57
  - john@hawthorn.email
@@ -128,14 +128,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 3.2.1
131
+ version: 3.3.0
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - ">="
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 4.0.16
138
+ rubygems_version: 4.0.20
139
139
  specification_version: 4
140
140
  summary: A next generation CRuby profiler
141
141
  test_files: []