@slot-engine/core 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2422,6 +2422,24 @@ var Simulation = class {
|
|
|
2422
2422
|
const lookupSegmentedStream = fs3.createWriteStream(tempLookupSegPath, {
|
|
2423
2423
|
highWaterMark: this.maxHighWaterMark
|
|
2424
2424
|
});
|
|
2425
|
+
const WRITE_BATCH_SIZE = 200;
|
|
2426
|
+
let booksIndexBatch = [];
|
|
2427
|
+
let lookupBatch = [];
|
|
2428
|
+
let lookupSegBatch = [];
|
|
2429
|
+
const flushWriteBatches = async () => {
|
|
2430
|
+
if (booksIndexBatch.length === 0) return;
|
|
2431
|
+
const booksIndexData = booksIndexBatch.join("");
|
|
2432
|
+
const lookupData = lookupBatch.join("");
|
|
2433
|
+
const lookupSegData = lookupSegBatch.join("");
|
|
2434
|
+
booksIndexBatch = [];
|
|
2435
|
+
lookupBatch = [];
|
|
2436
|
+
lookupSegBatch = [];
|
|
2437
|
+
await Promise.all([
|
|
2438
|
+
write(booksIndexStream, booksIndexData),
|
|
2439
|
+
write(lookupStream, lookupData),
|
|
2440
|
+
write(lookupSegmentedStream, lookupSegData)
|
|
2441
|
+
]);
|
|
2442
|
+
};
|
|
2425
2443
|
let writeChain = Promise.resolve();
|
|
2426
2444
|
worker.on("message", (msg) => {
|
|
2427
2445
|
if (msg.type === "log" || msg.type === "user-log") {
|
|
@@ -2501,20 +2519,19 @@ var Simulation = class {
|
|
|
2501
2519
|
if (!this.tempBookIndexPaths.includes(booksIndexPath)) {
|
|
2502
2520
|
this.tempBookIndexPaths.push(booksIndexPath);
|
|
2503
2521
|
}
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
booksIndexStream,
|
|
2507
|
-
`${book.id},${index},${this.bookChunkIndexes.get(index) || 0}
|
|
2522
|
+
booksIndexBatch.push(
|
|
2523
|
+
`${book.id},${index},${this.bookChunkIndexes.get(index) || 0}
|
|
2508
2524
|
`
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
`)
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
`${book.id},${book.criteria},${book.basegameWins},${book.freespinsWins}
|
|
2525
|
+
);
|
|
2526
|
+
lookupBatch.push(`${book.id},1,${Math.round(book.payout)}
|
|
2527
|
+
`);
|
|
2528
|
+
lookupSegBatch.push(
|
|
2529
|
+
`${book.id},${book.criteria},${book.basegameWins},${book.freespinsWins}
|
|
2515
2530
|
`
|
|
2516
|
-
|
|
2517
|
-
|
|
2531
|
+
);
|
|
2532
|
+
if (booksIndexBatch.length >= WRITE_BATCH_SIZE) {
|
|
2533
|
+
await flushWriteBatches();
|
|
2534
|
+
}
|
|
2518
2535
|
if (this.bookBufferSizes.get(index) >= 10 * 1024 * 1024) {
|
|
2519
2536
|
await flushBookChunk();
|
|
2520
2537
|
}
|
|
@@ -2535,6 +2552,7 @@ var Simulation = class {
|
|
|
2535
2552
|
}
|
|
2536
2553
|
if (msg.type === "done") {
|
|
2537
2554
|
writeChain.then(async () => {
|
|
2555
|
+
await flushWriteBatches();
|
|
2538
2556
|
await flushBookChunk();
|
|
2539
2557
|
lookupStream.end();
|
|
2540
2558
|
lookupSegmentedStream.end();
|