pyroscope 0.0.10 → 0.0.12

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: 5e792f0a158e3a62701182d85fc321ae2be3a4c8f94ae00a4dc42d8ae8585a66
4
- data.tar.gz: cf973d165b8bf31688e458f808683d58f838502f559e2bd338fb3bc7a31de65a
3
+ metadata.gz: 36bb83e12718ebaaceda2abd73fe6aa04b7118186a2532a9a84334a8d9ea78a9
4
+ data.tar.gz: b7c5269520ffb6692ef147d781f7ebc1d1ee71f0810367ab8e9dd39149a5043a
5
5
  SHA512:
6
- metadata.gz: 7ba0c187bd82a3f2a8706bcf095a2a913dca8adb5c81b3bb95a4a142fa3cb0ef0a7d61d849d7faabe940fcb90011d1508c3d4bc515d7c5b7a0d0bbc7802cadec
7
- data.tar.gz: 157f08858a63c8293c5472dd5e0994753f8801e2e0f6836a4f295cd2e43e9b4e81cd0c8c06ea6226f6303d0bf8edc5479132041bfc57a449379559d1cc128777
6
+ metadata.gz: 50d07468d065727335c16c76fec8365f79aee6e10f924dfc8613b2bc2c8307a71db6586bd5efe15391288e86e1132c2bcdfd58b75d3972c9a519080bf4c63306
7
+ data.tar.gz: afd0327de15581b6cb6a48ea34472ce9c3b7ceeb1b39c197ba62b33e4b6fb0125d603d2595fe34a0757e0bb4b60b059a723a9d5fa787097753fd311269c56f26
data/Gemfile.lock CHANGED
@@ -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
@@ -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 = "24effc7"
12
+ COMMIT = "bfb9a32"
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,24 +19,27 @@ 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)
27
-
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)
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
+ res1 = http.get(PREFIX+"/libpyroscope.rbspy.a")
29
+ raise "HTTP error: #{res1.code}" unless res1.code == "200"
30
+ lib1 = res1.body
31
+ File.binwrite(File.join(ROOT, "lib/libpyroscope.rbspy.a"), lib1)
32
+
33
+ res2 = http.get(PREFIX+"/librustdeps.a")
34
+ raise "HTTP error: #{res2.code}" unless res2.code == "200"
35
+ lib2 = res2.body
36
+ File.binwrite(File.join(ROOT, "lib/librustdeps.a"), lib2)
37
+ end
32
38
  end
33
39
 
34
40
  # TODO: figure out how to fix this bug
35
41
  system "strip --strip-debug #{File.join(ROOT, "lib/libpyroscope.rbspy.a")}"
36
42
 
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")}"
39
-
40
43
  dir_config('pyroscope', HEADER_DIRS, LIB_DIRS)
41
44
 
42
45
  libs = ['-lpyroscope.rbspy', '-lrustdeps']
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.10".freeze
2
+ VERSION = "0.0.12".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.10
4
+ version: 0.0.12
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-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,7 +104,7 @@ homepage: http://rubygems.org/gems/pyroscope
104
104
  licenses:
105
105
  - Apache-2.0
106
106
  metadata: {}
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubygems_version: 3.2.15
124
- signing_key:
124
+ signing_key:
125
125
  specification_version: 4
126
126
  summary: pyroscope
127
127
  test_files: []