stackprof 0.2.27 → 0.2.28

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f919a966335bef57faaa01c783e1b204c435a2ba1d35f03ff6bf33302dfe34c9
4
- data.tar.gz: 679b2bc9c1cc4c9f89638e5ab05c864cb8e9bf10f53e6ae2047cfc835575eb5a
3
+ metadata.gz: 79a87e448ec4d0147b81316179de34549210e7d0e4dc5ed88a0e29ac2a29f78e
4
+ data.tar.gz: 7379be750f5818a56a00e8170802bfb56444efff17b2a663a4da86789405e329
5
5
  SHA512:
6
- metadata.gz: fb21acb48e4ea36eed09b5e82bb2780941a30ce973430acb10184df16893179dfd1d8e5092d546f1814b947d0693f10d2dacd526a4383b1b61cd64f75379b3f4
7
- data.tar.gz: '08112358f745eeacf16b4df2ca4627daccf2ee5fefc31975530859891a57049148025f36f63bd72fed1bb6a1650a0837a9a5a8e4ba6e506c912c5abdd0d9ab38'
6
+ metadata.gz: 3f87238f0afb0690fc26e09eb4d8c3d4ac4da173080852aee353967239dd98058be39303072db2e0f192311b4aabb58691765ae1a38d16cc0c45a7674aba2954
7
+ data.tar.gz: 03babedcf6978a18f801bd88c804924468c379692617cb5429b6453bae6db34c76293ef0f4aff7ca74cb415031a5c6476dc92f873e4cfe2b1ab0379f3edf465a
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [ ruby-head, '3.3','3.2', '3.1', '3.0', '2.7', truffleruby ]
11
+ ruby: [ ruby-head, '3.4', '3.3','3.2', '3.1', '3.0', truffleruby ]
12
12
  steps:
13
13
  - name: Checkout
14
14
  uses: actions/checkout@v2
@@ -5,7 +5,8 @@ if RUBY_ENGINE == 'truffleruby'
5
5
  return
6
6
  end
7
7
 
8
- if have_func('rb_postponed_job_register_one') &&
8
+ if (have_func('rb_postponed_job_preregister') ||
9
+ have_func('rb_postponed_job_register_one')) &&
9
10
  have_func('rb_profile_frames') &&
10
11
  have_func('rb_tracepoint_new') &&
11
12
  have_const('RUBY_INTERNAL_EVENT_NEWOBJ')
@@ -26,6 +26,16 @@
26
26
  #define FAKE_FRAME_MARK INT2FIX(1)
27
27
  #define FAKE_FRAME_SWEEP INT2FIX(2)
28
28
 
29
+ #ifdef HAVE_RB_POSTPONED_JOB_PREREGISTER
30
+ static rb_postponed_job_handle_t job_record_gc, job_sample_and_record, job_record_buffer;
31
+
32
+ # define preregister_job(job) (job = rb_postponed_job_preregister(0, stackprof_##job, (void*)0))
33
+ # define trigger_job(job) rb_postponed_job_trigger(job)
34
+ #else
35
+ # define preregister_job(job) ((void*)0)
36
+ # define trigger_job(job) rb_postponed_job_register_one(0, stackprof_##job, (void*)0)
37
+ #endif
38
+
29
39
  static const char *fake_frame_cstrs[] = {
30
40
  "(garbage collection)",
31
41
  "(marking)",
@@ -225,7 +235,7 @@ stackprof_start(int argc, VALUE *argv, VALUE self)
225
235
  sigaction(mode == sym_wall ? SIGALRM : SIGPROF, &sa, NULL);
226
236
 
227
237
  timer.it_interval.tv_sec = 0;
228
- timer.it_interval.tv_usec = NUM2LONG(interval);
238
+ timer.it_interval.tv_usec = NUM2UINT(interval);
229
239
  timer.it_value = timer.it_interval;
230
240
  setitimer(mode == sym_wall ? ITIMER_REAL : ITIMER_PROF, &timer, 0);
231
241
  } else if (mode == sym_custom) {
@@ -813,16 +823,16 @@ stackprof_signal_handler(int sig, siginfo_t *sinfo, void *ucontext)
813
823
  capture_timestamp(&_stackprof.gc_start_timestamp);
814
824
  }
815
825
  _stackprof.unrecorded_gc_samples++;
816
- rb_postponed_job_register_one(0, stackprof_job_record_gc, (void*)0);
826
+ trigger_job(job_record_gc);
817
827
  } else {
818
828
  if (stackprof_use_postponed_job) {
819
- rb_postponed_job_register_one(0, stackprof_job_sample_and_record, (void*)0);
829
+ trigger_job(job_sample_and_record);
820
830
  } else {
821
831
  // Buffer a sample immediately, if an existing sample exists this will
822
832
  // return immediately
823
833
  stackprof_buffer_sample();
824
834
  // Enqueue a job to record the sample
825
- rb_postponed_job_register_one(0, stackprof_job_record_buffer, (void*)0);
835
+ trigger_job(job_record_buffer);
826
836
  }
827
837
  }
828
838
  pthread_mutex_unlock(&lock);
