fiber-profiler 0.3.1 → 0.5.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: babeb0fbb4a600a487a2f90ad86f7f98a393978055a3409d8c67084e5f649a26
4
- data.tar.gz: 62ab31b197bfa49f84fbf5c03d2f5fd59321e84bffab755b5c3b5387a9d27eea
3
+ metadata.gz: 1d62567e3ffd2eb3e9fd7ff6ad432d1fdda2d5d23f73284fdc91b4407851bd98
4
+ data.tar.gz: d37839a3d1c08c12b4a0dadd808c46698678a7b8f646ead271a5defd5ffe4427
5
5
  SHA512:
6
- metadata.gz: 13a477d15ba50e6c858b63a0250493c48eb6ea26256340ea46de57effbdc6ac87ced1e3a51c0f7b3c8c74b8538b59c29730146e22a532fb913f79a5ff5c03531
7
- data.tar.gz: d9d93e687484c38033cbe68778c6e018b323e9b1281480a35cf3cf6dbc2809d75712faf6318527482242373c2af01dc2ec9cfcc64a612c8725bfdb5890cf0017
6
+ metadata.gz: e7a5b9dcbfd5c80c735dd36c2961e16c2cc97bc4f1a1496f612b36552fb03a7993c0da17d0fe81d2519d0760607c51a9c36573c4ceaa249cb4d201fa1154b92d
7
+ data.tar.gz: f1ff0b98c24d6c15736c3d15da1375f73f3c2fc6608d2669c554d6ae773ec8df7e21921599f314750bb99da8aeaa518f9607bc5982e8b81ce429b3acf308dd1a
checksums.yaml.gz.sig CHANGED
Binary file
data/ext/extconf.rb CHANGED
@@ -9,12 +9,12 @@ require "mkmf"
9
9
  gem_name = File.basename(__dir__)
10
10
  extension_name = "Fiber_Profiler"
11
11
 
12
- $CFLAGS << " -Wall -Wno-unknown-pragmas -std=c99"
12
+ append_cflags(["-Wall", "-Wno-unknown-pragmas", "-std=c99"])
13
13
 
14
14
  if ENV.key?("RUBY_DEBUG")
15
15
  $stderr.puts "Enabling debug mode..."
16
16
 
17
- $CFLAGS << " -DRUBY_DEBUG -O0"
17
+ append_cflags(["-DRUBY_DEBUG", "-O0"])
18
18
  end
19
19
 
20
20
  $srcs = ["fiber/profiler/profiler.c", "fiber/profiler/time.c", "fiber/profiler/fiber.c", "fiber/profiler/capture.c"]
@@ -754,14 +754,40 @@ void Fiber_Profiler_Capture_print_json(struct Fiber_Profiler_Capture *capture, F
754
754
  fprintf(stream, ",\"switches\":%zu,\"samples\":%zu,\"stalls\":%zu}\n", capture->switches, capture->samples, capture->stalls);
755
755
  }
756
756
 
757
+ VALUE output_write(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, data))
758
+ {
759
+ struct Fiber_Profiler_Capture *capture = (struct Fiber_Profiler_Capture*)data;
760
+
761
+ // Actually perform the write to IO here.
762
+ rb_io_write(
763
+ capture->output,
764
+ rb_str_new_static(capture->stream.buffer, capture->stream.size)
765
+ );
766
+
767
+ return Qnil;
768
+ }
769
+
757
770
  void Fiber_Profiler_Capture_print(struct Fiber_Profiler_Capture *capture, double duration) {
771
+ static VALUE Fiber = Qnil;
772
+
773
+ if (Fiber == Qnil) {
774
+ Fiber = rb_const_get(rb_cObject, rb_intern("Fiber"));
775
+ }
776
+
758
777
  if (capture->output == Qnil) return;
759
778
 
760
779
  FILE *stream = capture->stream.file;
761
780
  capture->print(capture, stream, duration);
762
781
  fflush(stream);
763
782
 
764
- rb_io_write(capture->output, rb_str_new_static(capture->stream.buffer, capture->stream.size));
783
+ // Do the actual write in Fiber.blocking.
784
+ rb_block_call(
785
+ Fiber,
786
+ rb_intern("blocking"),
787
+ 0, NULL, // no args
788
+ output_write,
789
+ (VALUE)capture
790
+ );
765
791
 
766
792
  fseek(stream, 0, SEEK_SET);
767
793
  }
@@ -7,6 +7,6 @@
7
7
  class Fiber
8
8
  # @namespace
9
9
  module Profiler
10
- VERSION = "0.3.1"
10
+ VERSION = "0.5.0"
11
11
  end
12
12
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiber-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
@@ -37,21 +36,14 @@ cert_chain:
37
36
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
37
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
38
  -----END CERTIFICATE-----
40
- date: 2025-02-15 00:00:00.000000000 Z
39
+ date: 1980-01-02 00:00:00.000000000 Z
41
40
  dependencies: []
42
- description:
43
- email:
44
41
  executables: []
45
42
  extensions:
46
43
  - ext/extconf.rb
47
44
  extra_rdoc_files: []
