Class RateLimiter
- Namespace
- RocksDbNet
- Assembly
- RocksDb.Net.dll
Limits the rate of I/O operations (bytes per second).
Maps to rocksdb_ratelimiter_t.
public sealed class RateLimiter : RocksDbHandle, IDisposable
- Inheritance
-
RateLimiter
- Implements
- Inherited Members
Constructors
RateLimiter(long, long, int)
public RateLimiter(long rateBytesPerSec, long refillPeriodMicros = 100000, int fairness = 10)
Parameters
rateBytesPerSeclongTarget I/O rate in bytes per second.
refillPeriodMicroslongRefill period in microseconds (default: 100 ms).
fairnessintFairness factor between high-priority and low-priority requests (default: 10).
Methods
Create(long, RateLimiterMode, bool, long, int)
Creates a rate limiter that limits only the I/O mode names.
public static RateLimiter Create(long rateBytesPerSec, RateLimiterMode mode, bool autoTuned = false, long refillPeriodMicros = 100000, int fairness = 10)
Parameters
rateBytesPerSeclongThe rate, or the upper bound when
autoTunedis set.modeRateLimiterModeWhich I/O counts against the limit. The other constructors limit writes only, which is RocksDb's default.
autoTunedboolWhether to adjust the rate to the load, as CreateAutoTuned(long, long, int) does.
refillPeriodMicroslongRefill period in microseconds.
fairnessintFairness factor between high- and low-priority requests.
Returns
CreateAutoTuned(long, long, int)
Creates a rate limiter that adjusts its own rate to the load, between
1/20th of rateBytesPerSec and the full figure.
public static RateLimiter CreateAutoTuned(long rateBytesPerSec, long refillPeriodMicros = 100000, int fairness = 10)
Parameters
rateBytesPerSeclongThe upper bound, in bytes per second.
refillPeriodMicroslongRefill period in microseconds.
fairnessintFairness factor between high- and low-priority requests.
Returns
Remarks
What RocksDb recommends when the right fixed rate is not known: it raises the rate while background work is falling behind and lowers it when there is slack, so compaction does not starve foreground I/O.
DisposeHandle()
Releases the native handle. Called during disposal.
protected override void DisposeHandle()
Remarks
Protected rather than public: it destroys the native object without marking this instance disposed or clearing the handle, so calling it from outside and then disposing normally would free the same pointer twice. It was the most Dispose-looking member on the type. Callers want Dispose().