Skip to content

Commit fcbed38

Browse files
TedHartMSTalZaccaivazois
authored
LogRecord and SpanByte changes (#1186)
* Refactors prior to storage-v2: - Move CountdownWrapper to its own file - Rename Lockable* to Transactional* - Rename Transient* to Ephemeral* * WIP; first cut at LogRecord etc. implementations * WIP: more LogRecord * More *LogRecord, and DiskRecord * WIP: Convert allocators to new LogRecord and DiskRecord * WIP: incorporate LogRecord into ISessionFunctions * More logRecord WIP * More WIP on MainSessionFunctions RMWMethods (and PrivateMethods) with LogRecord * WIP LogRecord (MainStore RMWMethods) * WIP: Consolidate to a single LogRecord; convert InternalRMW * TKey removal * A few more TKey removals * WIP more logRecord * Remove pendingConterxt.recordInfo as it is no longer in RecordMetadata Other work to get CreateNewRecordRMW clean * WIP; Internal(RUMD) converted. * added PendingContext implementation of ISourceLogRecord * Finish ContinuePending * Iterator changes - consolidate to RecordScanIterator * Mostly IO work * WIP: Reintroduce TValue through ObjectAllocator, LogRecord, etc. * WIP Convert Garnet to LogRecord and ObjectAllocator (MainStoreFunctions first pass done) * WIP converting Garnet to non-ref SpanByte-only keys * More WIP on Garnet migration to LogRecord * WIP Tsavorite LogRecord odds and ends * Rename TsavoriteLog to TsavoriteAof * More processing-layer LogRecord etc. fixes * fix iterator as ISourceLogRecord * More Expiration etc. cleanup in processing layer * WIP BlockAllocate work * FInalize removal of SpanByte.Metadata * More param fixes in processing layer * SpanField and OptionalFieldsShift structs * Propagate some SpanField etc. changes * First pass at LogRecord-based Revivification * Finish OverflowAllocator * OK now I finished this iteration of OverflowAllocator * improve callers' use of OverflowAllocator * More LogRecord-related cleanup * // TODOMigrate: temporarily clear errors related to Expiration in Key Migration * Fixes for first test runs * More fixes for CopyRecord and setting of Expiration etc * Cleanup OversizeAllocator.BlockHeader and usage * SpanField and LogRecord documentation and cleanup; BlockHeader GetUserSize * More improvements to overflow allocator and usage * More fixes for tests * Remove unneeded IAllocator(Callbacks) methods (superseded by LogRecord) * more overflow allocator fixes * sizeInfo on ISessionFunctions and TrySetValueSpanLength improvements * Remove SpanByte serialized usage (but leave an assert on .Serialized in case I missed some). Also fix CopyUpdater copies from old record and some more OverflowAllocator tweaks * Improved FreeList handling and ObjectIdMap growth/FreeList via SimpleConcurrentStack and TailAndLatch * Make sure DiskLogRecord Value and Record lengths are long * Remove ISerializer (not used and not planned to be) * TIghten up SpanByte !IsSerialized assert and fix SETEX "expiration set mismatch" * Some TODO cleanup * Begin converting Tsavorite tests and benchmarks to LogRecord * Tsavorite RevivificationTests and ObjectTests * More ObjectIdMap and OverflowAllocator work and tests * More overflowAllocator work: FixedSizePages and other fixes for YCSB, add tests and fixes for OversizePages * Clean up Locking.md (had some referenced to obsolete locking modes); start of LogRecord-related docs * support for "inline struct" as SpanByte for Object value optimization * finish "inline struct" testing; update processing layer to Tsavorite changes; update LogRecord docs * Convert RecordFieldInfo Key/Value TotalSize to DataSize - caller should not need to know about the length prefix (especially bc it changes between Inline, Overflow, ObjectId) * Fixes from merging main * More testing and fixes * More merge fixes * fix more tests * minor comment cleanup * some doc-related updates, mostly comments * Add DisposeReason.Deleted, .Elided Add YCSB --di (Delete and reInsert) option * WIP Span<byte> * WIP Span<byte> * WIP Span<byte> * WIP Span<byte> * WIP Span<byte> * WIP Span<byte> * WIP Span<byte> * WIP Span<byte> (Tsavorite builds, with a couple hacks) * WIP Span<byte>: YCSB fixes * WIP Span<byte>: more fixes found during YCSB * Switching CTT, CTRC, TempKv insertions to TSourceLogRecord direct copies (eliminating need for ISessionFunctions calls for those operations) * WIP Span<byte>: more cleanup in Compaction (no TSessionFunctions needed), other fixes related to prior changes * WIP Span<byte>: LogRecord revisions in functions and prep Migrate/Repl for change to LogRecord based * ISessionFunctions revisions - Rename SingleWriter() => InitialWriter(), ConcurrentWriter() => InPlaceWriter() - Rename SinglecDeleter() => InitialDeleter(), ConcurrentDeleter() => InPlaceDeleter() - Consolidate SingleReader() and ConcurrentReader() to just Reader() * Remove TInput, TOutput, TContext from Compact and PrepareIOForConditionalOperation chain * Remove WriteReason as it is no longer needed with Compaction, CopyToTail, and CopyToReadCache now being fully internal operations. * Missed a few WriteReason * WIP Span<byte>: Cleanup DiskLogRecord deserialization and remove some no-longer-needed allocator functions that are now done by DLR * Varebyte in DiskLogRecord * More LogRecord testing * FInish DiskLogRecord serialization tests * Rename SpanField to LogField * Various cleanup, including PrepareForRevivification * WIP on converting Replication and Migration to LogRecord * WIP on Repl (done-ish) and Migrate (mostly done except ISF) conversion to DiskLogRecord * Split IHO.Size into .MemorySize, DiskSize Almost done with Migrate changeover to LogRecord * Finish LogRecordization of Migrate * First fixes for Migration testing * More Migrate testing; use SBAM.MemorySpan * SImple Migrate tests now run * Simple diskless replica runs * Fixes for in-memory tests * Add UpsertValueSelector * Remove PendingContext.IsAsync (a remnant of earlier, since-removed async APIs) from Tsavorite * Cleanup Read initialization of PendingContext * Fix record alignment in YCSB test * tune HashBytes * Fix initial inserting in YCSB * Update LogRecord.md and some cleanup * Restore TsavoriteAof naming back to TsavoriteLog * Add changes for AddressType in logicalAddresses and enable minimal IO 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 * Fix a few more cursor tests (int => long) * Fixes for review comments (except for "ref RecordSizeInfo") * TSourceLogRecord and RecordSizeInfo parameters are readonly so make them "in" rather than "ref" * Fix some missing ref => in for TSourceLogRecord * Merge fixes; MigrateKeysWithObjects test still fails * Fix Object store migration typo * format * ObjectAllocator serialization - not yet complete * Garnet Storage v2 (#1384) * wip * wip * wip * Added unified store session * Correcting generic typing * Added MEMORY USAGE + TYPE to unified ops * Added TTL, EXPIRETIME and EXISTS to unified ops * implemented DEL in unified ops * wip - expire & persist (broken) * wip - adding expire to unified ops * wip - expire * add cref to server-side replication inter-node commands * fix server-side BeginRecoverReplica * wip * Fix transaction key locking * format * Some test fixes * Fixing tests * reverting a couple of unnecessary changes * Eliminating more multi-context methods from API * Removed some unnecessary stuff * Some more cleanup to TransactionManager * merge tedhar/storage-v2 (ObjectAllocator serialization updates) * Updating memory usage values * format * Handling wrong type ops * Revert "Updating memory usage values" This reverts commit 88ba307. * fix no-object-log case * Fixes for Tsavorite UTs * Fixes for Tsavorite UTs (mostly ReadCache, TsavoriteLog, Compaction) * Tsavorite Iterator work and UT re-enabling * Fixes to Object iteration, LogRecord.ToString() * Add RecordMetadata.ETag * Readding --no-obj config * fix * test fix * Prep for Recovery * wip * wip * fix * More fixes for UT (mostly Recovery, Migration) * Moving DELIFEXPIM to unified store * ObjectLogTail in Recovery, and more UT fixes (Migration record serialization, ReadCache size and tailAddress verification calculations, etc.) * More Tsavorite recovery tests * Removing unnecessary isObject flag from record serialization --------- Co-authored-by: Vasileios Zois <[email protected]> Co-authored-by: TedHartMS <[email protected]> * Removing unnecessary output flag * Fixes for StateMachineTests (Recovery) * Fixes, mostly for Replication to include object log for UnifiedStore; correctly initialized SegmentSize for ObjectLogDevice; other fixes to UTs to work with UnifiedStore * fixes * Fixes for RESP UTs for Unified; clear logRecord on deserialization error * Remove SerializedSize(IsExact) from IHeapObject; various UT fixes * All Cluster.test now passes * small fixes * Fix TailAddress from Rescovery not being PageHeader-aligned * Move RENAME to Unified Store and modify for LogRecord * Fixing rename with etag + removing remaining unnecessary GarnetObjectTypes * Add ITsavoriteRecordObserver and fix Readcache size tracking * Convert LogRecord to use RecordLength * More work on LogRecord.RecordLength * Finish LogRecord.RecordLength * Remove ObjectDb* from Sample*Txn * MultiLevelPageArray stress fixes; improved LogRecord and RecordDataHeader ToString() * Fix GetObjectLogSegmentSize() * update docs * Fix a couple comments * Trim ObjectIdMap arrays on ClearPage * wip * wip * wip * wip * wip * wip * wip * wip * formatting tsavo * Fixing website build error * some renames * small rename * some small changes * Version update * Address review comments; implement OA Truncate; add --value-overflow-threshold configuration option * ObjectAllocator testing * Add large (multi-GB) object tests (and fix associated issues, mostly object-log segments); PendingContext is no longer itself a TSourceLogRecord; * readcache fixes * Move KVSettings from GarnetServer to the individual Database, so we can dispose the log devices. Remove KVSettings from CachedSizeTracker as it was unused Fix some Tsavorite LogRecord-lifetime issues on scan and conditional insert/push * WIP to fix replica for object log segments * Fixes for ObjectLog recovery * Some additional ObjectRecovery test conversion, not ready yet * Convert and re-enable more Tsavorite ObjectRecovery tests. Fix CacheSerializedData to not overwrite if CopyUpdater already set the object Fix foldover checkpoint storage of object log tail * format * A couple fixes for DiskLogRecord serialization * Fix SimpleIncrementByFloatWithOutOfRangeFloat exception verification to use Throws.TypeOf<>().Or.TypeOf<>()) Make SpanByteRcMultiThreadTest [Explicit] until I figure out the request_key issue * Address review comments Fix merge error that resulted in Cluster timeouts Minor cleanup * format * Comment out [Repeat] --------- Co-authored-by: Tal Zaccai <[email protected]> Co-authored-by: Vasileios Zois <[email protected]>
1 parent 935cf3f commit fcbed38

File tree

588 files changed

+31149
-26764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

588 files changed

+31149
-26764
lines changed

Version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<!-- VersionPrefix property for builds and packages -->
33
<PropertyGroup>
4-
<VersionPrefix>1.0.91</VersionPrefix>
4+
<VersionPrefix>2.0.0-beta.1</VersionPrefix>
55
</PropertyGroup>
66
</Project>

benchmark/BDN.benchmark/Custom/CustomTxnSet.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ sealed class CustomTxnSet : CustomTransactionProcedure
2222
/// </summary>
2323
public const string CommandName = "CTXNSET";
2424

25-
ArgSlice setA;
26-
ArgSlice setB;
27-
ArgSlice setC;
28-
ArgSlice setD;
25+
PinnedSpanByte setA;
26+
PinnedSpanByte setB;
27+
PinnedSpanByte setC;
28+
PinnedSpanByte setD;
2929

30-
ArgSlice valueA;
31-
ArgSlice valueB;
32-
ArgSlice valueC;
33-
ArgSlice valueD;
30+
PinnedSpanByte valueA;
31+
PinnedSpanByte valueB;
32+
PinnedSpanByte valueC;
33+
PinnedSpanByte valueD;
3434

3535
/// <summary>
3636
/// CTXNSET key1 key2 key3 key4 value1 value2 value3 value4
@@ -52,10 +52,10 @@ public override bool Prepare<TGarnetReadApi>(TGarnetReadApi api, ref CustomProce
5252
valueC = GetNextArg(ref procInput, ref offset);
5353
valueD = GetNextArg(ref procInput, ref offset);
5454

55-
AddKey(setA, LockType.Exclusive, isObject: false);
56-
AddKey(setB, LockType.Exclusive, isObject: false);
57-
AddKey(setC, LockType.Exclusive, isObject: false);
58-
AddKey(setD, LockType.Exclusive, isObject: false);
55+
AddKey(setA, LockType.Exclusive, StoreType.Main);
56+
AddKey(setB, LockType.Exclusive, StoreType.Main);
57+
AddKey(setC, LockType.Exclusive, StoreType.Main);
58+
AddKey(setD, LockType.Exclusive, StoreType.Main);
5959

6060
return true;
6161
}

benchmark/Resp.benchmark/OnlineReqGen.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public unsafe partial class OnlineReqGen
2020
/// <summary>
2121
/// DbSize, ObjectDbSize, NumBuffs
2222
/// </summary>
23-
public readonly int DbSize, ObjectDbSize, NumBuffs;
23+
public readonly int DbSize, NumBuffs;
2424

2525
readonly byte[] ascii_chars = Encoding.ASCII.GetBytes("abcdefghijklmnopqrstvuwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
2626
readonly byte[] number_chars = Encoding.ASCII.GetBytes("0123456789");
@@ -35,19 +35,11 @@ public unsafe partial class OnlineReqGen
3535

3636
public readonly int keyLen, valueLen;
3737

38-
public OnlineReqGen(int thread_id, int DbSize, bool randomGen = true, bool zipf = false, int keyLen = default, int valueLen = default, int objectDbSize = -1)
38+
public OnlineReqGen(int thread_id, int DbSize, bool randomGen = true, bool zipf = false, int keyLen = default, int valueLen = default)
3939
{
4040
this.randomGen = randomGen;
4141
this.DbSize = DbSize;
4242
this.zipf = zipf;
43-
if (objectDbSize == -1)
44-
{
45-
this.ObjectDbSize = DbSize;
46-
}
47-
else
48-
{
49-
this.ObjectDbSize = objectDbSize;
50-
}
5143

5244
this.keyLen = Math.Max(NumUtils.NumDigits(DbSize), keyLen);
5345
this.valueLen = valueLen == default ? 8 : valueLen;
@@ -113,7 +105,8 @@ public Memory<byte> GenerateKeyBytesRandom()
113105
{
114106
uint key = (uint)(randomGen ? (zipf ? zipfg.Next() : keyRandomGen.Next(DbSize)) : (keyIndex++ % DbSize));
115107
key *= 20323;
116-
for (int i = 0; i < keyLen; i++)
108+
keyBuffer[0] = (byte)'S'; // Uniquifier to avoid collisions with object keys.
109+
for (int i = 1; i < keyLen; i++)
117110
{
118111
keyBuffer[i] = ascii_chars[key % ascii_chars.Length];
119112
key *= 3;
@@ -188,8 +181,9 @@ public Memory<byte> GenerateObjectEntryScoreBytes()
188181
/// </summary>
189182
public Memory<byte> GenerateObjectKeyBytesRandom()
190183
{
191-
uint key = (uint)(randomGen ? (zipf ? zipfg.Next() : keyRandomGen.Next(ObjectDbSize)) : (keyIndex++ % ObjectDbSize));
192-
for (int i = 0; i < keyLen; i++)
184+
uint key = (uint)(randomGen ? (zipf ? zipfg.Next() : keyRandomGen.Next(DbSize)) : (keyIndex++ % DbSize));
185+
keyBuffer[0] = (byte)'O'; // Uniquifier to avoid collisions with string keys.
186+
for (int i = 1; i < keyLen; i++)
193187
{
194188
keyBuffer[i] = ascii_chars[key % ascii_chars.Length];
195189
key *= 3;

benchmark/Resp.benchmark/Options.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ public partial class Options
102102
[Option("op-workload", Separator = ',', Default = new[] { OpType.GET, OpType.SET, OpType.DEL }, HelpText = "Workload of commands for online bench.")]
103103
public IEnumerable<OpType> OpWorkload { get; set; }
104104

105-
[Option("object-dbsize", Required = false, Default = -1, HelpText = "Object DB size")]
106-
public int ObjectDbSize { get; set; }
107-
108105
[Option("save-freq", Required = false, Default = 0, HelpText = "Save (checkpoint) frequency in seconds")]
109106
public int SaveFreqSecs { get; set; }
110107

benchmark/Resp.benchmark/PeriodicCheckpointer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public void Start(string address, int port)
2626
var server = redis.GetServer(address, port);
2727
while (true)
2828
{
29-
if (cts.IsCancellationRequested) break;
29+
if (cts.IsCancellationRequested)
30+
break;
3031
Thread.Sleep(periodMs);
3132
try
3233
{

benchmark/Resp.benchmark/ReqGen.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ private void RandomString()
306306
{
307307
for (int i = 0; i < valueBuffer.Length; i++)
308308
{
309+
// The first digit of the output string should not be zero.
309310
if (i == 0)
310311
valueBuffer[i] = ascii_digits[1 + valueRandomGen.Next(ascii_digits.Length - 1)];
311312
else

benchmark/Resp.benchmark/RespOnlineBench.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private void InitializeClients()
209209
private Thread[] InitializeThreadWorkers()
210210
{
211211
Thread[] workers = new Thread[NumThreads];
212-
for (int idx = 0; idx < NumThreads; ++idx)
212+
for (int idx = 0; idx < NumThreads; idx++)
213213
{
214214
int x = idx;
215215

@@ -563,7 +563,7 @@ public async void OpRunnerGarnetClientSession(int thread_id)
563563
_ = Interlocked.Increment(ref workerCount);
564564
if (opts.BatchSize.First() != 1)
565565
throw new Exception("Only batch size 1 supported for online bench");
566-
var req = new OnlineReqGen(thread_id, opts.DbSize, true, opts.Zipf, opts.KeyLength, opts.ValueLength, opts.ObjectDbSize);
566+
var req = new OnlineReqGen(thread_id, opts.DbSize, true, opts.Zipf, opts.KeyLength, opts.ValueLength);
567567

568568
GarnetClientSession client = null;
569569
if (!opts.Pool)
@@ -607,8 +607,12 @@ public async void OpRunnerGarnetClientSession(int thread_id)
607607
OpType.ZREM => await ZREM(),
608608
OpType.ZCARD => await ZCARD(),
609609
OpType.READWRITETX => await c.ExecuteAsync("READWRITETX", req.GenerateKey(), req.GenerateKey(), req.GenerateKey(), "1000"),
610-
OpType.SAMPLEUPDATETX => await c.ExecuteAsync("SAMPLEUPDATETX", req.GenerateKeyRandom(), req.GenerateValue(), req.GenerateObjectKeyRandom(), req.GenerateObjectEntry(), req.GenerateObjectEntryScore(), req.GenerateObjectKeyRandom(), req.GenerateObjectEntry(), req.GenerateObjectEntryScore()),
611-
OpType.SAMPLEDELETETX => await c.ExecuteAsync("SAMPLEDELETETX", req.GenerateKeyRandom(), req.GenerateObjectKeyRandom(), req.GenerateObjectEntry(), req.GenerateObjectKeyRandom(), req.GenerateObjectEntry()),
610+
OpType.SAMPLEUPDATETX => await c.ExecuteAsync("SAMPLEUPDATETX", req.GenerateKeyRandom(), req.GenerateValue(), // stringKey
611+
req.GenerateObjectKeyRandom(), req.GenerateObjectEntry(), req.GenerateObjectEntryScore(), // sortedSetKey1
612+
req.GenerateObjectKeyRandom(), req.GenerateObjectEntry(), req.GenerateObjectEntryScore()), // sortedSetKey2
613+
OpType.SAMPLEDELETETX => await c.ExecuteAsync("SAMPLEDELETETX", req.GenerateKeyRandom(), // stringKey
614+
req.GenerateObjectKeyRandom(), req.GenerateObjectEntry(), // sortedSetKey1
615+
req.GenerateObjectKeyRandom(), req.GenerateObjectEntry()), // sortedSetKey2
612616
_ => throw new Exception($"opType: {op} benchmark not supported with {opts.Client} ClientType!")
613617
};
614618

benchmark/Resp.benchmark/RespPerfBench.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public void PerformMGET(int NumOps, int NumThreads, int BatchSize = 1 << 12)
209209
Thread[] workers = new Thread[NumThreads];
210210

211211
// Run the experiment.
212-
for (int idx = 0; idx < NumThreads; ++idx)
212+
for (int idx = 0; idx < NumThreads; idx++)
213213
{
214214
int x = idx;
215215
workers[idx] = new Thread(() => MGetThreadRunner(x, NumOps, BatchSize));
@@ -323,7 +323,7 @@ public ReqGen LightOperate(
323323
Thread[] workers = new Thread[NumThreads];
324324

325325
// Run the experiment.
326-
for (int idx = 0; idx < NumThreads; ++idx)
326+
for (int idx = 0; idx < NumThreads; idx++)
327327
{
328328
int x = idx;
329329
workers[idx] = opts.Client switch

benchmark/Resp.benchmark/TxnPerfBench.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void Run()
132132
redis = Program.redis;
133133
}
134134
}
135-
for (int idx = 0; idx < NumThreads; ++idx)
135+
for (int idx = 0; idx < NumThreads; idx++)
136136
{
137137
int x = idx;
138138

benchmark/Resp.benchmark/ZipfGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public ZipfGenerator(RandomGenerator rng, int size, double theta = 0.99)
2929
private static double Zeta(int count, double theta)
3030
{
3131
double zetaN = 0.0;
32-
for (var ii = 1; ii <= count; ++ii)
32+
for (var ii = 1; ii <= count; ii++)
3333
zetaN += 1.0 / Math.Pow(ii, theta);
3434
return zetaN;
3535
}

0 commit comments

Comments
 (0)