summaryrefslogtreecommitdiff
path: root/internal/contentenc/content.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-02-15 21:28:12 +0100
committerJakob Unterwurzacher2020-02-15 21:28:12 +0100
commitabc59fa96802f1b79fc92ba3a4ae78b58b905535 (patch)
treebb6d4ce5ea88de34d7bc7f8d31577a93b50adf38 /internal/contentenc/content.go
parentff210a06fb3097eecd5668ddb3ace9c76873eb00 (diff)
contentenc: encryptBlocksParallel: explain why last part runs in new goroutine
The result is counter-intuitive, so explain it here.
Diffstat (limited to 'internal/contentenc/content.go')
-rw-r--r--internal/contentenc/content.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go
index 81864d4..697026a 100644
--- a/internal/contentenc/content.go
+++ b/internal/contentenc/content.go
@@ -219,7 +219,11 @@ func (be *ContentEnc) encryptBlocksParallel(plaintextBlocks [][]byte, ciphertext
low := i * groupSize
high := (i + 1) * groupSize
if i == ncpu-1 {
- // Last group, pick up any left-over blocks
+ // Last part picks up any left-over blocks
+ //
+ // The last part could run in the original goroutine, but
+ // doing that complicates the code, and, surprisingly,
+ // incurs a 1 % performance penalty.
high = len(plaintextBlocks)
}
be.doEncryptBlocks(plaintextBlocks[low:high], ciphertextBlocks[low:high], firstBlockNo+uint64(low), fileID)