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
35f7f3d0
Unverified
Commit
35f7f3d0
authored
Aug 11, 2023
by
Delweng
Committed by
GitHub
Aug 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethdb/leveldb: support more than 7 levels in metrics (#27904)
parent
6ddb92ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
leveldb.go
ethdb/leveldb/leveldb.go
+7
-9
No files found.
ethdb/leveldb/leveldb.go
View file @
35f7f3d0
...
...
@@ -75,7 +75,7 @@ type Database struct {
seekCompGauge
metrics
.
Gauge
// Gauge for tracking the number of table compaction caused by read opt
manualMemAllocGauge
metrics
.
Gauge
// Gauge to track the amount of memory that has been manually allocated (not a part of runtime/GC)
levelsGauge
[
7
]
metrics
.
Gauge
// Gauge for tracking the number of tables in levels
levelsGauge
[]
metrics
.
Gauge
// Gauge for tracking the number of tables in levels
quitLock
sync
.
Mutex
// Mutex protecting the quit channel access
quitChan
chan
chan
error
// Quit channel to stop the metrics collection before closing the database
...
...
@@ -146,13 +146,8 @@ func NewCustom(file string, namespace string, customize func(options *opt.Option
ldb
.
seekCompGauge
=
metrics
.
NewRegisteredGauge
(
namespace
+
"compact/seek"
,
nil
)
ldb
.
manualMemAllocGauge
=
metrics
.
NewRegisteredGauge
(
namespace
+
"memory/manualalloc"
,
nil
)
// leveldb has only up to 7 levels
for
i
:=
range
ldb
.
levelsGauge
{
ldb
.
levelsGauge
[
i
]
=
metrics
.
NewRegisteredGauge
(
namespace
+
fmt
.
Sprintf
(
"tables/level%v"
,
i
),
nil
)
}
// Start up the metrics gathering and return
go
ldb
.
meter
(
metricsGatheringInterval
)
go
ldb
.
meter
(
metricsGatheringInterval
,
namespace
)
return
ldb
,
nil
}
...
...
@@ -271,7 +266,7 @@ func (db *Database) Path() string {
// meter periodically retrieves internal leveldb counters and reports them to
// the metrics subsystem.
func
(
db
*
Database
)
meter
(
refresh
time
.
Duration
)
{
func
(
db
*
Database
)
meter
(
refresh
time
.
Duration
,
namespace
string
)
{
// Create the counters to store current and previous compaction values
compactions
:=
make
([][]
int64
,
2
)
for
i
:=
0
;
i
<
2
;
i
++
{
...
...
@@ -360,8 +355,11 @@ func (db *Database) meter(refresh time.Duration) {
db
.
nonlevel0CompGauge
.
Update
(
int64
(
stats
.
NonLevel0Comp
))
db
.
seekCompGauge
.
Update
(
int64
(
stats
.
SeekComp
))
// update tables amount
for
i
,
tables
:=
range
stats
.
LevelTablesCounts
{
// Append metrics for additional layers
if
i
>=
len
(
db
.
levelsGauge
)
{
db
.
levelsGauge
=
append
(
db
.
levelsGauge
,
metrics
.
NewRegisteredGauge
(
namespace
+
fmt
.
Sprintf
(
"tables/level%v"
,
i
),
nil
))
}
db
.
levelsGauge
[
i
]
.
Update
(
int64
(
tables
))
}
...
...
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