Skip to content

Commit 815e397

Browse files
committed
cleanup
1 parent fdfaad5 commit 815e397

File tree

3 files changed

+6
-43
lines changed

3 files changed

+6
-43
lines changed

src/Servers/Connections.Abstractions/src/IMemoryPoolFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
namespace Microsoft.AspNetCore.Connections;
77

88
/// <summary>
9-
///
9+
/// Interface for creating memory pools.
1010
/// </summary>
1111
public interface IMemoryPoolFactory<T>
1212
{
1313
/// <summary>
14-
///
14+
/// Creates a new instance of a memory pool.
1515
/// </summary>
16-
/// <returns></returns>
16+
/// <returns>A new memory pool instance.</returns>
1717
MemoryPool<T> Create();
1818
}

src/Servers/Kestrel/Kestrel/src/WebHostBuilderKestrelExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ public static IWebHostBuilder UseKestrelCore(this IWebHostBuilder hostBuilder)
8181
hostBuilder.UseSockets();
8282
hostBuilder.ConfigureServices(services =>
8383
{
84-
// Don't override an already-configured transport
85-
//services.TryAddSingleton<IConnectionListenerFactory, SocketTransportFactory>();
86-
8784
services.AddTransient<IConfigureOptions<KestrelServerOptions>, KestrelServerOptionsSetup>();
8885
services.AddSingleton<IHttpsConfigurationService, HttpsConfigurationService>();
8986
services.AddSingleton<IServer, KestrelServerImpl>();

src/Shared/Buffers.MemoryPool/PinnedBlockMemoryPool.cs

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ public override IMemoryOwner<byte> Rent(int size = AnySize)
9292
MemoryPoolThrowHelper.ThrowObjectDisposedException(MemoryPoolThrowHelper.ExceptionArgument.MemoryPool);
9393
}
9494

95-
//Interlocked.Increment(ref _rentCount);
96-
//++_rentCount;
97-
ScalableCount(ref _rentCount);
95+
Interlocked.Increment(ref _rentCount);
9896

9997
if (_blocks.TryDequeue(out var block))
10098
{
@@ -108,13 +106,11 @@ public override IMemoryOwner<byte> Rent(int size = AnySize)
108106

109107
_metrics.IncrementTotalMemory(BlockSize);
110108
_metrics.Rent(BlockSize);
111-
//Interlocked.Increment(ref _rentCount);
112-
//++_rentCount;
113109

114110
// We already counted this Rent call above, but since we're now allocating (need more blocks)
115111
// that means the pool is 'very' active and we probably shouldn't evict blocks, so we count again
116112
// to reduce the chance of eviction occurring this cycle.
117-
ScalableCount(ref _rentCount);
113+
Interlocked.Increment(ref _rentCount);
118114

119115
return new MemoryPoolBlock(this, BlockSize);
120116
}
@@ -135,9 +131,7 @@ internal void Return(MemoryPoolBlock block)
135131
block.IsLeased = false;
136132
#endif
137133

138-
//Interlocked.Increment(ref _returnCount);
139-
//++_returnCount;
140-
ScalableCount(ref _returnCount);
134+
Interlocked.Increment(ref _returnCount);
141135

142136
if (!_isDisposed)
143137
{
@@ -248,32 +242,4 @@ public void Dispose()
248242
{
249243
}
250244
}
251-
252-
// https://github.com/dotnet/runtime/blob/db681fb307d754c3746ffb40e0634e4c4e0caa9e/docs/design/features/ScalableApproximateCounting.md
253-
static void ScalableCount(ref uint counter)
254-
{
255-
// Start using random for counting after 2^12 (4096)
256-
//const int threshold = 12;
257-
uint count = counter;
258-
uint delta = 1;
259-
#if false
260-
if (count > 0)
261-
{
262-
int logCount = 31 - (int)uint.LeadingZeroCount(count);
263-
264-
if (logCount >= threshold)
265-
{
266-
delta = 1u << (logCount - (threshold - 1));
267-
uint rand = (uint)Random.Shared.Next();
268-
bool update = (rand & (delta - 1)) == 0;
269-
if (!update)
270-
{
271-
return;
272-
}
273-
}
274-
}
275-
#endif
276-
277-
Interlocked.Add(ref counter, delta);
278-
}
279245
}

0 commit comments

Comments
 (0)