Skip to content

Commit

Permalink
RavenDB-23704 - adjust the test to the memory allocation pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
grisha-kotler committed Mar 5, 2025
1 parent e84b58f commit 8761a9e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/FastTests/Sparrow/ByteStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ public void AllocateAndReleaseShouldReuseAsSegment()
context.Allocate(2 * ByteStringContext.MinBlockSizeInBytes - sizeof(ByteStringStorage), out var byteStringInFirst);

long ptrLocation = (long)byteStringInFirst._pointer;
long nextPtrLocation = ptrLocation + byteStringInFirst._pointer->Size;

// we need to allocate this since we want the first block to be released as a new segment
context.Allocate(1, out var byteStringInSecond);
long nextPtrLocation = (long)byteStringInSecond._pointer + byteStringInSecond._pointer->Size;

context.Release(ref byteStringInFirst); // After the release the block should be reserved as a new segment.

Expand All @@ -135,9 +138,9 @@ public void AllocateAndReleaseShouldReuseAsSegment()
Assert.InRange((long)byteStringReused._pointer, ptrLocation, ptrLocation + allocationBlockSize);
Assert.Equal(ptrLocation, (long)byteStringReused._pointer); // We are the first in the segment.

// This allocation will have an allocation unit size of 128 and fit into the rest of the initial segment, which should be
// This allocation will have an allocation unit size of 64 and fit into the rest of the initial segment, which should be
// available for an exact reuse bucket allocation.
context.Allocate(64, out var byteStringReusedFromBucket);
context.Allocate(32, out var byteStringReusedFromBucket);

Assert.Equal((long)byteStringReusedFromBucket._pointer, nextPtrLocation);
}
Expand Down

0 comments on commit 8761a9e

Please sign in to comment.