@glimt/record 0.0.27 → 0.0.29
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/record.cjs +73 -22
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +73 -22
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +73 -22
- package/dist/record.umd.cjs.map +2 -2
- package/dist/record.umd.min.cjs +14 -14
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.umd.cjs
CHANGED
|
@@ -9465,38 +9465,89 @@ class MutationBuffer {
|
|
|
9465
9465
|
__publicField(this, "canvasManager");
|
|
9466
9466
|
__publicField(this, "processedNodeManager");
|
|
9467
9467
|
__publicField(this, "unattachedDoc");
|
|
9468
|
-
__publicField(this, "
|
|
9469
|
-
__publicField(this, "
|
|
9468
|
+
__publicField(this, "stormBatches", []);
|
|
9469
|
+
__publicField(this, "stormInfo");
|
|
9470
|
+
__publicField(this, "stormSettings", {
|
|
9471
|
+
batchSize: 300,
|
|
9472
|
+
timeout: 50,
|
|
9473
|
+
mutationLimit: 1500
|
|
9474
|
+
});
|
|
9475
|
+
__publicField(this, "handleStormMutations", (muts) => {
|
|
9476
|
+
const time = Date.now();
|
|
9477
|
+
if (this.stormInfo == null) {
|
|
9478
|
+
console.log("detected probable mutation storm start");
|
|
9479
|
+
this.stormInfo = {
|
|
9480
|
+
startedAt: time,
|
|
9481
|
+
totalMutations: 0,
|
|
9482
|
+
timeout: setTimeout(this.handleStormFinish, this.stormSettings.timeout),
|
|
9483
|
+
stormExceededLimit: false
|
|
9484
|
+
};
|
|
9485
|
+
}
|
|
9486
|
+
this.stormInfo.totalMutations += muts.length;
|
|
9487
|
+
console.log("current storm mutations", this.stormInfo.totalMutations);
|
|
9488
|
+
if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
|
|
9489
|
+
this.stormInfo.stormExceededLimit = true;
|
|
9490
|
+
this.stormBatches = [];
|
|
9491
|
+
} else {
|
|
9492
|
+
this.stormBatches.push({
|
|
9493
|
+
ts: time,
|
|
9494
|
+
mutations: muts
|
|
9495
|
+
});
|
|
9496
|
+
}
|
|
9497
|
+
if (muts.length < this.stormSettings.batchSize) {
|
|
9498
|
+
clearTimeout(this.stormInfo.timeout);
|
|
9499
|
+
this.handleStormFinish();
|
|
9500
|
+
}
|
|
9501
|
+
});
|
|
9502
|
+
__publicField(this, "handleStormFinish", () => {
|
|
9503
|
+
if (!this.stormInfo) return;
|
|
9504
|
+
const { stormExceededLimit } = this.stormInfo;
|
|
9505
|
+
console.log(
|
|
9506
|
+
"mutation storm finished",
|
|
9507
|
+
"totalMutations:",
|
|
9508
|
+
this.stormInfo.totalMutations,
|
|
9509
|
+
"stormExceededLimit:",
|
|
9510
|
+
stormExceededLimit,
|
|
9511
|
+
"storm duration:",
|
|
9512
|
+
Date.now() - this.stormInfo.startedAt,
|
|
9513
|
+
"ms"
|
|
9514
|
+
);
|
|
9515
|
+
clearTimeout(this.stormInfo.timeout);
|
|
9516
|
+
this.stormInfo = null;
|
|
9517
|
+
if (!stormExceededLimit) {
|
|
9518
|
+
let muts = [];
|
|
9519
|
+
for (const batch of this.stormBatches) {
|
|
9520
|
+
muts.push(...batch.mutations);
|
|
9521
|
+
}
|
|
9522
|
+
this.stormBatches = [];
|
|
9523
|
+
this.processInternalMutations(muts, true);
|
|
9524
|
+
} else {
|
|
9525
|
+
this.stormBatches = [];
|
|
9526
|
+
takeFullSnapshot();
|
|
9527
|
+
}
|
|
9528
|
+
});
|
|
9529
|
+
__publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
|
|
9530
|
+
if (!overrideStorm && (this.stormInfo != null || muts.length >= this.stormSettings.batchSize)) {
|
|
9531
|
+
this.handleStormMutations(muts);
|
|
9532
|
+
return;
|
|
9533
|
+
}
|
|
9470
9534
|
const start = performance.now();
|
|
9471
|
-
|
|
9472
|
-
for (const mut of mutations) {
|
|
9473
|
-
const mutStart = performance.now();
|
|
9535
|
+
for (const mut of muts) {
|
|
9474
9536
|
this.processMutation(mut);
|
|
9475
|
-
const took = performance.now() - mutStart;
|
|
9476
|
-
if (!uniqueTypes.includes(mut.type)) uniqueTypes.push(mut.type);
|
|
9477
|
-
if (!(mut.type in this.tempPerfStore)) {
|
|
9478
|
-
this.tempPerfStore[mut.type] = {
|
|
9479
|
-
avg: 0,
|
|
9480
|
-
times: []
|
|
9481
|
-
};
|
|
9482
|
-
}
|
|
9483
|
-
this.tempPerfStore[mut.type].times.push(took);
|
|
9484
|
-
if (this.tempPerfStore[mut.type].times.length > 1e3) {
|
|
9485
|
-
this.tempPerfStore[mut.type].times.shift();
|
|
9486
|
-
}
|
|
9487
|
-
this.tempPerfStore[mut.type].avg = this.tempPerfStore[mut.type].times.reduce((a2, b) => a2 + b, 0) / this.tempPerfStore[mut.type].times.length;
|
|
9488
9537
|
}
|
|
9489
9538
|
console.log(
|
|
9490
|
-
|
|
9539
|
+
muts.length,
|
|
9491
9540
|
"mutations processed in",
|
|
9492
9541
|
performance.now() - start,
|
|
9493
9542
|
"ms",
|
|
9494
|
-
"
|
|
9495
|
-
|
|
9543
|
+
"overrideStorm",
|
|
9544
|
+
overrideStorm
|
|
9496
9545
|
);
|
|
9497
|
-
window.temp_perf_store = this.tempPerfStore;
|
|
9498
9546
|
this.emit();
|
|
9499
9547
|
});
|
|
9548
|
+
__publicField(this, "processMutations", (mutations) => {
|
|
9549
|
+
this.processInternalMutations(mutations);
|
|
9550
|
+
});
|
|
9500
9551
|
__publicField(this, "emit", () => {
|
|
9501
9552
|
if (this.frozen || this.locked) {
|
|
9502
9553
|
return;
|