Skip to content

perf: Blocksync is double calling types.Block.ValidateBasic at costs to sync speed #1964

Closed
osmosis-labs/cometbft
#3

Description

@ValarDragon

Feature Request

Block sync is double-calling types.Block.ValidateBasic, which re-hashes every transaction in a block. In a 100 block CPU profile sync on Osmosis, over a period with especially large blocks, we found that this was the cause of some notable overhead. (18 seconds out of 185 seconds over all processes, at least 70s of which were in non-blocking operations) Under normal block sizes, this time is lower but still high/worth speeding up. (4.1 seconds for 100 blocks)

image

We should not be double verifying this.

Summary

We are double verifying block hashes in block sync by calling this in two different spots:
ValidateMsg here, which calls types.BlockFromProto which calls validate basic, and types.BlockFromProto right here

Problem Definition

Speed up block sync

Proposal

Do some mild API or order of operations changes to reuse the types.BlockFromProto result and only compute it once.

Activity

  1. added
    enhancement
    needs-triage
    on Jan 5, 2024
  2. faddat commented on Jan 5, 2024

    @faddat
    Contributor

    gonna check this out.

  3. faddat commented on Jan 5, 2024

    @faddat
    Contributor

    Got it :).

    I think that this will make your flame graph much happier.

  4. added and removed
    needs-triage
    on Jan 9, 2024
  5. melekes commented on Jan 9, 2024

    @melekes
    Collaborator

    Thanks @ValarDragon ❤️ Definitely something we should fix

  6. added this to the 2024-Q1 milestone on Jan 10, 2024
  7. added a commit that references this issue on Jan 11, 2024
    f8c9c3c
  8. self-assigned this
    on Jan 11, 2024
  9. moved this from Todo to Done in CometBFTon Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

block-syncenhancement

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions