pyroscope 0.0.10 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -0
- data/Rakefile +15 -1
- data/ext/pyroscope/Makefile.example +265 -0
- data/ext/pyroscope/extconf.rb +39 -15
- data/ext/pyroscope/lib/.gitkeep +0 -0
- data/ext/pyroscope/lib/libpyroscope.rbspy.a +0 -0
- data/ext/pyroscope/lib/libpyroscope.rbspy.combo.a +0 -0
- data/ext/pyroscope/lib/librustdeps.a +0 -0
- data/ext/pyroscope/pyroscope.c +6 -4
- data/lib/pyroscope.rb +1 -1
- data/lib/pyroscope/version.rb +1 -1
- data/test.rb +38 -8
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76993115eef4fc1b362e927bebb25727ec82ff9fb7015e344da5746f9c4c76bb
|
4
|
+
data.tar.gz: be474b604626cb0c1818a9f0348bb95941721e4c4ad7fa78c0b50cff7ce52e3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be636ff348bf2ee331acf07f14ea260de35b0f1e78a2265733a9952124fc0588cc96b286ba0e362c118d17f1085946cb054a9f24feb90e4ae8590ead6b338db8
|
7
|
+
data.tar.gz: 050e2d247e3b5742035f7c0957243d272230d08111927af81d1a638e01ad0334dca886b3c9673d3544b1acaef5f4cdbc2b9bcef6dd61dd301c4370149cae8ce8
|
data/Gemfile.lock
CHANGED
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 "
|
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)
|
data/ext/pyroscope/extconf.rb
CHANGED
@@ -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 = "
|
12
|
+
COMMIT = "3ad06ea"
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
35
|
-
|
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
|
-
#
|
38
|
-
# system "
|
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
|
Binary file
|
data/ext/pyroscope/pyroscope.c
CHANGED
@@ -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
|
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,
|
50
|
+
rb_define_module_function(rb_Pyroscope, "_change_name", pyroscope_change_name, 2);
|
49
51
|
}
|
data/lib/pyroscope.rb
CHANGED
data/lib/pyroscope/version.rb
CHANGED
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
|
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
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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.
|
4
|
+
version: 0.0.16
|
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-
|
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: []
|