-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve next epoch shuffling computation #6268
Comments
We can have a flag to skip the unshuffle computation and delegate it to the caller of the epoch transition, kind of like we do with execution payload verification |
one proposal for this work with some criterias:
given the epoch transition mostly get triggered by
|
another idea is to model export type ShufflingSource = {
epoch: Epoch;
activeIndices: Uint32Array;
// TODO: consider if we need this or not, in that case make it ShufflingSummary
// committeesPerSlot: number;
// committeeLens: number[][];
};
export type Shuffling = {
shuffling: Uint32Array;
committees: Uint32Array[][];
committeesPerSlot: number;
};
export type EpochShuffling = ShufflingSource & Shuffling;
export function isEpochShuffling(shufflingOrIndices: ShufflingSource): shufflingOrIndices is EpochShuffling {
return (shufflingOrIndices as EpochShuffling).shuffling !== undefined;
} then type previousShuffling: EpochShuffling;
currentShuffling: EpochShuffling;
nextShuffling: ShufflingSource; then in afterProcessEpoch(
state: BeaconStateAllForks,
epochTransitionCache: {
nextEpochShufflingActiveValidatorIndices: ValidatorIndex[];
nextEpochTotalActiveBalanceByIncrement: number;
}
): void {
this.previousShuffling = this.currentShuffling;
this.currentShuffling = isEpochShuffling(this.nextShuffling)
? this.nextShuffling
// should rarely/never happens
// TODO: track this is a metric
: computeEpochShuffling(state, this.nextShuffling.activeIndices, this.nextShuffling.epoch);
const currEpoch = this.currentShuffling.epoch;
const nextEpoch = currEpoch + 1;
this.nextShuffling = {
epoch: nextEpoch,
activeIndices: new Uint32Array(epochTransitionCache.nextEpochShufflingActiveValidatorIndices),
}; right after an epoch transition, |
after #6938 was merged
need to implement
|
|
Problem description
For now next epoch shuffling computation in
afterProcessEpoch
takes the most time of epoch transition in normal condition. In somegc
intensive condition,processRewardsAndPenalties
takes more time (I used to see it took up to 1.8s) see #6229this is a holesky profile:
Solution description
as discussed with @dapplion we can go with these 2 approaches:
beforeProcessEpoch
, we havenextEpochShufflingActiveValidatorIndices
and a finalizedrandaoMixes
, we should be able to offload next epoch shuffling computation to a worker thread, and epoch transition becomesasync
unshuffleList
is the main part of shuffling computation, we should be able to implement it in assembly script importingas-sha256
from thereAdditional context
No response
The text was updated successfully, but these errors were encountered: