Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
ed34a5e0
Unverified
Commit
ed34a5e0
authored
Apr 01, 2019
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd, core, eth: support disabling the concurrent state prefetcher
parent
bb9631c3
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
21 deletions
+40
-21
main.go
cmd/geth/main.go
+1
-0
usage.go
cmd/geth/usage.go
+1
-0
flags.go
cmd/utils/flags.go
+10
-4
blockchain.go
core/blockchain.go
+18
-15
backend.go
eth/backend.go
+7
-1
config.go
eth/config.go
+3
-1
No files found.
cmd/geth/main.go
View file @
ed34a5e0
...
...
@@ -102,6 +102,7 @@ var (
utils
.
CacheDatabaseFlag
,
utils
.
CacheTrieFlag
,
utils
.
CacheGCFlag
,
utils
.
CacheNoPrefetchFlag
,
utils
.
ListenPortFlag
,
utils
.
MaxPeersFlag
,
utils
.
MaxPendingPeersFlag
,
...
...
cmd/geth/usage.go
View file @
ed34a5e0
...
...
@@ -139,6 +139,7 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
CacheDatabaseFlag
,
utils
.
CacheTrieFlag
,
utils
.
CacheGCFlag
,
utils
.
CacheNoPrefetchFlag
,
},
},
{
...
...
cmd/utils/flags.go
View file @
ed34a5e0
...
...
@@ -349,6 +349,10 @@ var (
Usage
:
"Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)"
,
Value
:
25
,
}
CacheNoPrefetchFlag
=
cli
.
BoolFlag
{
Name
:
"cache.noprefetch"
,
Usage
:
"Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)"
,
}
// Miner settings
MiningEnabledFlag
=
cli
.
BoolFlag
{
Name
:
"mine"
,
...
...
@@ -1336,6 +1340,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
Fatalf
(
"--%s must be either 'full' or 'archive'"
,
GCModeFlag
.
Name
)
}
cfg
.
NoPruning
=
ctx
.
GlobalString
(
GCModeFlag
.
Name
)
==
"archive"
cfg
.
NoPrefetch
=
ctx
.
GlobalBool
(
CacheNoPrefetchFlag
.
Name
)
if
ctx
.
GlobalIsSet
(
CacheFlag
.
Name
)
||
ctx
.
GlobalIsSet
(
CacheTrieFlag
.
Name
)
{
cfg
.
TrieCleanCache
=
ctx
.
GlobalInt
(
CacheFlag
.
Name
)
*
ctx
.
GlobalInt
(
CacheTrieFlag
.
Name
)
/
100
...
...
@@ -1595,9 +1600,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
Fatalf
(
"--%s must be either 'full' or 'archive'"
,
GCModeFlag
.
Name
)
}
cache
:=
&
core
.
CacheConfig
{
Disabled
:
ctx
.
GlobalString
(
GCModeFlag
.
Name
)
==
"archive"
,
TrieCleanLimit
:
eth
.
DefaultConfig
.
TrieCleanCache
,
TrieCleanNoPrefetch
:
ctx
.
GlobalBool
(
CacheNoPrefetchFlag
.
Name
),
TrieDirtyLimit
:
eth
.
DefaultConfig
.
TrieDirtyCache
,
TrieDirtyDisabled
:
ctx
.
GlobalString
(
GCModeFlag
.
Name
)
==
"archive"
,
TrieTimeLimit
:
eth
.
DefaultConfig
.
TrieTimeout
,
}
if
ctx
.
GlobalIsSet
(
CacheFlag
.
Name
)
||
ctx
.
GlobalIsSet
(
CacheTrieFlag
.
Name
)
{
...
...
core/blockchain.go
View file @
ed34a5e0
...
...
@@ -90,9 +90,10 @@ const (
// CacheConfig contains the configuration values for the trie caching/pruning
// that's resident in a blockchain.
type
CacheConfig
struct
{
Disabled
bool
// Whether to disable trie write caching (archive node)
TrieCleanLimit
int
// Memory allowance (MB) to use for caching trie nodes in memory
TrieCleanNoPrefetch
bool
// Whether to disable heuristic state prefetching for followup blocks
TrieDirtyLimit
int
// Memory limit (MB) at which to start flushing dirty trie nodes to disk
TrieDirtyDisabled
bool
// Whether to disable trie write caching and GC altogether (archive node)
TrieTimeLimit
time
.
Duration
// Time limit after which to flush the current in-memory trie to disk
}
...
...
@@ -708,7 +709,7 @@ func (bc *BlockChain) Stop() {
// - HEAD: So we don't need to reprocess any blocks in the general case
// - HEAD-1: So we don't do large reorgs if our HEAD becomes an uncle
// - HEAD-127: So we have a hard limit on the number of blocks reexecuted
if
!
bc
.
cacheConfig
.
Disabled
{
if
!
bc
.
cacheConfig
.
TrieDirty
Disabled
{
triedb
:=
bc
.
stateCache
.
TrieDB
()
for
_
,
offset
:=
range
[]
uint64
{
0
,
1
,
triesInMemory
-
1
}
{
...
...
@@ -968,7 +969,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
triedb
:=
bc
.
stateCache
.
TrieDB
()
// If we're running an archive node, always flush
if
bc
.
cacheConfig
.
Disabled
{
if
bc
.
cacheConfig
.
TrieDirty
Disabled
{
if
err
:=
triedb
.
Commit
(
root
,
false
);
err
!=
nil
{
return
NonStatTy
,
err
}
...
...
@@ -1232,6 +1233,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
// transactions and probabilistically some of the account/storage trie nodes.
var
followupInterrupt
uint32
if
!
bc
.
cacheConfig
.
TrieCleanNoPrefetch
{
if
followup
,
err
:=
it
.
peek
();
followup
!=
nil
&&
err
==
nil
{
go
func
(
start
time
.
Time
)
{
throwaway
,
_
:=
state
.
New
(
parent
.
Root
,
bc
.
stateCache
)
...
...
@@ -1243,6 +1245,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
}
}(
time
.
Now
())
}
}
// Process block using the parent state as reference point
substart
:=
time
.
Now
()
receipts
,
logs
,
usedGas
,
err
:=
bc
.
processor
.
Process
(
block
,
statedb
,
bc
.
vmConfig
)
...
...
eth/backend.go
View file @
ed34a5e0
...
...
@@ -165,7 +165,13 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
EWASMInterpreter
:
config
.
EWASMInterpreter
,
EVMInterpreter
:
config
.
EVMInterpreter
,
}
cacheConfig
=
&
core
.
CacheConfig
{
Disabled
:
config
.
NoPruning
,
TrieCleanLimit
:
config
.
TrieCleanCache
,
TrieDirtyLimit
:
config
.
TrieDirtyCache
,
TrieTimeLimit
:
config
.
TrieTimeout
}
cacheConfig
=
&
core
.
CacheConfig
{
TrieCleanLimit
:
config
.
TrieCleanCache
,
TrieCleanNoPrefetch
:
config
.
NoPrefetch
,
TrieDirtyLimit
:
config
.
TrieDirtyCache
,
TrieDirtyDisabled
:
config
.
NoPruning
,
TrieTimeLimit
:
config
.
TrieTimeout
,
}
)
eth
.
blockchain
,
err
=
core
.
NewBlockChain
(
chainDb
,
cacheConfig
,
chainConfig
,
eth
.
engine
,
vmConfig
,
eth
.
shouldPreserve
)
if
err
!=
nil
{
...
...
eth/config.go
View file @
ed34a5e0
...
...
@@ -92,7 +92,9 @@ type Config struct {
// Protocol options
NetworkId
uint64
// Network ID to use for selecting peers to connect to
SyncMode
downloader
.
SyncMode
NoPruning
bool
NoPruning
bool
// Whether to disable pruning and flush everything to disk
NoPrefetch
bool
// Whether to disable prefetching and only load state on demand
// Whitelist of required block number -> hash values to accept
Whitelist
map
[
uint64
]
common
.
Hash
`toml:"-"`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment