Class: Skylight::Core::GC Private
- Inherits:
-
Object
- Object
- Skylight::Core::GC
- Includes:
- Util::Logging
- Defined in:
- lib/skylight/core/gc.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Window
Constant Summary collapse
- METHODS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ :enable, :total_time ]
- TH_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:SK_GC_CURR_WINDOW- MAX_COUNT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1000- MAX_TIME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
30_000_000
Instance Attribute Summary collapse
- #config ⇒ Object readonly private
Instance Method Summary collapse
- #enable ⇒ Object private
-
#initialize(config, profiler) ⇒ GC
constructor
private
A new instance of GC.
- #release(win) ⇒ Object private
-
#total_time ⇒ Object
private
Total time in microseconds for GC over entire process lifetime.
- #track ⇒ Object private
- #update ⇒ Object private
Methods included from Util::Logging
#config_for_logging, #debug, #error, #fmt, #info, #log, #log_context, #log_env_prefix, #raise_on_error?, #t, #trace, #trace?, #warn
Constructor Details
#initialize(config, profiler) ⇒ GC
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of GC.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/skylight/core/gc.rb', line 15 def initialize(config, profiler) @listeners = [] @config = config @lock = Mutex.new @time = 0 if METHODS.all? { |m| profiler.respond_to?(m) } @profiler = profiler @time = @profiler.total_time else debug "disabling GC profiling" end end |
Instance Attribute Details
#config ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/skylight/core/gc.rb', line 13 def config @config end |
Instance Method Details
#enable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/skylight/core/gc.rb', line 29 def enable @profiler.enable if @profiler end |
#release(win) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 65 66 |
# File 'lib/skylight/core/gc.rb', line 62 def release(win) @lock.synchronize do @listeners.delete(win) end end |
#total_time ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Total time in microseconds for GC over entire process lifetime
34 35 36 |
# File 'lib/skylight/core/gc.rb', line 34 def total_time @profiler ? @profiler.total_time : nil end |
#track ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/skylight/core/gc.rb', line 38 def track unless @profiler win = Window.new(nil) else win = Window.new(self) @lock.synchronize do __update @listeners << win # Cleanup any listeners that might have leaked until @listeners[0].time < MAX_TIME @listeners.shift end if @listeners.length > MAX_COUNT @listeners.shift end end end win end |
#update ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 71 72 73 74 |
# File 'lib/skylight/core/gc.rb', line 68 def update @lock.synchronize do __update end nil end |