-
Notifications
You must be signed in to change notification settings - Fork 66
mydump,restore: reduce parser memory allocation #108
Conversation
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
/run-all-tests |
/run-integration-test |
/run-all-tests |
/run-integration-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@july2993 @GregoryIan PTAL |
switch err { | ||
case io.ErrUnexpectedEOF, io.EOF: | ||
parser.isLastChunk = true | ||
fallthrough | ||
case nil: | ||
tryAppendTo(&parser.buf, block[:n]) | ||
parser.remainBuf.Reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we omit remainBuf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can not, because of parser.buf
reference to appendBuf.Bytes()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave a comment above code
LGTM |
f2521f1
to
c3ba4ad
Compare
@@ -1386,7 +1387,7 @@ func (cr *chunkRestore) restore( | |||
|
|||
// sql -> kv | |||
start = time.Now() | |||
kvs, _, err := kvEncoder.SQL2KV(buffer.String()) | |||
kvs, _, err := kvEncoder.SQL2KV(hack.String(buffer.Bytes())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change the argument type of SQL2KV from string to byte slice. You should not use hack package usually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
What problem does this PR solve?
Reduce parser memory allocation
Benchmark (SQL file: 1529669bytes ~1.5MB, Chunk size: 64KB, Rows: 223):
Previous benchmark ref: #107,
BenchmarkChunkRestoreReuseBuffer3
is the latest version.What is changed and how it works?
Add blockBuf to parser
Check List
Tests
Code changes
Side effects
Related changes