summaryrefslogtreecommitdiff
path: root/internal/contentenc/content.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-06-30 23:30:57 +0200
committerJakob Unterwurzacher2017-06-30 23:30:57 +0200
commit12c0101a232928e8969f23235ca45506e743d547 (patch)
treee7b16686ba038604151959d0e47d3a39ddbb40fa /internal/contentenc/content.go
parente4b5005bcce471ab017a3f8e44e1298424aefad4 (diff)
contentenc: add PReqPool and use it in DecryptBlocks
This gets us a massive speed boost in streaming reads.
Diffstat (limited to 'internal/contentenc/content.go')
-rw-r--r--internal/contentenc/content.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go
index 238683c..188b4e2 100644
--- a/internal/contentenc/content.go
+++ b/internal/contentenc/content.go
@@ -60,6 +60,8 @@ type ContentEnc struct {
CReqPool bPool
// Plaintext block pool. Always returns plainBS-sized byte slices.
pBlockPool bPool
+ // Plaintext request data pool. Slice have size fuse.MAX_KERNEL_WRITE.
+ PReqPool bPool
}
// New returns an initialized ContentEnc instance.
@@ -80,6 +82,7 @@ func New(cc *cryptocore.CryptoCore, plainBS uint64, forceDecode bool) *ContentEn
cBlockPool: newBPool(int(cipherBS)),
CReqPool: newBPool(cReqSize),
pBlockPool: newBPool(int(plainBS)),
+ PReqPool: newBPool(fuse.MAX_KERNEL_WRITE),
}
return c
}
@@ -98,7 +101,7 @@ func (be *ContentEnc) CipherBS() uint64 {
func (be *ContentEnc) DecryptBlocks(ciphertext []byte, firstBlockNo uint64, fileID []byte) ([]byte, error) {
cBuf := bytes.NewBuffer(ciphertext)
var err error
- var pBuf bytes.Buffer
+ pBuf := bytes.NewBuffer(be.PReqPool.Get()[:0])
for cBuf.Len() > 0 {
cBlock := cBuf.Next(int(be.cipherBS))
var pBlock []byte