48
45
  files:
49
- - ext/Fiber_Profiler.bundle
50
- - ext/Makefile
51
- - ext/capture.o
52
- - ext/extconf.h
53
46
  - ext/extconf.rb
54
- - ext/fiber.o
55
47
  - ext/fiber/profiler/capture.c
56
48
  - ext/fiber/profiler/capture.h
57
49
  - ext/fiber/profiler/deque.h
@@ -61,8 +53,6 @@ files:
61
53
  - ext/fiber/profiler/profiler.h
62
54
  - ext/fiber/profiler/time.c
63
55
  - ext/fiber/profiler/time.h
64
- - ext/profiler.o
65
- - ext/time.o
66
56
  - lib/fiber/profiler.rb
67
57
  - lib/fiber/profiler/capture.rb
68
58
  - lib/fiber/profiler/native.rb
@@ -76,7 +66,6 @@ licenses:
76
66
  metadata:
77
67
  documentation_uri: https://socketry.github.io/fiber-profiler/
78
68
  source_code_uri: https://github.com/socketry/fiber-profiler.git
79
- post_install_message:
80
69
  rdoc_options: []
81
70
  require_paths:
82
71
  - lib
@@ -84,15 +73,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
73
  requirements:
85
74
  - - ">="
86
75
  - !ruby/object:Gem::Version
87
- version: '3.1'
76
+ version: '3.2'
88
77
  required_rubygems_version: !ruby/object:Gem::Requirement
89
78
  requirements:
90
79
  - - ">="
91
80
  - !ruby/object:Gem::Version
92
81
  version: '0'
93
82
  requirements: []
94
- rubygems_version: 3.5.16
95
- signing_key:
83
+ rubygems_version: 3.6.7
96
84
  specification_version: 4
97
85
  summary: A fiber stall profiler.
98
86
  test_files: []
