HLSf use nuint rather than long, L4 now uses hlsf rather than array to alloc cache line.
This commit is contained in:
@@ -35,6 +35,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Hlsf = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
|
||||
using HlsfEntry = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator.Entry;
|
||||
|
||||
namespace StgSharp.HighPerformance.Memory
|
||||
{
|
||||
@@ -76,14 +77,14 @@ namespace StgSharp.HighPerformance.Memory
|
||||
int bitPos = BitOperations.TrailingZeroCount(evictMask);
|
||||
int index = bitPos + i;
|
||||
CacheLineHead* head = &_head[index];
|
||||
if (Interlocked.CompareExchange(ref head->_refCount, int.MinValue, 0) == 0)
|
||||
if (Interlocked.CompareExchange(ref head->RefCount, int.MinValue, 0) == 0)
|
||||
{
|
||||
// EvictLine(i + index);
|
||||
_ = _map.TryRemove(head->_origin, out _);
|
||||
int id = head->_predictor;
|
||||
_ = _map.TryRemove(head->Origin, out _);
|
||||
int id = head->Predictor;
|
||||
IL4Predict predict = pSpan[id] ??
|
||||
throw new L4PredictUnregisteredException(id);
|
||||
predict.WriteBack(head->_origin, head->_profile, new ReadOnlySpan<byte>((byte*)head->_address, Unsafe.SizeOf<CacheLineData>()));
|
||||
predict.WriteBack(head->Origin, head->Profile, new ReadOnlySpan<byte>((byte*)head->Address, (int)head->Size));
|
||||
RecycleLine(index);
|
||||
remain--;
|
||||
}
|
||||
@@ -103,24 +104,24 @@ namespace StgSharp.HighPerformance.Memory
|
||||
int id
|
||||
)
|
||||
{
|
||||
Hlsf.Entry* entry = _entryManager._basePtr + id;
|
||||
HlsfEntry* entry = (HlsfEntry*)(_entryManager._basePtr + id);
|
||||
_bufferAllocator.Free(entry);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe bool TryGetEmptyLine(
|
||||
nuint size,
|
||||
out int index,
|
||||
out HlsfHandle handle
|
||||
out int index
|
||||
|
||||
)
|
||||
{
|
||||
if (!_bufferAllocator.TryAlloc(size, out handle))
|
||||
if (!_bufferAllocator.TryAlloc(size, out HlsfHandle handle))
|
||||
{
|
||||
index = 0;
|
||||
return false;
|
||||
}
|
||||
Hlsf.Entry* entry = handle.EntryHandle;
|
||||
index = (int)(entry - _entryManager._basePtr);
|
||||
index = (int)(entry - ((HlsfEntry*)_entryManager._basePtr));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user