Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tsavorite allocator - tighten the packing of pages #657

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4cb40c9
Change allocator to enqueue with the invariant that the first record …
badrishc Sep 7, 2024
198e879
fixes based on comments
badrishc Sep 8, 2024
772cb56
add another comment
badrishc Sep 8, 2024
8b5708e
add comments
badrishc Sep 9, 2024
f53f516
fixes - we now always wrap TryAllocate with TryAllocateRetryNow.
badrishc Sep 9, 2024
b0f3886
Add Non-readcache "Insert At Tail" stress test
TedHartMS Sep 9, 2024
fb0a807
support 0% mutable fraction.
badrishc Sep 11, 2024
1c95a5a
Fix InernalUpsert srcRecordInfo setting when found below ReadOnlyAddress
TedHartMS Sep 12, 2024
3958da1
Adjust mutable-page counts in stress test
TedHartMS Sep 12, 2024
56db587
fix typo
TedHartMS Sep 12, 2024
845504b
Enforce at least two pages of memory.
badrishc Sep 12, 2024
2b41b13
nit
badrishc Sep 12, 2024
85ae71e
Merge remote-tracking branch 'origin/main' into badrishc/allocator-en…
badrishc Sep 12, 2024
4e1fdd9
update Garnet to use new allocator logic
badrishc Sep 12, 2024
454b8c0
Fix
badrishc Sep 13, 2024
d38a9a2
update low memory to meet new constraint
badrishc Sep 13, 2024
4867ddb
re-enable warning
badrishc Sep 13, 2024
d009215
handle comments
badrishc Sep 13, 2024
f4df546
fix bitmap tests to use at least 2 pages of memory.
badrishc Sep 13, 2024
5f676f9
fix hll tests
badrishc Sep 13, 2024
f487d5d
more testcase fixes
badrishc Sep 13, 2024
fcf78f0
fix replication logic to handle micro-skips within the same page
badrishc Sep 14, 2024
d00cb3b
PageAlignedShiftHeadAddress should always keep the head address, well…
badrishc Sep 14, 2024
dca9aab
Merge branch 'main' into badrishc/allocator-enqueue-tight
badrishc Sep 14, 2024
4559bbe
Merge branch 'main' into badrishc/allocator-enqueue-tight
badrishc Sep 16, 2024
a8fb59b
Merge branch 'main' into badrishc/allocator-enqueue-tight
badrishc Sep 17, 2024
324bc0c
Merge branch 'main' into badrishc/allocator-enqueue-tight
badrishc Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/cluster/Server/Replication/PrimaryOps/AofTaskStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public AofTaskStore(ClusterProvider clusterProvider, int initialSize = 1, ILogge
logPageSizeMask = logPageSize - 1;
if (clusterProvider.serverOptions.MainMemoryReplication)
clusterProvider.storeWrapper.appendOnlyFile.SafeTailShiftCallback = SafeTailShiftCallback;
TruncateLagAddress = clusterProvider.storeWrapper.appendOnlyFile.UnsafeGetReadOnlyLagAddress() - 2 * logPageSize;
TruncateLagAddress = clusterProvider.storeWrapper.appendOnlyFile.UnsafeGetReadOnlyAddressLagOffset() - 2 * logPageSize;
}
TruncatedUntil = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ public unsafe void ProcessPrimaryStream(byte* record, int recordLength, long pre

if (clusterProvider.serverOptions.MainMemoryReplication)
{
var firstRecordLength = GetFirstAofEntryLength(record);
if (previousAddress > ReplicationOffset ||
currentAddress >= previousAddress + firstRecordLength)
// If the incoming AOF chunk fits in the space between previousAddress and currentAddress (ReplicationOffset),
// an enqueue will result in an offset mismatch. So, we have to first reset the AOF to point to currentAddress.
if (currentAddress > previousAddress)
{
logger?.LogWarning("MainMemoryReplication: Skipping from {ReplicaReplicationOffset} to {currentAddress}", ReplicationOffset, currentAddress);
storeWrapper.appendOnlyFile.Initialize(currentAddress, currentAddress);
ReplicationOffset = currentAddress;
if (
(currentAddress % (1 << storeWrapper.appendOnlyFile.UnsafeGetLogPageSizeBits()) != 0) || // the skip was to a non-page-boundary
(currentAddress >= previousAddress + recordLength) // the skip will not be auto-handled by the AOF enqueue
)
{
logger?.LogWarning("MainMemoryReplication: Skipping from {ReplicaReplicationOffset} to {currentAddress}", ReplicationOffset, currentAddress);
storeWrapper.appendOnlyFile.Initialize(currentAddress, currentAddress);
ReplicationOffset = currentAddress;
}
}
}

Expand All @@ -56,15 +62,6 @@ public unsafe void ProcessPrimaryStream(byte* record, int recordLength, long pre
throw new GarnetException($"Before ProcessPrimaryStream: Replication offset mismatch: ReplicaReplicationOffset {ReplicationOffset}, aof.TailAddress {storeWrapper.appendOnlyFile.TailAddress}", LogLevel.Warning, clientResponse: false);
}

// If there is a gap between the local tail and incoming currentAddress, try to skip local AOF to the next page
if (currentAddress >= storeWrapper.appendOnlyFile.TailAddress + recordLength
&& storeWrapper.appendOnlyFile.GetPage(currentAddress) == storeWrapper.appendOnlyFile.GetPage(storeWrapper.appendOnlyFile.TailAddress) + 1)
{
logger?.LogWarning("SkipPage from {previousAddress} to {currentAddress}, tail is {tailAddress}", previousAddress, currentAddress, storeWrapper.appendOnlyFile.TailAddress);
storeWrapper.appendOnlyFile.UnsafeSkipPage();
logger?.LogWarning("New tail after SkipPage is {tailAddress}", storeWrapper.appendOnlyFile.TailAddress);
}

// Enqueue to AOF
_ = clusterProvider.storeWrapper.appendOnlyFile?.UnsafeEnqueueRaw(new Span<byte>(record, recordLength), noCommit: clusterProvider.serverOptions.EnableFastCommit);

Expand Down
2 changes: 1 addition & 1 deletion libs/server/Resp/RespServerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ private void ProcessMessages()
}
else
{
if (CanServeSlot(cmd))
if (clusterSession == null || CanServeSlot(cmd))
_ = ProcessBasicCommands(cmd, ref basicGarnetApi);
}
}
Expand Down
5 changes: 2 additions & 3 deletions libs/server/Resp/RespServerSessionSlotVerify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

using System;
using System.Diagnostics;
using Garnet.common;

namespace Garnet.server
Expand Down Expand Up @@ -33,9 +34,7 @@ bool NetworkKeyArraySlotVerify(Span<ArgSlice> keys, bool readOnly, int count = -

bool CanServeSlot(RespCommand cmd)
{
// If cluster is disable all commands
if (clusterSession == null)
return true;
Debug.Assert(clusterSession != null);

// Verify slot for command if it falls into data command category
if (!cmd.IsDataCommand())
Expand Down
Loading
Loading