diff --git a/src/Nethermind/Nethermind.Db.Rocks/DbOnTheRocks.cs b/src/Nethermind/Nethermind.Db.Rocks/DbOnTheRocks.cs index a509f96e874..99f4b222dcb 100644 --- a/src/Nethermind/Nethermind.Db.Rocks/DbOnTheRocks.cs +++ b/src/Nethermind/Nethermind.Db.Rocks/DbOnTheRocks.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.IO; using System.IO.Abstractions; -using System.Net.Sockets; using System.Reflection; using System.Threading; using ConcurrentCollections; @@ -15,7 +14,6 @@ using Nethermind.Core.Crypto; using Nethermind.Core.Exceptions; using Nethermind.Core.Extensions; -using Nethermind.Core.Threading; using Nethermind.Db.Rocks.Config; using Nethermind.Db.Rocks.Statistics; using Nethermind.Logging; @@ -26,9 +24,6 @@ namespace Nethermind.Db.Rocks; public class DbOnTheRocks : IDb, ITunableDb { - private McsPriorityLock _readThrottle = new(); - private McsPriorityLock _writeThrottle = new(); - private ILogger _logger; private string? _fullPath; @@ -505,7 +500,6 @@ public byte[]? this[ReadOnlySpan key] } } - using var handle = _readThrottle.Acquire(); return _db.Get(key, cf); } catch (RocksDbSharpException e) @@ -528,7 +522,6 @@ internal void SetWithColumnFamily(ReadOnlySpan key, ColumnFamilyHandle? cf try { - using var handle = _writeThrottle.Acquire(); if (value.IsNull()) { _db.Remove(key, cf, WriteFlagsToWriteOptions(flags)); @@ -572,7 +565,6 @@ internal void SetWithColumnFamily(ReadOnlySpan key, ColumnFamilyHandle? cf { try { - using var handle = _readThrottle.Acquire(); return _db.MultiGet(keys); } catch (RocksDbSharpException e) @@ -596,11 +588,8 @@ internal Span GetSpanWithColumnFamily(ReadOnlySpan key, ColumnFamily try { - Span span; - using (var handle = _readThrottle.Acquire()) - { - span = _db.GetSpan(key, cf); - } + Span span = _db.GetSpan(key, cf); + if (!span.IsNullOrEmpty()) { Interlocked.Increment(ref _allocatedSpan); @@ -636,7 +625,6 @@ public void Remove(ReadOnlySpan key) try { - using var handle = _writeThrottle.Acquire(); _db.Remove(key, null, WriteOptions); } catch (RocksDbSharpException e) @@ -824,7 +812,6 @@ public bool KeyExists(ReadOnlySpan key) try { - using var handle = _readThrottle.Acquire(); // seems it has no performance impact return _db.Get(key) is not null; // return _db.Get(key, 32, _keyExistsBuffer, 0, 0, null, null) != -1; @@ -903,10 +890,7 @@ public void Dispose() try { - using (var handle = _dbOnTheRocks._writeThrottle.Acquire()) - { - _dbOnTheRocks._db.Write(_rocksBatch, _dbOnTheRocks.WriteFlagsToWriteOptions(_writeFlags)); - } + _dbOnTheRocks._db.Write(_rocksBatch, _dbOnTheRocks.WriteFlagsToWriteOptions(_writeFlags)); _dbOnTheRocks._currentBatches.TryRemove(this); ReturnWriteBatch(_rocksBatch); @@ -960,10 +944,7 @@ private void FlushOnTooManyWrites() try { - using (var handle = _dbOnTheRocks._writeThrottle.Acquire()) - { - _dbOnTheRocks._db.Write(currentBatch, _dbOnTheRocks.WriteFlagsToWriteOptions(_writeFlags)); - } + _dbOnTheRocks._db.Write(currentBatch, _dbOnTheRocks.WriteFlagsToWriteOptions(_writeFlags)); ReturnWriteBatch(currentBatch); } catch (RocksDbSharpException e)