Skip to content

Commit 3ebf3d0

Browse files
committed
triedb/pathdb: sort the locations by read order
Signed-off-by: jsvisa <delweng@gmail.com>
1 parent a616748 commit 3ebf3d0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

triedb/pathdb/difflayer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (dl *diffLayer) node(owner common.Hash, path []byte, depth int) ([]byte, co
9191
dirtyNodeHitMeter.Mark(1)
9292
dirtyNodeHitDepthHist.Update(int64(depth))
9393
dirtyNodeReadMeter.Mark(int64(len(n.Blob)))
94-
return n.Blob, n.Hash, &nodeLoc{loc: locDiffLayer, depth: depth}, nil
94+
return n.Blob, n.Hash, &nodeLoc{loc: locDiffCache, depth: depth}, nil
9595
}
9696
// Trie node unknown to this layer, resolve from parent
9797
return dl.parent.node(owner, path, depth+1)

triedb/pathdb/reader.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ import (
2929

3030
// The types of locations where the node is found.
3131
const (
32-
locDirtyCache = "dirty" // dirty cache
33-
locCleanCache = "clean" // clean cache
34-
locDiskLayer = "disk" // persistent state
35-
locDiffLayer = "diff" // diff layers
32+
locDiffCache = "diff" // in-memory cache for nodes from the diff layer
33+
locDirtyCache = "dirty" // not yet persisted write buffer for modified nodes
34+
locCleanCache = "clean" // fastcache for clean nodes from the disk layer
35+
locDiskLayer = "disk" // on-disk persistent state
3636
)
3737

3838
// nodeLoc is a helpful structure that contains the location where the node
@@ -67,12 +67,12 @@ func (r *reader) Node(owner common.Hash, path []byte, hash common.Hash) ([]byte,
6767
// Location is always available even if the node
6868
// is not found.
6969
switch loc.loc {
70-
case locCleanCache:
71-
nodeCleanFalseMeter.Mark(1)
70+
case locDiffCache:
71+
nodeDiffFalseMeter.Mark(1)
7272
case locDirtyCache:
7373
nodeDirtyFalseMeter.Mark(1)
74-
case locDiffLayer:
75-
nodeDiffFalseMeter.Mark(1)
74+
case locCleanCache:
75+
nodeCleanFalseMeter.Mark(1)
7676
case locDiskLayer:
7777
nodeDiskFalseMeter.Mark(1)
7878
}

0 commit comments

Comments
 (0)