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-dms3
Commits
d373e93e
Commit
d373e93e
authored
Mar 02, 2017
by
Jeromy Johnson
Committed by
GitHub
Mar 02, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3615 from ipfs/feat/metrics/perf
Add multiple performance metrics
parents
57e4e210
acfaf9ac
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
30 deletions
+61
-30
cmd/ipfs/daemon.go
cmd/ipfs/daemon.go
+0
-2
exchange/bitswap/bitswap.go
exchange/bitswap/bitswap.go
+30
-13
exchange/bitswap/wantmanager.go
exchange/bitswap/wantmanager.go
+24
-9
package.json
package.json
+2
-2
repo/fsrepo/defaultds.go
repo/fsrepo/defaultds.go
+2
-2
repo/fsrepo/fsrepo.go
repo/fsrepo/fsrepo.go
+3
-2
No files found.
cmd/ipfs/daemon.go
View file @
d373e93e
...
@@ -28,8 +28,6 @@ import (
...
@@ -28,8 +28,6 @@ import (
"gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus"
"gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus"
util
"gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
util
"gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
iconn
"gx/ipfs/QmcYnysCkyGezY6k6MQ1yHHdrRiZaU9x3M9Y1tE9qZ5hD2/go-libp2p-interface-conn"
iconn
"gx/ipfs/QmcYnysCkyGezY6k6MQ1yHHdrRiZaU9x3M9Y1tE9qZ5hD2/go-libp2p-interface-conn"
_
"gx/ipfs/QmV3NSS3A1kX5s28r7yLczhDsXzkgo65cqRgKFXYunWZmD/metrics/runtime"
)
)
const
(
const
(
...
...
exchange/bitswap/bitswap.go
View file @
d373e93e
...
@@ -19,6 +19,7 @@ import (
...
@@ -19,6 +19,7 @@ import (
flags
"github.com/ipfs/go-ipfs/flags"
flags
"github.com/ipfs/go-ipfs/flags"
"github.com/ipfs/go-ipfs/thirdparty/delay"
"github.com/ipfs/go-ipfs/thirdparty/delay"
metrics
"gx/ipfs/QmRg1gKTHzc3CZXSKzem8aR4E3TubFhbgXwfVuWnSK5CC5/go-metrics-interface"
process
"gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
process
"gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
procctx
"gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context"
procctx
"gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context"
logging
"gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
logging
"gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
...
@@ -47,6 +48,9 @@ var (
...
@@ -47,6 +48,9 @@ var (
HasBlockBufferSize
=
256
HasBlockBufferSize
=
256
provideKeysBufferSize
=
2048
provideKeysBufferSize
=
2048
provideWorkerMax
=
512
provideWorkerMax
=
512
// the 1<<18+15 is to observe old file chunks that are 1<<18 + 14 in size
metricsBuckets
=
[]
float64
{
1
<<
6
,
1
<<
10
,
1
<<
14
,
1
<<
18
,
1
<<
18
+
15
,
1
<<
22
}
)
)
func
init
()
{
func
init
()
{
...
@@ -74,6 +78,11 @@ func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
...
@@ -74,6 +78,11 @@ func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
// shouldn't accept a context anymore. Clients should probably use Close()
// shouldn't accept a context anymore. Clients should probably use Close()
// 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"
)
dupHist
:=
metrics
.
NewCtx
(
ctx
,
"recv_dup_blocks_bytes"
,
"Summary of duplicate"
+
" data blocks recived"
)
.
Histogram
(
metricsBuckets
)
allHist
:=
metrics
.
NewCtx
(
ctx
,
"recv_all_blocks_bytes"
,
"Summary of all"
+
" data blocks recived"
)
.
Histogram
(
metricsBuckets
)
notif
:=
notifications
.
New
()
notif
:=
notifications
.
New
()
px
:=
process
.
WithTeardown
(
func
()
error
{
px
:=
process
.
WithTeardown
(
func
()
error
{
...
@@ -91,6 +100,9 @@ func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
...
@@ -91,6 +100,9 @@ func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
newBlocks
:
make
(
chan
*
cid
.
Cid
,
HasBlockBufferSize
),
newBlocks
:
make
(
chan
*
cid
.
Cid
,
HasBlockBufferSize
),
provideKeys
:
make
(
chan
*
cid
.
Cid
,
provideKeysBufferSize
),
provideKeys
:
make
(
chan
*
cid
.
Cid
,
provideKeysBufferSize
),
wm
:
NewWantManager
(
ctx
,
network
),
wm
:
NewWantManager
(
ctx
,
network
),
dupMetric
:
dupHist
,
allMetric
:
allHist
,
}
}
go
bs
.
wm
.
Run
()
go
bs
.
wm
.
Run
()
network
.
SetDelegate
(
bs
)
network
.
SetDelegate
(
bs
)
...
@@ -145,6 +157,10 @@ type Bitswap struct {
...
@@ -145,6 +157,10 @@ type Bitswap struct {
blocksRecvd
int
blocksRecvd
int
dupBlocksRecvd
int
dupBlocksRecvd
int
dupDataRecvd
uint64
dupDataRecvd
uint64
// Metrics interface metrics
dupMetric
metrics
.
Histogram
allMetric
metrics
.
Histogram
}
}
type
blockRequest
struct
{
type
blockRequest
struct
{
...
@@ -352,9 +368,7 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
...
@@ -352,9 +368,7 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
go
func
(
b
blocks
.
Block
)
{
go
func
(
b
blocks
.
Block
)
{
defer
wg
.
Done
()
defer
wg
.
Done
()
if
err
:=
bs
.
updateReceiveCounters
(
b
);
err
!=
nil
{
bs
.
updateReceiveCounters
(
b
)
return
// ignore error, is either logged previously, or ErrAlreadyHaveBlock
}
k
:=
b
.
Cid
()
k
:=
b
.
Cid
()
log
.
Event
(
ctx
,
"Bitswap.GetBlockRequest.End"
,
k
)
log
.
Event
(
ctx
,
"Bitswap.GetBlockRequest.End"
,
k
)
...
@@ -370,24 +384,27 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
...
@@ -370,24 +384,27 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
var
ErrAlreadyHaveBlock
=
errors
.
New
(
"already have block"
)
var
ErrAlreadyHaveBlock
=
errors
.
New
(
"already have block"
)
func
(
bs
*
Bitswap
)
updateReceiveCounters
(
b
blocks
.
Block
)
error
{
func
(
bs
*
Bitswap
)
updateReceiveCounters
(
b
blocks
.
Block
)
{
bs
.
counterLk
.
Lock
()
blkLen
:=
len
(
b
.
RawData
())
defer
bs
.
counterLk
.
Unlock
()
bs
.
blocksRecvd
++
has
,
err
:=
bs
.
blockstore
.
Has
(
b
.
Cid
())
has
,
err
:=
bs
.
blockstore
.
Has
(
b
.
Cid
())
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Infof
(
"blockstore.Has error: %s"
,
err
)
log
.
Infof
(
"blockstore.Has error: %s"
,
err
)
return
err
return
}
}
if
err
==
nil
&&
has
{
bs
.
dupBlocksRecvd
++
bs
.
allMetric
.
Observe
(
float64
(
blkLen
))
bs
.
dupDataRecvd
+=
uint64
(
len
(
b
.
RawData
()))
if
has
{
bs
.
dupMetric
.
Observe
(
float64
(
blkLen
))
}
}
bs
.
counterLk
.
Lock
()
defer
bs
.
counterLk
.
Unlock
()
bs
.
blocksRecvd
++
if
has
{
if
has
{
return
ErrAlreadyHaveBlock
bs
.
dupBlocksRecvd
++
bs
.
dupDataRecvd
+=
uint64
(
blkLen
)
}
}
return
nil
}
}
// Connected/Disconnected warns bitswap about peer connections
// Connected/Disconnected warns bitswap about peer connections
...
...
exchange/bitswap/wantmanager.go
View file @
d373e93e
...
@@ -9,6 +9,8 @@ import (
...
@@ -9,6 +9,8 @@ import (
bsmsg
"github.com/ipfs/go-ipfs/exchange/bitswap/message"
bsmsg
"github.com/ipfs/go-ipfs/exchange/bitswap/message"
bsnet
"github.com/ipfs/go-ipfs/exchange/bitswap/network"
bsnet
"github.com/ipfs/go-ipfs/exchange/bitswap/network"
wantlist
"github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
wantlist
"github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
metrics
"gx/ipfs/QmRg1gKTHzc3CZXSKzem8aR4E3TubFhbgXwfVuWnSK5CC5/go-metrics-interface"
cid
"gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid"
cid
"gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid"
peer
"gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer"
peer
"gx/ipfs/QmZcUPvPhD1Xvk6mwijYF8AfR3mG31S1YsEfHG4khrFPRr/go-libp2p-peer"
)
)
...
@@ -27,20 +29,29 @@ type WantManager struct {
...
@@ -27,20 +29,29 @@ type WantManager struct {
network
bsnet
.
BitSwapNetwork
network
bsnet
.
BitSwapNetwork
ctx
context
.
Context
ctx
context
.
Context
cancel
func
()
cancel
func
()
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"
,
"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
,
wantlistGauge
:
wantlistGauge
,
sentHistogram
:
sentHistogram
,
}
}
}
}
...
@@ -109,6 +120,8 @@ func (pm *WantManager) SendBlock(ctx context.Context, env *engine.Envelope) {
...
@@ -109,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
)
...
@@ -282,10 +295,12 @@ func (pm *WantManager) Run() {
...
@@ -282,10 +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
.
wantlistGauge
.
Dec
()
filtered
=
append
(
filtered
,
e
)
filtered
=
append
(
filtered
,
e
)
}
}
}
else
{
}
else
{
if
pm
.
wl
.
AddEntry
(
e
.
Entry
)
{
if
pm
.
wl
.
AddEntry
(
e
.
Entry
)
{
pm
.
wantlistGauge
.
Inc
()
filtered
=
append
(
filtered
,
e
)
filtered
=
append
(
filtered
,
e
)
}
}
}
}
...
...
package.json
View file @
d373e93e
...
@@ -208,9 +208,9 @@
...
@@ -208,9 +208,9 @@
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
bUSMTQtK9GRrUbD4ngqJwSzHsquUc8nyDubRWp4vPybH
"
,
"hash"
:
"Qm
NPv1yzXBqxzqjfTzHCeBoicxxZgHzLezdY2hMCZ3r6EU
"
,
"name"
:
"go-ds-measure"
,
"name"
:
"go-ds-measure"
,
"version"
:
"1.
1
.0"
"version"
:
"1.
2
.0"
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
...
...
repo/fsrepo/defaultds.go
View file @
d373e93e
...
@@ -8,12 +8,12 @@ import (
...
@@ -8,12 +8,12 @@ import (
config
"github.com/ipfs/go-ipfs/repo/config"
config
"github.com/ipfs/go-ipfs/repo/config"
"github.com/ipfs/go-ipfs/thirdparty/dir"
"github.com/ipfs/go-ipfs/thirdparty/dir"
measure
"gx/ipfs/QmNPv1yzXBqxzqjfTzHCeBoicxxZgHzLezdY2hMCZ3r6EU/go-ds-measure"
ds
"gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
ds
"gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
mount
"gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/syncmount"
mount
"gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/syncmount"
"gx/ipfs/QmXZEfbEv9sXG9JnLoMNhREDMDgkq5Jd7uWJ7d77VJ4pxn/go-ds-flatfs"
flatfs
"gx/ipfs/QmXZEfbEv9sXG9JnLoMNhREDMDgkq5Jd7uWJ7d77VJ4pxn/go-ds-flatfs"
levelds
"gx/ipfs/QmaHHmfEozrrotyhyN44omJouyuEtx6ahddqV6W5yRaUSQ/go-ds-leveldb"
levelds
"gx/ipfs/QmaHHmfEozrrotyhyN44omJouyuEtx6ahddqV6W5yRaUSQ/go-ds-leveldb"
ldbopts
"gx/ipfs/QmbBhyDKsY4mbY6xsKt3qu9Y7FPvMJ6qbD8AMjYYvPRw1g/goleveldb/leveldb/opt"
ldbopts
"gx/ipfs/QmbBhyDKsY4mbY6xsKt3qu9Y7FPvMJ6qbD8AMjYYvPRw1g/goleveldb/leveldb/opt"
measure
"gx/ipfs/QmbUSMTQtK9GRrUbD4ngqJwSzHsquUc8nyDubRWp4vPybH/go-ds-measure"
)
)
const
(
const
(
...
...
repo/fsrepo/fsrepo.go
View file @
d373e93e
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
"strings"
"strings"
"sync"
"sync"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
keystore
"github.com/ipfs/go-ipfs/keystore"
keystore
"github.com/ipfs/go-ipfs/keystore"
repo
"github.com/ipfs/go-ipfs/repo"
repo
"github.com/ipfs/go-ipfs/repo"
"github.com/ipfs/go-ipfs/repo/common"
"github.com/ipfs/go-ipfs/repo/common"
...
@@ -21,10 +20,12 @@ import (
...
@@ -21,10 +20,12 @@ import (
serialize
"github.com/ipfs/go-ipfs/repo/fsrepo/serialize"
serialize
"github.com/ipfs/go-ipfs/repo/fsrepo/serialize"
dir
"github.com/ipfs/go-ipfs/thirdparty/dir"
dir
"github.com/ipfs/go-ipfs/thirdparty/dir"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
measure
"gx/ipfs/QmNPv1yzXBqxzqjfTzHCeBoicxxZgHzLezdY2hMCZ3r6EU/go-ds-measure"
ma
"gx/ipfs/QmSWLfmj5frN9xVLMMN846dMDriy5wN5jeghUm7aTW3DAG/go-multiaddr"
ma
"gx/ipfs/QmSWLfmj5frN9xVLMMN846dMDriy5wN5jeghUm7aTW3DAG/go-multiaddr"
logging
"gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
logging
"gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
util
"gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
util
"gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
"gx/ipfs/QmbUSMTQtK9GRrUbD4ngqJwSzHsquUc8nyDubRWp4vPybH/go-ds-measure"
)
)
var
log
=
logging
.
Logger
(
"fsrepo"
)
var
log
=
logging
.
Logger
(
"fsrepo"
)
...
...
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