[#2139] object/put: Use sync.Pool
for temporary payloads
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
9e0decd12d
commit
04b5ec759b
4 changed files with 27 additions and 0 deletions
|
@ -26,6 +26,7 @@ Changelog for NeoFS Node
|
||||||
- Policer cache size is now 1024 (#2158)
|
- Policer cache size is now 1024 (#2158)
|
||||||
- Tree service now synchronizes with container nodes in a random order (#2127)
|
- Tree service now synchronizes with container nodes in a random order (#2127)
|
||||||
- Pilorama no longer tries to apply already applied operations (#2161)
|
- Pilorama no longer tries to apply already applied operations (#2161)
|
||||||
|
- Use `sync.Pool` in Object.PUT service (#2139)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Open FSTree in sync mode by default (#1992)
|
- Open FSTree in sync mode by default (#1992)
|
||||||
|
|
|
@ -128,6 +128,11 @@ func (t *distributedTarget) Write(p []byte) (n int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) {
|
func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) {
|
||||||
|
defer func() {
|
||||||
|
putPayload(t.payload)
|
||||||
|
t.payload = nil
|
||||||
|
}()
|
||||||
|
|
||||||
t.obj.SetPayload(t.payload)
|
t.obj.SetPayload(t.payload)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
20
pkg/services/object/put/pool.go
Normal file
20
pkg/services/object/put/pool.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package putsvc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
const defaultAllocSize = 1024
|
||||||
|
|
||||||
|
var putBytesPool = &sync.Pool{
|
||||||
|
New: func() interface{} { return make([]byte, 0, defaultAllocSize) },
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPayload() []byte {
|
||||||
|
return putBytesPool.Get().([]byte)
|
||||||
|
}
|
||||||
|
|
||||||
|
func putPayload(p []byte) {
|
||||||
|
//nolint:staticcheck
|
||||||
|
putBytesPool.Put(p[:0])
|
||||||
|
}
|
|
@ -215,6 +215,7 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget {
|
||||||
|
|
||||||
extraBroadcastEnabled: withBroadcast,
|
extraBroadcastEnabled: withBroadcast,
|
||||||
},
|
},
|
||||||
|
payload: getPayload(),
|
||||||
remotePool: p.remotePool,
|
remotePool: p.remotePool,
|
||||||
localPool: p.localPool,
|
localPool: p.localPool,
|
||||||
nodeTargetInitializer: func(node nodeDesc) preparedObjectTarget {
|
nodeTargetInitializer: func(node nodeDesc) preparedObjectTarget {
|
||||||
|
|
Loading…
Reference in a new issue