fiber-profiler 0.4.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64e27c2a0ba665e441f7fa4e89044961c777572bc9a47bf9d3a25db83b3e6b90
4
- data.tar.gz: 514104f2792a95d4262e99adec6108d36e7d9c0b1ea927ffed4fadc8cfae5836
3
+ metadata.gz: 4eb8511c2bd355496fcb3461944f5fc7881795e7e44d13f4a59497689feaa838
4
+ data.tar.gz: 5146ceedbb0f9fc2230b5c3f50b1c0fac9ef2b424078ced732051b6e7e303431
5
5
  SHA512:
6
- metadata.gz: 3501a3d76137aa083c27c1f552171ea07915a1ac87c10d16b3d0cb2ff5dd11a48b0f7cb353aaa7b1c452b5d2251b8d2a46fa52178f9f50a66c4d0b100253bc9b
7
- data.tar.gz: e42ef50211f27eccbdb83eb7682fd736fbc6e40a082de68d0b4e34f65f8820c97f9132ef5ed922b8c31a35906cfac1e380d0510a2c2f3f727c234e0417071e6e
6
+ metadata.gz: 427ddb031dc285d0c45c7c1dc72e0793c200b216ca3854272d675ad2cf677c58bf5a7a07bdaf043890f583527fe32ec263b0e12cf53ac11e95a90921e6576013
7
+ data.tar.gz: 625fe37c351399c0c1a5588f2577238899b2cad5b3b876d2e4fbe7c76ffdd26865c31111d68c09e04160a369cb0ca149e9c2eb97e1417dacdb7247a5a6b06861
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ # @parameter input [Input] The input to process.
7
+ def analyze(input:)
8
+ summary = {}
9
+
10
+ input.each do |sample|
11
+ duration = sample["duration"]
12
+ calls = sample["calls"]
13
+
14
+ if duration and calls
15
+ calls.each do |call|
16
+ location = "#{call["path"]}:#{call["line"]}"
17
+
18
+ summary[location] ||= {duration: 0, calls: 0, class: call["class"], method: call["method"]}
19
+ summary[location][:duration] += call["duration"]
20
+ summary[location][:calls] += 1
21
+ end
22
+ end
23
+ end
24
+
25
+ summary.sort_by{|location, data| -data[:duration]}
26
+ end
@@ -0,0 +1,72 @@
1
+ # Getting Started
2
+
3
+ This guide explains how to detect stalls using the fiber profiler.
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your project:
8
+
9
+ ```bash
10
+ $ bundle add fiber-profiler
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Instrument your code using the default profiler:
16
+
17
+ ```ruby
18
+ #!/usr/bin/env ruby
19
+
20
+ require "fiber/profiler"
21
+
22
+ profiler = Fiber::Profiler.default
23
+
24
+ profiler&.start
25
+
26
+ # Your application code:
27
+ Fiber.new do
28
+ sleep 0.1
29
+ end.resume
30
+
31
+ profiler&.stop
32
+ ```
33
+
34
+ Running this program will output the following:
35
+
36
+ ```bash
37
+ $ FIBER_PROFILER_CAPTURE=true bundle exec ./test.rb
38
+ Fiber stalled for 0.105 seconds
39
+ /Users/samuel/Developer/socketry/fiber-profiler/test.rb:11 in c-call 'Kernel#sleep' (0.105s)
40
+ ```
41
+
42
+ ## Integration with Async
43
+
44
+ The fiber profiler is optionally supported by `Async`. Simply enable the profiler using `FIBER_PROFILER_CAPTURE=true` to capture and report stalls.
45
+
46
+ ## Default Environment Variables
47
+
48
+ ### `FIBER_PROFILER_CAPTURE`
49
+
50
+ Set to `true` to enable capturing of stalled fibers.
51
+
52
+ ### `FIBER_PROFILER_CAPTURE_STALL_THRESHOLD`
53
+
54
+ Set the threshold in seconds for reporting a stalled fiber. Default is `0.01`.
55
+
56
+ ### `FIBER_PROFILER_CAPTURE_TRACK_CALLS`
57
+
58
+ Set to `true` to track calls within the fiber. Default is `true`. This can be disabled to reduce overhead.
59
+
60
+ ### `FIBER_PROFILER_CAPTURE_SAMPLE_RATE`
61
+
62
+ Set the sample rate of the profiler as a percentage of all context switches. The default is 1.0 (100%).
63
+
64
+ ## Analyzing Logs
65
+
66
+ If you collect your logs in a file (e.g. as `ndjson`) you can analyze them using the included `bake` commands:
67
+
68
+ ```bash
69
+ $ bundle exec bake input --file samples.ndjson fiber:profiler:analyze output
70
+ ```
71
+
72
+ This will aggregate all the call logs and generate a short summary, ordered by duration.
@@ -0,0 +1,11 @@
1
+ # Automatically generated context index for Utopia::Project guides.
2
+ # Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
3
+ ---
4
+ description: A fiber stall profiler.
5
+ metadata:
6
+ documentation_uri: https://socketry.github.io/fiber-profiler/
7
+ source_code_uri: https://github.com/socketry/fiber-profiler.git
8
+ files:
9
+ - path: getting-started.md
10
+ title: Getting Started
11
+ description: This guide explains how to detect stalls using the fiber profiler.
@@ -181,8 +181,6 @@ static void Fiber_Profiler_Capture_compact(void *ptr) {
181
181
  static void Fiber_Profiler_Capture_free(void *ptr) {
182
182
  struct Fiber_Profiler_Capture *capture = (struct Fiber_Profiler_Capture*)ptr;
183
183
 
184
- RUBY_ASSERT(capture->running == 0);
185
-
186
184
  Fiber_Profiler_Stream_free(&capture->stream);
187
185
  Fiber_Profiler_Deque_free(&capture->calls);
188
186
 
@@ -754,14 +752,40 @@ void Fiber_Profiler_Capture_print_json(struct Fiber_Profiler_Capture *capture, F
754
752
  fprintf(stream, ",\"switches\":%zu,\"samples\":%zu,\"stalls\":%zu}\n", capture->switches, capture->samples, capture->stalls);
755
753
  }
756
754
 
755
+ VALUE output_write(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, data))
756
+ {
757
+ struct Fiber_Profiler_Capture *capture = (struct Fiber_Profiler_Capture*)data;
758
+
759
+ // Actually perform the write to IO here.
760
+ rb_io_write(
761
+ capture->output,
762
+ rb_str_new_static(capture->stream.buffer, capture->stream.size)
763
+ );
764
+
765
+ return Qnil;
766
+ }
767
+
757
768
  void Fiber_Profiler_Capture_print(struct Fiber_Profiler_Capture *capture, double duration) {
769
+ static VALUE Fiber = Qnil;
770
+
771
+ if (Fiber == Qnil) {
772
+ Fiber = rb_const_get(rb_cObject, rb_intern("Fiber"));
773
+ }
774
+
758
775
  if (capture->output == Qnil) return;
759
776
 
760
777
  FILE *stream = capture->stream.file;
761
778
  capture->print(capture, stream, duration);
762
779
  fflush(stream);
763
780
 
764
- rb_io_write(capture->output, rb_str_new_static(capture->stream.buffer, capture->stream.size));
781
+ // Do the actual write in Fiber.blocking.
782
+ rb_block_call(
783
+ Fiber,
784
+ rb_intern("blocking"),
785
+ 0, NULL, // no args
786
+ output_write,
787
+ (VALUE)capture
788
+ );
765
789
 
766
790
  fseek(stream, 0, SEEK_SET);
767
791
  }
@@ -1,6 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2025, by Samuel Williams.
4
+ # Copyright, 2025-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "native"
7
+ require_relative "fork_handler"
8
+
9
+ module Fiber::Profiler
10
+ # Thread-local storage for the active profiler capture.
11
+ ::Thread.attr_accessor :fiber_profiler_capture
12
+
13
+ # Private module that wraps start/stop to manage thread-local storage.
14
+ module ThreadLocalCapture
15
+ # Start profiling and store the capture in the current thread's thread-local storage.
16
+ def start
17
+ result = super
18
+
19
+ if result
20
+ Thread.current.fiber_profiler_capture = self
21
+ end
22
+
23
+ return result
24
+ end
25
+
26
+ # Stop profiling and clear the capture from the current thread's thread-local storage.
27
+ def stop
28
+ result = super
29
+
30
+ if result
31
+ Thread.current.fiber_profiler_capture = nil
32
+ end
33
+
34
+ return result
35
+ end
36
+ end
37
+
38
+ private_constant :ThreadLocalCapture
39
+
40
+ # Represents a running profiler capture.
41
+ class Capture
42
+ prepend ThreadLocalCapture
43
+ end
44
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2026, by Samuel Williams.
5
+
6
+ module Fiber::Profiler
7
+ # Private module that hooks into Process._fork to handle fork events.
8
+ #
9
+ # If `Scheduler#process_fork` hook is adopted in Ruby 4, this code can be removed after Ruby < 4 is no longer supported.
10
+ module ForkHandler
11
+ def _fork(&block)
12
+ result = super
13
+
14
+ if result.zero?
15
+ # Child process: disable the profiler for the current thread
16
+ if capture = Thread.current.fiber_profiler_capture
17
+ begin
18
+ capture.stop
19
+ rescue
20
+ # Ignore errors - the profiler may be in an invalid state after fork
21
+ end
22
+ end
23
+ end
24
+
25
+ return result
26
+ end
27
+ end
28
+
29
+ private_constant :ForkHandler
30
+
31
+ # Hook into Process._fork to handle fork events automatically:
32
+ ::Process.singleton_class.prepend(ForkHandler)
33
+ end
@@ -7,6 +7,6 @@
7
7
  class Fiber
