Table of Contents

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

rateBytesPerSec long

Target I/O rate in bytes per second.

refillPeriodMicros long

Refill period in microseconds (default: 100 ms).

fairness int

Fairness 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

rateBytesPerSec long

The rate, or the upper bound when autoTuned is set.

mode RateLimiterMode

Which I/O counts against the limit. The other constructors limit writes only, which is RocksDb's default.

autoTuned bool

Whether to adjust the rate to the load, as CreateAutoTuned(long, long, int) does.

refillPeriodMicros long

Refill period in microseconds.

fairness int

Fairness factor between high- and low-priority requests.

Returns

RateLimiter

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

rateBytesPerSec long

The upper bound, in bytes per second.

refillPeriodMicros long

Refill period in microseconds.

fairness int

Fairness factor between high- and low-priority requests.

Returns

RateLimiter

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().