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

perf: speedup pbss trienode read #2508

Merged
merged 23 commits into from
Jun 18, 2024

Conversation

will-2012
Copy link
Contributor

@will-2012 will-2012 commented Jun 6, 2024

Description

In the native transfer test scenario, we found that the bottleneck of pbss trienode reading is the recursive query of the 128-layer difflayer. The current PR is mainly to optimize the pbss trienode reading latency.

Rationale

In difflayer, a new cache map with node hash as key is added. The Node interface gives priority to accessing the cache. If a hit is found, it is returned directly. If it is not found, the disklayer is queried. Compared with the recursive query of the 128-layer difflayer, this cache query is O(1). The original query path is optimized, and most of them are fastpath.
The cache is added when the difflayer is added to the layertree and is released when the difflayer is merged into the disklayer.

Performance

image

pbss+cache has better performance, and the optimization effects are as follows:

  • As a validator test scenario, 1 million accounts were randomly selected from 25 million accounts, and native transfer transactions were performed at 600qps. The difflayer cache optimization effect was significant, and the validation phase was reduced from 450ms to 100ms.
  • As a test scenario for bsc fullnode, starting from block 34.1 million, the validate node was reduced from 73ms to 54ms, which accounts for a small proportion of the entire import block, so the overall optimization effect is not obvious.

Changes

Notable changes:

  • Pbss difflayer: add hash cache.
  • Pbss disklayer: adjust clean cache size.

@will-2012 will-2012 marked this pull request as draft June 6, 2024 06:45
@will-2012 will-2012 changed the title Perf trienode read perf: speedup pbss trienode read latency Jun 6, 2024
@will-2012 will-2012 changed the title perf: speedup pbss trienode read latency perf: speedup pbss trienode read Jun 6, 2024
@will-2012 will-2012 added the wip work in process label Jun 6, 2024
@will-2012 will-2012 marked this pull request as ready for review June 11, 2024 02:20
@will-2012 will-2012 added r4r ready for review and removed wip work in process labels Jun 11, 2024
eth/backend.go Show resolved Hide resolved
triedb/pathdb/asyncnodebuffer.go Outdated Show resolved Hide resolved
triedb/pathdb/difflayer.go Outdated Show resolved Hide resolved
triedb/pathdb/difflayer.go Outdated Show resolved Hide resolved
triedb/pathdb/difflayer.go Outdated Show resolved Hide resolved
triedb/pathdb/disklayer.go Outdated Show resolved Hide resolved
@will-2012 will-2012 added wip work in process and removed r4r ready for review labels Jun 11, 2024
@will-2012 will-2012 marked this pull request as draft June 11, 2024 16:45
@will-2012 will-2012 marked this pull request as ready for review June 13, 2024 01:43
@will-2012 will-2012 added r4r ready for review and removed wip work in process labels Jun 13, 2024
Copy link
Contributor

@sysvm sysvm left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@fynnss fynnss left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@RenRick RenRick left a comment

Choose a reason for hiding this comment

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

LGTM

@zzzckck zzzckck merged commit 99d31ae into bnb-chain:develop Jun 18, 2024
7 checks passed
jellyb0y pushed a commit to jellyb0y/bsc that referenced this pull request Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r4r ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants