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
50317bda
Unverified
Commit
50317bda
authored
Mar 30, 2023
by
s7v7nislands
Committed by
GitHub
Mar 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethdb/pebble: use atomic type (#27014)
parent
2d149282
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
pebble.go
ethdb/pebble/pebble.go
+17
-17
No files found.
ethdb/pebble/pebble.go
View file @
50317bda
...
@@ -75,14 +75,14 @@ type Database struct {
...
@@ -75,14 +75,14 @@ type Database struct {
log
log
.
Logger
// Contextual logger tracking the database path
log
log
.
Logger
// Contextual logger tracking the database path
activeComp
int
// Current number of active compactions
activeComp
int
// Current number of active compactions
compStartTime
time
.
Time
// The start time of the earliest currently-active compaction
compStartTime
time
.
Time
// The start time of the earliest currently-active compaction
compTime
int64
// Total time spent in compaction in ns
compTime
atomic
.
Int64
// Total time spent in compaction in ns
level0Comp
uint32
// Total number of level-zero compactions
level0Comp
atomic
.
Uint32
// Total number of level-zero compactions
nonLevel0Comp
uint32
// Total number of non level-zero compactions
nonLevel0Comp
atomic
.
Uint32
// Total number of non level-zero compactions
writeDelayStartTime
time
.
Time
// The start time of the latest write stall
writeDelayStartTime
time
.
Time
// The start time of the latest write stall
writeDelayCount
int64
// Total number of write stall counts
writeDelayCount
atomic
.
Int64
// Total number of write stall counts
writeDelayTime
int64
// Total time spent in write stalls
writeDelayTime
atomic
.
Int64
// Total time spent in write stalls
}
}
func
(
d
*
Database
)
onCompactionBegin
(
info
pebble
.
CompactionInfo
)
{
func
(
d
*
Database
)
onCompactionBegin
(
info
pebble
.
CompactionInfo
)
{
...
@@ -91,16 +91,16 @@ func (d *Database) onCompactionBegin(info pebble.CompactionInfo) {
...
@@ -91,16 +91,16 @@ func (d *Database) onCompactionBegin(info pebble.CompactionInfo) {
}
}
l0
:=
info
.
Input
[
0
]
l0
:=
info
.
Input
[
0
]
if
l0
.
Level
==
0
{
if
l0
.
Level
==
0
{
atomic
.
AddUint32
(
&
d
.
level0Comp
,
1
)
d
.
level0Comp
.
Add
(
1
)
}
else
{
}
else
{
atomic
.
AddUint32
(
&
d
.
nonLevel0Comp
,
1
)
d
.
nonLevel0Comp
.
Add
(
1
)
}
}
d
.
activeComp
++
d
.
activeComp
++
}
}
func
(
d
*
Database
)
onCompactionEnd
(
info
pebble
.
CompactionInfo
)
{
func
(
d
*
Database
)
onCompactionEnd
(
info
pebble
.
CompactionInfo
)
{
if
d
.
activeComp
==
1
{
if
d
.
activeComp
==
1
{
atomic
.
AddInt64
(
&
d
.
compTime
,
int64
(
time
.
Since
(
d
.
compStartTime
)))
d
.
compTime
.
Add
(
int64
(
time
.
Since
(
d
.
compStartTime
)))
}
else
if
d
.
activeComp
==
0
{
}
else
if
d
.
activeComp
==
0
{
panic
(
"should not happen"
)
panic
(
"should not happen"
)
}
}
...
@@ -112,7 +112,7 @@ func (d *Database) onWriteStallBegin(b pebble.WriteStallBeginInfo) {
...
@@ -112,7 +112,7 @@ func (d *Database) onWriteStallBegin(b pebble.WriteStallBeginInfo) {
}
}
func
(
d
*
Database
)
onWriteStallEnd
()
{
func
(
d
*
Database
)
onWriteStallEnd
()
{
atomic
.
AddInt64
(
&
d
.
writeDelayTime
,
int64
(
time
.
Since
(
d
.
writeDelayStartTime
)))
d
.
writeDelayTime
.
Add
(
int64
(
time
.
Since
(
d
.
writeDelayStartTime
)))
}
}
// New returns a wrapped pebble DB object. The namespace is the prefix that the
// New returns a wrapped pebble DB object. The namespace is the prefix that the
...
@@ -407,11 +407,11 @@ func (d *Database) meter(refresh time.Duration) {
...
@@ -407,11 +407,11 @@ func (d *Database) meter(refresh time.Duration) {
nWrite
int64
nWrite
int64
metrics
=
d
.
db
.
Metrics
()
metrics
=
d
.
db
.
Metrics
()
compTime
=
atomic
.
LoadInt64
(
&
d
.
compTime
)
compTime
=
d
.
compTime
.
Load
(
)
writeDelayCount
=
atomic
.
LoadInt64
(
&
d
.
writeDelayCount
)
writeDelayCount
=
d
.
writeDelayCount
.
Load
(
)
writeDelayTime
=
atomic
.
LoadInt64
(
&
d
.
writeDelayTime
)
writeDelayTime
=
d
.
writeDelayTime
.
Load
(
)
nonLevel0CompCount
=
int64
(
atomic
.
LoadUint32
(
&
d
.
nonLevel0Comp
))
nonLevel0CompCount
=
int64
(
d
.
nonLevel0Comp
.
Load
(
))
level0CompCount
=
int64
(
atomic
.
LoadUint32
(
&
d
.
level0Comp
))
level0CompCount
=
int64
(
d
.
level0Comp
.
Load
(
))
)
)
writeDelayTimes
[
i
%
2
]
=
writeDelayTime
writeDelayTimes
[
i
%
2
]
=
writeDelayTime
writeDelayCounts
[
i
%
2
]
=
writeDelayCount
writeDelayCounts
[
i
%
2
]
=
writeDelayCount
...
...
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