Skip to content

Commit

Permalink
Use buffered channels in AllKeysChan to increase performance.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina authored and whyrusleeping committed Mar 6, 2017
1 parent 8e1a03d commit 8082af7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion filestore/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ipfs/go-ipfs/blocks/blockstore"
posinfo "github.com/ipfs/go-ipfs/thirdparty/posinfo"

dsq "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/query"
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid"
)
Expand All @@ -30,7 +31,7 @@ func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) {
return nil, err
}

out := make(chan *cid.Cid)
out := make(chan *cid.Cid, dsq.KeysOnlyBufSize)
go func() {
defer cancel()
defer close(out)
Expand Down
2 changes: 1 addition & 1 deletion filestore/fsrefstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (f *FileManager) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
return nil, err
}

out := make(chan *cid.Cid)
out := make(chan *cid.Cid, dsq.KeysOnlyBufSize)
go func() {
defer close(out)
for {
Expand Down

0 comments on commit 8082af7

Please sign in to comment.