From 1035e47446ffb80811d673e5e3d0d83b18b76a5e Mon Sep 17 00:00:00 2001 From: vnugent Date: Fri, 8 Sep 2023 23:21:04 -0400 Subject: Extra debug --- .../src/CacheBucketHandle.cs | 1 + .../src/CacheEntry.cs | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'lib/VNLib.Data.Caching.ObjectCache') diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs b/lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs index 4b88957..92db1d4 100644 --- a/lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs +++ b/lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs @@ -76,6 +76,7 @@ namespace VNLib.Data.Caching.ObjectCache /// The other handle to compare /// True if the handles hold a referrence to the same bucket public bool Equals(CacheBucketHandle other) => ReferenceEquals(_bucket, other._bucket); + /// /// Determines if the other handle instance is equal to the current. Handles are /// equal iff the underlying bucket referrence is equal. diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs b/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs index f650cc3..9183d0a 100644 --- a/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs +++ b/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs @@ -31,7 +31,6 @@ using System.Runtime.CompilerServices; using VNLib.Utils.Memory; using VNLib.Utils.Extensions; - namespace VNLib.Data.Caching { /// @@ -66,41 +65,37 @@ namespace VNLib.Data.Caching MemoryHandle handle = heap.Alloc(bufferSize); //Create new entry from handle - CacheEntry entry = new (handle, data.Length); + CacheEntry entry = new (handle); + entry.SetLength(data.Length); //Get the data segment Span segment = entry.GetDataSegment(); + Debug.Assert(segment.Length == data.Length); + //Copy data segment data.CopyTo(segment); return entry; } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static int GetRequiredHandleSize(int size) { //Caculate the minimum handle size to store all required information, rounded to nearest page return (int)MemoryUtil.NearestPage(size + DATA_SEGMENT_START); } - private CacheEntry(MemoryHandle handle, int length) + private CacheEntry(MemoryHandle handle) { _handle = handle; - //Store data length, assumes the handle is large enough to store it - SetLength(length); } - /// public readonly void Dispose() => _handle?.Dispose(); - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] + private readonly Span GetTimeSegment() => _handle.AsSpan(0, TIME_SEGMENT_SIZE); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] + private readonly Span GetLengthSegment() => _handle.AsSpan(TIME_SEGMENT_SIZE, LENGTH_SEGMENT_SIZE); /// @@ -115,7 +110,6 @@ namespace VNLib.Data.Caching return _handle.ByteLength; } - /// /// Gets the last set time /// -- cgit