pyroscope 0.0.8 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 636e6eb94acda6f2898c25e4d086c93ae7d897fedc9d4bd57ac482baa6b1c7f7
4
- data.tar.gz: 626bc1113cc58199c9591522a842e2a91d5a42f9b91753f53e327e234f1e191c
3
+ metadata.gz: 42f5e0729331e9002034247e8e90daf55c4efee52fd9c73a09bcf97ea3faf073
4
+ data.tar.gz: a15a4611dd40f44d1a3dd82d3fc15fe92efd3ac61bcba0ea4eb94e94748a34e4
5
5
  SHA512:
6
- metadata.gz: a254c4e5702763ccdcf0350c1f5e4cf85a31fa26eae60a65028715e5b9acbc056711344f10dfa47161449953c87991c537007947cd24c5c95e75395c89a7f0a7
7
- data.tar.gz: 8bd44ff1cc9588d2daebd43bb77e3a5bdb2ef9f567528aa0b0541993a7d977ad35e73a04e9bca0b539890ec81844868785606a0708cf07c5e54d105ebd08c23b
6
+ metadata.gz: 702c84e56457539ce3872df0b9639c0f1ca3d8f70b6a5053a62056bec9cfb52272a99f8a4b9b795fc340dca5b34d9d1b2c02985f4a36ff96ae65f2981da69413
7
+ data.tar.gz: 3c8bef0ab7f2bd2a86e8971eed949ea22e6a4edf1c0ad5bd274ab91c0f8d4538cef49a9ee441c54d0941b173329bd364ba434a17ffa49e2afe9919c52acd3143
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pyroscope (0.0.8)
4
+ pyroscope (0.0.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -34,6 +34,7 @@ GEM
34
34
  PLATFORMS
35
35
  arm64-darwin-20
36
36
  x86_64-darwin-20
37
+ x86_64-linux
37
38
 
38
39
  DEPENDENCIES
39
40
  bundler
data/Rakefile CHANGED
@@ -42,7 +42,19 @@ task :build => [:clean, :compile]
42
42
  task :default => [:build, :spec]
43
43
 
44
44
  task :test do
45
- system "rake build && gem install pkg/pyroscope-#{Pyroscope::VERSION}.gem && sudo -E ruby test.rb"
45
+ system "rsync -a /home/dmitry/rbspy/ /home/dmitry/pyroscope/third_party/local-clones/rbspy"
46
+ # system "cd ../pyroscope && DOCKER_BUILDKIT=1 docker build -f Dockerfile.static-libs --output type=local,dest=out ." if RUBY_PLATFORM.include?("linux")
47
+ system "cd ../pyroscope && rm out/*.a"
48
+ system "cd ../pyroscope && ENABLED_SPIES=rbspy make build-rust-dependencies"
49
+ system "cd ../pyroscope && make build-rbspy-static-library"
50
+ system "cd ../pyroscope && cp third_party/rustdeps/target/x86_64-unknown-linux-gnu/release/librustdeps.a ./out/librustdeps.a"
51
+
52
+ system "PYROSCOPE_RUBY_LOCAL=1 rake build && PYROSCOPE_RUBY_LOCAL=1 sudo -E gem install pkg/pyroscope-#{Pyroscope::VERSION}.gem && sudo -E ruby test.rb"
53
+ end
54
+
55
+ task :test_exec do
56
+ # system "cd ../pyroscope && DOCKER_BUILDKIT=1 docker build -f Dockerfile.static-libs --output type=local,dest=out ." if RUBY_PLATFORM.include?("linux")
57
+ system "sudo -E pyroscope exec ruby test.rb"
46
58
  end
47
59
 
48
60
  task :publish do
@@ -0,0 +1,265 @@
1
+ SHELL = /bin/sh
2
+
3
+ # V=0 quiet, V=1 verbose. other values don't work.
4
+ V = 1
5
+ Q1 = $(V:1=)
6
+ Q = $(Q1:0=@)
7
+ ECHO1 = $(V:1=@ :)
8
+ ECHO = $(ECHO1:0=@ echo)
9
+ NULLCMD = :
10
+
11
+ #### Start of system configuration section. ####
12
+
13
+ srcdir = ../../../../ext/pyroscope
14
+ topdir = /usr/include
15
+ hdrdir = $(topdir)
16
+ arch_hdrdir = /usr/include
17
+ PATH_SEPARATOR = :
18
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
+ prefix = $(DESTDIR)/usr
20
+ rubysitearchprefix = $(sitearchlibdir)/$(RUBY_BASE_NAME)
21
+ rubyarchprefix = $(DESTDIR)/usr/lib64/ruby
22
+ rubylibprefix = $(exec_prefix)/share/ruby
23
+ exec_prefix = $(DESTDIR)/usr
24
+ vendorarchhdrdir = $(vendorhdrdir)/$(arch)
25
+ sitearchhdrdir = $(sitehdrdir)/$(arch)
26
+ rubyarchhdrdir = $(DESTDIR)/usr/include
27
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
28
+ sitehdrdir = $(rubyhdrdir)/site_ruby
29
+ rubyhdrdir = $(DESTDIR)/usr/include
30
+ rubygemsdir = $(DESTDIR)/usr/share/rubygems
31
+ vendorarchdir = $(DESTDIR)/usr/lib64/ruby/vendor_ruby
32
+ vendorlibdir = $(vendordir)
33
+ vendordir = $(DESTDIR)/usr/share/ruby/vendor_ruby
34
+ sitearchdir = $(DESTDIR)/usr/local/lib64/ruby/site_ruby
35
+ sitelibdir = $(sitedir)
36
+ sitedir = $(DESTDIR)/usr/local/share/ruby/site_ruby
37
+ rubyarchdir = $(rubyarchprefix)
38
+ rubylibdir = $(rubylibprefix)
39
+ sitearchincludedir = $(includedir)/$(sitearch)
40
+ archincludedir = $(includedir)/$(arch)
41
+ sitearchlibdir = $(libdir)/$(sitearch)
42
+ archlibdir = $(DESTDIR)/usr/lib64
43
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
44
+ mandir = $(DESTDIR)/usr/share/man
45
+ localedir = $(datarootdir)/locale
46
+ libdir = $(exec_prefix)/lib64
47
+ psdir = $(docdir)
48
+ pdfdir = $(docdir)
49
+ dvidir = $(docdir)
50
+ htmldir = $(docdir)
51
+ infodir = $(DESTDIR)/usr/share/info
52
+ docdir = $(datarootdir)/doc/$(PACKAGE)
53
+ oldincludedir = $(DESTDIR)/usr/include
54
+ includedir = $(DESTDIR)/usr/include
55
+ localstatedir = $(DESTDIR)/var
56
+ sharedstatedir = $(DESTDIR)/var/lib
57
+ sysconfdir = $(DESTDIR)/etc
58
+ datadir = $(DESTDIR)/usr/share
59
+ datarootdir = $(prefix)/share
60
+ libexecdir = $(DESTDIR)/usr/libexec
61
+ sbindir = $(DESTDIR)/usr/sbin
62
+ bindir = $(exec_prefix)/bin
63
+ archdir = $(rubyarchdir)
64
+
65
+
66
+ CC_WRAPPER =
67
+ CC = gcc
68
+ CXX = g++
69
+ LIBRUBY = $(LIBRUBY_SO)
70
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
71
+ LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
72
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static $(MAINLIBS)
73
+ empty =
74
+ OUTFLAG = -o $(empty)
75
+ COUTFLAG = -o $(empty)
76
+ CSRCFLAG = $(empty)
77
+
78
+ RUBY_EXTCONF_H =
79
+ cflags = $(optflags) $(debugflags) $(warnflags)
80
+ cxxflags =
81
+ optflags = -O3
82
+ debugflags = -ggdb3
83
+ warnflags = -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable
84
+ cppflags =
85
+ CCDLFLAGS = -fPIC
86
+ CFLAGS = $(CCDLFLAGS) -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -mtune=generic -fPIC $(ARCH_FLAG)
87
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
88
+ DEFS =
89
+ CPPFLAGS = -I/usr/include $(DEFS) $(cppflags)
90
+ CXXFLAGS = $(CCDLFLAGS) -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -mtune=generic $(ARCH_FLAG)
91
+ ldflags = -L. -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -rdynamic -Wl,-export-dynamic
92
+ dldflags = -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
93
+ ARCH_FLAG = -m64
94
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
95
+ LDSHARED = $(CC) -shared
96
+ LDSHAREDXX = $(CXX) -shared
97
+ AR = gcc-ar
98
+ EXEEXT =
99
+
100
+ RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
101
+ RUBY_SO_NAME = ruby
102
+ RUBYW_INSTALL_NAME =
103
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version_dir_name)
104
+ RUBYW_BASE_NAME = rubyw
105
+ RUBY_BASE_NAME = ruby
106
+
107
+ arch = x86_64-linux
108
+ sitearch = $(arch)
109
+ ruby_version = 3.0.0
110
+ ruby = $(bindir)/$(RUBY_BASE_NAME)
111
+ RUBY = $(ruby)
112
+ 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
113
+
114
+ RM = rm -f
115
+ RM_RF = $(RUBY) -run -e rm -- -rf
116
+ RMDIRS = rmdir --ignore-fail-on-non-empty -p
117
+ MAKEDIRS = /usr/bin/mkdir -p
118
+ INSTALL = /usr/bin/install -c
119
+ INSTALL_PROG = $(INSTALL) -m 0755
120
+ INSTALL_DATA = $(INSTALL) -m 644
121
+ COPY = cp
122
+ TOUCH = exit >
123
+
124
+ #### End of system configuration section. ####
125
+
126
+ preload =
127
+ libpath = . $(archlibdir) /usr/lib64 /home/dmitry/pyroscope-ruby/ext/pyroscope/lib
128
+ LIBPATH = -L. -L$(archlibdir) -L/usr/lib64 -L/home/dmitry/pyroscope-ruby/ext/pyroscope/lib
129
+ DEFFILE =
130
+
131
+ CLEANFILES = mkmf.log
132
+ DISTCLEANFILES =
133
+ DISTCLEANDIRS =
134
+
135
+ extout =
136
+ extout_prefix =
137
+ target_prefix =
138
+ LOCAL_LIBS = -lpyroscope.rbspy -lrustdeps
139
+ LIBS = $(LIBRUBYARG_SHARED) -lm -lc
140
+ ORIG_SRCS = pyroscope.c
141
+ SRCS = $(ORIG_SRCS)
142
+ OBJS = pyroscope.o
143
+ HDRS =
144
+ LOCAL_HDRS =
145
+ TARGET = pyroscope_c
146
+ TARGET_NAME = pyroscope_c
147
+ TARGET_ENTRY = Init_$(TARGET_NAME)
148
+ DLLIB = $(TARGET).so
149
+ EXTSTATIC =
150
+ STATIC_LIB =
151
+
152
+ TIMESTAMP_DIR = .
153
+ BINDIR = $(bindir)
154
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
155
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
156
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
157
+ HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
158
+ ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
159
+ TARGET_SO_DIR =
160
+ TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
161
+ CLEANLIBS = $(TARGET_SO)
162
+ CLEANOBJS = *.o *.bak
163
+
164
+ all: $(DLLIB)
165
+ static: $(STATIC_LIB)
166
+ .PHONY: all install static install-so install-rb
167
+ .PHONY: clean clean-so clean-static clean-rb
168
+
169
+ clean-static::
170
+ clean-rb-default::
171
+ clean-rb::
172
+ clean-so::
173
+ clean: clean-so clean-static clean-rb-default clean-rb
174
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
175
+
176
+ distclean-rb-default::
177
+ distclean-rb::
178
+ distclean-so::
179
+ distclean-static::
180
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
181
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
182
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
183
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
184
+
185
+ realclean: distclean
186
+ install: install-so install-rb
187
+
188
+ install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.time
189
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
190
+ clean-static::
191
+ -$(Q)$(RM) $(STATIC_LIB)
192
+ install-rb: pre-install-rb do-install-rb install-rb-default
193
+ install-rb-default: pre-install-rb-default do-install-rb-default
194
+ pre-install-rb: Makefile
195
+ pre-install-rb-default: Makefile
196
+ do-install-rb:
197
+ do-install-rb-default:
198
+ pre-install-rb-default:
199
+ @$(NULLCMD)
200
+ $(TIMESTAMP_DIR)/.sitearchdir.time:
201
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
202
+ $(Q) $(TOUCH) $@
203
+
204
+ site-install: site-install-so site-install-rb
205
+ site-install-so: install-so
206
+ site-install-rb: install-rb
207
+
208
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
209
+
210
+ .cc.o:
211
+ $(ECHO) compiling $(<)
212
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
213
+
214
+ .cc.S:
215
+ $(ECHO) translating $(<)
216
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
217
+
218
+ .mm.o:
219
+ $(ECHO) compiling $(<)
220
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
221
+
222
+ .mm.S:
223
+ $(ECHO) translating $(<)
224
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
225
+
226
+ .cxx.o:
227
+ $(ECHO) compiling $(<)
228
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
229
+
230
+ .cxx.S:
231
+ $(ECHO) translating $(<)
232
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
233
+
234
+ .cpp.o:
235
+ $(ECHO) compiling $(<)
236
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
237
+
238
+ .cpp.S:
239
+ $(ECHO) translating $(<)
240
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
241
+
242
+ .c.o:
243
+ $(ECHO) compiling $(<)
244
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
245
+
246
+ .c.S:
247
+ $(ECHO) translating $(<)
248
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
249
+
250
+ .m.o:
251
+ $(ECHO) compiling $(<)
252
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
253
+
254
+ .m.S:
255
+ $(ECHO) translating $(<)
256
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
257
+
258
+ $(TARGET_SO): $(OBJS) Makefile
259
+ $(ECHO) linking shared-object $(DLLIB)
260
+ -$(Q)$(RM) $(@)
261
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
262
+
263
+
264
+
265
+ $(OBJS): $(HDRS) $(ruby_headers)
@@ -9,7 +9,7 @@ HEADER_DIRS = [INCLUDEDIR]
9
9
 
10
10
  LIB_DIRS = [LIBDIR, File.expand_path(File.join(File.dirname(__FILE__), "lib"))]
11
11
 
12
- COMMIT = "2e383e4"
12
+ COMMIT = "39a3d9c"
13
13
 
14
14
  # TODO: this is not very accurate, but it works for now
15
15
  OS = RUBY_PLATFORM.include?("darwin") ? "mac" : "linux"
@@ -19,27 +19,48 @@ PREFIX = "/static-libs/#{COMMIT}/#{OS}-#{ARCH}"
19
19
 
20
20
  ROOT = File.expand_path("..", __FILE__)
21
21
 
22
- Net::HTTP.start("dl.pyroscope.io", 443, :use_ssl => true) do |http|
23
- res1 = http.get(PREFIX+"/libpyroscope.rbspy.a")
24
- raise "HTTP error: #{res1.code}" unless res1.code == "200"
25
- lib1 = res1.body
26
- File.binwrite(File.join(ROOT, "lib/libpyroscope.rbspy.a"), lib1)
22
+ if ENV["PYROSCOPE_RUBY_LOCAL"]
23
+ puts "PYROSCOPE_RUBY_LOCAL yes"
24
+ system "cp #{ENV["HOME"]}/pyroscope/out/libpyroscope.rbspy.a #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}"
25
+ system "cp #{ENV["HOME"]}/pyroscope/out/librustdeps.a #{File.join(ROOT, "lib/librustdeps.a")}"
26
+ else
27
+ Net::HTTP.start("dl.pyroscope.io", 443, :use_ssl => true) do |http|
28
+ req = Net::HTTP::Get.new(PREFIX+"/libpyroscope.rbspy.combo.a.gz")
29
+ http.request(req) do |resp|
30
+ raise "HTTP error: #{resp.code}" unless resp.code == "200"
27
31
 
28
- res2 = http.get(PREFIX+"/librustdeps.a")
29
- raise "HTTP error: #{res2.code}" unless res2.code == "200"
30
- lib2 = res2.body
31
- File.binwrite(File.join(ROOT, "lib/librustdeps.a"), lib2)
32
- end
32
+ r, w = IO.pipe
33
+
34
+ t = Thread.new do
35
+ zreader = Zlib::GzipReader.new(r)
36
+ File.open(File.join(ROOT, "lib/libpyroscope.rbspy.combo.a"), "wb") do |f|
37
+ loop do
38
+ begin
39
+ chunk = zreader.readpartial(32768)
40
+ break if chunk.nil?
41
+ rescue EOFError
42
+ break
43
+ end
44
+ f.write(chunk)
45
+ end
46
+ end
47
+ end
33
48
 
34
- # TODO: figure out how to fix this bug
35
- system "strip --strip-debug #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}"
49
+ resp.read_body do |chunk|
50
+ w.write(chunk)
51
+ end
52
+
53
+ t.join
54
+ end
55
+ end
56
+ end
36
57
 
37
- # system "cp /Users/dmitry/Dev/ps/pyroscope/out/libpyroscope.rbspy.a #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}"
38
- # system "cp /Users/dmitry/Dev/ps/pyroscope/third_party/rustdeps/target/release/librustdeps.a #{File.join(ROOT, "lib/librustdeps.a")}"
58
+ # this is now done upstream
59
+ # system "strip --strip-debug #{File.join(ROOT, "lib/libpyroscope.rbspy.combo.a")}"
39
60
 
