good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
3ee91b9f
Unverified
Commit
3ee91b9f
authored
Aug 24, 2020
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
core/state/snapshot: reduce disk layer depth during generation
parent
0f4e7c9b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/state/snapshot/generate.go
+10
-8
10 additions, 8 deletions
core/state/snapshot/generate.go
core/state/snapshot/journal.go
+1
-1
1 addition, 1 deletion
core/state/snapshot/journal.go
core/state/snapshot/snapshot.go
+7
-0
7 additions, 0 deletions
core/state/snapshot/snapshot.go
with
18 additions
and
9 deletions
core/state/snapshot/generate.go
+
10
−
8
View file @
3ee91b9f
...
...
@@ -54,9 +54,11 @@ type generatorStats struct {
// Log creates an contextual log with the given message and the context pulled
// from the internally maintained statistics.
func
(
gs
*
generatorStats
)
Log
(
msg
string
,
marker
[]
byte
)
{
func
(
gs
*
generatorStats
)
Log
(
msg
string
,
root
common
.
Hash
,
marker
[]
byte
)
{
var
ctx
[]
interface
{}
if
root
!=
(
common
.
Hash
{})
{
ctx
=
append
(
ctx
,
[]
interface
{}{
"root"
,
root
}
...
)
}
// Figure out whether we're after or within an account
switch
len
(
marker
)
{
case
common
.
HashLength
:
...
...
@@ -120,7 +122,7 @@ func generateSnapshot(diskdb ethdb.KeyValueStore, triedb *trie.Database, cache i
func
(
dl
*
diskLayer
)
generate
(
stats
*
generatorStats
)
{
// If a database wipe is in operation, wait until it's done
if
stats
.
wiping
!=
nil
{
stats
.
Log
(
"Wiper running, state snapshotting paused"
,
dl
.
genMarker
)
stats
.
Log
(
"Wiper running, state snapshotting paused"
,
common
.
Hash
{},
dl
.
genMarker
)
select
{
// If wiper is done, resume normal mode of operation
case
<-
stats
.
wiping
:
...
...
@@ -137,13 +139,13 @@ func (dl *diskLayer) generate(stats *generatorStats) {
accTrie
,
err
:=
trie
.
NewSecure
(
dl
.
root
,
dl
.
triedb
)
if
err
!=
nil
{
// The account trie is missing (GC), surf the chain until one becomes available
stats
.
Log
(
"Trie missing, state snapshotting paused"
,
dl
.
genMarker
)
stats
.
Log
(
"Trie missing, state snapshotting paused"
,
dl
.
root
,
dl
.
genMarker
)
abort
:=
<-
dl
.
genAbort
abort
<-
stats
return
}
stats
.
Log
(
"Resuming state snapshot generation"
,
dl
.
genMarker
)
stats
.
Log
(
"Resuming state snapshot generation"
,
dl
.
root
,
dl
.
genMarker
)
var
accMarker
[]
byte
if
len
(
dl
.
genMarker
)
>
0
{
// []byte{} is the start, use nil for that
...
...
@@ -192,7 +194,7 @@ func (dl *diskLayer) generate(stats *generatorStats) {
dl
.
lock
.
Unlock
()
}
if
abort
!=
nil
{
stats
.
Log
(
"Aborting state snapshot generation"
,
accountHash
[
:
])
stats
.
Log
(
"Aborting state snapshot generation"
,
dl
.
root
,
accountHash
[
:
])
abort
<-
stats
return
}
...
...
@@ -230,7 +232,7 @@ func (dl *diskLayer) generate(stats *generatorStats) {
dl
.
lock
.
Unlock
()
}
if
abort
!=
nil
{
stats
.
Log
(
"Aborting state snapshot generation"
,
append
(
accountHash
[
:
],
storeIt
.
Key
...
))
stats
.
Log
(
"Aborting state snapshot generation"
,
dl
.
root
,
append
(
accountHash
[
:
],
storeIt
.
Key
...
))
abort
<-
stats
return
}
...
...
@@ -238,7 +240,7 @@ func (dl *diskLayer) generate(stats *generatorStats) {
}
}
if
time
.
Since
(
logged
)
>
8
*
time
.
Second
{
stats
.
Log
(
"Generating state snapshot"
,
accIt
.
Key
)
stats
.
Log
(
"Generating state snapshot"
,
dl
.
root
,
accIt
.
Key
)
logged
=
time
.
Now
()
}
// Some account processed, unmark the marker
...
...
This diff is collapsed.
Click to expand it.
core/state/snapshot/journal.go
+
1
−
1
View file @
3ee91b9f
...
...
@@ -193,7 +193,7 @@ func (dl *diskLayer) Journal(buffer *bytes.Buffer) (common.Hash, error) {
dl
.
genAbort
<-
abort
if
stats
=
<-
abort
;
stats
!=
nil
{
stats
.
Log
(
"Journalling in-progress snapshot"
,
dl
.
genMarker
)
stats
.
Log
(
"Journalling in-progress snapshot"
,
dl
.
root
,
dl
.
genMarker
)
}
}
// Ensure the layer didn't get stale
...
...
This diff is collapsed.
Click to expand it.
core/state/snapshot/snapshot.go
+
7
−
0
View file @
3ee91b9f
...
...
@@ -263,6 +263,13 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
if
!
ok
{
return
fmt
.
Errorf
(
"snapshot [%#x] is disk layer"
,
root
)
}
// If the generator is still running, use a more aggressive cap
diff
.
origin
.
lock
.
RLock
()
if
diff
.
origin
.
genMarker
!=
nil
&&
layers
>
8
{
layers
=
8
}
diff
.
origin
.
lock
.
RUnlock
()
// Run the internal capping and discard all stale layers
t
.
lock
.
Lock
()
defer
t
.
lock
.
Unlock
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment