Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce allocation of log batch compression #98

Merged
merged 4 commits into from
Sep 8, 2021
Merged

Conversation

tabokie
Copy link
Member

@tabokie tabokie commented Sep 8, 2021

Signed-off-by: tabokie xy.tao@outlook.com

  1. Reuse log batch buffer for storing compressed content, instead of replacing the buffer
  2. Avoid allocate twice when creating protobuf::Message from decompressed slice
  3. Use entry reference for log batch append

Bench results:

Patched:
test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench:     136,299 ns/iter (+/- 44,912)
test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench:     131,405 ns/iter (+/- 82,630)

Master:
test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench:     199,314 ns/iter (+/- 95,954)
test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench:     197,948 ns/iter (+/- 16,842)

Without streaming encoding(#91):
test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench:     407,738 ns/iter (+/- 142,417)
test log_batch::tests::bench_log_batch_add_entry_and_encode ... bench:     411,079 ns/iter (+/- 111,409)

Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
@tabokie tabokie merged commit c2abe9f into tikv:master Sep 8, 2021
@tabokie tabokie deleted the stream branch September 8, 2021 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant