Skip to content

Added prefix match for consistent hash#103

Open
bobhansen wants to merge 1 commit into
golang:masterfrom
bobhansen:master
Open

Added prefix match for consistent hash#103
bobhansen wants to merge 1 commit into
golang:masterfrom
bobhansen:master

Conversation

@bobhansen

Copy link
Copy Markdown

No description provided.

@googlebot

Copy link
Copy Markdown
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot

Copy link
Copy Markdown
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot

Copy link
Copy Markdown
Collaborator

CLAs look good, thanks!

1 similar comment
@googlebot

Copy link
Copy Markdown
Collaborator

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Sep 4, 2018
@bobhansen

Copy link
Copy Markdown
Author

Changes consistenthash's get() function from O(log n) to O(1), with a memory overhead of 6*n (where n is the number of virtual nodes).

On an AWS t3.2xlarge dedicated instance, this reduces the consistenthash benchmark times by 56% (8 nodes) to 72% (512 nodes). Data available at https://docs.google.com/spreadsheets/d/1K_kmk0_Lqk6iaSDUytjkT8RNGPTptBwBEWO8q4uAn3w/edit?usp=sharing

image

Comment thread consistenthash/consistenthash.go Outdated
}

func New(replicas int, fn Hash) *Map {
func New(replicas int, tableExpansion int, fn Hash) *Map {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a breaking API change for anybody using this package. Also, this parameter isn't documented.

Maybe make a new NewXxx func instead taking the new parameter and make the existing New default to 6 or whatever?

hashMap map[int]string
hash Hash
replicas int
prefixTableExpansion int

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

document these fields now that they're non-obvious?

@bobhansen

Copy link
Copy Markdown
Author

This is a breaking API change for anybody using this package. Also, this parameter isn't documented. Maybe make a new NewXxx func instead taking the new parameter and make the existing New default to 6 or whatever?

Done. I didn't know we had external consumers of the package.

document these fields now that they're non-obvious?

Done, and gladly. Let me know if the documentation is too verbose or unclear.

@bhansen-uber

Copy link
Copy Markdown

@bradfitz : ping

@bradfitz

bradfitz commented Oct 4, 2018

Copy link
Copy Markdown
Contributor

I'm not seeing any changes. Did you forget to push?

@bobhansen bobhansen force-pushed the master branch 2 times, most recently from 54a257b to 86a154e Compare October 4, 2018 17:47
@bobhansen

bobhansen commented Oct 4, 2018

Copy link
Copy Markdown
Author

Oh, my. That's embarrassing. I got back to your comments in the hour after you made them, then forgot to push them up.

They're pushed now.

Comment thread consistenthash/consistenthash.go Outdated
Comment thread consistenthash/consistenthash.go Outdated
Comment thread consistenthash/consistenthash_test.go Outdated
@bobhansen

Copy link
Copy Markdown
Author

Oh, my. That doesn't inspire confidence in someone's changes, does it? I had run go test at the root of the project, assuming that it would run for the transitive projects.

Fixed the issues requested (in all instances). All of the tests pass now.

@bobhansen

Copy link
Copy Markdown
Author

@bradfitz Requested changes made. Would love to see this change included so I can drop my forked repo.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants