Skip to content

Disable LMDB read ahead on Windows#4961

Open
RickiNano wants to merge 1 commit intonanocurrency:developfrom
RickiNano:Lmdb-windows
Open

Disable LMDB read ahead on Windows#4961
RickiNano wants to merge 1 commit intonanocurrency:developfrom
RickiNano:Lmdb-windows

Conversation

@RickiNano
Copy link
Copy Markdown
Contributor

LMDB's read-ahead feature works well on Linux and Mac, but causes excessive memory usage on Windows, consuming all
available RAM and making the node slow to a crawl after a few hours.
This PR disables read ahead for windows but maintains it on Mac and Linux

@qwahzi
Copy link
Copy Markdown
Collaborator

qwahzi commented Nov 13, 2025

@RickiNano - Were you able to do any performance tests for read-ahead on Mac/Linux? I'm wondering if there's any benefit to keeping read-ahead enabled on Mac/Linux, since I'm guessing Nano is pretty heavy on random reads (except maybe when bootstrapping)?

The excessive reads were caused by OS read-ahead. By default, when we read a page, the OS will prefetch the pages following that page into memory. However, this is usually undesirable in a DB, since we are usually doing random read. So we need to disable read-ahead to get optimal performance for random read.

https://stackoverflow.com/a/49354913

MDB_NORDAHEAD Turn off readahead. Most operating systems perform readahead on read requests by default. This option turns it off if the OS supports it. Turning it off may help random read performance when the DB is larger than RAM and system RAM is full. The option is not implemented on Windows.

http://www.lmdb.tech/doc/group__mdb.html

@RickiNano
Copy link
Copy Markdown
Contributor Author

@qwahzi I don't own a Mac or Linux computer so I can't test that unfortunately.

@gr0vity-dev-bot
Copy link
Copy Markdown

Test Results for Commit 5b388eb

Pull Request 4961: Results
Overall Status:

Test Case Results

  • 5n4pr_conf_10k_bintree: PASS (Duration: 126s)
  • 5n4pr_conf_10k_change: PASS (Duration: 205s)
  • 5n4pr_conf_change_dependant: PASS (Duration: 157s)
  • 5n4pr_conf_change_independant: PASS (Duration: 152s)
  • 5n4pr_conf_send_dependant: PASS (Duration: 144s)
  • 5n4pr_conf_send_independant: PASS (Duration: 151s)
  • 5n4pr_rocks_10k_bintree: PASS (Duration: 131s)
  • 5n4pr_rocks_10k_change: FAIL (Duration: 288s)
  • Log

Last updated: 2025-11-13 20:39:27 UTC

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.

3 participants