Smarter unpinning of MemoryPoolBlock2 in SocketOutput
This commit is contained in:
parent
2572256d3f
commit
0dbf108353
|
|
@ -305,12 +305,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
var returnBlock = block;
|
var returnBlock = block;
|
||||||
block = block.Next;
|
block = block.Next;
|
||||||
|
|
||||||
returnBlock.Unpin();
|
|
||||||
returnBlock.Pool?.Return(returnBlock);
|
returnBlock.Pool?.Return(returnBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
_tail.Unpin();
|
|
||||||
|
|
||||||
if (_isProducing)
|
if (_isProducing)
|
||||||
{
|
{
|
||||||
_returnFromOnProducingComplete = _tail;
|
_returnFromOnProducingComplete = _tail;
|
||||||
|
|
@ -381,6 +378,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
|
||||||
var writeReq = new UvWriteReq(Self._log);
|
var writeReq = new UvWriteReq(Self._log);
|
||||||
writeReq.Init(Self._thread.Loop);
|
writeReq.Init(Self._thread.Loop);
|
||||||
|
|
||||||
writeReq.Write(Self._socket, _lockedStart, _lockedEnd, _bufferCount, (_writeReq, status, error, state) =>
|
writeReq.Write(Self._socket, _lockedStart, _lockedEnd, _bufferCount, (_writeReq, status, error, state) =>
|
||||||
{
|
{
|
||||||
_writeReq.Dispose();
|
_writeReq.Dispose();
|
||||||
|
|
@ -453,6 +451,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
returnBlock.Unpin();
|
returnBlock.Unpin();
|
||||||
returnBlock.Pool?.Return(returnBlock);
|
returnBlock.Pool?.Return(returnBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_lockedEnd.Block.Unpin();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LockWrite()
|
private void LockWrite()
|
||||||
|
|
|
||||||
|
|
@ -105,15 +105,13 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public IntPtr Pin()
|
public IntPtr Pin()
|
||||||
{
|
{
|
||||||
|
Debug.Assert(!_pinHandle.IsAllocated);
|
||||||
|
|
||||||
if (_dataArrayPtr != IntPtr.Zero)
|
if (_dataArrayPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
// this is a slab managed block - use the native address of the slab which is always locked
|
// this is a slab managed block - use the native address of the slab which is always locked
|
||||||
return _dataArrayPtr;
|
return _dataArrayPtr;
|
||||||
}
|
}
|
||||||
else if (_pinHandle.IsAllocated)
|
|
||||||
{
|
|
||||||
return _pinHandle.AddrOfPinnedObject();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// this is one-time-use memory - lock the managed memory until Unpin is called
|
// this is one-time-use memory - lock the managed memory until Unpin is called
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,14 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
_callback = null;
|
_callback = null;
|
||||||
_state = null;
|
_state = null;
|
||||||
Unpin(this);
|
Unpin(this);
|
||||||
|
|
||||||
|
var block = start.Block;
|
||||||
|
for (var index = 0; index < nBuffers; index++)
|
||||||
|
{
|
||||||
|
block.Unpin();
|
||||||
|
block = block.Next;
|
||||||
|
}
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue