pooling []byte

reduce the number of requests to make([]byte)
This commit is contained in:
chrislusf
2016-04-14 01:30:26 -07:00
parent 95e0d2f1b2
commit 0649d778a7
9 changed files with 216 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/chrislusf/seaweedfs/go/glog"
"github.com/chrislusf/seaweedfs/go/images"
"github.com/chrislusf/seaweedfs/go/operation"
"github.com/chrislusf/seaweedfs/go/util"
)
const (
@@ -22,6 +23,14 @@ const (
MaxPossibleVolumeSize = 4 * 1024 * 1024 * 1024 * 8
)
var (
BYTESPOOL *util.BytesPool
)
func init() {
BYTESPOOL = util.NewBytesPool()
}
/*
* A Needle means a uploaded and stored file.
* Needle file size is limited to 4GB for now.
@@ -43,6 +52,8 @@ type Needle struct {
Checksum CRC `comment:"CRC32 to check integrity"`
Padding []byte `comment:"Aligned to 8 bytes"`
rawBytes []byte // underlying supporing []byte, fetched and released into a pool
}
func (n *Needle) String() (str string) {