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 +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/ext/stackprof/extconf.rb +2 -1
- data/ext/stackprof/stackprof.c +19 -5
- data/lib/stackprof/report.rb +8 -4
- data/lib/stackprof.rb +1 -1
- data/stackprof.gemspec +1 -1
- data/test/test_stackprof.rb +10 -3
- metadata +9 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79a87e448ec4d0147b81316179de34549210e7d0e4dc5ed88a0e29ac2a29f78e
|
|
4
|
+
data.tar.gz: 7379be750f5818a56a00e8170802bfb56444efff17b2a663a4da86789405e329
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f87238f0afb0690fc26e09eb4d8c3d4ac4da173080852aee353967239dd98058be39303072db2e0f192311b4aabb58691765ae1a38d16cc0c45a7674aba2954
|
|
7
|
+
data.tar.gz: 03babedcf6978a18f801bd88c804924468c379692617cb5429b6453bae6db34c76293ef0f4aff7ca74cb415031a5c6476dc92f873e4cfe2b1ab0379f3edf465a
|
data/.github/workflows/ci.yml
CHANGED
data/ext/stackprof/extconf.rb
CHANGED
|
@@ -5,7 +5,8 @@ if RUBY_ENGINE == 'truffleruby'
|
|
|
5
5
|
return
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
if have_func('
|
|
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')
|
data/ext/stackprof/stackprof.c
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
826
|
+
trigger_job(job_record_gc);
|
|
817
827
|
} else {
|
|
818
828
|
if (stackprof_use_postponed_job) {
|
|
819
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
}
|
data/lib/stackprof/report.rb
CHANGED
|
@@ -10,10 +10,14 @@ module StackProf
|
|
|
10
10
|
|
|
11
11
|
class << self
|
|
12
12
|
def from_file(file)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
data/stackprof.gemspec
CHANGED
data/test/test_stackprof.rb
CHANGED
|
@@ -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
|
-
|
|
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 >= '
|
|
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
|
|
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.
|
|
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:
|
|
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.
|
|
88
|
-
documentation_uri: https://www.rubydoc.info/gems/stackprof/0.2.
|
|
89
|
-
source_code_uri: https://github.com/tmm1/stackprof/tree/v0.2.
|
|
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.
|
|
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: []
|