8
8
  # @namespace
9
9
  module Profiler
10
- VERSION = "0.4.0"
10
+ VERSION = "0.6.0"
11
11
  end
12
12
  end
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2025, by Samuel Williams.
4
+ # Copyright, 2025-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "profiler/version"
7
7
  require_relative "profiler/native"
8
+ require_relative "profiler/fork_handler"
8
9
 
9
10
  module Fiber::Profiler
10
11
  # The default profiler to use, if any.
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2025, by Samuel Williams.
3
+ Copyright, 2025-2026, by Samuel Williams.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -18,6 +18,10 @@ Please see the [project documentation](https://socketry.github.io/fiber-profiler
18
18
 
19
19
  Please see the [project releases](https://socketry.github.io/fiber-profiler/releases/index) for all releases.
20
20
 
21
+ ### v0.6.0
22
+
23
+ - Fixed compatibility with `Process.fork`.
24
+
21
25
  ### v0.1.3
22
26
 
23
27
  - Improved performance when not profiling (when sampling is enabled).
@@ -36,6 +40,22 @@ We welcome contributions to this project.
36
40
  4. Push to the branch (`git push origin my-new-feature`).
37
41
  5. Create new Pull Request.
38
42
 
43
+ ### Running Tests
44
+
45
+ To run the test suite:
46
+
47
+ ``` shell
48
+ bundle exec sus
49
+ ```
50
+
51
+ ### Making Releases
52
+
53
+ To make a new release:
54
+
55
+ ``` shell
56
+ bundle exec bake gem:release:patch # or minor or major
57
+ ```
58
+
39
59
  ### Developer Certificate of Origin
40
60
 
41
61
  In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.6.0
4
+
5
+ - Fixed compatibility with `Process.fork`.
6
+
3
7
  ## v0.1.3
4
8
 
5
9
  - Improved performance when not profiling (when sampling is enabled).
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiber-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -43,15 +43,10 @@ extensions:
43
43
  - ext/extconf.rb
44
44
  extra_rdoc_files: []
45
45
  files:
46
- - ext/Fiber_Profiler.bundle
47
- - ext/Fiber_Profiler.bundle.dSYM/Contents/Info.plist
48
- - ext/Fiber_Profiler.bundle.dSYM/Contents/Resources/DWARF/Fiber_Profiler.bundle
49
- - ext/Fiber_Profiler.bundle.dSYM/Contents/Resources/Relocations/aarch64/Fiber_Profiler.bundle.yml
50
- - ext/Makefile
51
- - ext/capture.o
52
- - ext/extconf.h
46
+ - bake/fiber/profiler/analyze.rb
47
+ - context/getting-started.md
48
+ - context/index.yaml
53
49
  - ext/extconf.rb
54
- - ext/fiber.o
55
50
  - ext/fiber/profiler/capture.c
56
51
  - ext/fiber/profiler/capture.h
57
52
  - ext/fiber/profiler/deque.h
@@ -61,11 +56,9 @@ files:
61
56
  - ext/fiber/profiler/profiler.h
62
57
  - ext/fiber/profiler/time.c
63
58
  - ext/fiber/profiler/time.h
64
- - ext/mkmf.log
65
- - ext/profiler.o
66
- - ext/time.o
67
59
  - lib/fiber/profiler.rb
68
60
  - lib/fiber/profiler/capture.rb
61
+ - lib/fiber/profiler/fork_handler.rb
69
62
  - lib/fiber/profiler/native.rb
70
63
  - lib/fiber/profiler/version.rb
71
64
  - license.md
@@ -84,14 +77,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
77
  requirements:
85
78
  - - ">="
86
79
  - !ruby/object:Gem::Version
87
- version: '3.2'
80
+ version: '3.3'
88
81
  required_rubygems_version: !ruby/object:Gem::Requirement
89
82
  requirements:
90
83
  - - ">="
91
84
  - !ruby/object:Gem::Version
92
85
  version: '0'
93
86
  requirements: []
94
- rubygems_version: 3.6.7
87
+ rubygems_version: 4.0.6
95
88
  specification_version: 4
96
89
  summary: A fiber stall profiler.
97
90
  test_files: []
metadata.gz.sig CHANGED
Binary file
Binary file
@@ -1,20 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>CFBundleDevelopmentRegion</key>
6
- <string>English</string>
7
- <key>CFBundleIdentifier</key>
8
- <string>com.apple.xcode.dsym.Fiber_Profiler.bundle</string>
9
- <key>CFBundleInfoDictionaryVersion</key>
10
- <string>6.0</string>
11
- <key>CFBundlePackageType</key>
12
- <string>dSYM</string>
13
- <key>CFBundleSignature</key>
14
- <string>????</string>
15
- <key>CFBundleShortVersionString</key>
16
- <string>1.0</string>
17
- <key>CFBundleVersion</key>
18
- <string>1</string>
19
- </dict>
20
- </plist>
@@ -1,5 +0,0 @@
1
- ---
2
- triple: 'arm64-apple-darwin'
3
- binary-path: Fiber_Profiler.bundle
4
- relocations: []
5
- ...
data/ext/Makefile DELETED
@@ -1,273 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- # V=0 quiet, V=1 verbose. other values don't work.
5
- V = 0
6
- V0 = $(V:0=)
7
- Q1 = $(V:1=)
8
- Q = $(Q1:0=@)
9
- ECHO1 = $(V:1=@ :)
10
- ECHO = $(ECHO1:0=@ echo)
11
- NULLCMD = :
12
-
13
- #### Start of system configuration section. ####
14
-
15
- srcdir = .
16
- topdir = /Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0
17
- hdrdir = $(topdir)
18
- arch_hdrdir = /Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0/arm64-darwin24
19
- PATH_SEPARATOR = :
20
- VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir)/fiber/profiler
21
- prefix = $(DESTDIR)/Users/samuel/.rubies/ruby-3.4.2
22
- rubysitearchprefix = $(rubylibprefix)/$(sitearch)
23
- rubyarchprefix = $(rubylibprefix)/$(arch)
24
- rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
25
- exec_prefix = $(prefix)
26
- vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
27
- sitearchhdrdir = $(sitehdrdir)/$(sitearch)
28
- rubyarchhdrdir = $(rubyhdrdir)/$(arch)
29
- vendorhdrdir = $(rubyhdrdir)/vendor_ruby
30
- sitehdrdir = $(rubyhdrdir)/site_ruby
31
- rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
32
- vendorarchdir = $(vendorlibdir)/$(sitearch)
33
- vendorlibdir = $(vendordir)/$(ruby_version)
34
- vendordir = $(rubylibprefix)/vendor_ruby
35
- sitearchdir = $(sitelibdir)/$(sitearch)
36
- sitelibdir = $(sitedir)/$(ruby_version)
37
- sitedir = $(rubylibprefix)/site_ruby
38
- rubyarchdir = $(rubylibdir)/$(arch)
39
- rubylibdir = $(rubylibprefix)/$(ruby_version)
40
- sitearchincludedir = $(includedir)/$(sitearch)
41
- archincludedir = $(includedir)/$(arch)
42
- sitearchlibdir = $(libdir)/$(sitearch)
43
- archlibdir = $(libdir)/$(arch)
44
- ridir = $(datarootdir)/$(RI_BASE_NAME)
45
- modular_gc_dir = $(DESTDIR)
46
- mandir = $(datarootdir)/man
47
- localedir = $(datarootdir)/locale
48
- libdir = $(exec_prefix)/lib
49
- psdir = $(docdir)
50
- pdfdir = $(docdir)
51
- dvidir = $(docdir)
52
- htmldir = $(docdir)
53
- infodir = $(datarootdir)/info
54
- docdir = $(datarootdir)/doc/$(PACKAGE)
55
- oldincludedir = $(DESTDIR)/usr/include
56
- includedir = $(SDKROOT)$(prefix)/include
57
- runstatedir = $(localstatedir)/run
58
- localstatedir = $(prefix)/var
59
- sharedstatedir = $(prefix)/com
60
- sysconfdir = $(prefix)/etc
61
- datadir = $(datarootdir)
62
- datarootdir = $(prefix)/share
63
- libexecdir = $(exec_prefix)/libexec
64
- sbindir = $(exec_prefix)/sbin
65
- bindir = $(exec_prefix)/bin
66
- archdir = $(rubyarchdir)
67
-
68
-
69
- CC_WRAPPER =
70
- CC = clang
71
- CXX = clang++ -std=gnu++11
72
- LIBRUBY = $(LIBRUBY_A)
73
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
74
- LIBRUBYARG_SHARED =
75
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework CoreFoundation $(MAINLIBS)
76
- empty =
77
- OUTFLAG = -o $(empty)
78
- COUTFLAG = -o $(empty)
79
- CSRCFLAG = $(empty)
80
-
81
- RUBY_EXTCONF_H = extconf.h
82
- cflags = $(hardenflags) -fdeclspec $(optflags) $(debugflags) $(warnflags)
83
- cxxflags =
84
- optflags = -O3 -fno-fast-math
85
- debugflags = -ggdb3
86
- warnflags = -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef
87
- cppflags =
88
- CCDLFLAGS = -fno-common
89
- CFLAGS = $(CCDLFLAGS) $(cflags) -pipe -Wall -Wno-unknown-pragmas -std=c99 $(ARCH_FLAG)
90
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
91
- DEFS =
92
- CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags)
93
- CXXFLAGS = $(CCDLFLAGS) -fdeclspec $(ARCH_FLAG)
94
- ldflags = -L. -fstack-protector-strong -L/opt/local/lib
95
- dldflags = -L/opt/local/lib -Wl,-undefined,dynamic_lookup -bundle_loader '$(BUILTRUBY)'
96
- ARCH_FLAG = -arch arm64
97
- DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
98
- LDSHARED = $(CC) -dynamic -bundle
99
- LDSHAREDXX = $(CXX) -dynamic -bundle
100
- POSTLINK = dsymutil $@ 2>/dev/null; { test -z '$(RUBY_CODESIGN)' || codesign -s '$(RUBY_CODESIGN)' $@; }
101
- AR = ar
102
- LD = ld
103
- EXEEXT =
104
-
105
- RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
106
- RUBY_SO_NAME = ruby.3.4
107
- RUBYW_INSTALL_NAME =
108
- RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
109
- RUBYW_BASE_NAME = rubyw
110
- RUBY_BASE_NAME = ruby
111
-
112
- arch = arm64-darwin24
113
- sitearch = $(arch)
114
- ruby_version = 3.4.0
115
- ruby = $(bindir)/$(RUBY_BASE_NAME)
116
- RUBY = $(ruby)
117
- BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME)
118
- ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
119
-
120
- RM = rm -f
121
- RM_RF = rm -fr
122
- RMDIRS = rmdir -p
123
- MAKEDIRS = /opt/local/bin/gmkdir -p
124
- INSTALL = /opt/local/bin/ginstall -c
125
- INSTALL_PROG = $(INSTALL) -m 0755
126
- INSTALL_DATA = $(INSTALL) -m 644
127
- COPY = cp
128
- TOUCH = exit >
129
-
130
- #### End of system configuration section. ####
131
-
132
- preload =
133
- libpath = . $(libdir) /opt/local/lib
134
- LIBPATH = -L. -L$(libdir) -L/opt/local/lib
135
- DEFFILE =
136
-
137
- CLEANFILES = mkmf.log
138
- DISTCLEANFILES =
139
- DISTCLEANDIRS =
140
-
141
- extout =
142
- extout_prefix =
143
- target_prefix =
144
- LOCAL_LIBS =
145
- LIBS = -lpthread
146
- ORIG_SRCS =
147
- SRCS = $(ORIG_SRCS) profiler.c time.c fiber.c capture.c
148
- OBJS = profiler.o time.o fiber.o capture.o
149
- HDRS = $(srcdir)/extconf.h
150
- LOCAL_HDRS =
151
- TARGET = Fiber_Profiler
152
- TARGET_NAME = Fiber_Profiler
153
- TARGET_ENTRY = Init_$(TARGET_NAME)
154
- DLLIB = $(TARGET).bundle
155
- EXTSTATIC =
156
- STATIC_LIB =
157
-
158
- TIMESTAMP_DIR = .
159
- BINDIR = $(bindir)
160
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
161
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
162
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
163
- HDRDIR = $(sitehdrdir)$(target_prefix)
164
- ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix)
165
- TARGET_SO_DIR =
166
- TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
167
- CLEANLIBS = $(TARGET_SO) $(TARGET_SO:=.dSYM)
168
- CLEANOBJS = $(OBJS) *.bak
169
- TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.time
170
-
171
- all: $(DLLIB)
172
- static: $(STATIC_LIB)
173
- .PHONY: all install static install-so install-rb
174
- .PHONY: clean clean-so clean-static clean-rb
175
-
176
- clean-static::
177
- clean-rb-default::
178
- clean-rb::
179
- clean-so::
180
- clean: clean-so clean-static clean-rb-default clean-rb
181
- -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
182
-
183
- distclean-rb-default::
184
- distclean-rb::
185
- distclean-so::
186
- distclean-static::
187
- distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
188
- -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
189
- -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
190
- -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
191
-
192
- realclean: distclean
193
- install: install-so install-rb
194
-
195
- install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP)
196
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
197
- clean-static::
198
- -$(Q)$(RM) $(STATIC_LIB)
199
- install-rb: pre-install-rb do-install-rb install-rb-default
200
- install-rb-default: pre-install-rb-default do-install-rb-default
201
- pre-install-rb: Makefile
202
- pre-install-rb-default: Makefile
203
- do-install-rb:
204
- do-install-rb-default:
205
- pre-install-rb-default:
206
- @$(NULLCMD)
207
- $(TARGET_SO_DIR_TIMESTAMP):
208
- $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
209
- $(Q) $(TOUCH) $@
210
-
211
- site-install: site-install-so site-install-rb
212
- site-install-so: install-so
213
- site-install-rb: install-rb
214
-
215
- .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
216
-
217
- .cc.o:
218
- $(ECHO) compiling $(<)
219
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
220
-
221
- .cc.S:
222
- $(ECHO) translating $(<)
223
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
224
-
225
- .mm.o:
226
- $(ECHO) compiling $(<)
227
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
228
-
229
- .mm.S:
230
- $(ECHO) translating $(<)
231
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
232
-
233
- .cxx.o:
234
- $(ECHO) compiling $(<)
235
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
236
-
237
- .cxx.S:
238
- $(ECHO) translating $(<)
239
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
240
-
241
- .cpp.o:
242
- $(ECHO) compiling $(<)
243
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
244
-
245
- .cpp.S:
246
- $(ECHO) translating $(<)
247
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
248
-
249
- .c.o:
250
- $(ECHO) compiling $(<)
251
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
252
-
253
- .c.S:
254
- $(ECHO) translating $(<)
255
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
256
-
257
- .m.o:
258
- $(ECHO) compiling $(<)
259
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
260
-
261
- .m.S:
262
- $(ECHO) translating $(<)
263
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
264
-
265
- $(TARGET_SO): $(OBJS) Makefile
266
- $(ECHO) linking shared-object $(DLLIB)
267
- -$(Q)$(RM) $(@)
268
- $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
269
- $(Q) $(POSTLINK)
270
-
271
-
272
-
273
- $(OBJS): $(HDRS) $(ruby_headers)
data/ext/capture.o DELETED
Binary file
data/ext/extconf.h DELETED
@@ -1,5 +0,0 @@
1
- #ifndef EXTCONF_H
2
- #define EXTCONF_H
3
- #define HAVE_RB_FIBER_CURRENT 1
4
- #define HAVE_RB_EXT_RACTOR_SAFE 1
5
- #endif
data/ext/fiber.o DELETED
Binary file
data/ext/mkmf.log DELETED
@@ -1,69 +0,0 @@
1
- have_func: checking for rb_fiber_current()... -------------------- yes
2
-
3
- DYLD_LIBRARY_PATH=.:/Users/samuel/.rubies/ruby-3.4.2/lib ASAN_OPTIONS=detect_leaks=0 "clang -o conftest -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0/arm64-darwin24 -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0/ruby/backward -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef -pipe -Wall -Wno-unknown-pragmas -std=c99 conftest.c -L. -L/Users/samuel/.rubies/ruby-3.4.2/lib -L/opt/local/lib -L. -fstack-protector-strong -L/opt/local/lib -arch arm64 -lruby.3.4-static -framework CoreFoundation -lgmp -ldl -lobjc -lpthread -lpthread "
4
- ld: warning: ignoring duplicate libraries: '-lpthread'
5
- checked program was:
6
- /* begin */
7
- 1: #include "ruby.h"
8
- 2:
9
- 3: int main(int argc, char **argv)
10
- 4: {
11
- 5: return !!argv[argc];
12
- 6: }
13
- /* end */
14
-
15
- DYLD_LIBRARY_PATH=.:/Users/samuel/.rubies/ruby-3.4.2/lib ASAN_OPTIONS=detect_leaks=0 "clang -o conftest -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0/arm64-darwin24 -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0/ruby/backward -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef -pipe -Wall -Wno-unknown-pragmas -std=c99 conftest.c -L. -L/Users/samuel/.rubies/ruby-3.4.2/lib -L/opt/local/lib -L. -fstack-protector-strong -L/opt/local/lib -arch arm64 -lruby.3.4-static -framework CoreFoundation -lgmp -ldl -lobjc -lpthread -lpthread "
16
- ld: warning: ignoring duplicate libraries: '-lpthread'
17
- checked program was:
18
- /* begin */
19
- 1: #include "ruby.h"
20
- 2:
21
- 3: /*top*/
22
- 4: extern int t(void);
23
- 5: int main(int argc, char **argv)
24
- 6: {
25
- 7: if (argc > 1000000) {
26
- 8: int (* volatile tp)(void)=(int (*)(void))&t;
27
- 9: printf("%d", (*tp)());
28
- 10: }
29
- 11:
30
- 12: return !!argv[argc];
31
- 13: }
32
- 14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_fiber_current; return !p; }
33
- /* end */
34
-
35
- --------------------
36
-
37
- have_func: checking for rb_ext_ractor_safe()... -------------------- yes
38
-
39
- DYLD_LIBRARY_PATH=.:/Users/samuel/.rubies/ruby-3.4.2/lib ASAN_OPTIONS=detect_leaks=0 "clang -o conftest -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0/arm64-darwin24 -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0/ruby/backward -I/Users/samuel/.rubies/ruby-3.4.2/include/ruby-3.4.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef -pipe -Wall -Wno-unknown-pragmas -std=c99 conftest.c -L. -L/Users/samuel/.rubies/ruby-3.4.2/lib -L/opt/local/lib -L. -fstack-protector-strong -L/opt/local/lib -arch arm64 -lruby.3.4-static -framework CoreFoundation -lgmp -ldl -lobjc -lpthread -lpthread "
40
- ld: warning: ignoring duplicate libraries: '-lpthread'
41
- checked program was:
42
- /* begin */
43
- 1: #include "ruby.h"
44
- 2:
45
- 3: /*top*/
46
- 4: extern int t(void);
47
- 5: int main(int argc, char **argv)
48
- 6: {
49
- 7: if (argc > 1000000) {
50
- 8: int (* volatile tp)(void)=(int (*)(void))&t;
51
- 9: printf("%d", (*tp)());
52
- 10: }
53
- 11:
54
- 12: return !!argv[argc];
55
- 13: }
56
- 14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_ext_ractor_safe; return !p; }
57
- /* end */
58
-
59
- --------------------
60
-
61
- extconf.h is:
62
- /* begin */
63
- 1: #ifndef EXTCONF_H
64
- 2: #define EXTCONF_H
65
- 3: #define HAVE_RB_FIBER_CURRENT 1
66
- 4: #define HAVE_RB_EXT_RACTOR_SAFE 1
67
- 5: #endif
68
- /* end */
69
-
data/ext/profiler.o DELETED
Binary file
data/ext/time.o DELETED
Binary file