Bitcoin Forum
November 09, 2024, 03:46:35 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Lots of disk activity on Bitcoin startup: easy fix?  (Read 2506 times)
patvarilly
Guest

July 06, 2011, 06:40:48 AM
 #1

For a few days now, I've noticed that every time I start the Bitcoin client, it goes nuts on disk usage for about 5 minutes and then quiets down.  I finally got curious enough to find out what was going on, and it turns out that I get a large burst of disk activity every time a line "AddAddress(...)" appears in debug.log.  Tracking this down, it seems to boil down to this offending line in net.cpp:

429: bool AddAddress(CAddress addr, int64 nTimePenalty)
430: {
...
444:              CAddrDB().WriteAddress(addr);
...
470: }

So what's going on is that every time there's a new address, the address database is opened, a new record is stored, and then the database is closed (and presumably flushed to disk).  This last part is what I think is driving BDB nuts writing stuff out.

Would it be too hard to keep a single CAddrDB object floating around (maybe lock it with a CRITICAL_SECTION), open it once on startup and close it once on shutdown?  Addresses are volatile information that doesn't need to be stored *right this minute* or bitcoin will fail.  They can be recreated by polling peers if need be after a crash.  The code should reflect this lack of urgency to store addresses, and doing so will substantially reduce the disk usage on Bitcoin startup.
Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1134


View Profile
July 06, 2011, 08:59:38 AM
 #2

You're right, patches would be welcome. Also see the bitcoin-development mailing list.
patvarilly
Guest

July 06, 2011, 04:13:54 PM
 #3

You're right, patches would be welcome. Also see the bitcoin-development mailing list.

Thanks for the heads up about the mailing list.  I'll try to put a patch together soon.
BombaUcigasa
Legendary
*
Offline Offline

Activity: 1442
Merit: 1005



View Profile
July 09, 2011, 12:12:19 PM
 #4

Please also consider the file fragmentation isssue. A brand new blockchain database will split in over 15000 fragments all over the disk.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!