metadata.gz.sig CHANGED
Binary file
Binary file
data/ext/Makefile DELETED
@@ -1,270 +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.3.5/include/ruby-3.3.0
17
- hdrdir = $(topdir)
18
- arch_hdrdir = /Users/samuel/.rubies/ruby-3.3.5/include/ruby-3.3.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.3.5
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
- mandir = $(datarootdir)/man
46
- localedir = $(datarootdir)/locale
47
- libdir = $(exec_prefix)/lib
48
- psdir = $(docdir)
49
- pdfdir = $(docdir)
50
- dvidir = $(docdir)
51
- htmldir = $(docdir)
52
- infodir = $(datarootdir)/info
53
- docdir = $(datarootdir)/doc/$(PACKAGE)
54
- oldincludedir = $(DESTDIR)/usr/include
55
- includedir = $(SDKROOT)$(prefix)/include
56
- runstatedir = $(localstatedir)/run
57
- localstatedir = $(prefix)/var
58
- sharedstatedir = $(prefix)/com
59
- sysconfdir = $(prefix)/etc
60
- datadir = $(datarootdir)
61
- datarootdir = $(prefix)/share
62
- libexecdir = $(exec_prefix)/libexec
63
- sbindir = $(exec_prefix)/sbin
64
- bindir = $(exec_prefix)/bin
65
- archdir = $(rubyarchdir)
66
-
67
-
68
- CC_WRAPPER =
69
- CC = clang
70
- CXX = clang++
71
- LIBRUBY = $(LIBRUBY_A)
72
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
73
- LIBRUBYARG_SHARED =
74
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework CoreFoundation $(MAINLIBS)
75
- empty =
76
- OUTFLAG = -o $(empty)
77
- COUTFLAG = -o $(empty)
78
- CSRCFLAG = $(empty)
79
-
80
- RUBY_EXTCONF_H = extconf.h
81
- cflags = -fdeclspec $(optflags) $(debugflags) $(warnflags)
82
- cxxflags =
83
- optflags = -O3 -fno-fast-math
84
- debugflags = -ggdb3
85
- 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
86
- cppflags =
87
- CCDLFLAGS = -fno-common
88
- CFLAGS = $(CCDLFLAGS) $(cflags) -pipe -Wall -Wno-unknown-pragmas -std=c99 $(ARCH_FLAG)
89
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
90
- DEFS =
91
- 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)
92
- CXXFLAGS = $(CCDLFLAGS) -fdeclspec $(ARCH_FLAG)
93
- ldflags = -L. -fstack-protector-strong -L/opt/local/lib
94
- dldflags = -L/opt/local/lib -Wl,-undefined,dynamic_lookup -bundle_loader '$(BUILTRUBY)'
95
- ARCH_FLAG = -arch arm64
96
- DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
97
- LDSHARED = $(CC) -dynamic -bundle
98
- LDSHAREDXX = $(CXX) -dynamic -bundle
99
- AR = ar
100
- EXEEXT =
101
-
102
- RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
103
- RUBY_SO_NAME = ruby.3.3
104
- RUBYW_INSTALL_NAME =
105
- RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
106
- RUBYW_BASE_NAME = rubyw
107
- RUBY_BASE_NAME = ruby
108
-
109
- arch = arm64-darwin24
110
- sitearch = $(arch)
111
- ruby_version = 3.3.0
112
- ruby = $(bindir)/$(RUBY_BASE_NAME)
113
- RUBY = $(ruby)
114
- BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME)
115
- 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)
116
-
117
- RM = rm -f
118
- RM_RF = rm -fr
119
- RMDIRS = rmdir -p
120
- MAKEDIRS = /opt/local/bin/gmkdir -p
121
- INSTALL = /opt/local/bin/ginstall -c
122
- INSTALL_PROG = $(INSTALL) -m 0755
123
- INSTALL_DATA = $(INSTALL) -m 644
124
- COPY = cp
125
- TOUCH = exit >
126
-
127
- #### End of system configuration section. ####
128
-
129
- preload =
130
- libpath = . $(libdir) /opt/local/lib
131
- LIBPATH = -L. -L$(libdir) -L/opt/local/lib
132
- DEFFILE =
133
-
134
- CLEANFILES = mkmf.log
135
- DISTCLEANFILES =
136
- DISTCLEANDIRS =
137
-
138
- extout =
139
- extout_prefix =
140
- target_prefix =
141
- LOCAL_LIBS =
142
- LIBS = -lpthread
143
- ORIG_SRCS =
144
- SRCS = $(ORIG_SRCS) profiler.c time.c fiber.c capture.c
145
- OBJS = profiler.o time.o fiber.o capture.o
146
- HDRS = $(srcdir)/extconf.h
147
- LOCAL_HDRS =
148
- TARGET = Fiber_Profiler
149
- TARGET_NAME = Fiber_Profiler
150
- TARGET_ENTRY = Init_$(TARGET_NAME)
151
- DLLIB = $(TARGET).bundle
152
- EXTSTATIC =
153
- STATIC_LIB =
154
-
155
- TIMESTAMP_DIR = .
156
- BINDIR = $(bindir)
157
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
158
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
159
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
160
- HDRDIR = $(sitehdrdir)$(target_prefix)
161
- ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix)
162
- TARGET_SO_DIR =
163
- TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
164
- CLEANLIBS = $(TARGET_SO) $(TARGET_SO).dSYM
165
- CLEANOBJS = $(OBJS) *.bak
166
- TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.time
167
-
168
- all: $(DLLIB)
169
- static: $(STATIC_LIB)
170
- .PHONY: all install static install-so install-rb
171
- .PHONY: clean clean-so clean-static clean-rb
172
-
173
- clean-static::
174
- clean-rb-default::
175
- clean-rb::
176
- clean-so::
177
- clean: clean-so clean-static clean-rb-default clean-rb
178
- -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
179
-
180
- distclean-rb-default::
181
- distclean-rb::
182
- distclean-so::
183
- distclean-static::
184
- distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
185
- -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
186
- -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
187
- -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
188
-
189
- realclean: distclean
190
- install: install-so install-rb
191
-
192
- install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP)
193
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
194
- clean-static::
195
- -$(Q)$(RM) $(STATIC_LIB)
196
- install-rb: pre-install-rb do-install-rb install-rb-default
197
- install-rb-default: pre-install-rb-default do-install-rb-default
198
- pre-install-rb: Makefile
199
- pre-install-rb-default: Makefile
200
- do-install-rb:
201
- do-install-rb-default:
202
- pre-install-rb-default:
203
- @$(NULLCMD)
204
- $(TARGET_SO_DIR_TIMESTAMP):
205
- $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
206
- $(Q) $(TOUCH) $@
207
-
208
- site-install: site-install-so site-install-rb
209
- site-install-so: install-so
210
- site-install-rb: install-rb
211
-
212
- .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
213
-
214
- .cc.o:
215
- $(ECHO) compiling $(<)
216
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
217
-
218
- .cc.S:
219
- $(ECHO) translating $(<)
220
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
221
-
222
- .mm.o:
223
- $(ECHO) compiling $(<)
224
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
225
-
226
- .mm.S:
227
- $(ECHO) translating $(<)
228
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
229
-
230
- .cxx.o:
231
- $(ECHO) compiling $(<)
232
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
233
-
234
- .cxx.S:
235
- $(ECHO) translating $(<)
236
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
237
-
238
- .cpp.o:
239
- $(ECHO) compiling $(<)
240
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
241
-
242
- .cpp.S:
243
- $(ECHO) translating $(<)
244
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
245
-
246
- .c.o:
247
- $(ECHO) compiling $(<)
248
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
249
-
250
- .c.S:
251
- $(ECHO) translating $(<)
252
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
253
-
254
- .m.o:
255
- $(ECHO) compiling $(<)
256
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
257
-
258
- .m.S:
259
- $(ECHO) translating $(<)
260
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
261
-
262
- $(TARGET_SO): $(OBJS) Makefile
263
- $(ECHO) linking shared-object $(DLLIB)
264
- -$(Q)$(RM) $(@)
265
- $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
266
- $(Q) $(POSTLINK)
267
-
268
-
269
-
270
- $(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/profiler.o DELETED
Binary file
data/ext/time.o DELETED
Binary file