Skip to content
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

Electra: performance issue computing sync committee indices #7366

Closed
twoeths opened this issue Jan 16, 2025 · 2 comments · Fixed by #7456
Closed

Electra: performance issue computing sync committee indices #7366

twoeths opened this issue Jan 16, 2025 · 2 comments · Fixed by #7456
Assignees
Labels
meta-bug Issues that identify a bug and require a fix. prio-high Resolve issues as soon as possible. spec-electra 🦒 Issues targeting the Electra spec version

Comments

@twoeths
Copy link
Contributor

twoeths commented Jan 16, 2025

Describe the bug

as informed by @dapplion it could be much slow to compute sync committee indices in electra, theorically 64x slower

const MAX_EFFECTIVE_BALANCE_INCREMENT =

Expected behavior

  • need to write a benchmark for it when all validators have effectiveBalanceIncrement = 32 (worse case scenario)
  • improve it. 2 ways i can think of:
    • use hashtree. Considering the below for loop, we can compute randByte ahead for the next n loops
 while (syncCommitteeIndices.length < SYNC_COMMITTEE_SIZE) {
    const shuffledIndex = computeShuffledIndex(i % activeValidatorCount, activeValidatorCount, seed);
    const candidateIndex = activeValidatorIndices[shuffledIndex];
    const randByte = digest(
      Buffer.concat([
        seed,
        //
        intToBytes(Math.floor(i / 32), 8, "le"),
      ])
    )[i % 32];

    const effectiveBalanceIncrement = effectiveBalanceIncrements[candidateIndex];
    if (effectiveBalanceIncrement * MAX_RANDOM_BYTE >= MAX_EFFECTIVE_BALANCE_INCREMENT * randByte) {
      syncCommitteeIndices.push(candidateIndex);
    }

    i++;
  }
- otherwise go native

Steps to reproduce

No response

Additional context

No response

Operating system

Linux

Lodestar version or commit hash

v1.25.0

@twoeths twoeths added the meta-bug Issues that identify a bug and require a fix. label Jan 16, 2025
@nflaig nflaig added the spec-electra 🦒 Issues targeting the Electra spec version label Jan 18, 2025
@twoeths twoeths self-assigned this Feb 7, 2025
@twoeths
Copy link
Contributor Author

twoeths commented Feb 12, 2025

got 10s processSyncCommitteeUpdates() in peerdas-devnet-4, seems like due to electra

Image

@twoeths
Copy link
Contributor Author

twoeths commented Feb 12, 2025

also found this in pectra-devnet-6

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta-bug Issues that identify a bug and require a fix. prio-high Resolve issues as soon as possible. spec-electra 🦒 Issues targeting the Electra spec version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants