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.
%i[enable total_time].freeze
- 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.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/skylight/core/gc.rb', line 13 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.
11 12 13 |
# File 'lib/skylight/core/gc.rb', line 11 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.
27 28 29 |
# File 'lib/skylight/core/gc.rb', line 27 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.
58 59 60 61 62 |
# File 'lib/skylight/core/gc.rb', line 58 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
32 33 34 |
# File 'lib/skylight/core/gc.rb', line 32 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.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/skylight/core/gc.rb', line 36 def track if @profiler win = Window.new(self) @lock.synchronize do __update @listeners << win # Cleanup any listeners that might have leaked @listeners.shift until @listeners[0].time < MAX_TIME if @listeners.length > MAX_COUNT @listeners.shift end end win else Window.new(nil) end 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.
64 65 66 67 68 69 70 |
# File 'lib/skylight/core/gc.rb', line 64 def update @lock.synchronize do __update end nil end |