-
Notifications
You must be signed in to change notification settings - Fork 579
LogRecord and SpanByte changes #1186
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
base: main
Are you sure you want to change the base?
Conversation
- Move CountdownWrapper to its own file - Rename Lockable* to Transactional* - Rename Transient* to Ephemeral*
Other work to get CreateNewRecordRMW clean
…ns first pass done)
…ync APIs) from Tsavorite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked through the first 150 files of this - up to libs/server/Transaction/TransactionManager.cs
.
I'll continue with my review tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another 150 files reviewed, up through libs/storage/Tsavorite/cs/src/core/Index/Tsavorite/Implementation/UpsertValueSelector.cs
. I'll wrap up tomorrow, time allowing.
...torage/Tsavorite/cs/src/core/Index/Tsavorite/Implementation/Revivification/FreeRecordPool.cs
Outdated
Show resolved
Hide resolved
...torage/Tsavorite/cs/src/core/Index/Tsavorite/Implementation/Revivification/FreeRecordPool.cs
Outdated
Show resolved
Hide resolved
...torage/Tsavorite/cs/src/core/Index/Tsavorite/Implementation/Revivification/FreeRecordPool.cs
Outdated
Show resolved
Hide resolved
...torage/Tsavorite/cs/src/core/Index/Tsavorite/Implementation/Revivification/FreeRecordPool.cs
Outdated
Show resolved
Hide resolved
...torage/Tsavorite/cs/src/core/Index/Tsavorite/Implementation/Revivification/FreeRecordPool.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finished review.
Mostly nits, some far this is looking very promising.
libs/storage/Tsavorite/cs/src/core/TsavoriteLog/TsavoriteLogSettings.cs
Outdated
Show resolved
Hide resolved
libs/storage/Tsavorite/cs/src/core/Utilities/MultiLevelPageArray.cs
Outdated
Show resolved
Hide resolved
libs/storage/Tsavorite/cs/src/core/Utilities/SimpleConcurrentStack.cs
Outdated
Show resolved
Hide resolved
libs/storage/Tsavorite/cs/src/core/Utilities/SimpleConcurrentStack.cs
Outdated
Show resolved
Hide resolved
… for SpanByteAllocator. The AddressType change is a breaking on-disk format change: it shuffles bits around in RecordInfo to add an additional bit adjacent to the old ReadCache bit to mark an address as: - 00: Reserved - 11: ReadCache - 10: InMemory portion of the main log - 01: On-Disk
…hem "in" rather than "ref"
I'll be able to have a look tomorrow at this beast! I have been glancing through it and in general I like the direction 👍 update: this is gonna take a while 😅 Half-way through reading the changes, I'll leave comments/questions for later once I understand the changes a bit better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review marathon mostly over (I skipped test diffs) and I like the changes a lot! A lot of nice consolidation and reducing the complexity of certain parts. Thanks for the useful documentation too, but I won't pretend that I understand all of the new Log changes thoroughly yet.
This PR also seems to do a lot of nice work that is useful if we want to switch (de)serialization logic from Stream
(BinaryReader
/BinaryWriter
) to span based approach in future (I have some local attempts at this and it looks more approachable after this PRs changes).
var result = 0; | ||
do | ||
{ | ||
num >>= 8; | ||
result++; | ||
} while (num > 0); | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can turn this branchless :) (given we don't use this for negative values here)
var result = 0; | |
do | |
{ | |
num >>= 8; | |
result++; | |
} while (num > 0); | |
return result; | |
var bitLength = (sizeof(ulong) * 8) - BitOperations.LeadingZeroCount((ulong)(x | 1)); | |
return (bitLength + 7) / 8; |
throw new TsavoriteException("SpanByte Keys cannot be mixed with object Values"); | ||
if (typeof(TValue) == typeof(SpanByte)) | ||
throw new TsavoriteException("SpanByte Values cannot be mixed with object Keys"); | ||
freePagePool = new OverflowPool<PageUnit<ObjectPage>>(4, static p => { }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading this right (that it is same logic as in my experiment PR), we need to free these overflowing pages.
We could also report these unmanaged allocations for GC if we want to be nice.
|
||
public SpanByteAllocatorImpl(AllocatorSettings settings, TStoreFunctions storeFunctions, Func<object, SpanByteAllocator<TStoreFunctions>> wrapperCreator) | ||
: base(settings.LogSettings, storeFunctions, wrapperCreator, settings.evictCallback, settings.epoch, settings.flushCallback, settings.logger) | ||
{ | ||
overflowPagePool = new OverflowPool<PageUnit>(4, p => { }); | ||
freePagePool = new OverflowPool<PageUnit<Empty>>(4, p => { }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, we should free the unmanaged pool pages.
public int MaxInlineKeySize = 1 << LogSettings.kDefaultMaxInlineKeySizeBits; | ||
|
||
/// <summary> | ||
/// Maximum size of a valuie stored inline in the in-memory portion of the main log for <see cref="SpanByteAllocator{TStoreFunctions}"/>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Maximum size of a valuie stored inline in the in-memory portion of the main log for <see cref="SpanByteAllocator{TStoreFunctions}"/>. | |
/// Maximum size of a value stored inline in the in-memory portion of the main log for <see cref="SpanByteAllocator{TStoreFunctions}"/>. |
namespace Tsavorite.core | ||
{ | ||
/// <summary> | ||
/// Represents contiguous region of arbitrary _pinned_ memory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This emphasis that I added some time ago with the original comment is now much less useful when the type name contains the information 😅
/// Represents contiguous region of arbitrary _pinned_ memory. | |
/// Represents contiguous region of arbitrary pinned memory. |
This is an initial draft of a PR to convert Garnet to use a new ObjectAllocator with a revised on-disk format that will use only a single log file, change ISessionFunctions to be (Disk)LogRecord-based and propagate this to operations such as Compaction and Migration, remove TKey and TValue from TsavoriteKV, and many related refactors.
This PR will be long-lived as additional task PRs are merged into storage-v2 before it is ready for merge to main (see "Major Remaining Tasks" below). Currently this branch implements ONLY the in-memory portion; the IO work is not yet implemented.
Highlights:
(ReadOnly)Span<byte>
extensions.ReadOnlySpan<byte>
at the StorageSession and below, including Tsavorite. There are no longer any byte[] keys. The TKey type argument is gone from Tsavorite and Garnet.(ReadOnly)Span<byte>
or objects implementing IHeapObject. TValue has been removed from TsavoriteKV.Major remaining tasks (this will be updated as they are implemented):
(ReadOnly)Span<byte>
path by replacing byte* usage (such as was done for Utility.HashBytes).