Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
optimize the size of iavl cache (#137)
Browse files Browse the repository at this point in the history
* expand the size of iavl cache

* format code
  • Loading branch information
summerpro authored Aug 12, 2021
1 parent 65b96a1 commit a2ad2e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package server

import (
"fmt"
"github.com/cosmos/cosmos-sdk/store/iavl"
"os"
"runtime/pprof"

Expand Down Expand Up @@ -127,6 +128,8 @@ which accepts a path for the resulting pprof file.
cmd.Flags().String(FlagEvmImportMode, "default", "Select import mode for evm state (default|files|db)")
cmd.Flags().String(FlagEvmImportPath, "", "Evm contract & storage db or files used for InitGenesis")
cmd.Flags().Uint64(FlagGoroutineNum, 0, "Limit on the number of goroutines used to import evm data(ignored if evm-import-mode is 'default')")
cmd.Flags().IntVar(&iavl.IavlCacheSize, iavl.FlagIavlCacheSize, 1000000, "Max size of iavl cache")

viper.BindPFlag(FlagTrace, cmd.Flags().Lookup(FlagTrace))
viper.BindPFlag(FlagPruning, cmd.Flags().Lookup(FlagPruning))
viper.BindPFlag(FlagPruningKeepRecent, cmd.Flags().Lookup(FlagPruningKeepRecent))
Expand Down
11 changes: 6 additions & 5 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package iavl

import (
"errors"
"fmt"
"io"
"sync"
"fmt"
"errors"

"github.com/tendermint/iavl"
abci "github.com/tendermint/tendermint/abci/types"
Expand All @@ -18,8 +18,9 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

const (
defaultIAVLCacheSize = 10000
var (
FlagIavlCacheSize = "iavl-cache-size"
IavlCacheSize = 1000000
)

var (
Expand All @@ -45,7 +46,7 @@ func LoadStore(db dbm.DB, id types.CommitID, lazyLoading bool, startVersion int6
// to the one given. Internally, it will load the store's version (id) from the
// provided DB. An error is returned if the version fails to load.
func LoadStoreWithInitialVersion(db dbm.DB, id types.CommitID, lazyLoading bool, initialVersion uint64) (types.CommitKVStore, error) {
tree, err := iavl.NewMutableTreeWithOpts(db, defaultIAVLCacheSize, &iavl.Options{InitialVersion: initialVersion})
tree, err := iavl.NewMutableTreeWithOpts(db, IavlCacheSize, &iavl.Options{InitialVersion: initialVersion})
if err != nil {
return nil, err
}
Expand Down

0 comments on commit a2ad2e4

Please sign in to comment.