skylight 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/skylight.rb +3 -0
- data/lib/skylight/config.rb +1 -1
- data/lib/skylight/gc.rb +19 -9
- data/lib/skylight/instrumenter.rb +7 -1
- data/lib/skylight/messages/trace.rb +3 -1
- data/lib/skylight/version.rb +1 -1
- data/lib/skylight/vm/gc.rb +68 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 560f8a033762d7bf39d090b9aefed3b9c754c7dd
|
4
|
+
data.tar.gz: 5c1628596dcf13425d22c8a9a9ec4974f2179d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a2bac2b3dadfcc72088c27be115ba207f5b5e1da7b59d979c2f76b8ce1d35c978e2b1bbc457c557a93070d46d3b3d1e8a0777d94a5d621917a3fc4e006e587c
|
7
|
+
data.tar.gz: 5060b3d9efc2a6ea197eece768f5c28481eb6716d9f8a2230607c429d88ae8509bbb5dbcace6c183e79f227f0951a737722b331b8afdd1abe05197072b62e9fd
|
data/lib/skylight.rb
CHANGED
data/lib/skylight/config.rb
CHANGED
data/lib/skylight/gc.rb
CHANGED
@@ -2,7 +2,7 @@ require 'thread'
|
|
2
2
|
|
3
3
|
module Skylight
|
4
4
|
class GC
|
5
|
-
METHODS = [ :enable, :total_time
|
5
|
+
METHODS = [ :enable, :total_time ]
|
6
6
|
TH_KEY = :SK_GC_CURR_WINDOW
|
7
7
|
|
8
8
|
include Util::Logging
|
@@ -27,9 +27,11 @@ module Skylight
|
|
27
27
|
@listeners = []
|
28
28
|
@config = config
|
29
29
|
@lock = Mutex.new
|
30
|
+
@time = 0.0
|
30
31
|
|
31
32
|
if METHODS.all? { |m| profiler.respond_to?(m) }
|
32
33
|
@profiler = profiler
|
34
|
+
@time = @profiler.total_time
|
33
35
|
else
|
34
36
|
debug "disabling GC profiling"
|
35
37
|
end
|
@@ -48,6 +50,7 @@ module Skylight
|
|
48
50
|
win = Window.new(self)
|
49
51
|
|
50
52
|
@lock.synchronize do
|
53
|
+
__update
|
51
54
|
@listeners << win
|
52
55
|
end
|
53
56
|
end
|
@@ -82,19 +85,26 @@ module Skylight
|
|
82
85
|
|
83
86
|
def update
|
84
87
|
@lock.synchronize do
|
85
|
-
|
86
|
-
|
87
|
-
if time > 0
|
88
|
-
@profiler.clear
|
89
|
-
@listeners.each do |l|
|
90
|
-
l.add(time)
|
91
|
-
end
|
92
|
-
end
|
88
|
+
__update
|
93
89
|
end
|
94
90
|
|
95
91
|
nil
|
96
92
|
end
|
97
93
|
|
94
|
+
private
|
95
|
+
|
96
|
+
def __update
|
97
|
+
time = @profiler.total_time
|
98
|
+
diff = time - @time
|
99
|
+
@time = time
|
100
|
+
|
101
|
+
if diff > 0.0
|
102
|
+
@listeners.each do |l|
|
103
|
+
l.add(diff)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
98
108
|
class Window
|
99
109
|
attr_reader :time
|
100
110
|
|
@@ -95,7 +95,13 @@ module Skylight
|
|
95
95
|
if built && built.valid?
|
96
96
|
process(built)
|
97
97
|
else
|
98
|
-
|
98
|
+
if built && built.spans.empty?
|
99
|
+
debug "trace invalid -- dropping; spans=0"
|
100
|
+
elsif built
|
101
|
+
debug "trace invalid -- dropping; spans=%d; started_at=%d", built.spans, built.spans[-1].started_at
|
102
|
+
else
|
103
|
+
debug "trace invalid -- dropping; trace=nil"
|
104
|
+
end
|
99
105
|
end
|
100
106
|
rescue Exception => e
|
101
107
|
error e
|
@@ -121,7 +121,9 @@ module Skylight
|
|
121
121
|
|
122
122
|
if sp.started_at < 0
|
123
123
|
@busted = true
|
124
|
-
raise TraceError, "[BUG] span started_at negative; event=#{cat}"
|
124
|
+
raise TraceError, "[BUG] span started_at negative; event=#{cat};" \
|
125
|
+
" started_at=#{sp.started_at};" \
|
126
|
+
" duration=#{sp.duration}"
|
125
127
|
end
|
126
128
|
|
127
129
|
sp
|
data/lib/skylight/version.rb
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
module Skylight
|
3
|
+
module VM
|
4
|
+
if defined?(JRUBY_VERSION)
|
5
|
+
|
6
|
+
# This doesn't quite work as we would like it. I believe that the GC
|
7
|
+
# statistics includes time that is not stop-the-world, this does not
|
8
|
+
# necessarily take time away from the application.
|
9
|
+
#
|
10
|
+
# require 'java'
|
11
|
+
# class GC
|
12
|
+
# def initialize
|
13
|
+
# @factory = Java::JavaLangManagement::ManagementFactory
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# def enable
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# def total_time
|
20
|
+
# res = 0.0
|
21
|
+
#
|
22
|
+
# @factory.garbage_collector_mx_beans.each do |mx|
|
23
|
+
# res += (mx.collection_time.to_f / 1_000.0)
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# res
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
|
30
|
+
elsif defined?(::GC::Profiler)
|
31
|
+
|
32
|
+
class GC
|
33
|
+
def initialize
|
34
|
+
@total = 0.0
|
35
|
+
end
|
36
|
+
|
37
|
+
def enable
|
38
|
+
::GC::Profiler.enable
|
39
|
+
end
|
40
|
+
|
41
|
+
def total_time
|
42
|
+
run = ::GC::Profiler.total_time
|
43
|
+
|
44
|
+
if run > 0
|
45
|
+
::GC::Profiler.clear
|
46
|
+
end
|
47
|
+
|
48
|
+
@total += run
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# Fallback
|
55
|
+
unless defined?(VM::GC)
|
56
|
+
|
57
|
+
class GC
|
58
|
+
def enable
|
59
|
+
end
|
60
|
+
|
61
|
+
def total_time
|
62
|
+
0.0
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skylight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilde, Inc.
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/skylight/vendor/thread_safe/non_concurrent_cache_backend.rb
|
132
132
|
- lib/skylight/vendor/thread_safe/synchronized_cache_backend.rb
|
133
133
|
- lib/skylight/version.rb
|
134
|
+
- lib/skylight/vm/gc.rb
|
134
135
|
- lib/skylight/worker.rb
|
135
136
|
- lib/skylight/worker/builder.rb
|
136
137
|
- lib/skylight/worker/collector.rb
|