-
-
Save ancazamfir/1b48fbd7565527a7f4102f9ddfde754a to your computer and use it in GitHub Desktop.
gaia disk usage analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Build Tendermint with the diffs in this gist | |
Run the script to start gaia, collect du, run compact command: | |
./compact_n <rpc_port> <home> <every_n_blocks> | |
for example to collect data and compact every 1000 blocks: | |
./compact_n 26657 ~/.gaia 1000 | |
Plot and check the results: | |
Rscript plot.R ; open Rplots.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function record_du { | |
height=$1 | |
data_file=$2 | |
csv_file=$3 | |
du -k $home/data/$data_file | |
du=`du -k $home/data/$data_file | head -n1 | awk '{print $1;}'` | |
echo -e "$height,$du" >> $home/$csv_file | |
} | |
function compact { | |
height=$1 | |
#start the compaction routine | |
echo -e "\nCompact at $height" | |
pkill gaiad | |
sleep 1 | |
tendermint experimental-compact-goleveldb --home $home > /dev/null 2>&1 | |
gaiad --home $home start --log_level error > $logfile 2>&1 & | |
sleep 2 | |
#take disk usage after gaia start otherwise the space is not really freed | |
du -k $home/data/application.db | |
du -k $home/data/blockstore.db | |
du -k $home/data/state.db | |
du -k $home/data/tx_index.db | |
echo "----------------" | |
} | |
# ./compact_n <port> <home> <every_n_blocks> | |
port=$1 | |
home=$2 | |
everyn=$3 | |
#cleanup | |
pkill gaiad | |
tendermint experimental-compact-goleveldb --home $home > /dev/null 2>&1 | |
#start gaia | |
logfile=$home"/gaia.log" | |
gaiad --home $home start --log_level error > $logfile 2>&1 & | |
sleep 1 | |
#get current height | |
height="$(curl -s localhost:$port/status | jq -r .result.sync_info.latest_block_height)" | |
#get the height's <n> quotient | |
base=$(($height/$everyn)) | |
#du file header | |
echo -e "height,usage" > $home/application_du.csv | |
echo -e "height,usage" > $home/blockstore_du.csv | |
echo -e "height,usage" > $home/state_du.csv | |
echo -e "height,usage" > $home/tx_index_du.csv | |
for i in {1..100} | |
do | |
#determine the compaction height | |
compheight=$((($base+$i)*$everyn)) | |
#wait for the compaction height to be reached | |
#collect du at each height | |
echo "height is $height" | |
while [ $height -lt $compheight ] | |
do | |
sleep 1 | |
height="$(curl -s localhost:$port/status | jq -r .result.sync_info.latest_block_height)" | |
echo -e "\nDu at $height" | |
record_du $height "application.db" "application_du.csv" | |
record_du $height "blockstore.db" "blockstore_du.csv" | |
record_du $height "state.db" "state_du.csv" | |
record_du $height "tx_index.db" "tx_index_du.csv" | |
echo -e "----------------" | |
done | |
compact $height | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app=read.csv("application_du.csv") | |
bl=read.csv("blockstore_du.csv") | |
state=read.csv("state_du.csv") | |
tx_index=read.csv("tx_index_du.csv") | |
plot(app,type ="l", main="application.db") | |
plot(bl,type ="l", main="blockstore.db") | |
plot(state, type="l", main="state.db") | |
plot(tx_index, type="l", main="tx_index.db") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cmd/tendermint/commands/compact.go b/cmd/tendermint/commands/compact.go | |
index 4813cf1b3..634342583 100644 | |
--- a/cmd/tendermint/commands/compact.go | |
+++ b/cmd/tendermint/commands/compact.go | |
@@ -17,8 +17,8 @@ var CompactGoLevelDBCmd = &cobra.Command{ | |
Use: "experimental-compact-goleveldb", | |
Short: "force compacts the tendermint storage engine (only GoLevelDB supported)", | |
Long: ` | |
-This is a temporary utility command that performs a force compaction on the state | |
-and blockstores to reduce disk space for a pruning node. This should only be run | |
+This is a temporary utility command that performs a force compaction on the state | |
+and blockstores to reduce disk space for a pruning node. This should only be run | |
once the node has stopped. This command will likely be omitted in the future after | |
the planned refactor to the storage engine. | |
@@ -35,7 +35,7 @@ Currently, only GoLevelDB is supported. | |
} | |
func compactGoLevelDBs(rootDir string, logger log.Logger) { | |
- dbNames := []string{"state", "blockstore"} | |
+ dbNames := []string{"state", "blockstore", "tx_index", "application"} | |
o := &opt.Options{ | |
DisableSeeksCompaction: true, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment