Skip to content

Commit

Permalink
fix: prune checkpoint states at syncing time (#7241)
Browse files Browse the repository at this point in the history
* fix: prune checkpoint states at syncing time

* fix: lint

* fix: check-types in test
  • Loading branch information
twoeths authored Nov 27, 2024
1 parent 18f4218 commit e86e816
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 37 deletions.
1 change: 0 additions & 1 deletion packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ export class BeaconChain implements IBeaconChain {
metrics,
logger,
clock,
shufflingCache: this.shufflingCache,
blockStateCache,
bufferPool: this.bufferPool,
datastore: fileDataStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,20 @@ import {AllocSource, BufferPool, BufferWithKey} from "../../util/bufferPool.js";
import {IClock} from "../../util/clock.js";
import {StateCloneOpts} from "../regen/interface.js";
import {serializeState} from "../serializeState.js";
import {ShufflingCache} from "../shufflingCache.js";
import {CPStateDatastore, DatastoreKey, datastoreKeyToCheckpoint} from "./datastore/index.js";
import {MapTracker} from "./mapMetrics.js";
import {BlockStateCache, CacheItemType, CheckpointHex, CheckpointStateCache} from "./types.js";

export type PersistentCheckpointStateCacheOpts = {
/** Keep max n states in memory, persist the rest to disk */
maxCPStateEpochsInMemory?: number;
/** for testing only */
processLateBlock?: boolean;
};

type PersistentCheckpointStateCacheModules = {
metrics?: Metrics | null;
logger: Logger;
clock?: IClock | null;
signal?: AbortSignal;
shufflingCache: ShufflingCache;
datastore: CPStateDatastore;
blockStateCache: BlockStateCache;
bufferPool?: BufferPool | null;
Expand Down Expand Up @@ -102,24 +98,12 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
private preComputedCheckpoint: string | null = null;
private preComputedCheckpointHits: number | null = null;
private readonly maxEpochsInMemory: number;
// only for testing, default false for production
private readonly processLateBlock: boolean;
private readonly datastore: CPStateDatastore;
private readonly shufflingCache: ShufflingCache;
private readonly blockStateCache: BlockStateCache;
private readonly bufferPool?: BufferPool | null;

constructor(
{
metrics,
logger,
clock,
signal,
shufflingCache,
datastore,
blockStateCache,
bufferPool,
}: PersistentCheckpointStateCacheModules,
{metrics, logger, clock, signal, datastore, blockStateCache, bufferPool}: PersistentCheckpointStateCacheModules,
opts: PersistentCheckpointStateCacheOpts
) {
this.cache = new MapTracker(metrics?.cpStateCache);
Expand Down Expand Up @@ -153,10 +137,8 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
throw new Error("maxEpochsInMemory must be >= 0");
}
this.maxEpochsInMemory = opts.maxCPStateEpochsInMemory ?? DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY;
this.processLateBlock = opts.processLateBlock ?? false;
// Specify different datastore for testing
this.datastore = datastore;
this.shufflingCache = shufflingCache;
this.blockStateCache = blockStateCache;
this.bufferPool = bufferPool;
}
Expand Down Expand Up @@ -487,12 +469,9 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
// 2/3 of slot is the most free time of every slot, take that chance to persist checkpoint states
// normally it should only persist checkpoint states at 2/3 of slot 0 of epoch
await sleep(secToTwoThirdsSlot * 1000, this.signal);
} else if (!this.processLateBlock) {
// normally the block persist happens at 2/3 of slot 0 of epoch, if it's already late then just skip to allow other tasks to run
// there are plenty of chances in the same epoch to persist checkpoint states, also if block is late it could be reorged
this.logger.verbose("Skip persist checkpoint states", {blockSlot, root: blockRootHex});
return 0;
}
// at syncing time, it's critical to persist checkpoint states as soon as possible to avoid OOM during unfinality time
// if node is synced this is not a hot time because block comes late, we'll likely miss attestation already, or the block is orphaned

const persistEpochs = sortedEpochs.slice(0, sortedEpochs.length - this.maxEpochsInMemory);
for (const lowestEpoch of persistEpochs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ describe("PersistentCheckpointStateCache", () => {
{
datastore,
logger: testLogger(),
shufflingCache: new ShufflingCache(),
blockStateCache: new FIFOBlockStateCache({}, {}),
},
{maxCPStateEpochsInMemory: 2, processLateBlock: true}
{maxCPStateEpochsInMemory: 2}
);
cache.add(cp0a, states["cp0a"]);
cache.add(cp0b, states["cp0b"]);
Expand Down Expand Up @@ -165,10 +164,9 @@ describe("PersistentCheckpointStateCache", () => {
{
datastore,
logger: testLogger(),
shufflingCache: new ShufflingCache(),
blockStateCache: new FIFOBlockStateCache({}, {}),
},
{maxCPStateEpochsInMemory: 2, processLateBlock: true}
{maxCPStateEpochsInMemory: 2}
);
cache.add(cp0a, states["cp0a"]);
cache.add(cp0b, states["cp0b"]);
Expand Down Expand Up @@ -242,10 +240,9 @@ describe("PersistentCheckpointStateCache", () => {
{
datastore,
logger: testLogger(),
shufflingCache: new ShufflingCache(),
blockStateCache: new FIFOBlockStateCache({}, {}),
},
{maxCPStateEpochsInMemory: 2, processLateBlock: true}
{maxCPStateEpochsInMemory: 2}
);
cache.add(cp0a, states["cp0a"]);
cache.add(cp0b, states["cp0b"]);
Expand Down Expand Up @@ -548,10 +545,9 @@ describe("PersistentCheckpointStateCache", () => {
{
datastore,
logger: testLogger(),
shufflingCache: new ShufflingCache(),
blockStateCache: new FIFOBlockStateCache({}, {}),
},
{maxCPStateEpochsInMemory: 1, processLateBlock: true}
{maxCPStateEpochsInMemory: 1}
);
cache.add(cp0a, states["cp0a"]);
cache.add(cp0b, states["cp0b"]);
Expand Down Expand Up @@ -820,10 +816,9 @@ describe("PersistentCheckpointStateCache", () => {
{
datastore,
logger: testLogger(),
shufflingCache: new ShufflingCache(),
blockStateCache: new FIFOBlockStateCache({}, {}),
},
{maxCPStateEpochsInMemory: 0, processLateBlock: true}
{maxCPStateEpochsInMemory: 0}
);
cache.add(cp0a, states["cp0a"]);
cache.add(cp0b, states["cp0b"]);
Expand Down Expand Up @@ -911,10 +906,9 @@ describe("PersistentCheckpointStateCache", () => {
{
datastore,
logger: testLogger(),
shufflingCache: new ShufflingCache(),
blockStateCache: new FIFOBlockStateCache({}, {}),
},
{maxCPStateEpochsInMemory: 0, processLateBlock: true}
{maxCPStateEpochsInMemory: 0}
);

const root1a = Buffer.alloc(32, 100);
Expand Down

1 comment on commit e86e816

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for some benchmarks.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold.

Benchmark suite Current: e86e816 Previous: 18f4218 Ratio
Set add up to 64 items then delete first 5.4352 us/op 1.7920 us/op 3.03
OrderedSet add up to 64 items then delete last 10.848 us/op 3.0898 us/op 3.51
Set add up to 64 items then delete middle 7.1179 us/op 2.0410 us/op 3.49
OrderedSet add up to 64 items then delete middle 13.770 us/op 4.5580 us/op 3.02
Set add up to 128 items then delete first 12.779 us/op 4.0353 us/op 3.17
OrderedSet add up to 128 items then delete last 18.181 us/op 5.9651 us/op 3.05
Set add up to 128 items then delete middle 12.316 us/op 3.8608 us/op 3.19
OrderedSet add up to 128 items then delete middle 37.389 us/op 12.052 us/op 3.10
Set add up to 256 items then delete first 26.898 us/op 7.9101 us/op 3.40
OrderedSet add up to 256 items then delete first 39.576 us/op 12.341 us/op 3.21
Set add up to 256 items then delete last 23.779 us/op 7.6223 us/op 3.12
OrderedSet add up to 256 items then delete last 36.783 us/op 11.674 us/op 3.15
Set add up to 256 items then delete middle 22.747 us/op 7.5639 us/op 3.01
forkChoice updateHead vc 600000 bc 320 eq 0 7.2735 ms/op 2.2329 ms/op 3.26
computeDeltas 750000 validators 7200 proto nodes 17.019 ms/op 5.6229 ms/op 3.03
computeDeltas 1400000 validators 7200 proto nodes 34.253 ms/op 11.094 ms/op 3.09
computeDeltas 2100000 validators 300 proto nodes 48.519 ms/op 15.617 ms/op 3.11
computeDeltas 2100000 validators 1200 proto nodes 45.539 ms/op 14.922 ms/op 3.05
altair processAttestation - setStatus - 1/6 committees join 255.00 us/op 69.999 us/op 3.64
altair processAttestation - setStatus - 1/3 committees join 417.31 us/op 138.01 us/op 3.02
altair processEth1Data - 250000 vs - 7PWei normalcase 1.0445 ms/op 272.46 us/op 3.83
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 3.8361 ms/op 1.2373 ms/op 3.10
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 4.3989 ms/op 1.1865 ms/op 3.71
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 10.409 ms/op 2.9855 ms/op 3.49
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 11.572 ms/op 3.3390 ms/op 3.47
Array.fill - length 1000000 10.721 ms/op 2.7042 ms/op 3.96
Uint8Array.get 1.2354 ns/op 0.34837 ns/op 3.55
phase0 processEffectiveBalanceUpdates - 250000 normalcase 3.9062 ms/op 1.0017 ms/op 3.90
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 6.5039 ms/op 1.8746 ms/op 3.47
regular array get 100000 times 94.704 us/op 29.810 us/op 3.18
processSlot - 1 slots 38.197 us/op 12.137 us/op 3.15
getCommitteeAssignments - req 1000 vs - 250000 vc 13.545 ms/op 3.7587 ms/op 3.60
findModifiedValidators - 10000 modified validators 1.1316 s/op 241.54 ms/op 4.68
findModifiedValidators - 1000 modified validators 1.0635 s/op 143.46 ms/op 7.41
findModifiedValidators - 100 modified validators 602.27 ms/op 135.70 ms/op 4.44
findModifiedValidators - 10 modified validators 550.20 ms/op 144.80 ms/op 3.80
findModifiedValidators - 1 modified validators 608.72 ms/op 135.00 ms/op 4.51
findModifiedValidators - no difference 558.11 ms/op 145.99 ms/op 3.82
compare ViewDU to Uint8Array 2.4348 s/op 753.23 ms/op 3.23
state getBlockRootAtSlot - 250000 vs - 7PWei 1.4510 us/op 376.82 ns/op 3.85
toHexString serialized data 2.7225 us/op 811.85 ns/op 3.35
Buffer.toString(base64) 472.65 ns/op 138.27 ns/op 3.42
nodejs block root to RootHex using toHex 468.69 ns/op 126.28 ns/op 3.71
nodejs block root to RootHex using toRootHex 287.90 ns/op 79.003 ns/op 3.64
browser block root to RootHex using the deprecated toHexString 946.00 ns/op 216.69 ns/op 4.37
browser block root to RootHex using toHex 581.09 ns/op 164.95 ns/op 3.52
browser block root to RootHex using toRootHex 442.48 ns/op 146.22 ns/op 3.03
Full benchmark results
Benchmark suite Current: e86e816 Previous: 18f4218 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 4.7388 ms/op 1.9524 ms/op 2.43
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 115.42 us/op 42.152 us/op 2.74
BLS verify - blst 2.2845 ms/op 881.18 us/op 2.59
BLS verifyMultipleSignatures 3 - blst 3.8191 ms/op 1.7449 ms/op 2.19
BLS verifyMultipleSignatures 8 - blst 4.5186 ms/op 2.0996 ms/op 2.15
BLS verifyMultipleSignatures 32 - blst 13.094 ms/op 4.4837 ms/op 2.92
BLS verifyMultipleSignatures 64 - blst 24.268 ms/op 9.0045 ms/op 2.70
BLS verifyMultipleSignatures 128 - blst 40.627 ms/op 16.094 ms/op 2.52
BLS deserializing 10000 signatures 1.5251 s/op 631.17 ms/op 2.42
BLS deserializing 100000 signatures 10.891 s/op 6.3028 s/op 1.73
BLS verifyMultipleSignatures - same message - 3 - blst 1.4225 ms/op 1.0428 ms/op 1.36
BLS verifyMultipleSignatures - same message - 8 - blst 1.5788 ms/op 1.1274 ms/op 1.40
BLS verifyMultipleSignatures - same message - 32 - blst 2.5292 ms/op 1.6910 ms/op 1.50
BLS verifyMultipleSignatures - same message - 64 - blst 4.2388 ms/op 2.5148 ms/op 1.69
BLS verifyMultipleSignatures - same message - 128 - blst 7.8239 ms/op 4.1142 ms/op 1.90
BLS aggregatePubkeys 32 - blst 37.863 us/op 18.158 us/op 2.09
BLS aggregatePubkeys 128 - blst 122.82 us/op 64.005 us/op 1.92
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 137.87 ms/op 83.374 ms/op 1.65
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 100.14 ms/op 65.261 ms/op 1.53
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 80.792 ms/op 41.730 ms/op 1.94
getSlashingsAndExits - default max 146.77 us/op 74.184 us/op 1.98
getSlashingsAndExits - 2k 370.18 us/op 336.02 us/op 1.10
proposeBlockBody type=full, size=empty 10.967 ms/op 6.1156 ms/op 1.79
isKnown best case - 1 super set check 598.00 ns/op 599.00 ns/op 1.00
isKnown normal case - 2 super set checks 564.00 ns/op 561.00 ns/op 1.01
isKnown worse case - 16 super set checks 604.00 ns/op 637.00 ns/op 0.95
InMemoryCheckpointStateCache - add get delete 5.2860 us/op 2.7810 us/op 1.90
validate api signedAggregateAndProof - struct 3.0948 ms/op 1.8835 ms/op 1.64
validate gossip signedAggregateAndProof - struct 2.9868 ms/op 1.8017 ms/op 1.66
batch validate gossip attestation - vc 640000 - chunk 32 247.51 us/op 130.01 us/op 1.90
batch validate gossip attestation - vc 640000 - chunk 64 232.85 us/op 113.79 us/op 2.05
batch validate gossip attestation - vc 640000 - chunk 128 221.98 us/op 115.57 us/op 1.92
batch validate gossip attestation - vc 640000 - chunk 256 196.72 us/op 106.34 us/op 1.85
pickEth1Vote - no votes 2.0823 ms/op 864.90 us/op 2.41
pickEth1Vote - max votes 13.268 ms/op 5.7705 ms/op 2.30
pickEth1Vote - Eth1Data hashTreeRoot value x2048 24.698 ms/op 11.654 ms/op 2.12
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 39.767 ms/op 18.539 ms/op 2.15
pickEth1Vote - Eth1Data fastSerialize value x2048 849.53 us/op 370.63 us/op 2.29
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.5651 ms/op 3.5914 ms/op 1.55
bytes32 toHexString 898.00 ns/op 632.00 ns/op 1.42
bytes32 Buffer.toString(hex) 465.00 ns/op 468.00 ns/op 0.99
bytes32 Buffer.toString(hex) from Uint8Array 826.00 ns/op 558.00 ns/op 1.48
bytes32 Buffer.toString(hex) + 0x 459.00 ns/op 480.00 ns/op 0.96
Object access 1 prop 0.31900 ns/op 0.33600 ns/op 0.95
Map access 1 prop 0.23700 ns/op 0.32300 ns/op 0.73
Object get x1000 12.063 ns/op 5.6860 ns/op 2.12
Map get x1000 12.474 ns/op 6.6140 ns/op 1.89
Object set x1000 60.446 ns/op 29.109 ns/op 2.08
Map set x1000 44.818 ns/op 20.276 ns/op 2.21
Return object 10000 times 0.42900 ns/op 0.31150 ns/op 1.38
Throw Error 10000 times 6.9885 us/op 2.9703 us/op 2.35
toHex 289.99 ns/op 141.10 ns/op 2.06
Buffer.from 262.50 ns/op 120.56 ns/op 2.18
shared Buffer 164.04 ns/op 79.098 ns/op 2.07
fastMsgIdFn sha256 / 200 bytes 3.7610 us/op 2.1850 us/op 1.72
fastMsgIdFn h32 xxhash / 200 bytes 471.00 ns/op 521.00 ns/op 0.90
fastMsgIdFn h64 xxhash / 200 bytes 501.00 ns/op 484.00 ns/op 1.04
fastMsgIdFn sha256 / 1000 bytes 12.207 us/op 5.9110 us/op 2.07
fastMsgIdFn h32 xxhash / 1000 bytes 662.00 ns/op 651.00 ns/op 1.02
fastMsgIdFn h64 xxhash / 1000 bytes 590.00 ns/op 581.00 ns/op 1.02
fastMsgIdFn sha256 / 10000 bytes 104.73 us/op 50.992 us/op 2.05
fastMsgIdFn h32 xxhash / 10000 bytes 3.4480 us/op 2.1020 us/op 1.64
fastMsgIdFn h64 xxhash / 10000 bytes 2.2670 us/op 1.4220 us/op 1.59
send data - 1000 256B messages 24.681 ms/op 13.138 ms/op 1.88
send data - 1000 512B messages 34.228 ms/op 20.279 ms/op 1.69
send data - 1000 1024B messages 54.178 ms/op 30.035 ms/op 1.80
send data - 1000 1200B messages 54.439 ms/op 30.757 ms/op 1.77
send data - 1000 2048B messages 61.967 ms/op 31.605 ms/op 1.96
send data - 1000 4096B messages 59.699 ms/op 32.852 ms/op 1.82
send data - 1000 16384B messages 114.37 ms/op 71.452 ms/op 1.60
send data - 1000 65536B messages 894.86 ms/op 341.02 ms/op 2.62
enrSubnets - fastDeserialize 64 bits 2.8340 us/op 1.2060 us/op 2.35
enrSubnets - ssz BitVector 64 bits 924.00 ns/op 654.00 ns/op 1.41
enrSubnets - fastDeserialize 4 bits 360.00 ns/op 426.00 ns/op 0.85
enrSubnets - ssz BitVector 4 bits 876.00 ns/op 650.00 ns/op 1.35
prioritizePeers score -10:0 att 32-0.1 sync 2-0 337.93 us/op 183.11 us/op 1.85
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 367.35 us/op 148.52 us/op 2.47
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 798.06 us/op 270.86 us/op 2.95
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 975.11 us/op 424.28 us/op 2.30
prioritizePeers score 0:0 att 64-1 sync 4-1 1.4829 ms/op 721.93 us/op 2.05
array of 16000 items push then shift 3.5190 us/op 1.3118 us/op 2.68
LinkedList of 16000 items push then shift 16.851 ns/op 8.3460 ns/op 2.02
array of 16000 items push then pop 260.83 ns/op 123.44 ns/op 2.11
LinkedList of 16000 items push then pop 15.630 ns/op 6.9130 ns/op 2.26
array of 24000 items push then shift 5.7521 us/op 1.9320 us/op 2.98
LinkedList of 24000 items push then shift 15.429 ns/op 6.6210 ns/op 2.33
array of 24000 items push then pop 323.42 ns/op 118.67 ns/op 2.73
LinkedList of 24000 items push then pop 15.276 ns/op 6.3020 ns/op 2.42
intersect bitArray bitLen 8 15.404 ns/op 5.7850 ns/op 2.66
intersect array and set length 8 106.16 ns/op 38.262 ns/op 2.77
intersect bitArray bitLen 128 72.376 ns/op 26.919 ns/op 2.69
intersect array and set length 128 1.7279 us/op 675.21 ns/op 2.56
bitArray.getTrueBitIndexes() bitLen 128 3.5640 us/op 2.3200 us/op 1.54
bitArray.getTrueBitIndexes() bitLen 248 7.1730 us/op 3.5150 us/op 2.04
bitArray.getTrueBitIndexes() bitLen 512 16.396 us/op 7.1310 us/op 2.30
Buffer.concat 32 items 1.8010 us/op 1.0560 us/op 1.71
Uint8Array.set 32 items 2.9500 us/op 1.4470 us/op 2.04
Buffer.copy 3.6830 us/op 2.3660 us/op 1.56
Uint8Array.set - with subarray 6.6760 us/op 2.8830 us/op 2.32
Uint8Array.set - without subarray 3.4700 us/op 2.2970 us/op 1.51
getUint32 - dataview 597.00 ns/op 460.00 ns/op 1.30
getUint32 - manual 446.00 ns/op 354.00 ns/op 1.26
Set add up to 64 items then delete first 5.4352 us/op 1.7920 us/op 3.03
OrderedSet add up to 64 items then delete first 8.2815 us/op 2.8668 us/op 2.89
Set add up to 64 items then delete last 6.1118 us/op 2.1009 us/op 2.91
OrderedSet add up to 64 items then delete last 10.848 us/op 3.0898 us/op 3.51
Set add up to 64 items then delete middle 7.1179 us/op 2.0410 us/op 3.49
OrderedSet add up to 64 items then delete middle 13.770 us/op 4.5580 us/op 3.02
Set add up to 128 items then delete first 12.779 us/op 4.0353 us/op 3.17
OrderedSet add up to 128 items then delete first 16.085 us/op 6.3447 us/op 2.54
Set add up to 128 items then delete last 11.567 us/op 3.9750 us/op 2.91
OrderedSet add up to 128 items then delete last 18.181 us/op 5.9651 us/op 3.05
Set add up to 128 items then delete middle 12.316 us/op 3.8608 us/op 3.19
OrderedSet add up to 128 items then delete middle 37.389 us/op 12.052 us/op 3.10
Set add up to 256 items then delete first 26.898 us/op 7.9101 us/op 3.40
OrderedSet add up to 256 items then delete first 39.576 us/op 12.341 us/op 3.21
Set add up to 256 items then delete last 23.779 us/op 7.6223 us/op 3.12
OrderedSet add up to 256 items then delete last 36.783 us/op 11.674 us/op 3.15
Set add up to 256 items then delete middle 22.747 us/op 7.5639 us/op 3.01
OrderedSet add up to 256 items then delete middle 99.782 us/op 34.724 us/op 2.87
transfer serialized Status (84 B) 3.2260 us/op 1.3930 us/op 2.32
copy serialized Status (84 B) 2.9510 us/op 1.2000 us/op 2.46
transfer serialized SignedVoluntaryExit (112 B) 3.7540 us/op 1.4940 us/op 2.51
copy serialized SignedVoluntaryExit (112 B) 2.7830 us/op 1.2670 us/op 2.20
transfer serialized ProposerSlashing (416 B) 4.5900 us/op 1.6320 us/op 2.81
copy serialized ProposerSlashing (416 B) 4.4460 us/op 1.8190 us/op 2.44
transfer serialized Attestation (485 B) 5.2340 us/op 1.7710 us/op 2.96
copy serialized Attestation (485 B) 4.6380 us/op 1.6600 us/op 2.79
transfer serialized AttesterSlashing (33232 B) 4.7800 us/op 1.6620 us/op 2.88
copy serialized AttesterSlashing (33232 B) 11.484 us/op 4.4390 us/op 2.59
transfer serialized Small SignedBeaconBlock (128000 B) 6.3310 us/op 2.4300 us/op 2.61
copy serialized Small SignedBeaconBlock (128000 B) 31.836 us/op 11.083 us/op 2.87
transfer serialized Avg SignedBeaconBlock (200000 B) 7.2280 us/op 3.8480 us/op 1.88
copy serialized Avg SignedBeaconBlock (200000 B) 46.829 us/op 33.781 us/op 1.39
transfer serialized BlobsSidecar (524380 B) 7.6210 us/op 5.0600 us/op 1.51
copy serialized BlobsSidecar (524380 B) 122.89 us/op 96.778 us/op 1.27
transfer serialized Big SignedBeaconBlock (1000000 B) 6.8700 us/op 4.2620 us/op 1.61
copy serialized Big SignedBeaconBlock (1000000 B) 360.69 us/op 170.37 us/op 2.12
pass gossip attestations to forkchoice per slot 6.3562 ms/op 2.6393 ms/op 2.41
forkChoice updateHead vc 100000 bc 64 eq 0 1.0230 ms/op 362.03 us/op 2.83
forkChoice updateHead vc 600000 bc 64 eq 0 6.4963 ms/op 2.3142 ms/op 2.81
forkChoice updateHead vc 1000000 bc 64 eq 0 10.692 ms/op 3.7612 ms/op 2.84
forkChoice updateHead vc 600000 bc 320 eq 0 7.2735 ms/op 2.2329 ms/op 3.26
forkChoice updateHead vc 600000 bc 1200 eq 0 5.8919 ms/op 2.2768 ms/op 2.59
forkChoice updateHead vc 600000 bc 7200 eq 0 8.4927 ms/op 3.2816 ms/op 2.59
forkChoice updateHead vc 600000 bc 64 eq 1000 26.272 ms/op 9.8071 ms/op 2.68
forkChoice updateHead vc 600000 bc 64 eq 10000 21.837 ms/op 10.598 ms/op 2.06
forkChoice updateHead vc 600000 bc 64 eq 300000 30.910 ms/op 33.287 ms/op 0.93
computeDeltas 500000 validators 300 proto nodes 9.2878 ms/op 3.9676 ms/op 2.34
computeDeltas 500000 validators 1200 proto nodes 9.3039 ms/op 4.4810 ms/op 2.08
computeDeltas 500000 validators 7200 proto nodes 10.266 ms/op 4.4845 ms/op 2.29
computeDeltas 750000 validators 300 proto nodes 14.767 ms/op 5.9240 ms/op 2.49
computeDeltas 750000 validators 1200 proto nodes 14.326 ms/op 5.9333 ms/op 2.41
computeDeltas 750000 validators 7200 proto nodes 17.019 ms/op 5.6229 ms/op 3.03
computeDeltas 1400000 validators 300 proto nodes 33.264 ms/op 11.291 ms/op 2.95
computeDeltas 1400000 validators 1200 proto nodes 32.279 ms/op 10.959 ms/op 2.95
computeDeltas 1400000 validators 7200 proto nodes 34.253 ms/op 11.094 ms/op 3.09
computeDeltas 2100000 validators 300 proto nodes 48.519 ms/op 15.617 ms/op 3.11
computeDeltas 2100000 validators 1200 proto nodes 45.539 ms/op 14.922 ms/op 3.05
computeDeltas 2100000 validators 7200 proto nodes 43.079 ms/op 14.947 ms/op 2.88
altair processAttestation - 250000 vs - 7PWei normalcase 4.0879 ms/op 1.8098 ms/op 2.26
altair processAttestation - 250000 vs - 7PWei worstcase 6.4581 ms/op 2.7148 ms/op 2.38
altair processAttestation - setStatus - 1/6 committees join 255.00 us/op 69.999 us/op 3.64
altair processAttestation - setStatus - 1/3 committees join 417.31 us/op 138.01 us/op 3.02
altair processAttestation - setStatus - 1/2 committees join 547.62 us/op 223.06 us/op 2.46
altair processAttestation - setStatus - 2/3 committees join 774.54 us/op 298.36 us/op 2.60
altair processAttestation - setStatus - 4/5 committees join 1.1695 ms/op 432.70 us/op 2.70
altair processAttestation - setStatus - 100% committees join 1.4096 ms/op 534.07 us/op 2.64
altair processBlock - 250000 vs - 7PWei normalcase 12.242 ms/op 6.5070 ms/op 1.88
altair processBlock - 250000 vs - 7PWei normalcase hashState 67.060 ms/op 27.734 ms/op 2.42
altair processBlock - 250000 vs - 7PWei worstcase 93.731 ms/op 39.817 ms/op 2.35
altair processBlock - 250000 vs - 7PWei worstcase hashState 171.27 ms/op 74.339 ms/op 2.30
phase0 processBlock - 250000 vs - 7PWei normalcase 4.8821 ms/op 1.7987 ms/op 2.71
phase0 processBlock - 250000 vs - 7PWei worstcase 56.352 ms/op 24.167 ms/op 2.33
altair processEth1Data - 250000 vs - 7PWei normalcase 1.0445 ms/op 272.46 us/op 3.83
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 16.109 us/op 6.8150 us/op 2.36
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 83.354 us/op 35.235 us/op 2.37
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 17.366 us/op 10.994 us/op 1.58
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 20.587 us/op 7.4530 us/op 2.76
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 307.03 us/op 130.70 us/op 2.35
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 2.3727 ms/op 942.07 us/op 2.52
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 3.8361 ms/op 1.2373 ms/op 3.10
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 4.3989 ms/op 1.1865 ms/op 3.71
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 10.409 ms/op 2.9855 ms/op 3.49
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 3.7871 ms/op 1.3108 ms/op 2.89
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 11.572 ms/op 3.3390 ms/op 3.47
Tree 40 250000 create 651.39 ms/op 205.63 ms/op 3.17
Tree 40 250000 get(125000) 369.55 ns/op 120.17 ns/op 3.08
Tree 40 250000 set(125000) 1.8217 us/op 544.81 ns/op 3.34
Tree 40 250000 toArray() 34.528 ms/op 18.600 ms/op 1.86
Tree 40 250000 iterate all - toArray() + loop 34.871 ms/op 19.371 ms/op 1.80
Tree 40 250000 iterate all - get(i) 118.99 ms/op 56.823 ms/op 2.09
Array 250000 create 5.3874 ms/op 3.5482 ms/op 1.52
Array 250000 clone - spread 2.3070 ms/op 1.4740 ms/op 1.57
Array 250000 get(125000) 0.99000 ns/op 0.67400 ns/op 1.47
Array 250000 set(125000) 1.0350 ns/op 0.66100 ns/op 1.57
Array 250000 iterate all - loop 244.75 us/op 84.189 us/op 2.91
phase0 afterProcessEpoch - 250000 vs - 7PWei 131.94 ms/op 46.251 ms/op 2.85
Array.fill - length 1000000 10.721 ms/op 2.7042 ms/op 3.96
Array push - length 1000000 49.867 ms/op 19.503 ms/op 2.56
Array.get 0.73461 ns/op 0.27241 ns/op 2.70
Uint8Array.get 1.2354 ns/op 0.34837 ns/op 3.55
phase0 beforeProcessEpoch - 250000 vs - 7PWei 41.925 ms/op 14.886 ms/op 2.82
altair processEpoch - mainnet_e81889 638.87 ms/op 239.57 ms/op 2.67
mainnet_e81889 - altair beforeProcessEpoch 34.863 ms/op 18.722 ms/op 1.86
mainnet_e81889 - altair processJustificationAndFinalization 24.742 us/op 16.217 us/op 1.53
mainnet_e81889 - altair processInactivityUpdates 14.574 ms/op 5.7208 ms/op 2.55
mainnet_e81889 - altair processRewardsAndPenalties 74.896 ms/op 41.907 ms/op 1.79
mainnet_e81889 - altair processRegistryUpdates 4.8320 us/op 2.5940 us/op 1.86
mainnet_e81889 - altair processSlashings 1.3200 us/op 1.2780 us/op 1.03
mainnet_e81889 - altair processEth1DataReset 559.00 ns/op 902.00 ns/op 0.62
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.8208 ms/op 1.1205 ms/op 2.52
mainnet_e81889 - altair processSlashingsReset 5.8880 us/op 4.3230 us/op 1.36
mainnet_e81889 - altair processRandaoMixesReset 7.1150 us/op 6.9260 us/op 1.03
mainnet_e81889 - altair processHistoricalRootsUpdate 826.00 ns/op 1.2960 us/op 0.64
mainnet_e81889 - altair processParticipationFlagUpdates 3.7130 us/op 3.9950 us/op 0.93
mainnet_e81889 - altair processSyncCommitteeUpdates 682.00 ns/op 902.00 ns/op 0.76
mainnet_e81889 - altair afterProcessEpoch 117.98 ms/op 44.422 ms/op 2.66
capella processEpoch - mainnet_e217614 1.7436 s/op 1.0892 s/op 1.60
mainnet_e217614 - capella beforeProcessEpoch 124.18 ms/op 71.670 ms/op 1.73
mainnet_e217614 - capella processJustificationAndFinalization 30.055 us/op 14.652 us/op 2.05
mainnet_e217614 - capella processInactivityUpdates 26.896 ms/op 18.642 ms/op 1.44
mainnet_e217614 - capella processRewardsAndPenalties 384.88 ms/op 231.55 ms/op 1.66
mainnet_e217614 - capella processRegistryUpdates 22.646 us/op 15.166 us/op 1.49
mainnet_e217614 - capella processSlashings 720.00 ns/op 755.00 ns/op 0.95
mainnet_e217614 - capella processEth1DataReset 707.00 ns/op 969.00 ns/op 0.73
mainnet_e217614 - capella processEffectiveBalanceUpdates 19.144 ms/op 17.095 ms/op 1.12
mainnet_e217614 - capella processSlashingsReset 14.614 us/op 4.8910 us/op 2.99
mainnet_e217614 - capella processRandaoMixesReset 13.109 us/op 3.7280 us/op 3.52
mainnet_e217614 - capella processHistoricalRootsUpdate 2.0710 us/op 812.00 ns/op 2.55
mainnet_e217614 - capella processParticipationFlagUpdates 8.8770 us/op 1.9490 us/op 4.55
mainnet_e217614 - capella afterProcessEpoch 210.67 ms/op 106.48 ms/op 1.98
phase0 processEpoch - mainnet_e58758 608.45 ms/op 288.65 ms/op 2.11
mainnet_e58758 - phase0 beforeProcessEpoch 156.83 ms/op 89.901 ms/op 1.74
mainnet_e58758 - phase0 processJustificationAndFinalization 56.971 us/op 19.786 us/op 2.88
mainnet_e58758 - phase0 processRewardsAndPenalties 45.072 ms/op 34.784 ms/op 1.30
mainnet_e58758 - phase0 processRegistryUpdates 20.843 us/op 9.6730 us/op 2.15
mainnet_e58758 - phase0 processSlashings 1.0790 us/op 869.00 ns/op 1.24
mainnet_e58758 - phase0 processEth1DataReset 988.00 ns/op 747.00 ns/op 1.32
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.7254 ms/op 814.30 us/op 3.35
mainnet_e58758 - phase0 processSlashingsReset 9.4760 us/op 5.2260 us/op 1.81
mainnet_e58758 - phase0 processRandaoMixesReset 9.0970 us/op 3.6550 us/op 2.49
mainnet_e58758 - phase0 processHistoricalRootsUpdate 869.00 ns/op 846.00 ns/op 1.03
mainnet_e58758 - phase0 processParticipationRecordUpdates 14.912 us/op 3.2040 us/op 4.65
mainnet_e58758 - phase0 afterProcessEpoch 90.299 ms/op 36.038 ms/op 2.51
phase0 processEffectiveBalanceUpdates - 250000 normalcase 3.9062 ms/op 1.0017 ms/op 3.90
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 6.5039 ms/op 1.8746 ms/op 3.47
altair processInactivityUpdates - 250000 normalcase 38.414 ms/op 17.320 ms/op 2.22
altair processInactivityUpdates - 250000 worstcase 39.792 ms/op 16.996 ms/op 2.34
phase0 processRegistryUpdates - 250000 normalcase 18.800 us/op 9.2270 us/op 2.04
phase0 processRegistryUpdates - 250000 badcase_full_deposits 509.90 us/op 309.50 us/op 1.65
phase0 processRegistryUpdates - 250000 worstcase 0.5 237.70 ms/op 110.84 ms/op 2.14
altair processRewardsAndPenalties - 250000 normalcase 96.802 ms/op 34.267 ms/op 2.82
altair processRewardsAndPenalties - 250000 worstcase 80.878 ms/op 43.353 ms/op 1.87
phase0 getAttestationDeltas - 250000 normalcase 17.255 ms/op 6.3054 ms/op 2.74
phase0 getAttestationDeltas - 250000 worstcase 16.593 ms/op 6.2771 ms/op 2.64
phase0 processSlashings - 250000 worstcase 108.49 us/op 95.435 us/op 1.14
altair processSyncCommitteeUpdates - 250000 227.37 ms/op 104.39 ms/op 2.18
BeaconState.hashTreeRoot - No change 415.00 ns/op 442.00 ns/op 0.94
BeaconState.hashTreeRoot - 1 full validator 165.38 us/op 144.94 us/op 1.14
BeaconState.hashTreeRoot - 32 full validator 2.2582 ms/op 1.4787 ms/op 1.53
BeaconState.hashTreeRoot - 512 full validator 16.293 ms/op 10.679 ms/op 1.53
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 202.69 us/op 142.06 us/op 1.43
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.6761 ms/op 1.8790 ms/op 1.42
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 36.827 ms/op 22.012 ms/op 1.67
BeaconState.hashTreeRoot - 1 balances 138.64 us/op 106.58 us/op 1.30
BeaconState.hashTreeRoot - 32 balances 1.1669 ms/op 1.0473 ms/op 1.11
BeaconState.hashTreeRoot - 512 balances 12.702 ms/op 7.7566 ms/op 1.64
BeaconState.hashTreeRoot - 250000 balances 272.17 ms/op 129.55 ms/op 2.10
aggregationBits - 2048 els - zipIndexesInBitList 48.055 us/op 50.929 us/op 0.94
byteArrayEquals 32 101.61 ns/op 47.742 ns/op 2.13
Buffer.compare 32 39.555 ns/op 15.808 ns/op 2.50
byteArrayEquals 1024 2.9933 us/op 1.2760 us/op 2.35
Buffer.compare 1024 57.162 ns/op 24.547 ns/op 2.33
byteArrayEquals 16384 43.930 us/op 20.198 us/op 2.17
Buffer.compare 16384 373.26 ns/op 187.46 ns/op 1.99
byteArrayEquals 123687377 363.96 ms/op 146.16 ms/op 2.49
Buffer.compare 123687377 8.9059 ms/op 5.5138 ms/op 1.62
byteArrayEquals 32 - diff last byte 93.896 ns/op 46.076 ns/op 2.04
Buffer.compare 32 - diff last byte 30.214 ns/op 15.199 ns/op 1.99
byteArrayEquals 1024 - diff last byte 2.8598 us/op 1.2391 us/op 2.31
Buffer.compare 1024 - diff last byte 49.676 ns/op 22.217 ns/op 2.24
byteArrayEquals 16384 - diff last byte 41.463 us/op 19.368 us/op 2.14
Buffer.compare 16384 - diff last byte 319.49 ns/op 187.16 ns/op 1.71
byteArrayEquals 123687377 - diff last byte 437.26 ms/op 147.14 ms/op 2.97
Buffer.compare 123687377 - diff last byte 9.3703 ms/op 5.3933 ms/op 1.74
byteArrayEquals 32 - random bytes 10.469 ns/op 4.7700 ns/op 2.19
Buffer.compare 32 - random bytes 33.018 ns/op 15.169 ns/op 2.18
byteArrayEquals 1024 - random bytes 10.318 ns/op 4.7960 ns/op 2.15
Buffer.compare 1024 - random bytes 35.003 ns/op 14.900 ns/op 2.35
byteArrayEquals 16384 - random bytes 11.465 ns/op 4.8320 ns/op 2.37
Buffer.compare 16384 - random bytes 36.374 ns/op 14.986 ns/op 2.43
byteArrayEquals 123687377 - random bytes 13.510 ns/op 7.5900 ns/op 1.78
Buffer.compare 123687377 - random bytes 43.530 ns/op 17.710 ns/op 2.46
regular array get 100000 times 94.704 us/op 29.810 us/op 3.18
wrappedArray get 100000 times 71.699 us/op 29.748 us/op 2.41
arrayWithProxy get 100000 times 26.415 ms/op 9.6938 ms/op 2.72
ssz.Root.equals 94.636 ns/op 38.378 ns/op 2.47
byteArrayEquals 90.784 ns/op 41.944 ns/op 2.16
Buffer.compare 19.610 ns/op 8.7390 ns/op 2.24
processSlot - 1 slots 38.197 us/op 12.137 us/op 3.15
processSlot - 32 slots 5.6557 ms/op 2.0926 ms/op 2.70
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 82.609 ms/op 38.011 ms/op 2.17
getCommitteeAssignments - req 1 vs - 250000 vc 7.3724 ms/op 1.8038 ms/op 4.09
getCommitteeAssignments - req 100 vs - 250000 vc 11.465 ms/op 3.5153 ms/op 3.26
getCommitteeAssignments - req 1000 vs - 250000 vc 13.545 ms/op 3.7587 ms/op 3.60
findModifiedValidators - 10000 modified validators 1.1316 s/op 241.54 ms/op 4.68
findModifiedValidators - 1000 modified validators 1.0635 s/op 143.46 ms/op 7.41
findModifiedValidators - 100 modified validators 602.27 ms/op 135.70 ms/op 4.44
findModifiedValidators - 10 modified validators 550.20 ms/op 144.80 ms/op 3.80
findModifiedValidators - 1 modified validators 608.72 ms/op 135.00 ms/op 4.51
findModifiedValidators - no difference 558.11 ms/op 145.99 ms/op 3.82
compare ViewDUs 7.4571 s/op 3.0838 s/op 2.42
compare each validator Uint8Array 3.1472 s/op 1.1173 s/op 2.82
compare ViewDU to Uint8Array 2.4348 s/op 753.23 ms/op 3.23
migrate state 1000000 validators, 24 modified, 0 new 1.4898 s/op 704.54 ms/op 2.11
migrate state 1000000 validators, 1700 modified, 1000 new 1.9632 s/op 886.77 ms/op 2.21
migrate state 1000000 validators, 3400 modified, 2000 new 1.8550 s/op 1.1221 s/op 1.65
migrate state 1500000 validators, 24 modified, 0 new 980.00 ms/op 662.53 ms/op 1.48
migrate state 1500000 validators, 1700 modified, 1000 new 1.2472 s/op 911.90 ms/op 1.37
migrate state 1500000 validators, 3400 modified, 2000 new 2.2354 s/op 1.1103 s/op 2.01
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 10.980 ns/op 6.1000 ns/op 1.80
state getBlockRootAtSlot - 250000 vs - 7PWei 1.4510 us/op 376.82 ns/op 3.85
computeProposers - vc 250000 14.933 ms/op 5.4958 ms/op 2.72
computeEpochShuffling - vc 250000 89.858 ms/op 35.092 ms/op 2.56
getNextSyncCommittee - vc 250000 207.38 ms/op 106.70 ms/op 1.94
computeSigningRoot for AttestationData 39.863 us/op 22.188 us/op 1.80
hash AttestationData serialized data then Buffer.toString(base64) 3.3946 us/op 1.1877 us/op 2.86
toHexString serialized data 2.7225 us/op 811.85 ns/op 3.35
Buffer.toString(base64) 472.65 ns/op 138.27 ns/op 3.42
nodejs block root to RootHex using toHex 468.69 ns/op 126.28 ns/op 3.71
nodejs block root to RootHex using toRootHex 287.90 ns/op 79.003 ns/op 3.64
browser block root to RootHex using the deprecated toHexString 946.00 ns/op 216.69 ns/op 4.37
browser block root to RootHex using toHex 581.09 ns/op 164.95 ns/op 3.52
browser block root to RootHex using toRootHex 442.48 ns/op 146.22 ns/op 3.03

Please sign in to comment.