@@ -31,9 +31,9 @@ import (
3131)
3232
3333var (
34- nullHash = common .HexToHash ("0x0000000000000000000000000000000000000000000000000000000000000000" )
35- pipeSize = 65336 // min(linuxPipeSize, macOSPipeSize)
36- collatedStmtSize = pipeSize * 16
34+ nullHash = common .HexToHash ("0x0000000000000000000000000000000000000000000000000000000000000000" )
35+ pipeSize = 65336 // min(linuxPipeSize, macOSPipeSize)
36+ writeBufferSize = pipeSize * 16 * 48
3737)
3838
3939// SQLWriter writes sql statements to a file
@@ -54,7 +54,7 @@ func NewSQLWriter(wc io.WriteCloser) *SQLWriter {
5454 return & SQLWriter {
5555 wc : wc ,
5656 stmts : make (chan []byte ),
57- collatedStmt : make ([]byte , collatedStmtSize ),
57+ collatedStmt : make ([]byte , writeBufferSize ),
5858 flushChan : make (chan struct {}),
5959 flushFinished : make (chan struct {}),
6060 quitChan : make (chan struct {}),
@@ -74,7 +74,7 @@ func (sqw *SQLWriter) Loop() {
7474 select {
7575 case stmt := <- sqw .stmts :
7676 l = len (stmt )
77- if l + sqw .collationIndex + 1 > collatedStmtSize {
77+ if sqw .collationIndex + l > writeBufferSize {
7878 if err := sqw .flush (); err != nil {
7979 panic (fmt .Sprintf ("error writing sql stmts buffer to file: %v" , err ))
8080 }
0 commit comments