class Cryload::RateLimiter

Overview

Open-loop pacer: slots are reserved on an absolute schedule anchored to the benchmark start, so the requested rate is a constant arrival rate rather than a per-worker throttle.

The schedule is never re-anchored to "now". v5 clamped the next slot to the current time, so when every worker blocked on a stalled target nobody advanced the schedule and the missed slots were erased: the run silently issued fewer requests than asked for and the outage never showed up in the percentiles. Keeping the schedule monotonic turns that backlog into measurable send delay, which is what corrected latency is computed from.

Defined in:

cryload/rate_limiter.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(rate : Float64, reference : Time::Instant = Time.instant) #

Class Method Detail

def self.interval_ns_for(rate : Float64) : Int64 #

Shared by the limiter and by the report, so the number of slots the schedule hands out is computed exactly one way.


def self.scheduled_count(rate : Float64, span : Time::Span) : Int64 #

Slots the schedule hands out over span, counting the slot at offset 0.


Instance Method Detail

def acquire(deadline : Time::Instant | Nil = nil) : Time::Instant | Nil #

Reserves the next slot and sleeps until it is due. Returns the instant the request was scheduled for, which is the baseline for corrected latency, or nil when the reserved slot falls at or past deadline (run is over).


def interval_ns : Int64 #

def reference : Time::Instant #