@@ -899,7 +909,7 @@ stackprof_atfork_parent(void)
899
909
  if (STACKPROF_RUNNING()) {
900
910
  if (_stackprof.mode == sym_wall || _stackprof.mode == sym_cpu) {
901
911
  timer.it_interval.tv_sec = 0;
902
- timer.it_interval.tv_usec = NUM2LONG(_stackprof.interval);
912
+ timer.it_interval.tv_usec = NUM2UINT(_stackprof.interval);
903
913
  timer.it_value = timer.it_interval;
904
914
  setitimer(_stackprof.mode == sym_wall ? ITIMER_REAL : ITIMER_PROF, &timer, 0);
905
915
  }
@@ -1010,5 +1020,9 @@ Init_stackprof(void)
1010
1020
  rb_define_singleton_method(rb_mStackProf, "sample", stackprof_sample, 0);
1011
1021
  rb_define_singleton_method(rb_mStackProf, "use_postponed_job!", stackprof_use_postponed_job_l, 0);
1012
1022
 
1023
+ preregister_job(job_record_gc);
1024
+ preregister_job(job_sample_and_record);
1025
+ preregister_job(job_record_buffer);
1026
+
1013
1027
  pthread_atfork(stackprof_atfork_prepare, stackprof_atfork_parent, stackprof_atfork_child);
1014
1028
  }
@@ -10,10 +10,14 @@ module StackProf
10
10
 
11
11
  class << self
12
12
  def from_file(file)
13
- if (content = IO.binread(file)).start_with?(MARSHAL_SIGNATURE)
14
- new(Marshal.load(content))
15
- else
16
- from_json(JSON.parse(content))
13
+ File.open(file, 'rb') do |f|
14
+ signature_bytes = f.read(2)
15
+ f.rewind
16
+ if signature_bytes == MARSHAL_SIGNATURE
17
+ new(Marshal.load(f))
18
+ else
19
+ from_json(JSON.parse(f.read))
20
+ end
17
21
  end
18
22
  end
19
23
 
data/lib/stackprof.rb CHANGED
@@ -18,7 +18,7 @@ elsif RUBY_VERSION == "3.2.0"
18
18
  end
19
19
 
20
20
  module StackProf
21
- VERSION = '0.2.27'
21
+ VERSION = '0.2.28'
22
22
  end
23
23
 
24
24
  StackProf.autoload :Report, "stackprof/report.rb"
data/stackprof.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'stackprof'
3
- s.version = '0.2.27'
3
+ s.version = '0.2.28'
4
4
  s.homepage = 'http://github.com/tmm1/stackprof'
5
5
 
6
6
  s.authors = 'Aman Gupta'
@@ -51,9 +51,16 @@ class StackProfTest < Minitest::Test
51
51
 
52
52
  frame = profile[:frames].values.first
53
53
  assert_includes frame[:name], "StackProfTest#test_object_allocation"
54
- assert_equal 2, frame[:samples]
54
+ if RUBY_VERSION >= '4'
55
+ assert_equal 4, frame[:samples]
56
+ else
57
+ assert_equal 2, frame[:samples]
58
+ end
55
59
  assert_includes [profile_base_line - 2, profile_base_line], frame[:line]
56
- if RUBY_VERSION >= '3'
60
+ if RUBY_VERSION >= '4'
61
+ assert_equal [2, 2], frame[:lines][profile_base_line+1]
62
+ assert_equal [2, 2], frame[:lines][profile_base_line+2]
63
+ elsif RUBY_VERSION >= '3'
57
64
  assert_equal [2, 1], frame[:lines][profile_base_line+1]
58
65
  assert_equal [2, 1], frame[:lines][profile_base_line+2]
59
66
  else
@@ -151,7 +158,7 @@ class StackProfTest < Minitest::Test
151
158
  assert_equal 10, raw_lines[-1] # seen 10 times
152
159
 
153
160
  offset = RUBY_VERSION >= '3' ? -3 : -2
154
- assert_equal 140, raw_lines[offset] # sample caller is on 140
161
+ assert_equal 147, raw_lines[offset] # sample caller is on 140
155
162
  assert_includes profile[:frames][raw[offset]][:name], 'StackProfTest#test_raw'
156
163
 
157
164
  assert_equal 10, profile[:raw_sample_timestamps].size
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.27
4
+ version: 0.2.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-01-14 00:00:00.000000000 Z
11
+ date: 2026-02-13 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rake-compiler
@@ -84,9 +85,10 @@ licenses:
84
85
  - MIT
85
86
  metadata:
86
87
  bug_tracker_uri: https://github.com/tmm1/stackprof/issues
87
- changelog_uri: https://github.com/tmm1/stackprof/blob/v0.2.27/CHANGELOG.md
88
- documentation_uri: https://www.rubydoc.info/gems/stackprof/0.2.27
89
- source_code_uri: https://github.com/tmm1/stackprof/tree/v0.2.27
88
+ changelog_uri: https://github.com/tmm1/stackprof/blob/v0.2.28/CHANGELOG.md
89
+ documentation_uri: https://www.rubydoc.info/gems/stackprof/0.2.28
90
+ source_code_uri: https://github.com/tmm1/stackprof/tree/v0.2.28
91
+ post_install_message:
90
92
  rdoc_options: []
91
93
  require_paths:
92
94
  - lib
@@ -101,7 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
103
  - !ruby/object:Gem::Version
102
104
  version: '0'
103
105
  requirements: []
104
- rubygems_version: 3.7.0.dev
106
+ rubygems_version: 3.0.3.1
107
+ signing_key:
105
108
  specification_version: 4
106
109
  summary: sampling callstack-profiler for ruby 2.2+
107
110
  test_files: []