Skip to content

Commit

Permalink
Merge PR #2623: Speedup simulator by switching to goleveldb
Browse files Browse the repository at this point in the history
Due to requiring app.Commit() at the moment, golevel db is significantly faster than a memdb
  • Loading branch information
ValarDragon authored and cwgoes committed Oct 29, 2018
1 parent c93b116 commit 0d8325b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ test_sim_gaia_nondeterminism:

test_sim_gaia_fast:
@echo "Running quick Gaia simulation. This may take several minutes..."
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=400 -SimulationBlockSize=200 -SimulationCommit=true -SimulationSeed=9 -v -timeout 24h
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=500 -SimulationBlockSize=200 -SimulationCommit=true -SimulationSeed=9 -v -timeout 24h

test_sim_gaia_multi_seed:
@echo "Running multi-seed Gaia simulation. This may take awhile!"
@bash scripts/multisim.sh 10
@bash scripts/multisim.sh 25

SIM_NUM_BLOCKS ?= 210
SIM_NUM_BLOCKS ?= 500
SIM_BLOCK_SIZE ?= 200
SIM_COMMIT ?= true
test_sim_gaia_benchmark:
Expand Down
17 changes: 14 additions & 3 deletions cmd/gaia/app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"math/rand"
"os"
"testing"
Expand Down Expand Up @@ -141,7 +142,7 @@ func BenchmarkFullGaiaSimulation(b *testing.B) {
var logger log.Logger
logger = log.NewNopLogger()
var db dbm.DB
dir := os.TempDir()
dir, _ := ioutil.TempDir("", "goleveldb-gaia-sim")
db, _ = dbm.NewGoLevelDB("Simulation", dir)
defer func() {
db.Close()
Expand Down Expand Up @@ -183,7 +184,13 @@ func TestFullGaiaSimulation(t *testing.T) {
} else {
logger = log.NewNopLogger()
}
db := dbm.NewMemDB()
var db dbm.DB
dir, _ := ioutil.TempDir("", "goleveldb-gaia-sim")
db, _ = dbm.NewGoLevelDB("Simulation", dir)
defer func() {
db.Close()
os.RemoveAll(dir)
}()
app := NewGaiaApp(logger, db, nil)
require.Equal(t, "GaiaApp", app.Name())

Expand All @@ -198,7 +205,11 @@ func TestFullGaiaSimulation(t *testing.T) {
commit,
)
if commit {
fmt.Println("Database Size", db.Stats()["database.size"])
// for memdb:
// fmt.Println("Database Size", db.Stats()["database.size"])
fmt.Println("GoLevelDB Stats")
fmt.Println(db.Stats()["leveldb.stats"])
fmt.Println("GoLevelDB cached block size", db.Stats()["leveldb.cachedblock"])
}
require.Nil(t, err)
}
Expand Down

0 comments on commit 0d8325b

Please sign in to comment.