public unsafe void Populate() { List <Guid> tokens = new List <Guid>(); Empty context; // Prepare the dataset var inputArray = new Input[numOps]; for (int i = 0; i < numOps; i++) { inputArray[i].adId.adId = i % numUniqueKeys; inputArray[i].numClicks.numClicks = 1; } // Register thread with FASTER fht.StartSession(); // Prpcess the batch of input data fixed(Input *input = inputArray) { for (int i = 0; i < numOps; i++) { fht.RMW(&((input + i)->adId), input + i, &context, i); if (i % checkpointInterval == 0) { if (fht.TakeFullCheckpoint(out Guid token)) { tokens.Add(token); } } if (i % completePendingInterval == 0) { fht.CompletePending(false); } else if (i % refreshInterval == 0) { fht.Refresh(); } } } // Make sure operations are completed fht.CompletePending(true); // Deregister thread from FASTER fht.StopSession(); Console.WriteLine("Populate successful"); foreach (var token in tokens) { Console.WriteLine(token); } Console.ReadLine(); }
private unsafe void PopulateWorker(int threadId) { Native32.AffinitizeThreadRoundRobin((uint)threadId); Empty context; var success = inputArrays.TryTake(out Input[] inputArray); if (!success) { Console.WriteLine("No input array for {0}", threadId); return; } // Register thread with the store fht.StartSession(); Interlocked.Increment(ref numActiveThreads); // Process the batch of input data fixed(Input *input = inputArray) { for (long i = 0; i < numOps; i++) { fht.RMW(&((input + i)->adId), input + i, &context, i); if ((i + 1) % checkpointInterval == 0 && numActiveThreads == threadCount) { if (fht.TakeFullCheckpoint(out Guid token)) { tokens.Add(token); } } if (i % completePendingInterval == 0) { fht.CompletePending(false); } else if (i % refreshInterval == 0) { fht.Refresh(); } } } // Make sure operations are completed fht.CompletePending(true); // Deregister thread from FASTER fht.StopSession(); //Interlocked.Decrement(ref numActiveThreads); Console.WriteLine("Populate successful on thread {0}", threadId); }
private unsafe void PopulateWorker(int threadId) { Native32.AffinitizeThreadRoundRobin((uint)threadId); Empty context; var success = inputArrays.TryTake(out Input[] inputArray); if (!success) { Console.WriteLine("No input array for {0}", threadId); return; } // Register thread with the store fht.StartSession(); Interlocked.Increment(ref numActiveThreads); // Process the batch of input data var random = new Random(threadId + 1); threadNumOps[threadId] = (numOps / 2) + random.Next() % (numOps / 4); fixed(Input *input = inputArray) { for (long i = 0; i < threadNumOps[threadId]; i++) { fht.RMW(&((input + i)->adId), input + i, &context, i); if (i % completePendingInterval == 0) { fht.CompletePending(false); } else if (i % refreshInterval == 0) { fht.Refresh(); } } } // Make sure operations are completed fht.CompletePending(true); // Deregister thread from FASTER fht.StopSession(); //Interlocked.Decrement(ref numActiveThreads); Console.WriteLine("Populate successful on thread {0}", threadId); }
public void Setup() { log = new LocalStorageDevice("hybridlog_native.log", deleteOnClose: true); fht = FasterFactory.Create <KeyStruct, ValueStruct, InputStruct, OutputStruct, Empty, Functions, ICustomFaster> (128, log); fht.StartSession(); }
public void Setup() { var log = FASTERFactory.CreateLogDevice(Path.GetTempPath() + "\\hybridlog_native.log"); fht = FASTERFactory.Create <KeyStruct, ValueStruct, InputStruct, OutputStruct, Empty, Functions, ICustomFaster> (128, log); fht.StartSession(); }
public void Setup() { log = new LocalStorageDevice(TestContext.CurrentContext.TestDirectory + "\\hybridlog_native.log", deleteOnClose: true); fht = FasterFactory.Create <KeyStruct, ValueStruct, InputStruct, OutputStruct, Empty, Functions, ICustomFaster> (128, new LogSettings { LogDevice = log }); fht.StartSession(); }
public unsafe void Populate() { Empty context; // Prepare the dataset var inputArray = new Input[numOps]; for (int i = 0; i < numOps; i++) { inputArray[i].adId.adId = i % numUniqueKeys; inputArray[i].numClicks.numClicks = 1; } // Register thread with FASTER fht.StartSession(); // Prpcess the batch of input data bool first = true; fixed(Input *input = inputArray) { for (int i = 0; i < numOps; i++) { fht.RMW(&((input + i)->adId), input + i, &context, i); if ((i + 1) % checkpointInterval == 0) { if (first) { while (!fht.TakeFullCheckpoint(out token)) { fht.Refresh(); } } else { while (!fht.TakeFullCheckpoint(out Guid nextToken)) { fht.Refresh(); } } first = false; } if (i % completePendingInterval == 0) { fht.CompletePending(false); } else if (i % refreshInterval == 0) { fht.Refresh(); } } } // Make sure operations are completed fht.CompletePending(true); // Deregister thread from FASTER fht.StopSession(); }
public unsafe void SimpleRecoveryTest1() { log = FasterFactory.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog", deleteOnClose: true); Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints"); fht1 = FasterFactory.Create <AdId, NumClicks, Input, Output, Empty, SimpleFunctions, ICustomFaster> (indexSizeBuckets: 128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 }, checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints", CheckPointType = CheckpointType.Snapshot } ); fht2 = FasterFactory.Create <AdId, NumClicks, Input, Output, Empty, SimpleFunctions, ICustomFaster> (indexSizeBuckets: 128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 }, checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints", CheckPointType = CheckpointType.Snapshot } ); int numOps = 5000; var inputArray = new AdId[numOps]; for (int i = 0; i < numOps; i++) { inputArray[i].adId = i; } NumClicks value; Input inputArg; Output output; fixed(AdId *input = inputArray) { fht1.StartSession(); for (int key = 0; key < numOps; key++) { value.numClicks = key; fht1.Upsert(input + key, &value, null, 0); } fht1.TakeFullCheckpoint(out Guid token); fht1.CompleteCheckpoint(true); fht1.StopSession(); fht2.Recover(token); fht2.StartSession(); for (int key = 0; key < numOps; key++) { var status = fht2.Read(input + key, &inputArg, &output, null, 0); if (status == Status.PENDING) { fht2.CompletePending(true); } else { Assert.IsTrue(output.value.numClicks == key); } } fht2.StopSession(); } log.Close(); fht1.Dispose(); fht2.Dispose(); new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints").Delete(true); }