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
8048f4d4
Commit
8048f4d4
authored
Oct 19, 2016
by
Péter Szilágyi
Committed by
GitHub
Oct 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3173 from karalabe/parametrized-trie-cache-get
cmd, core/state: allow configurable trie cache generations
parents
d48e6ae6
4f46bd19
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
12 deletions
+29
-12
chaincmd.go
cmd/geth/chaincmd.go
+1
-1
main.go
cmd/geth/main.go
+2
-1
usage.go
cmd/geth/usage.go
+6
-0
flags.go
cmd/utils/flags.go
+15
-5
statedb.go
core/state/statedb.go
+5
-5
No files found.
cmd/geth/chaincmd.go
View file @
8048f4d4
...
@@ -99,6 +99,7 @@ func importChain(ctx *cli.Context) error {
...
@@ -99,6 +99,7 @@ func importChain(ctx *cli.Context) error {
utils
.
Fatalf
(
"Failed to read database stats: %v"
,
err
)
utils
.
Fatalf
(
"Failed to read database stats: %v"
,
err
)
}
}
fmt
.
Println
(
stats
)
fmt
.
Println
(
stats
)
fmt
.
Printf
(
"Trie cache misses: %d
\n\n
"
,
trie
.
CacheMisses
())
// Compact the entire database to more accurately measure disk io and print the stats
// Compact the entire database to more accurately measure disk io and print the stats
start
=
time
.
Now
()
start
=
time
.
Now
()
...
@@ -113,7 +114,6 @@ func importChain(ctx *cli.Context) error {
...
@@ -113,7 +114,6 @@ func importChain(ctx *cli.Context) error {
utils
.
Fatalf
(
"Failed to read database stats: %v"
,
err
)
utils
.
Fatalf
(
"Failed to read database stats: %v"
,
err
)
}
}
fmt
.
Println
(
stats
)
fmt
.
Println
(
stats
)
fmt
.
Println
(
"Trie cache misses:"
,
trie
.
CacheMisses
())
}
}
return
nil
return
nil
}
}
...
...
cmd/geth/main.go
View file @
8048f4d4
...
@@ -134,8 +134,9 @@ participating.
...
@@ -134,8 +134,9 @@ participating.
utils
.
KeyStoreDirFlag
,
utils
.
KeyStoreDirFlag
,
utils
.
OlympicFlag
,
utils
.
OlympicFlag
,
utils
.
FastSyncFlag
,
utils
.
FastSyncFlag
,
utils
.
CacheFlag
,
utils
.
LightKDFFlag
,
utils
.
LightKDFFlag
,
utils
.
CacheFlag
,
utils
.
TrieCacheGenFlag
,
utils
.
JSpathFlag
,
utils
.
JSpathFlag
,
utils
.
ListenPortFlag
,
utils
.
ListenPortFlag
,
utils
.
MaxPeersFlag
,
utils
.
MaxPeersFlag
,
...
...
cmd/geth/usage.go
View file @
8048f4d4
...
@@ -73,7 +73,13 @@ var AppHelpFlagGroups = []flagGroup{
...
@@ -73,7 +73,13 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
IdentityFlag
,
utils
.
IdentityFlag
,
utils
.
FastSyncFlag
,
utils
.
FastSyncFlag
,
utils
.
LightKDFFlag
,
utils
.
LightKDFFlag
,
},
},
{
Name
:
"PERFORMANCE TUNING"
,
Flags
:
[]
cli
.
Flag
{
utils
.
CacheFlag
,
utils
.
CacheFlag
,
utils
.
TrieCacheGenFlag
,
},
},
},
},
{
{
...
...
cmd/utils/flags.go
View file @
8048f4d4
...
@@ -141,11 +141,6 @@ var (
...
@@ -141,11 +141,6 @@ var (
Usage
:
"Document Root for HTTPClient file scheme"
,
Usage
:
"Document Root for HTTPClient file scheme"
,
Value
:
DirectoryString
{
homeDir
()},
Value
:
DirectoryString
{
homeDir
()},
}
}
CacheFlag
=
cli
.
IntFlag
{
Name
:
"cache"
,
Usage
:
"Megabytes of memory allocated to internal caching (min 16MB / database forced)"
,
Value
:
128
,
}
FastSyncFlag
=
cli
.
BoolFlag
{
FastSyncFlag
=
cli
.
BoolFlag
{
Name
:
"fast"
,
Name
:
"fast"
,
Usage
:
"Enable fast syncing through state downloads"
,
Usage
:
"Enable fast syncing through state downloads"
,
...
@@ -154,6 +149,17 @@ var (
...
@@ -154,6 +149,17 @@ var (
Name
:
"lightkdf"
,
Name
:
"lightkdf"
,
Usage
:
"Reduce key-derivation RAM & CPU usage at some expense of KDF strength"
,
Usage
:
"Reduce key-derivation RAM & CPU usage at some expense of KDF strength"
,
}
}
// Performance tuning settings
CacheFlag
=
cli
.
IntFlag
{
Name
:
"cache"
,
Usage
:
"Megabytes of memory allocated to internal caching (min 16MB / database forced)"
,
Value
:
128
,
}
TrieCacheGenFlag
=
cli
.
IntFlag
{
Name
:
"trie-cache-gens"
,
Usage
:
"Number of trie node generations to keep in memory"
,
Value
:
int
(
state
.
MaxTrieCacheGen
),
}
// Fork settings
// Fork settings
SupportDAOFork
=
cli
.
BoolFlag
{
SupportDAOFork
=
cli
.
BoolFlag
{
Name
:
"support-dao-fork"
,
Name
:
"support-dao-fork"
,
...
@@ -721,6 +727,10 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
...
@@ -721,6 +727,10 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
}
}
ethConf
.
PowTest
=
true
ethConf
.
PowTest
=
true
}
}
// Override any global options pertaining to the Ethereum protocol
if
gen
:=
ctx
.
GlobalInt
(
TrieCacheGenFlag
.
Name
);
gen
>
0
{
state
.
MaxTrieCacheGen
=
uint16
(
gen
)
}
if
err
:=
stack
.
Register
(
func
(
ctx
*
node
.
ServiceContext
)
(
node
.
Service
,
error
)
{
if
err
:=
stack
.
Register
(
func
(
ctx
*
node
.
ServiceContext
)
(
node
.
Service
,
error
)
{
return
eth
.
New
(
ctx
,
ethConf
)
return
eth
.
New
(
ctx
,
ethConf
)
...
...
core/state/statedb.go
View file @
8048f4d4
...
@@ -38,14 +38,14 @@ import (
...
@@ -38,14 +38,14 @@ import (
// created.
// created.
var
StartingNonce
uint64
var
StartingNonce
uint64
// Trie cache generation limit after which to evic trie nodes from memory.
var
MaxTrieCacheGen
=
uint16
(
120
)
const
(
const
(
// Number of past tries to keep. This value is chosen such that
// Number of past tries to keep. This value is chosen such that
// reasonable chain reorg depths will hit an existing trie.
// reasonable chain reorg depths will hit an existing trie.
maxPastTries
=
12
maxPastTries
=
12
// Trie cache generation limit.
maxTrieCacheGen
=
120
// Number of codehash->size associations to keep.
// Number of codehash->size associations to keep.
codeSizeCacheSize
=
100000
codeSizeCacheSize
=
100000
)
)
...
@@ -89,7 +89,7 @@ type StateDB struct {
...
@@ -89,7 +89,7 @@ type StateDB struct {
// Create a new state from a given trie
// Create a new state from a given trie
func
New
(
root
common
.
Hash
,
db
ethdb
.
Database
)
(
*
StateDB
,
error
)
{
func
New
(
root
common
.
Hash
,
db
ethdb
.
Database
)
(
*
StateDB
,
error
)
{
tr
,
err
:=
trie
.
NewSecure
(
root
,
db
,
m
axTrieCacheGen
)
tr
,
err
:=
trie
.
NewSecure
(
root
,
db
,
M
axTrieCacheGen
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -158,7 +158,7 @@ func (self *StateDB) openTrie(root common.Hash) (*trie.SecureTrie, error) {
...
@@ -158,7 +158,7 @@ func (self *StateDB) openTrie(root common.Hash) (*trie.SecureTrie, error) {
return
&
tr
,
nil
return
&
tr
,
nil
}
}
}
}
return
trie
.
NewSecure
(
root
,
self
.
db
,
m
axTrieCacheGen
)
return
trie
.
NewSecure
(
root
,
self
.
db
,
M
axTrieCacheGen
)
}
}
func
(
self
*
StateDB
)
pushTrie
(
t
*
trie
.
SecureTrie
)
{
func
(
self
*
StateDB
)
pushTrie
(
t
*
trie
.
SecureTrie
)
{
...
...
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