pyroscope 0.0.9 → 0.0.14

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: 28612d2ce21afe9f36931bc3c971fa7908aaca018dd970c8c24664a84485bde4
4
- data.tar.gz: a9b1febfcf52c6fdaa8a985a070b12a36d1ff8b2e97bfa71fe8991d8749c2c10
3
+ metadata.gz: 619c59b1c6e494e5e1b4b47889ea9de7eed5c44264ec0bd9f1372ea87c6a94d0
4
+ data.tar.gz: d4c3632f2ee191e8bb60529bd5699e11100500cc3ca1cbb4d119a183c38e279d
5
5
  SHA512:
6
- metadata.gz: 1dbf7be4d92a34e24bb0aa2086fc18f7296b6ce0cb0eb5a7bddd73e644e2c36bd97928f4d8f3bc7e1e3efc9453322bd2cbc3ccf4906d55e4911be4aeb8514049
7
- data.tar.gz: 10fd626b436fa02ab2243cbdc2169d33b2ab4a2af6de26413b0b3640124433943ca63e0b70bb70e467dc25ae7a026e04f44805bad3dab905f22a88f2cd7b0f27
6
+ metadata.gz: 98d120335fbe70f9527e4f9eeb3678dd8db7dfac0aefb1e44fb639c499911ddec9370bb91e9f22bd9ecda519cb3fa92e6982dd9eda135e7be9efe3f26042295d
7
+ data.tar.gz: '09f603d60123a92e983ac22eeefff6468e047edc99f5cffd4278dfa94e51fc837522daa669838430459bf0009f14eef4d31c1aaae8c647b0196bcd4bedeb0cb6'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pyroscope (0.0.9)
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,21 @@ 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
+ extra_env = "PYROSCOPE_RUBY_LOCAL=1"
52
+ extra_env = ""
53
+
54
+ system "#{extra_env} rake build && #{extra_env} sudo -E gem install pkg/pyroscope-#{Pyroscope::VERSION}.gem && sudo -E ruby test.rb"
55
+ end
56
+
57
+ task :test_exec do
58
+ # system "cd ../pyroscope && DOCKER_BUILDKIT=1 docker build -f Dockerfile.static-libs --output type=local,dest=out ." if RUBY_PLATFORM.include?("linux")
59
+ system "sudo -E pyroscope exec ruby test.rb"
46
60
  end
47
61
 
48
62
  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 = "5a6a823"
12
+ COMMIT = "a263249"
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,23 +19,47 @@ 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
+ ["libpyroscope.rbspy.a", "librustdeps.a"].each do |name|
29
+ url = PREFIX+"/#{name}.gz"
30
+ req = Net::HTTP::Get.new(url)
31
+ http.request(req) do |resp|
32
+ raise "HTTP error: #{resp.code}" unless resp.code == "200"
27
33
 
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
34
+ r, w = IO.pipe
35
+
36
+ t = Thread.new do
37
+ zreader = Zlib::GzipReader.new(r)
38
+ File.open(File.join(ROOT, "lib/#{name}"), "wb") do |f|
39
+ loop do
40
+ begin
41
+ chunk = zreader.readpartial(32768)
42
+ break if chunk.nil?
43
+ rescue EOFError
44
+ break
45
+ end
46
+ f.write(chunk)
47
+ end
48
+ end
49
+ end
33
50
 
34
- # TODO: figure out how to fix this bug
35
- system "strip --strip-debug #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}"
51
+ resp.read_body do |chunk|
52
+ w.write(chunk)
53
+ end
54
+
55
+ t.join
56
+ end
57
+ end
58
+ end
59
+ end
36
60
 
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")}"
61
+ # this is now done upstream
62
+ # system "strip --strip-debug #{File.join(ROOT, "lib/libpyroscope.rbspy.combo.a")}"
39
63
 
40
64
  dir_config('pyroscope', HEADER_DIRS, LIB_DIRS)
41
65
 
File without changes
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.9".freeze
2
+ VERSION = "0.0.14".freeze
3
3
  end
data/test.rb CHANGED
@@ -3,19 +3,49 @@ require 'pyroscope'
3
3
  puts "prestart #{Process.pid}"
4
4
 
5
5
  Pyroscope.configure do |config|
6
- config.app_name = "test.app.ruby2.cpu{}"
6
+ config.app_name = "test.ruby.app{}"
7
7
  config.server_address = "http://localhost:4040/"
8
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.9
4
+ version: 0.0.14
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,11 @@ files:
92
92
  - Gemfile.lock
93
93
  - README.md
94
94
  - Rakefile
95
+ - ext/pyroscope/Makefile.example
95
96
  - ext/pyroscope/extconf.rb
97
+ - ext/pyroscope/lib/.gitkeep
96
98
  - ext/pyroscope/lib/libpyroscope.rbspy.a
99
+ - ext/pyroscope/lib/libpyroscope.rbspy.combo.a
97
100
  - ext/pyroscope/lib/librustdeps.a
98
101
  - ext/pyroscope/pyroscope.c
99
102
  - lib/pyroscope.rb
@@ -104,7 +107,7 @@ homepage: http://rubygems.org/gems/pyroscope
104
107
  licenses:
105
108
  - Apache-2.0
106
109
  metadata: {}
107
- post_install_message:
110
+ post_install_message:
108
111
  rdoc_options: []
109
112
  require_paths:
110
113
  - lib
@@ -121,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
124
  version: '0'
122
125
  requirements: []
123
126
  rubygems_version: 3.2.15
124
- signing_key:
127
+ signing_key:
125
128
  specification_version: 4
126
129
  summary: pyroscope
127
130
  test_files: []