Class OccLockBuckets
- Namespace
- RocksDbNet
- Assembly
- RocksDb.Net.dll
A fixed set of lock buckets that several optimistic transaction databases
can share. Maps to rocksdb_optimistictransactiondb_lock_buckets_t.
public sealed class OccLockBuckets : RocksDbHandle, IDisposable
- Inheritance
-
OccLockBuckets
- Implements
- Inherited Members
Remarks
Only ValidateParallel uses these. The buckets are what a committing transaction locks its write set in, so more of them means fewer transactions colliding on the same bucket by accident, at the cost of memory.
Sharing one instance across databases is the reason this is a separate object rather than a number: a process running many small databases would otherwise pay for a full set of buckets per database. Give it to each through SetSharedLockBuckets(OccLockBuckets?).
RocksDb holds its own reference, so this may be disposed once every database that shares it has been opened.
Constructors
OccLockBuckets(nuint, bool)
Creates a set of lock buckets.
public OccLockBuckets(nuint bucketCount, bool cacheAligned = false)
Parameters
bucketCountnuintHow many buckets. Rounded up to a power of two by RocksDb.
cacheAlignedboolPad each bucket onto its own cache line. Costs memory and buys back the false sharing between threads locking neighbouring buckets.
Exceptions
- ArgumentOutOfRangeException
bucketCountis zero.
Properties
ApproximateMemoryUsage
Roughly how much memory the buckets occupy, in bytes.
public nuint ApproximateMemoryUsage { get; }
Property Value
Methods
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().