Skip to content

Preload block headers cache at startup time#9248

Merged
ahamlat merged 14 commits intobesu-eth:mainfrom
ahamlat:preload-cache-headers
Oct 1, 2025
Merged

Preload block headers cache at startup time#9248
ahamlat merged 14 commits intobesu-eth:mainfrom
ahamlat:preload-cache-headers

Conversation

@ahamlat
Copy link
Copy Markdown
Contributor

@ahamlat ahamlat commented Sep 30, 2025

PR description

This PR introduces a new flag --preload-block-headers-cache-enabled, that enables preloading the block headers cache during startup time. The number of blocks to preload is defined by --cache-last-block-headers, so this new flag --preload-block-headers-cache-enabled can work only if --cache-last-block-headers is defined.

When these two flags are enabled, there're two log lines that are displayed

--cache-last-block-headers and --cache-last-block-headers-preload-enabled are enabled, start preloading block headers cache
...
Preloading 50000 block headers to the cache finished in 725 ms

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests
  • hive tests: Engine or other RPCs modified?

…d is enabled

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
@ahamlat ahamlat added doc-change-required Indicates an issue or PR that requires doc to be updated performance labels Sep 30, 2025
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
@fluentcrafter
Copy link
Copy Markdown
Contributor

Can we improve the names of the CLI flags?

--preload-block-headers-cache-enabled
--preload-block-headers-cache-size

I think it makes it obvious the connection between the two, --cache-last-block-headers is not suitable anymore IMO

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
@ahamlat
Copy link
Copy Markdown
Contributor Author

ahamlat commented Sep 30, 2025

Can we improve the names of the CLI flags?

--preload-block-headers-cache-enabled
--preload-block-headers-cache-size

I think it makes it obvious the connection between the two, --cache-last-block-headers is not suitable anymore IMO

--preload-block-headers-cache-size does not really exist, where --cache-last-block-headers exists. We can have --cache-last-block-headers without any preloading mechanism.

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
@fluentcrafter
Copy link
Copy Markdown
Contributor

--preload-block-headers-cache-size does not exist on its own, where --cache-last-block-headers it exists. We can have --cache-last-block-headers without any preloading mechanism.

But , --cache-last-block-headers and preload-block-headers-cache-enabled are related, right?

Then I suggest following options:

// Option A
cache-last-block-headers:
cache-last-block-headers-preload-enabled:

// Option B
last-block-headers-cache-size:
last-block-headers-cache-preload-enabled: 

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: ahamlat <ameziane.hamlat@consensys.net>
@ahamlat ahamlat enabled auto-merge (squash) October 1, 2025 07:21
@ahamlat ahamlat merged commit f1e4953 into besu-eth:main Oct 1, 2025
46 of 61 checks passed
AliZDev-v0 pushed a commit to AliZDev-v0/besu that referenced this pull request Oct 5, 2025
* Preload cache block headers when --cache-last-block-headers-preload-enabled is enabled

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ali Zhagparov <alijakparov.kz@gmail.com>
jflo pushed a commit to jflo/besu that referenced this pull request Oct 13, 2025
* Preload cache block headers when --cache-last-block-headers-preload-enabled is enabled

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: jflo <justin+github@florentine.us>
@alexandratran alexandratran removed the doc-change-required Indicates an issue or PR that requires doc to be updated label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants