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

raftstore: remove uuid #1953

Merged
merged 5 commits into from
Jun 23, 2017
Merged

raftstore: remove uuid #1953

merged 5 commits into from
Jun 23, 2017

Conversation

BusyJay
Copy link
Member

@BusyJay BusyJay commented Jun 21, 2017

UUID is used for two reason in our project:

  1. used to find the correct callback for a raft entry;
  2. remove redundant request.

The first goal can be achieved via index + term. The second implementation is not complete and redundant request can still happen when leadership is changed or instance gets restarted. A complete correct implementation is not necessary and probably reduce performance.

Hence UUID is not necessary in our project, and sometimes it occupies a lot of CPU of scheduler thread and raftstore thread in our benches and tests. So let's remove it.

@siddontang
Copy link
Contributor

Do we need to update the kvproto?

@siddontang
Copy link
Contributor

PTAL @hhkbp2 @javaforfun

// It's ok to overflow. If there are two entries share same id, then
// there should be u64::MAX entries kept in memory in which case TiKV
// should oom already. At lease true for amd64 architect.
self.pending_reads.id_allocator = id.overflowing_add(1).0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please abstract alloc method for id allocator, and use it instead of overflowing_add.

impl ReadIndexRequest {
fn binary_id(&self) -> &[u8] {
unsafe {
let id = &self.id as *const u64 as *const u8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use transmute here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I need a slice rather than an array.

@lishuai87
Copy link
Contributor

LGTM

@siddontang
Copy link
Contributor

PTAL @hhkbp2

@siddontang
Copy link
Contributor

need use pingcap/kvproto#171 here?

@BusyJay
Copy link
Member Author

BusyJay commented Jun 23, 2017

It doesn't have to be included. It will be both source and binary compatible.

@hhkbp2
Copy link
Contributor

hhkbp2 commented Jun 23, 2017

LGTM

@BusyJay BusyJay merged commit 28fc87b into master Jun 23, 2017
@BusyJay BusyJay deleted the busyjay/remove-uuid branch June 23, 2017 04:56
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.

5 participants