Give more dbcache RAM during IBD #709

This commit is contained in:
Christian Rotzoll 2019-08-08 02:15:44 +02:00
parent 12270c4c69
commit 2d569da849
4 changed files with 59 additions and 3 deletions

View File

@ -56,6 +56,24 @@ if [ "$network" = "bitcoin" ]; then
fi
echo "*** Optimizing RAM for Sync ***"
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
echo "dont forget to reduce dbcache once IBD is done" > "/home/admin/selfsync.flag"
# RP4 4GB
if [ ${kbSizeRAM} -gt 3500000 ]; then
echo "Detected RAM >=4GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=3072/g" /mnt/hdd/${network}/${network}.conf
# RP4 2GB
elif [ ${kbSizeRAM} -gt 1500000 ]; then
echo "Detected RAM >=2GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=1536/g" /mnt/hdd/${network}/${network}.conf
# RP3/4 1GB
else
echo "Detected RAM <=1GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=768/g" /mnt/hdd/${network}/${network}.conf
fi
echo "*** Activating Blockain Sync ***"
sudo mkdir /mnt/hdd/${network} 2>/dev/null

View File

@ -261,6 +261,44 @@ do
fi
fi
####################################################
# CHECK FOR END OF IBD (self validation)
####################################################
# check every 60secs
recheckIBD=$((($counter % 60)+1))
if [ ${recheckIBD} -eq 1 ]; then
# check if flag exists (got created on 50syncHDD.sh)
flagExists=$(ls /home/admin/selfsync.flag 2>/dev/null | grep -c "selfsync.flag")
if [ ${flagExists} -eq 1 ]; then
finishedIBD=$(bitcoin-cli getblockchaininfo | grep "initialblockdownload" | grep -c "false")
if [ ${finishedIBD} -eq 1 ]; then
echo "CHECK FOR END OF IBD --> reduce RAM and restart bitcoind"
# remove flag
rm /home/admin/selfsync.flag
# stop bitcoind
sudo systemctl stop bitcoind
# set dbcache back to normal (to give room for other apps)
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
if [ ${kbSizeRAM} -gt 1500000 ]; then
echo "Detected RAM >1GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=1024/g" /mnt/hdd/${network}/${network}.conf
else
echo "Detected RAM 1GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=128/g" /mnt/hdd/${network}/${network}.conf
fi
# restart bitcoind
sudo systemctl start bitcoind
fi
fi
fi
###############################
# Prepare next loop
###############################

View File

@ -62,7 +62,7 @@ kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
if [ ${kbSizeRAM} -gt 1500000 ]; then
echo "Detected RAM >1GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=1024/g" /mnt/hdd/${network}/${network}.conf
sudo sed -i "s/^maxmempool=.*/maxmempool=300/g" /mnt/hdd/${network}/${network}.conf
sudo sed -i "s/^maxmempool=.*/maxmempool=256/g" /mnt/hdd/${network}/${network}.conf
fi
# link and copy HDD content into new OS

View File

@ -19,9 +19,9 @@ zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
# Raspberry Pi optimizations
dbcache=100
dbcache=128
maxorphantx=10
maxmempool=50
maxmempool=64
maxconnections=40
maxuploadtarget=5000