修改buffer pool大小

This commit is contained in:
hebo
2019-12-10 19:31:11 +08:00
parent 068871ea0c
commit 8db6c6f4fa
7 changed files with 87 additions and 59 deletions

View File

@@ -24,7 +24,7 @@ type BaseQueryPiece struct {
ServerIP *string `json:"sip"`
ServerPort int `json:"sport"`
CapturePacketRate float64 `json:"cpr"`
BeginTime int64 `json:"bt"`
EventTime int64 `json:"bt"`
jsonContent []byte `json:"-"`
}
@@ -33,8 +33,7 @@ const (
)
var (
mqpp = NewMysqlQueryPiecePool()
localSliceBufferPool = NewSliceBufferPool("json cache", 256*1024)
mqpp = NewMysqlQueryPiecePool()
)
var commonBaseQueryPiece = &BaseQueryPiece{}
@@ -47,7 +46,7 @@ func NewBaseQueryPiece(
bqp.ServerPort = serverPort
bqp.SyncSend = false
bqp.CapturePacketRate = capturePacketRate
bqp.BeginTime = time.Now().UnixNano() / millSecondUnit
bqp.EventTime = time.Now().UnixNano() / millSecondUnit
return
}
@@ -83,11 +82,7 @@ func (bqp *BaseQueryPiece) GetSQL() (*string) {
func (bqp *BaseQueryPiece) Recovery() {
}
func marsharQueryPieceShareMemory(qp interface{}) []byte {
var cacheBuffer = localSliceBufferPool.Dequeue()
if len(cacheBuffer) > 0 {
panic("there already have bytes in buffer")
}
func marsharQueryPieceShareMemory(qp interface{}, cacheBuffer []byte) []byte {
buffer := bytes.NewBuffer(cacheBuffer)
err := json.NewEncoder(buffer).Encode(qp)
@@ -105,4 +100,4 @@ func marsharQueryPieceMonopolize(qp interface{}) (content []byte) {
}
return content
}
}