pf2 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -2
  3. data/Cargo.lock +186 -17
  4. data/Cargo.toml +1 -1
  5. data/README.md +17 -6
  6. data/Rakefile +8 -0
  7. data/crates/backtrace-sys2/.gitignore +1 -0
  8. data/crates/backtrace-sys2/Cargo.toml +9 -0
  9. data/crates/backtrace-sys2/build.rs +48 -0
  10. data/crates/backtrace-sys2/src/lib.rs +5 -0
  11. data/crates/backtrace-sys2/src/libbacktrace/.gitignore +15 -0
  12. data/crates/backtrace-sys2/src/libbacktrace/Isaac.Newton-Opticks.txt +9286 -0
  13. data/crates/backtrace-sys2/src/libbacktrace/LICENSE +29 -0
  14. data/crates/backtrace-sys2/src/libbacktrace/Makefile.am +623 -0
  15. data/crates/backtrace-sys2/src/libbacktrace/Makefile.in +2666 -0
  16. data/crates/backtrace-sys2/src/libbacktrace/README.md +36 -0
  17. data/crates/backtrace-sys2/src/libbacktrace/aclocal.m4 +864 -0
  18. data/crates/backtrace-sys2/src/libbacktrace/alloc.c +167 -0
  19. data/crates/backtrace-sys2/src/libbacktrace/allocfail.c +136 -0
  20. data/crates/backtrace-sys2/src/libbacktrace/allocfail.sh +104 -0
  21. data/crates/backtrace-sys2/src/libbacktrace/atomic.c +113 -0
  22. data/crates/backtrace-sys2/src/libbacktrace/backtrace-supported.h.in +66 -0
  23. data/crates/backtrace-sys2/src/libbacktrace/backtrace.c +129 -0
  24. data/crates/backtrace-sys2/src/libbacktrace/backtrace.h +189 -0
  25. data/crates/backtrace-sys2/src/libbacktrace/btest.c +501 -0
  26. data/crates/backtrace-sys2/src/libbacktrace/compile +348 -0
  27. data/crates/backtrace-sys2/src/libbacktrace/config/enable.m4 +38 -0
  28. data/crates/backtrace-sys2/src/libbacktrace/config/lead-dot.m4 +31 -0
  29. data/crates/backtrace-sys2/src/libbacktrace/config/libtool.m4 +7436 -0
  30. data/crates/backtrace-sys2/src/libbacktrace/config/ltoptions.m4 +369 -0
  31. data/crates/backtrace-sys2/src/libbacktrace/config/ltsugar.m4 +123 -0
  32. data/crates/backtrace-sys2/src/libbacktrace/config/ltversion.m4 +23 -0
  33. data/crates/backtrace-sys2/src/libbacktrace/config/lt~obsolete.m4 +98 -0
  34. data/crates/backtrace-sys2/src/libbacktrace/config/multi.m4 +68 -0
  35. data/crates/backtrace-sys2/src/libbacktrace/config/override.m4 +117 -0
  36. data/crates/backtrace-sys2/src/libbacktrace/config/unwind_ipinfo.m4 +37 -0
  37. data/crates/backtrace-sys2/src/libbacktrace/config/warnings.m4 +227 -0
  38. data/crates/backtrace-sys2/src/libbacktrace/config.guess +1700 -0
  39. data/crates/backtrace-sys2/src/libbacktrace/config.h.in +182 -0
  40. data/crates/backtrace-sys2/src/libbacktrace/config.sub +1885 -0
  41. data/crates/backtrace-sys2/src/libbacktrace/configure +15740 -0
  42. data/crates/backtrace-sys2/src/libbacktrace/configure.ac +613 -0
  43. data/crates/backtrace-sys2/src/libbacktrace/dwarf.c +4402 -0
  44. data/crates/backtrace-sys2/src/libbacktrace/edtest.c +120 -0
  45. data/crates/backtrace-sys2/src/libbacktrace/edtest2.c +43 -0
  46. data/crates/backtrace-sys2/src/libbacktrace/elf.c +7443 -0
  47. data/crates/backtrace-sys2/src/libbacktrace/fileline.c +407 -0
  48. data/crates/backtrace-sys2/src/libbacktrace/filenames.h +52 -0
  49. data/crates/backtrace-sys2/src/libbacktrace/filetype.awk +13 -0
  50. data/crates/backtrace-sys2/src/libbacktrace/install-debuginfo-for-buildid.sh.in +65 -0
  51. data/crates/backtrace-sys2/src/libbacktrace/install-sh +501 -0
  52. data/crates/backtrace-sys2/src/libbacktrace/instrumented_alloc.c +114 -0
  53. data/crates/backtrace-sys2/src/libbacktrace/internal.h +389 -0
  54. data/crates/backtrace-sys2/src/libbacktrace/libtool.m4 +7436 -0
  55. data/crates/backtrace-sys2/src/libbacktrace/ltmain.sh +8636 -0
  56. data/crates/backtrace-sys2/src/libbacktrace/ltoptions.m4 +369 -0
  57. data/crates/backtrace-sys2/src/libbacktrace/ltsugar.m4 +123 -0
  58. data/crates/backtrace-sys2/src/libbacktrace/ltversion.m4 +23 -0
  59. data/crates/backtrace-sys2/src/libbacktrace/lt~obsolete.m4 +98 -0
  60. data/crates/backtrace-sys2/src/libbacktrace/macho.c +1355 -0
  61. data/crates/backtrace-sys2/src/libbacktrace/missing +215 -0
  62. data/crates/backtrace-sys2/src/libbacktrace/mmap.c +331 -0
  63. data/crates/backtrace-sys2/src/libbacktrace/mmapio.c +110 -0
  64. data/crates/backtrace-sys2/src/libbacktrace/move-if-change +83 -0
  65. data/crates/backtrace-sys2/src/libbacktrace/mtest.c +410 -0
  66. data/crates/backtrace-sys2/src/libbacktrace/nounwind.c +66 -0
  67. data/crates/backtrace-sys2/src/libbacktrace/pecoff.c +957 -0
  68. data/crates/backtrace-sys2/src/libbacktrace/posix.c +104 -0
  69. data/crates/backtrace-sys2/src/libbacktrace/print.c +92 -0
  70. data/crates/backtrace-sys2/src/libbacktrace/read.c +110 -0
  71. data/crates/backtrace-sys2/src/libbacktrace/simple.c +108 -0
  72. data/crates/backtrace-sys2/src/libbacktrace/sort.c +108 -0
  73. data/crates/backtrace-sys2/src/libbacktrace/state.c +72 -0
  74. data/crates/backtrace-sys2/src/libbacktrace/stest.c +137 -0
  75. data/crates/backtrace-sys2/src/libbacktrace/test-driver +148 -0
  76. data/crates/backtrace-sys2/src/libbacktrace/test_format.c +55 -0
  77. data/crates/backtrace-sys2/src/libbacktrace/testlib.c +234 -0
  78. data/crates/backtrace-sys2/src/libbacktrace/testlib.h +110 -0
  79. data/crates/backtrace-sys2/src/libbacktrace/ttest.c +161 -0
  80. data/crates/backtrace-sys2/src/libbacktrace/unittest.c +92 -0
  81. data/crates/backtrace-sys2/src/libbacktrace/unknown.c +65 -0
  82. data/crates/backtrace-sys2/src/libbacktrace/xcoff.c +1606 -0
  83. data/crates/backtrace-sys2/src/libbacktrace/xztest.c +508 -0
  84. data/crates/backtrace-sys2/src/libbacktrace/zstdtest.c +523 -0
  85. data/crates/backtrace-sys2/src/libbacktrace/ztest.c +541 -0
  86. data/ext/pf2/Cargo.toml +1 -0
  87. data/ext/pf2/src/backtrace.rs +126 -0
  88. data/ext/pf2/src/lib.rs +1 -0
  89. data/ext/pf2/src/profile.rs +16 -1
  90. data/ext/pf2/src/profile_serializer.rs +95 -21
  91. data/ext/pf2/src/ringbuffer.rs +7 -0
  92. data/ext/pf2/src/ruby_init.rs +18 -6
  93. data/ext/pf2/src/sample.rs +22 -1
  94. data/ext/pf2/src/signal_scheduler/configuration.rs +7 -0
  95. data/ext/pf2/src/signal_scheduler/timer_installer.rs +34 -27
  96. data/ext/pf2/src/signal_scheduler.rs +95 -26
  97. data/ext/pf2/src/timer_thread_scheduler.rs +88 -12
  98. data/ext/pf2/src/util.rs +2 -2
  99. data/lib/pf2/reporter.rb +12 -5
  100. data/lib/pf2/version.rb +1 -1
  101. data/lib/pf2.rb +3 -6
  102. metadata +96 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1062b7dd7fbbc96396e59dcd189bc63f20a98f81f68f871e8f2b36fb7be82f42
