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
p2p
go-p2p-kad-dht
Commits
c7d52d69
Commit
c7d52d69
authored
Nov 28, 2016
by
Jeromy Johnson
Committed by
GitHub
Nov 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #38 from libp2p/kevina/faster-query
Improve GetProviders Performance by around 2x
parents
2e4e4baa
ce68333c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
providers/providers.go
providers/providers.go
+5
-1
providers/providers_test.go
providers/providers_test.go
+11
-5
No files found.
providers/providers.go
View file @
c7d52d69
...
...
@@ -118,7 +118,11 @@ func loadProvSet(dstore ds.Datastore, k *cid.Cid) (*providerSet, error) {
}
out
:=
newProviderSet
()
for
e
:=
range
res
.
Next
()
{
for
{
e
,
ok
:=
res
.
NextSync
()
if
!
ok
{
break
}
if
e
.
Error
!=
nil
{
log
.
Error
(
"got an error: "
,
e
.
Error
)
continue
...
...
providers/providers_test.go
View file @
c7d52d69
...
...
@@ -10,9 +10,11 @@ import (
cid
"github.com/ipfs/go-cid"
ds
"github.com/ipfs/go-datastore"
//lds "github.com/ipfs/go-ds-leveldb"
u
"github.com/ipfs/go-ipfs-util"
peer
"github.com/libp2p/go-libp2p-peer"
//
// used by TestLargeProvidersSet: do not remove
// lds "github.com/ipfs/go-ds-leveldb"
)
func
TestProviderManager
(
t
*
testing
.
T
)
{
...
...
@@ -200,12 +202,16 @@ func TestLargeProvidersSet(t *testing.T) {
}
}
for _, c := range cids {
_ = p.GetProviders(ctx, c)
for i := 0; i < 5; i++ {
start := time.Now()
for _, c := range cids {
_ = p.GetProviders(ctx, c)
}
elapsed := time.Since(start)
fmt.Printf("query %f ms\n", elapsed.Seconds()*1000)
}
}
//
*/
*/
func
TestUponCacheMissProvidersAreReadFromDatastore
(
t
*
testing
.
T
)
{
old
:=
lruCacheSize
...
...
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