40
61
  dir_config('pyroscope', HEADER_DIRS, LIB_DIRS)
41
62
 
42
- libs = ['-lpyroscope.rbspy', '-lrustdeps']
63
+ libs = ['-lpyroscope.rbspy.combo']
43
64
  libs.each do |lib|
44
65
  $LOCAL_LIBS << "#{lib} "
45
66
  end
Binary file
Binary file
@@ -8,7 +8,7 @@ static VALUE rb_Pyroscope;
8
8
 
9
9
  int Start(char*, int, char*, char*);
10
10
  int Stop(int);
11
- int ChangeName(char*);
11
+ int ChangeName(char*, int);
12
12
 
13
13
  static VALUE
14
14
  pyroscope_start(VALUE self, VALUE appName, VALUE pid, VALUE serverAddress) {
@@ -33,10 +33,12 @@ pyroscope_stop(VALUE self, VALUE pid) {
33
33
  }
34
34
 
35
35
  static VALUE
36
- pyroscope_change_name(VALUE self, VALUE appName) {
36
+ pyroscope_change_name(VALUE self, VALUE appName, VALUE pid) {
37
37
  VALUE r_appName = StringValue(appName);
38
38
  char *c_appName = RSTRING_PTR(r_appName);
39
- int res = ChangeName(c_appName);
39
+ int c_pid = FIX2INT(pid);
40
+
41
+ int res = ChangeName(c_appName, c_pid);
40
42
  return INT2FIX(res);
41
43
  }
42
44
 
@@ -45,5 +47,5 @@ Init_pyroscope_c() {
45
47
  rb_Pyroscope = rb_define_module("Pyroscope");
46
48
  rb_define_module_function(rb_Pyroscope, "_start", pyroscope_start, 3);
47
49
  rb_define_module_function(rb_Pyroscope, "_stop", pyroscope_stop, 1);
48
- rb_define_module_function(rb_Pyroscope, "_change_name", pyroscope_change_name, 1);
50
+ rb_define_module_function(rb_Pyroscope, "_change_name", pyroscope_change_name, 2);
49
51
  }
data/lib/pyroscope.rb CHANGED
@@ -19,6 +19,6 @@ module Pyroscope
19
19
  end
20
20
 
21
21
  def self.change_name(new_name)
22
- _change_name(new_name)
22
+ _change_name(new_name, Process.pid)
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module Pyroscope
2
- VERSION = "0.0.8".freeze
2
+ VERSION = "0.0.13".freeze
3
3
  end
data/test.rb CHANGED
@@ -1,21 +1,51 @@
1
- require 'pyroscope'
1
+ # require 'pyroscope'
2
2
 
3
3
  puts "prestart #{Process.pid}"
4
4
 
5
- Pyroscope.configure do |config|
6
- config.app_name = "test.app.ruby2.cpu{}"
7
- config.server_address = "http://localhost:4040/"
8
- end
5
+ # Pyroscope.configure do |config|
6
+ # config.app_name = "test.ruby.app{}"
7
+ # config.server_address = "http://localhost:4040/"
8
+ # end
9
9
 
10
10
  puts "start"
11
- i=0
11
+ iteration=0
12
12
  st = Time.new
13
+
14
+ def work(n)
15
+ i = 0
16
+ while i < n
17
+ i += 1
18
+ end
19
+ end
20
+
21
+ def job_0
22
+ work(rand()*1_000_000)
23
+ end
24
+
25
+ def job_1
26
+ work(rand()*2_000_000)
27
+ end
28
+
29
+ def sleep_job
30
+ sleep(rand()*10)
31
+ end
32
+
33
+
13
34
  while true
14
- i+=1
15
- # puts Time.new - st
16
- if Time.new - st > 5
17
- puts "new name " + "test.app.ruby2.cpu{iteration=#{i}}"
18
- Pyroscope.change_name("test.app.ruby2.cpu{iteration=#{i}}")
19
- st = Time.new
35
+ iteration+=1
36
+
37
+ r = rand
38
+ if r < 0.1
39
+ sleep_job
40
+ elsif r < 0.5
41
+ puts(" * test.ruby.app{job=0}")
42
+ # Pyroscope.change_name("test.ruby.app{job=0}")
43
+ job_0
44
+ # Pyroscope.change_name("test.ruby.app{}")
45
+ else
46
+ puts(" * test.ruby.app{job=1}")
47
+ # Pyroscope.change_name("test.ruby.app{job=1}")
48
+ job_1
49
+ # Pyroscope.change_name("test.ruby.app{}")
20
50
  end
21
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyroscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pyroscope Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-15 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,8 +92,10 @@ files:
92
92
  - Gemfile.lock
93
93
  - README.md
94
94
  - Rakefile
95
+ - ext/pyroscope/Makefile.example
95
96
  - ext/pyroscope/extconf.rb
96
97
  - ext/pyroscope/lib/libpyroscope.rbspy.a
98
+ - ext/pyroscope/lib/libpyroscope.rbspy.combo.a
97
99
  - ext/pyroscope/lib/librustdeps.a
98
100
  - ext/pyroscope/pyroscope.c
99
101
  - lib/pyroscope.rb
@@ -104,7 +106,7 @@ homepage: http://rubygems.org/gems/pyroscope
104
106
  licenses:
105
107
  - Apache-2.0
106
108
  metadata: {}
107
- post_install_message:
109
+ post_install_message:
108
110
  rdoc_options: []
109
111
  require_paths:
110
112
  - lib
@@ -121,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  version: '0'
122
124
  requirements: []
123
125
  rubygems_version: 3.2.15
124
- signing_key:
126
+ signing_key:
125
127
  specification_version: 4
126
128
  summary: pyroscope
127
129
  test_files: []