Skip to content

ethdb: enlarge the number of memory tables#3173

Merged
zzzckck merged 1 commit intobnb-chain:developfrom
flywukong:pebble-memtable
Jun 17, 2025
Merged

ethdb: enlarge the number of memory tables#3173
zzzckck merged 1 commit intobnb-chain:developfrom
flywukong:pebble-memtable

Conversation

@flywukong
Copy link
Contributor

@flywukong flywukong commented Jun 17, 2025

Description

In the current BSC validator and miner workflow, write stalls frequently occur during the commit or block synchronization processes. Specifically, operations like writeStateID or writing block data often experience write delays of several hundred milliseconds, which negatively impacts commit performance and causes miners to exceed the 750ms block production time.

Pebble allows configuring multiple memtables for buffering unflushed data,if too many memtables are blocked and are waiting to be flushed, subsequent writes will stall, especially when Pebble performs a background flush while compaction is also ongoing. By default, Pebble is configured with only 2 memtables, each potentially exceeding 1GB in size. This behavior can be mitigated by increasing the number of memtables, which allows background flushes to be performed more smoothly and efficiently in a queue-like manner, thereby reducing the likelihood of write stalls under heavy load.
After shortening the BSC block interval, more frequent writes and compactions significantly increase the likelihood of write stalls. Adjusting the number of Pebble memtables is necessary to mitigate this issue.

Rationale

Improve the performance of commit db and reduce write stall. Testing shows that after tuning the Pebble parameters, write stalls were reduced by approximately 75%, and commit performance at the p99 percentile improved by around 30%.

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

@zzzckck zzzckck requested a review from Copilot June 17, 2025 03:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR increases Pebble's in-memory table count from 2 to 6 to smooth out flush operations and reduce write stalls under heavy load.

  • Updated default memTableLimit from 2 to 6
  • Adjusted comments to reflect the new memtable configuration
Comments suppressed due to low confidence (2)

ethdb/pebble/pebble.go:174

  • [nitpick] Consider exposing memTableLimit as a configuration parameter (e.g., via CLI flag or config file) instead of hardcoding it, so users can tune this value without modifying source code.
memTableLimit := 6

ethdb/pebble/pebble.go:174

  • Add or extend unit tests to cover scenarios with different memTableLimit values to ensure buffer sizing and flush logic remains correct and performant.
memTableLimit := 6

@zzzckck zzzckck merged commit a7831f5 into bnb-chain:develop Jun 17, 2025
6 of 8 checks passed
@zzzckck zzzckck mentioned this pull request Jun 17, 2025
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.

4 participants