Permutation trick#116
Open
aneubeck wants to merge 13 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new consistent-choose-k crate providing stateless consistent hashing primitives (choose‑k ranking, per-key consistent permutations, and a deletion-tolerant node map), and updates benchmark/test dependencies across existing crates to newer versions.
Changes:
- Add the new
crates/consistent-choose-klibrary with core algorithms, docs, examples, and benchmarks. - Add the new benchmark workspace member and align Criterion usage (including switching benchmarks to
std::hint::black_box). - Bump dev/benchmark dependencies (e.g.,
criterionandtiktoken-rs/tokenizers) in existing crates.
Show a summary per file
| File | Description |
|---|---|
| README.md | Lists the newly added consistent-choose-k crate in the repo overview. |
| Cargo.toml | Adds crates/consistent-choose-k/benchmarks to the workspace members. |
| crates/sparse-ngrams/Cargo.toml | Bumps Criterion dev-dependency version. |
| crates/sparse-ngrams/benchmarks/performance.rs | Updates benchmark black_box usage to std::hint::black_box. |
| crates/consistent-choose-k/Cargo.toml | Introduces the new crate’s package metadata and lib configuration. |
| crates/consistent-choose-k/src/lib.rs | Declares modules and exports the new crate’s public API surface. |
| crates/consistent-choose-k/src/choose_k.rs | Implements the consistent choose‑k ranking iterator and associated tests. |
| crates/consistent-choose-k/src/consistent_hash.rs | Implements the underlying consistent hash iterators and builder traits. |
| crates/consistent-choose-k/src/consistent_permutation.rs | Adds the “permutation trick” iterator (layered Feistel design) plus tests. |
| crates/consistent-choose-k/src/node_map.rs | Adds ConsistentNodeMap for deletion-tolerant assignment plus tests. |
| crates/consistent-choose-k/README.md | Adds crate-level documentation and proofs/derivations for the algorithm. |
| crates/consistent-choose-k/docs/permutation-design.md | Adds detailed design notes and rationale for the permutation construction. |
| crates/consistent-choose-k/examples/statistical_comparison.rs | Adds a chi-squared based statistical comparison example. |
| crates/consistent-choose-k/examples/bounded_load.rs | Adds a bounded-load consistent hashing example and comparisons. |
| crates/consistent-choose-k/benchmarks/Cargo.toml | Adds a dedicated benchmarks crate for consistent-choose-k. |
| crates/consistent-choose-k/benchmarks/performance.rs | Adds performance benchmarks comparing choose‑k vs permutation approaches. |
| crates/consistent-choose-k/benchmarks/criterion.toml | Adds Criterion chart/report configuration for the new benchmarks. |
| crates/bpe/Cargo.toml | Bumps tiktoken-rs dev-dependency version. |
| crates/bpe/tests/Cargo.toml | Bumps tiktoken-rs used by the test crate. |
| crates/bpe/benchmarks/Cargo.toml | Bumps tiktoken-rs and tokenizers versions in benchmarks. |
| crates/bpe-openai/Cargo.toml | Bumps tiktoken-rs dev-dependency version. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 21/21 changed files
- Comments generated: 4
jorendorff
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.