<p>Bitcoin (through BerkleyDB) frequently flushes writes to disc to main transaction integrity in wallet.dat and the blockchain databases. The operating system can cache the entire blockchain normally,</p>

<p>I have restarted Bitcoin several times and had it start instantly because the entire blockchain is already cached by the OS.</p>

CC BY-SA 3.0
2012-03-30T11:07:15.440Z
2012-03-30T11:07:15.440Z
Diablo-D3
<p>for the record:</p>

<p>file DB_CONFIG:<br>
set_lg_dir database<br>
set_lk_max_locks 120000<br>
set_cachesize 2 524288000 1  </p>

<p>--> 2.5GB cache</p>

<p><a href="http://docs.oracle.com/cd/E17076_02/html/api_reference/C/set_cachesize_parameter.html" rel="nofollow">http://docs.oracle.com/cd/E17076_02/html/api_reference/C/set_cachesize_parameter.html</a></p>

<p>For versions higher v0.6 Pieter's way sure is better. This still could be useful for older versions.</p>

<p>Unfortunately I can't get it to work with Namecoin 3.50</p>

CC BY-SA 3.0
2013-05-18T21:00:09.430Z
2013-05-19T16:42:47.673Z
2013-05-19T16:42:47.673Z
kermit
<p>The very recently released bitcoin v0.6.0 has modified bdb cache settings (25 megabytes by default), and provides a way to change this via the command-line option -dbcache=N, with N a number in megabytes.</p>

<p>This change caused a very significant speedup for synchronizing the block chain indeed.</p>

CC BY-SA 4.0
2021-01-14T15:45:33.550Z
Can setting the number of MB assigned to the cache to be greater than the number of MB of RAM of the machine further increase the speed of syncing? E.g. Would setting the cache at 2500 MB (instead of 2000 MB) on my laptop that has only 2GB of RAM increase the speed of syncing?
John Smith
CC BY-SA 4.0
2021-01-14T17:49:16.547Z
@JerzyBrzóska That is a very bad idea. You can set it higher, but at that point your system will either run out of memory and kill things, or it will start using swap space which will cause far more slowdown than just using a smaller cache.
Pieter Wuille
CC BY-SA 3.0
2012-03-31T12:48:59.450Z
2012-03-31T12:48:59.450Z
Pieter Wuille
<p>Bitcoin is very disk-intensive and that slows it down. It seems to flush data to disk often thus preventing proper caching. With the datadir on a RAMdisk it is much faster.</p>
<p>Is it possible to <a href="http://doc.gnu-darwin.org/am_conf/cachesize.html" rel="nofollow noreferrer">increase the db cache size</a> or do something else to improve cache performance.</p>
<p>Of course it would be nice to keep the wallet and important data saved but I would not mind the blockchain to be heavily cached.</p>
<p>I'm asking mainly about Windows OS.</p>

CC BY-SA 3.0
2012-02-23T10:32:10.000Z
It's not really clear what you're asking. Very disk intensive when? During startup? When downloading the block chain? When processing GUI requests? The OS should already be caching all disk data that it can fit in memory anyway.
David Schwartz
CC BY-SA 3.0
2012-02-24T19:32:45.223Z
A getnewaddress took 20 secs or so...   I reduced virtual memory and changed the cache settings to "server" - not sure if it did anything but it is much faster now. Will close the question.
kermit
CC BY-SA 3.0
2012-02-24T22:42:07.723Z
That was likely because you have it set to create several hundred addresses when it runs out. It didn't take as long after that because it was giving you the addresses it had pre-generated.
David Schwartz
CC BY-SA 3.0
2012-03-08T16:29:18.503Z
Hmm I tested it at least five times and it always took so long.
kermit
<database><cache>
Cache the Bitcoin Datadir to Improve Performance? Increase Bitcoin DB Cache Size?
kermit
# Cache the Bitcoin Datadir to Improve Performance? Increase Bitcoin DB Cache Size?

(Asked by: username_0 on 2012-02-22)

Bitcoin is very disk-intensive and that slows it down. It seems to flush data to disk often thus preventing proper caching. With the datadir on a RAMdisk it is much faster.

Is it possible to [increase the db cache size](http://doc.gnu-darwin.org/am_conf/cachesize.html) or do something else to improve cache performance.

Of course it would be nice to keep the wallet and important data saved but I would not mind the blockchain to be heavily cached.

I'm asking mainly about Windows OS.

**Tags:** database, cache

> **Comments:**
> **username_1**: It's not really clear what you're asking. Very disk intensive when? During startup? When downloading the block chain? When processing GUI requests? The OS should already be caching all disk data that it can fit in memory anyway.  
> **username_0**: A getnewaddress took 20 secs or so...   I reduced virtual memory and changed the cache settings to "server" - not sure if it did anything but it is much faster now. Will close the question.  
> **username_1**: That was likely because you have it set to create several hundred addresses when it runs out. It didn't take as long after that because it was giving you the addresses it had pre-generated.  
> **username_0**: Hmm I tested it at least five times and it always took so long.  

---

## 3 answers

### Answer by username_3 on 2012-03-31. Score: 7 | Accepted answer

The very recently released bitcoin v0.6.0 has modified bdb cache settings (25 megabytes by default), and provides a way to change this via the command-line option -dbcache=N, with N a number in megabytes.

This change caused a very significant speedup for synchronizing the block chain indeed.

> **Comments:**
> **username_4**: Can setting the number of MB assigned to the cache to be greater than the number of MB of RAM of the machine further increase the speed of syncing? E.g. Would setting the cache at 2500 MB (instead of 2000 MB) on my laptop that has only 2GB of RAM increase the speed of syncing?  
> **username_3**: @JerzyBrzóska That is a very bad idea. You can set it higher, but at that point your system will either run out of memory and kill things, or it will start using swap space which will cause far more slowdown than just using a smaller cache.  

---

### Answer by username_2 on 2012-03-30. Score: 2

Bitcoin (through BerkleyDB) frequently flushes writes to disc to main transaction integrity in wallet.dat and the blockchain databases. The operating system can cache the entire blockchain normally,

I have restarted Bitcoin several times and had it start instantly because the entire blockchain is already cached by the OS.


---

### Answer by username_0 on 2013-05-18. Score: 0

for the record:

file DB\_CONFIG:  
set\_lg\_dir database  
set\_lk\_max\_locks 120000  
set\_cachesize 2 524288000 1

--> 2.5GB cache

<http://docs.oracle.com/cd/E17076_02/html/api_reference/C/set_cachesize_parameter.html>

For versions higher v0.6 username_3's way sure is better. This still could be useful for older versions.

Unfortunately I can't get it to work with Namecoin 3.50


---

