-
Notifications
You must be signed in to change notification settings - Fork 964
Concurrently initialize LedgerStorage to optimize startup performance. #4594
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
base: master
Are you sure you want to change the base?
Conversation
71a0dbd to
0a8c0d4
Compare
0a8c0d4 to
1974657
Compare
|
I understand that this optimization requires providing the changes before and after the optimization? Is there any verification data available? |
hangc0276
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a big thread pool just for init storage instance is not a good idea.
How many disks are you configured for one bookie?
There was a problem hiding this 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 optimizes the startup performance of BookKeeper by initializing DbLedgerStorage concurrently across multiple ledger directories.
- Introduces a thread pool executor with a dynamic thread count based on available processors and ledger directories.
- Uses CountDownLatch and an AtomicInteger to manage and track initialization failures across threads.
Comments suppressed due to low confidence (1)
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorage.java:265
- Consider adding more context to the error log (e.g., the directory index or path that failed to initialize) to ease troubleshooting.
log.error("Failed to initialize DbLedgerStorage", e);
| Thread.currentThread().interrupt(); | ||
| log.error("Failed to initialize DbLedgerStorage", e); | ||
| } finally { | ||
| storageInitExecutor.shutdown(); |
Copilot
AI
Jun 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After shutting down the executor, consider awaiting its termination to ensure all tasks have completed gracefully before proceeding.
| storageInitExecutor.shutdown(); | |
| storageInitExecutor.shutdown(); | |
| try { | |
| if (!storageInitExecutor.awaitTermination(60, java.util.concurrent.TimeUnit.SECONDS)) { | |
| log.warn("storageInitExecutor did not terminate within the timeout."); | |
| } | |
| } catch (InterruptedException e) { | |
| Thread.currentThread().interrupt(); | |
| log.error("Interrupted while waiting for storageInitExecutor to terminate", e); | |
| } |
The single-threaded configuration cannot fully utilize the performance of SSDs. Each SSD configured for a bookie node is set up with 4 or 8 directories, depending on the disk performance. |
+1 |


Descriptions of the changes in this PR:
Optimize BookKeeper startup speed with multi-directory ledger configuration
Main Issue:

Motivation
During production upgrades, BookKeeper instances with existing data typically take 3 to 5 minutes to start up.
Changes
Parallelize the initialization of DbLedgerStorage to improve startup speed.