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

raft: reduce allocation #2391

Merged
merged 4 commits into from Oct 19, 2017

Conversation

Projects
None yet
3 participants
@BusyJay
Contributor

BusyJay commented Oct 18, 2017

No description provided.

@BusyJay BusyJay requested review from siddontang, overvenus and disksing Oct 18, 2017

Show outdated Hide outdated src/raft/raft.rs Outdated
Show outdated Hide outdated src/raft/raft.rs Outdated
..Default::default()
};
if !raft.msgs.is_empty() {
mem::swap(&mut raft.msgs, &mut rd.messages);

This comment has been minimized.

@siddontang

siddontang Oct 19, 2017

Contributor

any benchmark here?

@siddontang

siddontang Oct 19, 2017

Contributor

any benchmark here?

This comment has been minimized.

@BusyJay

BusyJay Oct 19, 2017

Contributor

It's very obvious that mem::swap does not copy the heap values however drain.collect will allocate a new buffer then copy all the content from original.

For a 100 length u64 vector:
test bench_drain_collect ... bench: 105 ns/iter (+/- 2)
test bench_swap ... bench: 2 ns/iter (+/- 0)

@BusyJay

BusyJay Oct 19, 2017

Contributor

It's very obvious that mem::swap does not copy the heap values however drain.collect will allocate a new buffer then copy all the content from original.

For a 100 length u64 vector:
test bench_drain_collect ... bench: 105 ns/iter (+/- 2)
test bench_swap ... bench: 2 ns/iter (+/- 0)

BusyJay added some commits Oct 19, 2017

@BusyJay

This comment has been minimized.

Show comment
Hide comment
@BusyJay

BusyJay Oct 19, 2017

Contributor

/run-unit-test

Contributor

BusyJay commented Oct 19, 2017

/run-unit-test

@siddontang

LGTM

@BusyJay

This comment has been minimized.

Show comment
Hide comment
@BusyJay

BusyJay Oct 19, 2017

Contributor

/run-integration-test

Contributor

BusyJay commented Oct 19, 2017

/run-integration-test

@BusyJay BusyJay merged commit 895b76a into master Oct 19, 2017

5 checks passed

ci/circleci Your tests passed on CircleCI!
Details
jenkins-ci-tikv/build Jenkins job succeeded.
Details
jenkins-ci-tikv/integration-common-test Jenkins job succeeded.
Details
jenkins-ci-tikv/integration-ddl-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@BusyJay BusyJay deleted the busyjay/reduce-allocation branch Oct 19, 2017

BusyJay added a commit to BusyJay/tikv that referenced this pull request Oct 30, 2017

@BusyJay BusyJay referenced this pull request Oct 30, 2017

Merged

raft: reduce allocation #2434

siddontang added a commit that referenced this pull request Oct 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment