Skip to content

Commit a582560

Browse files
fanquakefurszy
authored andcommitted
docs: add reduce-memory.md
Co-Authored-By: Wladimir J. van der Laan <[email protected]> Plus adapted it to PIVX. Github-Pull: #2262 Rebased-From: caa6734
1 parent f806584 commit a582560

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ The PIVX repo's [root README](/README.md) contains relevant information on the d
6464
### Miscellaneous
6565
- [Assets Attribution](assets-attribution.md)
6666
- [Files](files.md)
67+
- [Reduce Memory](reduce-memory.md)
6768
- [Tor Support](tor.md)
6869
- [Init Scripts (systemd/upstart/openrc)](init.md)
6970

doc/reduce-memory.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Reduce Memory
2+
3+
There are a few parameters that can be dialed down to reduce the memory usage of `pivxd`. This can be useful on embedded systems or small VPSes.
4+
5+
## In-memory caches
6+
7+
The size of some in-memory caches can be reduced. As caches trade off memory usage for performance, reducing these will usually have a negative effect on performance.
8+
9+
- `-dbcache=<n>` - the UTXO database cache size, this defaults to `450`. The unit is MiB (1024).
10+
- The minimum value for `-dbcache` is 4.
11+
- A lower `-dbcache` makes initial sync time much longer. After the initial sync, the effect is less pronounced for most use-cases, unless fast validation of blocks is important, such as for mining.
12+
13+
## Memory pool
14+
15+
- In PIVX Core there is a memory pool limiter which can be configured with `-maxmempool=<n>`, where `<n>` is the size in MB (1000). The default value is `300`.
16+
- The minimum value for `-maxmempool` is 5.
17+
- A lower maximum mempool size means that transactions will be evicted sooner. This will affect any uses of `pivxd` that process unconfirmed transactions.
18+
19+
- Unused memory allocated to the mempool (default: 300MB) is shared with the UTXO cache, so when trying to reduce memory usage you should limit the mempool, with the `-maxmempool` command line argument.
20+
21+
## Number of peers
22+
23+
- `-maxconnections=<n>` - the maximum number of connections, this defaults to `125`. Each active connection takes up some memory. Only significant if incoming
24+
connections are enabled, otherwise the number of connections will never be more than `8`.
25+
26+
## Thread configuration
27+
28+
For each thread a thread stack needs to be allocated. By default on Linux,
29+
threads take up 8MiB for the thread stack on a 64-bit system, and 4MiB in a
30+
32-bit system.
31+
32+
- `-par=<n>` - the number of script verification threads, defaults to the number of cores in the system minus one.
33+
- `-rpcthreads=<n>` - the number of threads used for processing RPC requests, defaults to `4`.
34+
35+
## Linux specific
36+
37+
By default, since glibc `2.10`, the C library will create up to two heap arenas per core. This is known to cause excessive memory usage in some scenarios. To avoid this make a script that sets `MALLOC_ARENA_MAX` before starting pivxd:
38+
39+
```bash
40+
#!/usr/bin/env bash
41+
export MALLOC_ARENA_MAX=1
42+
pivxd
43+
```
44+
45+
The behavior was introduced to increase CPU locality of allocated memory and performance with concurrent allocation, so this setting could in theory reduce performance. However, in PIVX Core very little parallel allocation happens, so the impact is expected to be small or absent.

0 commit comments

Comments
 (0)