From 428d0bbc280edb284f871f5d890d8f5c344fc32e Mon Sep 17 00:00:00 2001 From: Wei Shen Date: Fri, 20 Nov 2020 00:01:26 +0800 Subject: [PATCH] do not use ringbuffer --- unikmer/cmd/util-db.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/unikmer/cmd/util-db.go b/unikmer/cmd/util-db.go index 36c4197..01d0335 100644 --- a/unikmer/cmd/util-db.go +++ b/unikmer/cmd/util-db.go @@ -34,7 +34,6 @@ import ( "github.com/pkg/errors" "github.com/shenwei356/unikmer/index" "github.com/shenwei356/util/pathutil" - "github.com/smallnest/ringbuffer" "gopkg.in/yaml.v2" ) @@ -288,22 +287,22 @@ func (db *UnikIndexDB) searchHashes(hashes [][]uint64, threads int, queryCov flo ch := make([]*map[string][3]float64, len(db.Indices)) var wg sync.WaitGroup - // tokens := make(chan int, threads) - tokens := ringbuffer.New(threads) // ringbufer is faster than channel + tokens := make(chan int, threads) + // tokens := ringbuffer.New(threads) // ringbufer is faster than channel // for i, idx := range db.Indices { for i := len(db.Indices) - 1; i >= 0; i-- { // start from bigger files idx := db.Indices[i] wg.Add(1) - // tokens <- 1 - tokens.WriteByte(0) + tokens <- 1 + // tokens.WriteByte(0) go func(idx *UnikIndex, ch []*map[string][3]float64, i int) { _m := idx.Search(hashes, queryCov, targetCov) ch[i] = &_m wg.Done() - // <-tokens - tokens.ReadByte() + <-tokens + // tokens.ReadByte() }(idx, ch, i) } wg.Wait()