class IdleGC::IdleDetection
- IdleGC::IdleDetection
- Reference
- Object
Defined in:
idle-gc/idle_detection.crConstant Summary
-
DEFAULT_IDLE_DETECTION_REPEAT =
1_u8
-
DEFAULT_IDLE_THRESHOLD =
100.microseconds
Class Method Summary
- .enabled : Bool
-
.enabled=(v : Bool) : Nil
Idle detection is enabled by default, but it is based on a heuristic which may be inaccurate, so you may wish to disable it by calling
IdleGC::IdleDetection.enabled = false
. -
.fiber_yield_time : Time::Span
How long does it take for Fiber.yield to return?
- .fiber_yield_time_ns : UInt64
-
.idle_detection_repeat=(v : UInt8) : Nil
To reduce idle false-positives, we can check multiple times in succession.
-
.idle_threshold=(v : Time::Span) : Nil
Set the idle threshold for comparing to
IdleGC::IdleDetection.fiber_yield_time
. -
.process_is_idle? : Bool
Return true if the process is idle, as determined by
#fiber_yield_time
compared to#idle_threshold=
.
Class Method Detail
Idle detection is enabled by default, but it is based on a heuristic which may be inaccurate, so you may wish to disable it by calling IdleGC::IdleDetection.enabled = false
.
If disabled, then IdleGC::IdleDetection.process_is_idle?
will always return true, so the IdleGC garbage collection will always run.
If your workload is not latency-sensitive, then running GC periodicially regardless of whether the system is idle may be optimal.
How long does it take for Fiber.yield to return?
This is a measure of whether there are other Fibers waiting to do work.
To reduce idle false-positives, we can check multiple times in succession. Default is 1.
Set the idle threshold for comparing to IdleGC::IdleDetection.fiber_yield_time
.
Experimentally, I found Fiber.yield took about ~5us when idle, and ~500us (or more) when busy, but this will depend on your workload.
Return true if the process is idle, as determined by #fiber_yield_time
compared to #idle_threshold=
.