Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit12c0101

Browse files
committed
contentenc: add PReqPool and use it in DecryptBlocks
This gets us a massive speed boost in streaming reads.
1 parente4b5005 commit12c0101

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

‎internal/contentenc/content.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type ContentEnc struct {
6060
CReqPoolbPool
6161
// Plaintext block pool. Always returns plainBS-sized byte slices.
6262
pBlockPoolbPool
63+
// Plaintext request data pool. Slice have size fuse.MAX_KERNEL_WRITE.
64+
PReqPoolbPool
6365
}
6466

6567
// New returns an initialized ContentEnc instance.
@@ -80,6 +82,7 @@ func New(cc *cryptocore.CryptoCore, plainBS uint64, forceDecode bool) *ContentEn
8082
cBlockPool:newBPool(int(cipherBS)),
8183
CReqPool:newBPool(cReqSize),
8284
pBlockPool:newBPool(int(plainBS)),
85+
PReqPool:newBPool(fuse.MAX_KERNEL_WRITE),
8386
}
8487
returnc
8588
}
@@ -98,7 +101,7 @@ func (be *ContentEnc) CipherBS() uint64 {
98101
func (be*ContentEnc)DecryptBlocks(ciphertext []byte,firstBlockNouint64,fileID []byte) ([]byte,error) {
99102
cBuf:=bytes.NewBuffer(ciphertext)
100103
varerrerror
101-
varpBuf bytes.Buffer
104+
pBuf:=bytes.NewBuffer(be.PReqPool.Get()[:0])
102105
forcBuf.Len()>0 {
103106
cBlock:=cBuf.Next(int(be.cipherBS))
104107
varpBlock []byte

‎internal/fusefrontend/file.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu
214214
}
215215
// else: out stays empty, file was smaller than the requested offset
216216

217-
returnappend(dst,out...),fuse.OK
217+
out=append(dst,out...)
218+
f.fs.contentEnc.PReqPool.Put(plaintext)
219+
220+
returnout,fuse.OK
218221
}
219222

220223
// Read - FUSE call

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp