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

Commit a2ad2e4

Browse files
authored
optimize the size of iavl cache (#137)
* expand the size of iavl cache * format code
1 parent 65b96a1 commit a2ad2e4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

server/start.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package server
44

55
import (
66
"fmt"
7+
"github.com/cosmos/cosmos-sdk/store/iavl"
78
"os"
89
"runtime/pprof"
910

@@ -127,6 +128,8 @@ which accepts a path for the resulting pprof file.
127128
cmd.Flags().String(FlagEvmImportMode, "default", "Select import mode for evm state (default|files|db)")
128129
cmd.Flags().String(FlagEvmImportPath, "", "Evm contract & storage db or files used for InitGenesis")
129130
cmd.Flags().Uint64(FlagGoroutineNum, 0, "Limit on the number of goroutines used to import evm data(ignored if evm-import-mode is 'default')")
131+
cmd.Flags().IntVar(&iavl.IavlCacheSize, iavl.FlagIavlCacheSize, 1000000, "Max size of iavl cache")
132+
130133
viper.BindPFlag(FlagTrace, cmd.Flags().Lookup(FlagTrace))
131134
viper.BindPFlag(FlagPruning, cmd.Flags().Lookup(FlagPruning))
132135
viper.BindPFlag(FlagPruningKeepRecent, cmd.Flags().Lookup(FlagPruningKeepRecent))

store/iavl/store.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package iavl
22

33
import (
4+
"errors"
5+
"fmt"
46
"io"
57
"sync"
6-
"fmt"
7-
"errors"
88

99
"github.com/tendermint/iavl"
1010
abci "github.com/tendermint/tendermint/abci/types"
@@ -18,8 +18,9 @@ import (
1818
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
1919
)
2020

21-
const (
22-
defaultIAVLCacheSize = 10000
21+
var (
22+
FlagIavlCacheSize = "iavl-cache-size"
23+
IavlCacheSize = 1000000
2324
)
2425

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

0 commit comments

Comments
 (0)