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
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
6d7ff6ac
Unverified
Commit
6d7ff6ac
authored
3 years ago
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
eth/protocols, metrics, p2p: add handler performance metrics
parent
54c0d573
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
eth/protocols/eth/handler.go
+9
-1
9 additions, 1 deletion
eth/protocols/eth/handler.go
eth/protocols/snap/handler.go
+10
-0
10 additions, 0 deletions
eth/protocols/snap/handler.go
metrics/histogram.go
+9
-0
9 additions, 0 deletions
metrics/histogram.go
p2p/metrics.go
+10
-1
10 additions, 1 deletion
p2p/metrics.go
with
38 additions
and
2 deletions
eth/protocols/eth/handler.go
+
9
−
1
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
)
}
...
...
This diff is collapsed.
Click to expand it.
eth/protocols/snap/handler.go
+
10
−
0
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
:
...
...
This diff is collapsed.
Click to expand it.
metrics/histogram.go
+
9
−
0
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
{
...
...
This diff is collapsed.
Click to expand it.
p2p/metrics.go
+
10
−
1
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
(
...
...
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