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

suggestions for PR 910 #926

Conversation

AlexHentschel
Copy link
Member

@AlexHentschel AlexHentschel commented Jul 5, 2021

Implements suggestions for PR #910:

  • It would be great to fix this performance bottleneck:
    block, err := e.blocks.ByHeight(height)
    • In contrast to badger.Headers, which has a cache for heights, badger.blocks does not have such a cache and instead always hits the data base.
  • I think we could inline method
    // processIncoming processes an incoming block, so we can take into account the
    // overlap between block IDs and heights.
    func (e *Engine) processIncomingBlock(originID flow.Identifier, block *flow.Block) {
    shouldProcess := e.core.HandleBlock(block.Header)
    if !shouldProcess {
    return
    }
    synced := &events.SyncedBlock{
    OriginID: originID,
    Block: block,
    }
    e.comp.SubmitLocal(synced)
    }
    as it is only used once.
  • We might be able to reduce lock congestion in Core. HandleHeight :
    • we always lock right away, but on the happy path when the node is up to date, this code would return right away:
      // don't bother queueing anything if we're within tolerance
      if c.WithinTolerance(final, height) {
      return
      }
      . WithinTolerance is fully concurrency safe without any locks (we also call it externally, here). Hence, we could move the lock further down into the if statement, where we actually update Core's state.

• reduced locking in `synchronization.Core`
@AlexHentschel AlexHentschel changed the title minor revisions to badger.Blocks to utilize caching by block height implemented by badger.Headers suggestions for PR 910 Jul 5, 2021
@durkmurder durkmurder merged commit 2c6f3cd into yurii/5615-synchronization-engine-queue Jul 5, 2021
@durkmurder durkmurder deleted the alex/5615-synchronization-engine-queue_-_suggestions branch July 5, 2021 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants