Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-bitswap
Commits
2712d298
Commit
2712d298
authored
Jan 20, 2017
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce sent blocks histogram
License: MIT Signed-off-by:
Jakub Sztandera
<
kubuxu@protonmail.ch
>
parent
c4f7e855
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
15 deletions
+21
-15
bitswap.go
bitswap.go
+2
-2
wantmanager.go
wantmanager.go
+19
-13
No files found.
bitswap.go
View file @
2712d298
...
@@ -79,9 +79,9 @@ func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
...
@@ -79,9 +79,9 @@ func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
// exclusively. We should probably find another way to share logging data
// exclusively. We should probably find another way to share logging data
ctx
,
cancelFunc
:=
context
.
WithCancel
(
parent
)
ctx
,
cancelFunc
:=
context
.
WithCancel
(
parent
)
ctx
=
metrics
.
CtxSubScope
(
ctx
,
"bitswap"
)
ctx
=
metrics
.
CtxSubScope
(
ctx
,
"bitswap"
)
dupHist
:=
metrics
.
NewCtx
(
ctx
,
"dup_blocks_bytes"
,
"Summary of duplicate"
+
dupHist
:=
metrics
.
NewCtx
(
ctx
,
"
recv_
dup_blocks_bytes"
,
"Summary of duplicate"
+
" data blocks recived"
)
.
Histogram
(
metricsBuckets
)
" data blocks recived"
)
.
Histogram
(
metricsBuckets
)
allHist
:=
metrics
.
NewCtx
(
ctx
,
"all_blocks_bytes"
,
"Summary of all"
+
allHist
:=
metrics
.
NewCtx
(
ctx
,
"
recv_
all_blocks_bytes"
,
"Summary of all"
+
" data blocks recived"
)
.
Histogram
(
metricsBuckets
)
" data blocks recived"
)
.
Histogram
(
metricsBuckets
)
notif
:=
notifications
.
New
()
notif
:=
notifications
.
New
()
...
...
wantmanager.go
View file @
2712d298
...
@@ -30,24 +30,28 @@ type WantManager struct {
...
@@ -30,24 +30,28 @@ type WantManager struct {
ctx
context
.
Context
ctx
context
.
Context
cancel
func
()
cancel
func
()
metricWantlist
metrics
.
Gauge
wantlistGauge
metrics
.
Gauge
sentHistogram
metrics
.
Histogram
}
}
func
NewWantManager
(
ctx
context
.
Context
,
network
bsnet
.
BitSwapNetwork
)
*
WantManager
{
func
NewWantManager
(
ctx
context
.
Context
,
network
bsnet
.
BitSwapNetwork
)
*
WantManager
{
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
wantlistGauge
:=
metrics
.
NewCtx
(
ctx
,
"wanlist_total"
,
wantlistGauge
:=
metrics
.
NewCtx
(
ctx
,
"wanlist_total"
,
"Number of items in wantlist."
)
.
Gauge
()
"Number of items in wantlist."
)
.
Gauge
()
sentHistogram
:=
metrics
.
NewCtx
(
ctx
,
"sent_all_blocks_bytes"
,
"Histogram of blocks sent by"
+
" this bitswap"
)
.
Histogram
(
metricsBuckets
)
return
&
WantManager
{
return
&
WantManager
{
incoming
:
make
(
chan
[]
*
bsmsg
.
Entry
,
10
),
incoming
:
make
(
chan
[]
*
bsmsg
.
Entry
,
10
),
connect
:
make
(
chan
peer
.
ID
,
10
),
connect
:
make
(
chan
peer
.
ID
,
10
),
disconnect
:
make
(
chan
peer
.
ID
,
10
),
disconnect
:
make
(
chan
peer
.
ID
,
10
),
peerReqs
:
make
(
chan
chan
[]
peer
.
ID
),
peerReqs
:
make
(
chan
chan
[]
peer
.
ID
),
peers
:
make
(
map
[
peer
.
ID
]
*
msgQueue
),
peers
:
make
(
map
[
peer
.
ID
]
*
msgQueue
),
wl
:
wantlist
.
NewThreadSafe
(),
wl
:
wantlist
.
NewThreadSafe
(),
network
:
network
,
network
:
network
,
ctx
:
ctx
,
ctx
:
ctx
,
cancel
:
cancel
,
cancel
:
cancel
,
metricWantlist
:
wantlistGauge
,
wantlistGauge
:
wantlistGauge
,
sentHistogram
:
sentHistogram
,
}
}
}
}
...
@@ -116,6 +120,8 @@ func (pm *WantManager) SendBlock(ctx context.Context, env *engine.Envelope) {
...
@@ -116,6 +120,8 @@ func (pm *WantManager) SendBlock(ctx context.Context, env *engine.Envelope) {
// throughout the network stack
// throughout the network stack
defer
env
.
Sent
()
defer
env
.
Sent
()
pm
.
sentHistogram
.
Observe
(
float64
(
len
(
env
.
Block
.
RawData
())))
msg
:=
bsmsg
.
New
(
false
)
msg
:=
bsmsg
.
New
(
false
)
msg
.
AddBlock
(
env
.
Block
)
msg
.
AddBlock
(
env
.
Block
)
log
.
Infof
(
"Sending block %s to %s"
,
env
.
Block
,
env
.
Peer
)
log
.
Infof
(
"Sending block %s to %s"
,
env
.
Block
,
env
.
Peer
)
...
@@ -289,12 +295,12 @@ func (pm *WantManager) Run() {
...
@@ -289,12 +295,12 @@ func (pm *WantManager) Run() {
for
_
,
e
:=
range
entries
{
for
_
,
e
:=
range
entries
{
if
e
.
Cancel
{
if
e
.
Cancel
{
if
pm
.
wl
.
Remove
(
e
.
Cid
)
{
if
pm
.
wl
.
Remove
(
e
.
Cid
)
{
pm
.
metricW
antlist
.
Dec
()
pm
.
w
antlist
Gauge
.
Dec
()
filtered
=
append
(
filtered
,
e
)
filtered
=
append
(
filtered
,
e
)
}
}
}
else
{
}
else
{
if
pm
.
wl
.
AddEntry
(
e
.
Entry
)
{
if
pm
.
wl
.
AddEntry
(
e
.
Entry
)
{
pm
.
metricW
antlist
.
Inc
()
pm
.
w
antlist
Gauge
.
Inc
()
filtered
=
append
(
filtered
,
e
)
filtered
=
append
(
filtered
,
e
)
}
}
}
}
...
...
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