pyroscope 0.0.7 → 0.0.12

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: 5ac1555d2d06cff731f2c95471dcffd8e1754786b5927085cc09752474d43d1a
4
- data.tar.gz: 6248dddf8b7bdb17255ee289b469818b26f6ec151f6a9b4bca34b40504023cb2
3
+ metadata.gz: 36bb83e12718ebaaceda2abd73fe6aa04b7118186a2532a9a84334a8d9ea78a9
4
+ data.tar.gz: b7c5269520ffb6692ef147d781f7ebc1d1ee71f0810367ab8e9dd39149a5043a
5
5
  SHA512:
6
- metadata.gz: d5bfed7a06eb7f4411e31a7cead20bd64345e70517de0386e4c2584d8c9309dd278d1c94d8a6859d999bdb0b05ec1c20267d773aad0b46342701c668467ccb1f
7
- data.tar.gz: 0af8ba3a6834ecc2ebbbe5bd2cd9f6851a7ef6d7bcd065b7c576d00b81b5c4be4951addbde19f4dab6e63c51b9245ade50a6162e1af7f9985c2dfdb9dd0bbbe0
6
+ metadata.gz: 50d07468d065727335c16c76fec8365f79aee6e10f924dfc8613b2bc2c8307a71db6586bd5efe15391288e86e1132c2bcdfd58b75d3972c9a519080bf4c63306
7
+ data.tar.gz: afd0327de15581b6cb6a48ea34472ce9c3b7ceeb1b39c197ba62b33e4b6fb0125d603d2595fe34a0757e0bb4b60b059a723a9d5fa787097753fd311269c56f26
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pyroscope (0.0.7)
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
@@ -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 = "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
@@ -1,5 +1,5 @@
1
1
  require "pyroscope/version"
2
- require_relative "./pyroscope_c"
2
+ require "pyroscope_c"
3
3
 
4
4
  module Pyroscope
5
5
  Config = Struct.new(:app_name, :server_address)
@@ -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,4 +1,3 @@
1
1
  module Pyroscope
2
- VERSION = "0.0.7".freeze
3
-
2
+ VERSION = "0.0.12".freeze
4
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.7
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: []