diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-14 19:08:56 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-14 19:44:42 +0200 |
commit | f21468b03329a3751a50eb829e07271d23ce4720 (patch) | |
tree | daca8e0a5d5bc983ccda602665735141cfa10399 /sketch | |
parent | 20732336becb322729838a0283a4d1391f23de28 (diff) | |
download | dna-backup-f21468b03329a3751a50eb829e07271d23ce4720.tar.gz dna-backup-f21468b03329a3751a50eb829e07271d23ce4720.zip |
perf: move hash parallelism from sketch to repo
Diffstat (limited to 'sketch')
-rw-r--r-- | sketch/sketch.go | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/sketch/sketch.go b/sketch/sketch.go index ca8c238..7870c3d 100644 --- a/sketch/sketch.go +++ b/sketch/sketch.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/binary" "io" - "sync" "github.com/chmduquesne/rollinghash/rabinkarp64" "github.com/n-peugnet/dna-backup/logger" @@ -23,7 +22,6 @@ const fBytes = 8 // sfCount: the number of super-features, and fCount: the number of feature // per super-feature func SketchChunk(r io.Reader, pol rabinkarp64.Pol, chunkSize int, wSize int, sfCount int, fCount int) (Sketch, error) { - var wg sync.WaitGroup var fSize = FeatureSize(chunkSize, sfCount, fCount) var chunk bytes.Buffer superfeatures := make([]uint64, 0, sfCount) @@ -41,11 +39,9 @@ func SketchChunk(r io.Reader, pol rabinkarp64.Pol, chunkSize int, wSize int, sfC continue } features = append(features, 0) - wg.Add(1) - go calcFeature(&wg, pol, &fBuff, wSize, fSize, &features[f]) + calcFeature(pol, &fBuff, wSize, fSize, &features[f]) } hasher := rabinkarp64.NewFromPol(pol) - wg.Wait() for sf := 0; sf < len(features)/fCount; sf++ { for i := 0; i < fCount; i++ { binary.LittleEndian.PutUint64(sfBuff[i*fBytes:(i+1)*fBytes], features[i+sf*fCount]) @@ -57,8 +53,7 @@ func SketchChunk(r io.Reader, pol rabinkarp64.Pol, chunkSize int, wSize int, sfC return superfeatures, nil } -func calcFeature(wg *sync.WaitGroup, p rabinkarp64.Pol, r ReadByteReader, wSize int, fSize int, result *uint64) { - defer wg.Done() +func calcFeature(p rabinkarp64.Pol, r ReadByteReader, wSize int, fSize int, result *uint64) { hasher := rabinkarp64.NewFromPol(p) n, err := io.CopyN(hasher, r, int64(wSize)) if err != nil { |