Skip to content

Instantly share code, notes, and snippets.

@clayg
Created September 8, 2014 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/d46146719c4412fedb02 to your computer and use it in GitHub Desktop.
Save clayg/d46146719c4412fedb02 to your computer and use it in GitHub Desktop.
Najc,
Did you read part 2 of Greg's retelling of the design lessons learned when building swift's ring implementation? Because it specifically addresses this deficiency in the naive approach.
It's maybe too bad Greg didn't carry the balancing issue into the "final" example because then we all have to continue to think for ourselves; but I'm sure he never expected anyone to copy and use that code as is. Having gone through it a few times myself, I always enjoyed it as just a collection of exercises to help the reader build up some intuitive models for the different issues at hand - I certainly don't have delusions that I'm going to reimplement a "simpler" version of Swift's ring using some code I copied of a blog post as a starting point.
Unfortunately, the code in your gist is just calling build_ring twice, which has a shuffle in there for dispersion, but when you do that you get two unrelated rings rather than rebalancing the first one with additional capacity. Maybe we could petition Sam to write a followup based on the last example with weights that includes a rebalance implementation that uses the weights to gather up a minimum number of parts to be reassigned. You may already be working on something like - maybe you can share!?
-Clay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment