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

Increase default dbcache to ∞ #70

Open
luke-jr opened this issue Mar 19, 2024 · 9 comments
Open

Increase default dbcache to ∞ #70

luke-jr opened this issue Mar 19, 2024 · 9 comments

Comments

@luke-jr
Copy link
Member

luke-jr commented Mar 19, 2024

Bitcoin Knots already detects low-memory situations and flushes caches when there's only 10 MB left. It would be nice to just leave the UTXO cache unbound for optimal performance.

But is 10 MB enough? Or will it cause problems?

Testing requested :)

Just set dbcache=1048576 and let me know if you run into issues (maybe re-sync too)

@tchjntr
Copy link

tchjntr commented May 9, 2024

Currently testing this on a laptop with the following specs:

  • CPU: Intel Core i7-1165G7 @ 2.80GHz, 4 Cores, 8 Threads
  • RAM: 32GB Crucial DDR4-3200 (2 x 16GB)
  • SSD: Samsung 980 PRO PCIe 4.0 NVMe 1TB
  • OS: Windows 11 Pro (Version 10.0.22631 Build 22631)

Started a full IBD from scratch with Bitcoin Knots v26.1.knots20240325 and the following options in bitcoin.conf:

assumevalid=0
blockfilterindex=1
blocksonly=1
coinstatsindex=1
connect=[IP address of my main Bitcoin full node in my home network]
dbcache=1048576
discover=0
dns=0
dnsseed=0
listen=0
peerblockfilters=1
peerbloomfilters=1
server=1
txindex=1
v2transport=1

Will provide an update after it syncs or if there are issues.

UPDATE 05/10/2024:

IBD took about 33 hours and 19 minutes.

Start: 2024-05-09T09:49:53Z
Finished syncing to tip: 2024-05-10T18:47:35Z (Block 842887)

This was done in one go with no interruptions.

@chrisguida
Copy link

@luke-jr do i need to set any of the above options from @tchjntr other than dbcache=1048576? does assumevalid matter?

@luke-jr
Copy link
Member Author

luke-jr commented May 27, 2024

@luke-jr do i need to set any of the above options from @tchjntr other than dbcache=1048576? does assumevalid matter?

Shouldn't matter

@chrisguida
Copy link

Cool, syncing

@chrisguida
Copy link

chrisguida commented May 28, 2024

Hmm I was almost done syncing and needed to shut down gracefully. I ran sudo shutdown now and the kernel showed a message indicating that it would wait for 30 minutes before killing bitcoind. I waited 5-10 minutes, so it took at least this long to flush the utxo cache to disk. I stepped away for an hour or so.

I turned the system back on and it started rolling forward from block 1 :/

image

My system has about 13GB ram, so I'm not sure how the cache is 20GB. Is it using swap?

$ free -m
               total        used        free      shared  buff/cache   available
Mem:           13942        1985         554           8       11401       11620
Swap:          15336           7       15329

@luke-jr
Copy link
Member Author

luke-jr commented May 28, 2024

The log shows it was killed, so the rolling forward is expected at that point I guess. :( I suppose that indicates maybe this requires benchmarking the disk and making sure we never cache more than it can write in N=30 minutes.

That free output is from while it said it had 20 GB cached??? That doesn't make sense :/

@chrisguida
Copy link

chrisguida commented May 28, 2024

The log shows it was killed, so the rolling forward is expected at that point I guess.

I guess people need to keep in mind that flushing to disk will take a loooong time heh

I suppose that indicates maybe this requires benchmarking the disk and making sure we never cache more than it can write in N=30 minutes.

Yeah, unless we expect users to know not to use sudo shutdown now. Or unless 30 minutes is not a common setting for this. I'm just using the nix-bitcoin default system configuration (mostly).

That free output is from while it said it had 20 GB cached??? That doesn't make sense :/

No, the free output is from now. I didn't check it while the cache was full. I'm just wondering if you know whether bitcoind swaps or not. I suppose this is managed automatically by the system, so the answer is probably yes.

Another question, why is the cache 20GB? Isn't the entire utxoset like 12GB?

@chrisguida
Copy link

chrisguida commented May 28, 2024

I was slightly afraid this would happen given that I kept seeing this message...

May 28 12:53:01 nix-um350 bitcoind[88208]: [coindb] Node is still in IBD, rescheduling chainstate disk sync...

How are we able to put off flushing to disk indefinitely? I guess the cache stores more than just the current utxoset?

@luke-jr
Copy link
Member Author

luke-jr commented May 28, 2024

I'm just wondering if you know whether bitcoind swaps or not. I suppose this is managed automatically by the system, so the answer is probably yes.

The only reason this could have worked, is because Knots checks free memory often and flushes if it's getting low. So it would be a bug to activate swap (aside from the OS deciding swap is optimal anyway). It might be good to have further testing monitor swap usage and desktop usability while it syncs.

Another question, why is the cache 20GB? Isn't the entire utxoset like 12GB?

Size on disk is not necessarily size in memory. I would expect them to be closer, but I haven't ever compared. Perhaps this is another area things could be optimised? Obvious differences (coins.h class Coin) are that we store the height (in memory and disk) even when it's not strictly needed, and we only compress the UTXO set on disk.

May 28 12:53:01 nix-um350 bitcoind[88208]: [coindb] Node is still in IBD, rescheduling chainstate disk sync...

How are we able to put off flushing to disk indefinitely?

The log message is about the final disk sync after IBD completes. It might still sync periodically before that. Maybe comment on bitcoin#15218 that the message is confusing, so it gets addressed.

I guess the cache stores more than just the current utxoset?

I don't think it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants