ring: inline rendezvous hashing and remove external dependency#3762
Conversation
Replace usage of github.com/dgryski/go-rendezvous with an internal implementation to eliminate the external dependency and avoid licence propagation concerns. The implementation preserves the exact hashing algorithm and behaviour: - same hash combination: khash ^ nhash - same mixing function (xorshift* variant) - same node ordering semantics No functional changes intended.
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
There was a problem hiding this comment.
Pull request overview
This PR removes the external github.com/dgryski/go-rendezvous dependency by inlining an equivalent rendezvous (HRW) hashing implementation and wiring Ring’s default consistent-hash implementation to use it.
Changes:
- Replaced the
go-rendezvouswrapper usage inring.gowith an internal rendezvous hash implementation. - Added
internal/hashtagrendezvous hash implementation + basic unit tests. - Removed
go-rendezvousfrom the root module and various nested example/extra modules’go.mod/go.sum.
Reviewed changes
Copilot reviewed 23 out of 43 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ring.go | Switch default Ring consistent hashing implementation to the new internal rendezvous hash. |
| internal/hashtag/rendezvous.go | Adds the inlined rendezvous (HRW) hashing implementation. |
| internal/hashtag/rendezvous_test.go | Adds unit tests for empty/single-node rendezvous behavior. |
| go.mod | Removes direct dependency on github.com/dgryski/go-rendezvous. |
| go.sum | Removes checksums for github.com/dgryski/go-rendezvous. |
| extra/redisprometheus/go.mod | Removes indirect go-rendezvous dependency. |
| extra/redisprometheus/go.sum | Removes go-rendezvous sums. |
| extra/redisotel/go.mod | Removes indirect go-rendezvous dependency. |
| extra/redisotel/go.sum | Removes go-rendezvous sums. |
| extra/redisotel-native/go.mod | Removes indirect go-rendezvous dependency. |
| extra/redisotel-native/go.sum | Removes go-rendezvous sums. |
| extra/rediscmd/go.mod | Removes indirect go-rendezvous dependency. |
| extra/rediscmd/go.sum | Removes go-rendezvous sums. |
| extra/rediscensus/go.mod | Removes indirect go-rendezvous dependency. |
| extra/rediscensus/go.sum | Removes go-rendezvous sums. |
| example/tls-connection/go.mod | Removes indirect go-rendezvous dependency. |
| example/tls-connection/go.sum | Removes go-rendezvous sums. |
| example/tls-cert-auth/go.mod | Removes indirect go-rendezvous dependency. |
| example/tls-cert-auth/go.sum | Removes go-rendezvous sums. |
| example/scan-struct/go.mod | Removes indirect go-rendezvous dependency. |
| example/scan-struct/go.sum | Removes go-rendezvous sums. |
| example/redis-bloom/go.mod | Removes indirect go-rendezvous dependency. |
| example/redis-bloom/go.sum | Removes go-rendezvous sums. |
| example/otel/go.mod | Removes indirect go-rendezvous dependency. |
| example/otel/go.sum | Removes go-rendezvous sums. |
| example/otel-metrics/go.mod | Removes indirect go-rendezvous dependency. |
| example/otel-metrics/go.sum | Removes go-rendezvous sums. |
| example/maintnotifiations-pubsub/go.mod | Removes indirect go-rendezvous dependency. |
| example/maintnotifiations-pubsub/go.sum | Removes go-rendezvous sums. |
| example/lua-scripting/go.mod | Removes indirect go-rendezvous dependency. |
| example/lua-scripting/go.sum | Removes go-rendezvous sums. |
| example/hset-struct/go.mod | Removes indirect go-rendezvous dependency. |
| example/hset-struct/go.sum | Removes go-rendezvous sums. |
| example/hll/go.mod | Removes indirect go-rendezvous dependency. |
| example/hll/go.sum | Removes go-rendezvous sums. |
| example/disable-maintnotifications/go.mod | Removes indirect go-rendezvous dependency. |
| example/disable-maintnotifications/go.sum | Removes go-rendezvous sums. |
| example/digest-optimistic-locking/go.mod | Removes indirect go-rendezvous dependency. |
| example/digest-optimistic-locking/go.sum | Removes go-rendezvous sums. |
| example/del-keys-without-ttl/go.mod | Removes indirect go-rendezvous dependency. |
| example/del-keys-without-ttl/go.sum | Removes go-rendezvous sums. |
| example/cluster-mget/go.mod | Removes indirect go-rendezvous dependency. |
| example/cluster-mget/go.sum | Removes go-rendezvous sums. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replaced function with inline string generation for test cases.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 43 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…stribution balance
ndyakov
left a comment
There was a problem hiding this comment.
Just wondering, can we test better for (mostly) even distribution of the keys?
…redis#3762) * ring: remove external rendezvous dependency by inlining implementation Replace usage of github.com/dgryski/go-rendezvous with an internal implementation to eliminate the external dependency and avoid licence propagation concerns. The implementation preserves the exact hashing algorithm and behaviour: - same hash combination: khash ^ nhash - same mixing function (xorshift* variant) - same node ordering semantics No functional changes intended. * Refactor TestRendezvous to remove randomString function Replaced function with inline string generation for test cases. * test: refactor RendezvousHash tests to use Ginkgo and Gomega * test: improve RendezvousHash test for per-instance determinism and distribution balance * test: enhance distribution verification in RendezvousHash tests
* feat(vectorset): WIP * feat(vectorsets): WITHATTRIBS & VIsMember * fix(vectorsets): fix tests * fix(vectorsets): improve doctest/ * feat(vectorsets): add test with nil attrs * fix(vectorsets): typo Epsilon * fix: review issues * chore(go): use -compat=1.24 (#3754) Signed-off-by: Xiaolong Chen <fukua95@gmail.com> * chore(maps): Use `maps.Keys`, `slices.Collect` and `slices.Contains` instead of custom functions (#3758) * Optimize: Use modern Go standard library (maps.Keys, slices.Collect, slices.Contains) instead of custom functions * format * chore(deps): bump codecov/codecov-action from 5 to 6 (#3757) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5 to 6. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v5...v6) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(ring): inline rendezvous hashing and remove external dependency (#3762) * ring: remove external rendezvous dependency by inlining implementation Replace usage of github.com/dgryski/go-rendezvous with an internal implementation to eliminate the external dependency and avoid licence propagation concerns. The implementation preserves the exact hashing algorithm and behaviour: - same hash combination: khash ^ nhash - same mixing function (xorshift* variant) - same node ordering semantics No functional changes intended. * Refactor TestRendezvous to remove randomString function Replaced function with inline string generation for test cases. * test: refactor RendezvousHash tests to use Ginkgo and Gomega * test: improve RendezvousHash test for per-instance determinism and distribution balance * test: enhance distribution verification in RendezvousHash tests --------- Signed-off-by: Xiaolong Chen <fukua95@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: cxljs <fukua95@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bigsk <i@ianxia.com> Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
Why not keep the dependency?
The original implementation is small (~50 LOC) and stable. Inlining it:
Additionally, avoiding a single-purpose dependency helps keep the
dependency graph minimal and easier to maintain.
Changes
Compatibility
No behavior changes are intended.
Notes
The implementation is intentionally minimal and mirrors the original
algorithm to ensure deterministic behavior.
Checklist
Note
Medium Risk
Changes the ring sharding hash implementation and removes an external dependency; any subtle mismatch could alter key-to-shard mapping and affect routing in
Ringdeployments.Overview
Replaces the
Ringconsistent-hash implementation with an in-repo rendezvous (HRW) hash (internal/hashtag/RendezvousHash) and updatesring.goto use it instead ofgithub.com/dgryski/go-rendezvous.Removes the
go-rendezvousdependency from the root module plus allexample/*andextra/*modules, and adds a new test suite (internal/hashtag/rendezvous_test.go) to validate determinism, distribution, and basic stability characteristics.Written by Cursor Bugbot for commit 08832cc. This will update automatically on new commits. Configure here.