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
6d7ff6ac
Unverified
Commit
6d7ff6ac
authored
Mar 26, 2021
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/protocols, metrics, p2p: add handler performance metrics
parent
54c0d573
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
2 deletions
+38
-2
handler.go
eth/protocols/eth/handler.go
+9
-1
handler.go
eth/protocols/snap/handler.go
+10
-0
histogram.go
metrics/histogram.go
+9
-0
metrics.go
p2p/metrics.go
+10
-1
No files found.
eth/protocols/eth/handler.go
View file @
6d7ff6ac
...
...
@@ -24,6 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enr"
...
...
@@ -241,7 +242,14 @@ func handleMessage(backend Backend, peer *Peer) error {
}
else
if
peer
.
Version
()
>=
ETH66
{
handlers
=
eth66
}
// Track the emount of time it takes to serve the request and run the handler
if
metrics
.
Enabled
{
h
:=
fmt
.
Sprintf
(
"%s/%s/%d/%#02x"
,
p2p
.
HandleHistName
,
ProtocolName
,
peer
.
Version
(),
msg
.
Code
)
defer
func
(
start
time
.
Time
)
{
sampler
:=
func
()
metrics
.
Sample
{
return
metrics
.
NewExpDecaySample
(
1028
,
0.015
)
}
metrics
.
GetOrRegisterHistogramLazy
(
h
,
nil
,
sampler
)
.
Update
(
time
.
Since
(
start
)
.
Microseconds
())
}(
time
.
Now
())
}
if
handler
:=
handlers
[
msg
.
Code
];
handler
!=
nil
{
return
handler
(
backend
,
msg
,
peer
)
}
...
...
eth/protocols/snap/handler.go
View file @
6d7ff6ac
...
...
@@ -19,12 +19,14 @@ package snap
import
(
"bytes"
"fmt"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enr"
...
...
@@ -128,6 +130,14 @@ func handleMessage(backend Backend, peer *Peer) error {
}
defer
msg
.
Discard
()
// Track the emount of time it takes to serve the request and run the handler
if
metrics
.
Enabled
{
h
:=
fmt
.
Sprintf
(
"%s/%s/%d/%#02x"
,
p2p
.
HandleHistName
,
ProtocolName
,
peer
.
Version
(),
msg
.
Code
)
defer
func
(
start
time
.
Time
)
{
sampler
:=
func
()
metrics
.
Sample
{
return
metrics
.
NewExpDecaySample
(
1028
,
0.015
)
}
metrics
.
GetOrRegisterHistogramLazy
(
h
,
nil
,
sampler
)
.
Update
(
time
.
Since
(
start
)
.
Microseconds
())
}(
time
.
Now
())
}
// Handle the message depending on its contents
switch
{
case
msg
.
Code
==
GetAccountRangeMsg
:
...
...
metrics/histogram.go
View file @
6d7ff6ac
...
...
@@ -26,6 +26,15 @@ func GetOrRegisterHistogram(name string, r Registry, s Sample) Histogram {
return
r
.
GetOrRegister
(
name
,
func
()
Histogram
{
return
NewHistogram
(
s
)
})
.
(
Histogram
)
}
// GetOrRegisterHistogramLazy returns an existing Histogram or constructs and
// registers a new StandardHistogram.
func
GetOrRegisterHistogramLazy
(
name
string
,
r
Registry
,
s
func
()
Sample
)
Histogram
{
if
nil
==
r
{
r
=
DefaultRegistry
}
return
r
.
GetOrRegister
(
name
,
func
()
Histogram
{
return
NewHistogram
(
s
())
})
.
(
Histogram
)
}
// NewHistogram constructs a new StandardHistogram from a Sample.
func
NewHistogram
(
s
Sample
)
Histogram
{
if
!
Enabled
{
...
...
p2p/metrics.go
View file @
6d7ff6ac
...
...
@@ -25,8 +25,17 @@ import (
)
const
(
// ingressMeterName is the prefix of the per-packet inbound metrics.
ingressMeterName
=
"p2p/ingress"
egressMeterName
=
"p2p/egress"
// egressMeterName is the prefix of the per-packet outbound metrics.
egressMeterName
=
"p2p/egress"
// HandleHistName is the prefix of the per-packet serving time histograms.
HandleHistName
=
"p2p/handle"
// WaitHistName is the prefix of the per-packet (req only) waiting time histograms.
WaitHistName
=
"p2p/wait"
)
var
(
...
...
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