4
- data.tar.gz: 8c809750b5e2bca91b0d51a81f583ee31d8a2c63fd9162bc5d4bdbd946915f06
3
+ metadata.gz: 929c0f24675525d7d52bd0293ec45b9383579517119baac5b28da2bfe720d7d5
4
+ data.tar.gz: e75df94cf2085aea9d218b431e44ccda5f87e537a1c566ea67ae4ef04a03cb8a
5
5
  SHA512:
6
- metadata.gz: d1e1ac1962437b0f2d0fb89cc6d0ef5fa4dca4dec0a47a67500fb30d99ec4f17433f600288a32686d003e3771907273e3c1606a1345db1c658a12e7c1b11b51b
7
- data.tar.gz: 90a8c791f2e5a26a68b9bf90c70d302d63ce4ec77058dbfa8dd86e7aed1f13cafb61521ce12cddb42bb43019217a58a4b451edb858417748f32b140313610eef
6
+ metadata.gz: 2e28b5f4cbb99dc101b7f9a9092b1602d682f1001fa1c86a538d0d966a4c670df5fc5ecb971d8a25e093c3c3bdbe115b772ed40be50b8027cbc09fe6664c1db5
7
+ data.tar.gz: cf63fc413c60dda6fc0a360d39701cffc36aceeb98dc5d1d92a6e42761fa2ba1d2381e67a9a4af10fcb51fbf6e4b32afc89ff9307370fa542db278c6e76d40ae
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [Unreleased]
2
+
3
+
4
+ ## [0.3.0] - 2024-02-05
5
+
6
+ ### Added
7
+
8
+ - Native stack consolidation
9
+ - Pf2 now records native (C-level) stacks during sample capture.
10
+ - This functionality is based on [libbacktrace](https://github.com/ianlancetaylor/libbacktrace).
11
+ - New configuration interface for `Pf2.start`, `Pf2::SignalScheduler.start`, `Pf2::TimerThreadScheduler.start`
12
+ - They now accept keyword arguments (`interval_ms`, `threads`, `time_mode`, `track_new_threads`).
13
+ - New configuration options
14
+ - `interval_ms`: The sampling interval.
15
+ - `time_mode` (`:wall` or `:cpu`): The sampling timer's _mode_. `:wall` is wall-clock time (CLOCK_MONOTONIC to be specific), `:cpu` is per-thread CPU time (CLOCK_THREAD_CPUTIME_ID).
16
+
17
+ ### Removed
18
+
19
+ - Configuration through positional arguments is no longer supported.
20
+
21
+
1
22
  ## [0.2.0] - 2024-01-21
2
23
 
3
24
  - New Ruby interface: Pf2.start, Pf2.stop, Pf2.profile
@@ -5,8 +26,7 @@
5
26
  - Implement SignalScheduler and TimerThreadScheduler
6
27
  - Rewritten many components
7
28
 
29
+
8
30
  ## [0.1.0] - 2023-10-04
9
31
 
10
32
  - Initial release
11
-
12
- ## [Unreleased]
data/Cargo.lock CHANGED
@@ -46,7 +46,7 @@ version = "1.0.2"
46
46
  source = "registry+https://github.com/rust-lang/crates.io-index"
47
47
  checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
48
48
  dependencies = [
49
- "windows-sys",
49
+ "windows-sys 0.52.0",
50
50
  ]
51
51
 
52
52
  [[package]]
@@ -56,7 +56,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
56
56
  checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
57
57
  dependencies = [
58
58
  "anstyle",
59
- "windows-sys",
59
+ "windows-sys 0.52.0",
60
+ ]
61
+
62
+ [[package]]
63
+ name = "backtrace-sys2"
64
+ version = "0.1.0"
65
+ dependencies = [
66
+ "bindgen 0.69.2",
60
67
  ]
61
68
 
62
69
  [[package]]
@@ -79,6 +86,29 @@ dependencies = [
79
86
  "syn",
80
87
  ]
81
88
 
89
+ [[package]]
90
+ name = "bindgen"
91
+ version = "0.69.2"
92
+ source = "registry+https://github.com/rust-lang/crates.io-index"
93
+ checksum = "a4c69fae65a523209d34240b60abe0c42d33d1045d445c0839d8a4894a736e2d"
94
+ dependencies = [
95
+ "bitflags",
96
+ "cexpr",
97
+ "clang-sys",
98
+ "lazy_static",
99
+ "lazycell",
100
+ "log",
101
+ "peeking_take_while",
102
+ "prettyplease",
103
+ "proc-macro2",
104
+ "quote",
105
+ "regex",
106
+ "rustc-hash",
107
+ "shlex",
108
+ "syn",
109
+ "which",
110
+ ]
111
+
82
112
  [[package]]
83
113
  name = "bitflags"
84
114
  version = "2.4.1"
@@ -126,6 +156,12 @@ version = "1.0.0"
126
156
  source = "registry+https://github.com/rust-lang/crates.io-index"
127
157
  checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
128
158
 
159
+ [[package]]
160
+ name = "either"
161
+ version = "1.9.0"
162
+ source = "registry+https://github.com/rust-lang/crates.io-index"
163
+ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
164
+
129
165
  [[package]]
130
166
  name = "env_filter"
131
167
  version = "0.1.0"
@@ -149,12 +185,31 @@ dependencies = [
149
185
  "log",
150
186
  ]
151
187
 
188
+ [[package]]
189
+ name = "errno"
190
+ version = "0.3.8"
191
+ source = "registry+https://github.com/rust-lang/crates.io-index"
192
+ checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
193
+ dependencies = [
194
+ "libc",
195
+ "windows-sys 0.52.0",
196
+ ]
197
+
152
198
  [[package]]
153
199
  name = "glob"
154
200
  version = "0.3.1"
155
201
  source = "registry+https://github.com/rust-lang/crates.io-index"
156
202
  checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
157
203
 
204
+ [[package]]
205
+ name = "home"
206
+ version = "0.5.9"
207
+ source = "registry+https://github.com/rust-lang/crates.io-index"
208
+ checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
209
+ dependencies = [
210
+ "windows-sys 0.52.0",
211
+ ]
212
+
158
213
  [[package]]
159
214
  name = "humantime"
160
215
  version = "2.1.0"
@@ -195,6 +250,12 @@ dependencies = [
195
250
  "winapi",
196
251
  ]
197
252
 
253
+ [[package]]
254
+ name = "linux-raw-sys"
255
+ version = "0.4.13"
256
+ source = "registry+https://github.com/rust-lang/crates.io-index"
257
+ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
258
+
198
259
  [[package]]
199
260
  name = "log"
200
261
  version = "0.4.20"
@@ -223,6 +284,12 @@ dependencies = [
223
284
  "minimal-lexical",
224
285
  ]
225
286
 
287
+ [[package]]
288
+ name = "once_cell"
289
+ version = "1.19.0"
290
+ source = "registry+https://github.com/rust-lang/crates.io-index"
291
+ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
292
+
226
293
  [[package]]
227
294
  name = "peeking_take_while"
228
295
  version = "0.1.2"
@@ -233,6 +300,7 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
233
300
  name = "pf2"
234
301
  version = "0.1.0"
235
302
  dependencies = [
303
+ "backtrace-sys2",
236
304
  "cc",
237
305
  "env_logger",
238
306
  "libc",
@@ -243,20 +311,30 @@ dependencies = [
243
311
  "serde_json",
244
312
  ]
245
313
 
314
+ [[package]]
315
+ name = "prettyplease"
316
+ version = "0.2.16"
317
+ source = "registry+https://github.com/rust-lang/crates.io-index"
318
+ checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5"
319
+ dependencies = [
320
+ "proc-macro2",
321
+ "syn",
322
+ ]
323
+
246
324
  [[package]]
247
325
  name = "proc-macro2"
248
- version = "1.0.69"
326
+ version = "1.0.78"
249
327
  source = "registry+https://github.com/rust-lang/crates.io-index"
250
- checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
328
+ checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
251
329
  dependencies = [
252
330
  "unicode-ident",
253
331
  ]
254
332
 
255
333
  [[package]]
256
334
  name = "quote"
257
- version = "1.0.33"
335
+ version = "1.0.35"
258
336
  source = "registry+https://github.com/rust-lang/crates.io-index"
259
- checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
337
+ checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
260
338
  dependencies = [
261
339
  "proc-macro2",
262
340
  ]
@@ -276,7 +354,7 @@ version = "0.9.82"
276
354
  source = "registry+https://github.com/rust-lang/crates.io-index"
277
355
  checksum = "5482a1ed4cde58dddaf162b6aebcb5c25645822547832b8be101f2acd40bcdd6"
278
356
  dependencies = [
279
- "bindgen",
357
+ "bindgen 0.66.1",
280
358
  "lazy_static",
281
359
  "proc-macro2",
282
360
  "quote",
@@ -320,6 +398,19 @@ version = "1.1.0"
320
398
  source = "registry+https://github.com/rust-lang/crates.io-index"
321
399
  checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
322
400
 
401
+ [[package]]
402
+ name = "rustix"
403
+ version = "0.38.21"
404
+ source = "registry+https://github.com/rust-lang/crates.io-index"
405
+ checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
406
+ dependencies = [
407
+ "bitflags",
408
+ "errno",
409
+ "libc",
410
+ "linux-raw-sys",
411
+ "windows-sys 0.48.0",
412
+ ]
413
+
323
414
  [[package]]
324
415
  name = "ryu"
325
416
  version = "1.0.15"
@@ -371,9 +462,9 @@ checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380"
371
462
 
372
463
  [[package]]
373
464
  name = "syn"
374
- version = "2.0.38"
465
+ version = "2.0.48"
375
466
  source = "registry+https://github.com/rust-lang/crates.io-index"
376
- checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
467
+ checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
377
468
  dependencies = [
378
469
  "proc-macro2",
379
470
  "quote",
@@ -392,6 +483,18 @@ version = "0.2.1"
392
483
  source = "registry+https://github.com/rust-lang/crates.io-index"
393
484
  checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
394
485
 
486
+ [[package]]
487
+ name = "which"
488
+ version = "4.4.2"
489
+ source = "registry+https://github.com/rust-lang/crates.io-index"
490
+ checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
491
+ dependencies = [
492
+ "either",
493
+ "home",
494
+ "once_cell",
495
+ "rustix",
496
+ ]
497
+
395
498
  [[package]]
396
499
  name = "winapi"
397
500
  version = "0.3.9"
@@ -414,13 +517,37 @@ version = "0.4.0"
414
517
  source = "registry+https://github.com/rust-lang/crates.io-index"
415
518
  checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
416
519
 
520
+ [[package]]
521
+ name = "windows-sys"
522
+ version = "0.48.0"
523
+ source = "registry+https://github.com/rust-lang/crates.io-index"
524
+ checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
525
+ dependencies = [
526
+ "windows-targets 0.48.5",
527
+ ]
528
+
417
529
  [[package]]
418
530
  name = "windows-sys"
419
531
  version = "0.52.0"
420
532
  source = "registry+https://github.com/rust-lang/crates.io-index"
421
533
  checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
422
534
  dependencies = [
423
- "windows-targets",
535
+ "windows-targets 0.52.0",
536
+ ]
537
+
538
+ [[package]]
539
+ name = "windows-targets"
540
+ version = "0.48.5"
541
+ source = "registry+https://github.com/rust-lang/crates.io-index"
542
+ checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
543
+ dependencies = [
544
+ "windows_aarch64_gnullvm 0.48.5",
545
+ "windows_aarch64_msvc 0.48.5",
546
+ "windows_i686_gnu 0.48.5",
547
+ "windows_i686_msvc 0.48.5",
548
+ "windows_x86_64_gnu 0.48.5",
549
+ "windows_x86_64_gnullvm 0.48.5",
550
+ "windows_x86_64_msvc 0.48.5",
424
551
  ]
425
552
 
426
553
  [[package]]
@@ -429,51 +556,93 @@ version = "0.52.0"
429
556
  source = "registry+https://github.com/rust-lang/crates.io-index"
430
557
  checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
431
558
  dependencies = [
432
- "windows_aarch64_gnullvm",
433
- "windows_aarch64_msvc",
434
- "windows_i686_gnu",
435
- "windows_i686_msvc",
436
- "windows_x86_64_gnu",
437
- "windows_x86_64_gnullvm",
438
- "windows_x86_64_msvc",
559
+ "windows_aarch64_gnullvm 0.52.0",
560
+ "windows_aarch64_msvc 0.52.0",
561
+ "windows_i686_gnu 0.52.0",
562
+ "windows_i686_msvc 0.52.0",
563
+ "windows_x86_64_gnu 0.52.0",
564
+ "windows_x86_64_gnullvm 0.52.0",
565
+ "windows_x86_64_msvc 0.52.0",
439
566
  ]
440
567
 
568
+ [[package]]
569
+ name = "windows_aarch64_gnullvm"
570
+ version = "0.48.5"
571
+ source = "registry+https://github.com/rust-lang/crates.io-index"
572
+ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
573
+
441
574
  [[package]]
442
575
  name = "windows_aarch64_gnullvm"
443
576
  version = "0.52.0"
444
577
  source = "registry+https://github.com/rust-lang/crates.io-index"
445
578
  checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
446
579
 
580
+ [[package]]
581
+ name = "windows_aarch64_msvc"
582
+ version = "0.48.5"
583
+ source = "registry+https://github.com/rust-lang/crates.io-index"
584
+ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
585
+
447
586
  [[package]]
448
587
  name = "windows_aarch64_msvc"
449
588
  version = "0.52.0"
450
589
  source = "registry+https://github.com/rust-lang/crates.io-index"
451
590
  checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
452
591
 
592
+ [[package]]
593
+ name = "windows_i686_gnu"
594
+ version = "0.48.5"
595
+ source = "registry+https://github.com/rust-lang/crates.io-index"
596
+ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
597
+
453
598
  [[package]]
454
599
  name = "windows_i686_gnu"
455
600
  version = "0.52.0"
456
601
  source = "registry+https://github.com/rust-lang/crates.io-index"
457
602
  checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
458
603
 
604
+ [[package]]
605
+ name = "windows_i686_msvc"
606
+ version = "0.48.5"
607
+ source = "registry+https://github.com/rust-lang/crates.io-index"
608
+ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
609
+
459
610
  [[package]]
460
611
  name = "windows_i686_msvc"
461
612
  version = "0.52.0"
462
613
  source = "registry+https://github.com/rust-lang/crates.io-index"
463
614
  checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
464
615
 
616
+ [[package]]
617
+ name = "windows_x86_64_gnu"
618
+ version = "0.48.5"
619
+ source = "registry+https://github.com/rust-lang/crates.io-index"
620
+ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
621
+
465
622
  [[package]]
466
623
  name = "windows_x86_64_gnu"
467
624
  version = "0.52.0"
468
625
  source = "registry+https://github.com/rust-lang/crates.io-index"
469
626
  checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
470
627
 
628
+ [[package]]
629
+ name = "windows_x86_64_gnullvm"
630
+ version = "0.48.5"
631
+ source = "registry+https://github.com/rust-lang/crates.io-index"
632
+ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
633
+
471
634
  [[package]]
472
635
  name = "windows_x86_64_gnullvm"
473
636
  version = "0.52.0"
474
637
  source = "registry+https://github.com/rust-lang/crates.io-index"
475
638
  checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
476
639
 
640
+ [[package]]
641
+ name = "windows_x86_64_msvc"
642
+ version = "0.48.5"
643
+ source = "registry+https://github.com/rust-lang/crates.io-index"
644
+ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
645
+
477
646
  [[package]]
478
647
  name = "windows_x86_64_msvc"
479
648
  version = "0.52.0"
data/Cargo.toml CHANGED
@@ -1,3 +1,3 @@
1
1
  [workspace]
2
- members = ["./ext/pf2"]
2
+ members = ["./ext/pf2", "./crates/backtrace-sys2"]
3
3
  resolver = "2"
data/README.md CHANGED
@@ -17,11 +17,10 @@ Usage
17
17
  Pf2 will collect samples every 10 ms of wall time by default.
18
18
 
19
19
  ```ruby
20
- # Specify Ruby Threads to track in the first argument.
21
- # New Ruby Threads will be tracked if the second argument is true.
22
- Pf2.start([Thread.current], false)
23
- your_code_here() # will be profiled
24
- Thread.new { threaded_code() } # will also be profiled if second argument is true
20
+ # Threads in `threads` will be tracked
21
+ Pf2.start(threads: [Thread.current])
22
+
23
+ your_code_here
25
24
 
26
25
  # Stop profiling and save the profile for visualization
27
26
  profile = Pf2.stop
@@ -50,7 +49,19 @@ $ pf2 -o report.json my_program.pf2profile
50
49
 
51
50
  ### Configuration
52
51
 
53
- (TBD)
52
+ Pf2 accepts the following configuration keys:
53
+
54
+ ```rb
55
+ Pf2.start(
56
+ interval_ms: 49, # Integer: The sampling interval in milliseconds (default: 49)
57
+ threads: [], # Array<Thread>: A list of Ruby Threads to be tracked (default: `Thread.list`)
58
+ time_mode: :cpu, # `:cpu` or `:wall`: The sampling timer's mode
59
+ # (default: `:cpu` for SignalScheduler, `:wall` for TimerThreadScheduler)
60
+ track_new_threads: true # Boolean: Whether to automatically track Threads spawned after profiler start
61
+ # (default: false)
62
+ )
63
+ ```
64
+
54
65
 
55
66
  Overhead
56
67
  --------
data/Rakefile CHANGED
@@ -1,8 +1,16 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/extensiontask'
3
+ require 'minitest/test_task'
3
4
 
4
5
  task default: %i[]
5
6
 
6
7
  Rake::ExtensionTask.new 'pf2' do |ext|
7
8
  ext.lib_dir = 'lib/pf2'
8
9
  end
10
+
11
+ Minitest::TestTask.create(:test) do |t|
12
+ t.libs << "test"
13
+ t.libs << "lib"
14
+ t.warning = false
15
+ t.test_globs = ["test/**/*_test.rb"]
16
+ end
@@ -0,0 +1 @@
1
+ /target
@@ -0,0 +1,9 @@
1
+ [package]
2
+ name = "backtrace-sys2"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+ [build-dependencies]
9
+ bindgen = "0.69.2"
@@ -0,0 +1,48 @@
1
+ use std::env;
2
+ use std::path::Path;
3
+ use std::path::PathBuf;
4
+ use std::process::Command;
5
+
6
+ fn main() {
7
+ let libbacktrace_src_dir = Path::new("src/libbacktrace").canonicalize().unwrap();
8
+
9
+ // Run ./configure
10
+ let configure_status = Command::new("./configure")
11
+ .current_dir(&libbacktrace_src_dir)
12
+ .status()
13
+ .expect("libbacktrace: ./configure failed");
14
+ if !configure_status.success() {
15
+ panic!("libbacktrace: ./configure failed");
16
+ }
17
+
18
+ // Run make
19
+ let make_status = Command::new("make")
20
+ .current_dir(&libbacktrace_src_dir)
21
+ .status()
22
+ .expect("libbacktrace: make failed");
23
+ if !make_status.success() {
24
+ panic!("libbacktrace: make failed");
25
+ }
26
+
27
+ // Generate bindings
28
+ let bindings = bindgen::Builder::default()
29
+ .header(format!("{}/backtrace.h", libbacktrace_src_dir.display()))
30
+ .allowlist_function("backtrace_.*")
31
+ .generate_comments(true)
32
+ .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
33
+ .generate()
34
+ .expect("Failed to generate bindings");
35
+
36
+ // Output bindings to the src directory
37
+ let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
38
+ bindings
39
+ .write_to_file(out_path.join("backtrace_bindings.rs"))
40
+ .expect("Failed to write bindings");
41
+
42
+ println!("cargo:rerun-if-changed=build.rs");
43
+ println!(
44
+ "cargo:rustc-link-search=native={}",
45
+ libbacktrace_src_dir.join(".libs").display()
46
+ );
47
+ println!("cargo:rustc-link-lib=static=backtrace");
48
+ }
@@ -0,0 +1,5 @@
1
+ #![allow(non_upper_case_globals)]
2
+ #![allow(non_camel_case_types)]
3
+ #![allow(non_snake_case)]
4
+
5
+ include!(concat!(env!("OUT_DIR"), "/backtrace_bindings.rs"));
@@ -0,0 +1,15 @@
1
+ *~
2
+ *.o
3
+ *.lo
4
+ *.a
5
+ *.la
6
+
7
+ .libs
8
+ Makefile
9
+ backtrace-supported.h
10
+ config.h
11
+ config.log
12
+ config.status
13
+ install-debuginfo-for-buildid.sh
14
+ libtool
15
+ stamp-h1