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

[ENH] Add rust rendezvous hashing and errors #1508

Merged
merged 2 commits into from
Dec 13, 2023
Merged

Conversation

HammadB
Copy link
Collaborator

@HammadB HammadB commented Dec 12, 2023

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • /
  • New functionality
    • This adds the rendezvous hashing to the rust code so that it may be used by assigners.
    • It also introduces our philosophy on error handling in the rust codebase. We will use the 17 standard error codes in the grpc codebase, this is used so lower levels can send their codes higher, and in higher levels of the code we can Box<> a dyn Chroma Error to allow for generic handling over the codes. Lower levels will have to be specific, at the expense of verbosity in the errors they propagate and wrap. We will use the thiserror library, widely adopted in rust, in order to easily derive our errors. If a type needs to wrap a source error, thiserror provides #[from] in order to allow callers to have more nuanced information. After much research, my philosophy was informed by this post - https://mmapped.blog/posts/12-rust-error-handling.html.

Test plan

How are these changes tested?

  • Tests pass locally with cargo test

Documentation Changes

None required. Please evaluate the documentation quality of the code itself.

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readbility, Modularity, Intuitiveness)

@HammadB HammadB changed the title [ENH] Add rust assignmenment policy and errors [ENH] Add rust rendezvous hasing and errors Dec 12, 2023
}

/// Error codes for assignment
#[derive(Error, Debug)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an example of how to create errors.

HashError,
}

impl ChromaError for AssignmentError {
Copy link
Collaborator Author

@HammadB HammadB Dec 12, 2023

Choose a reason for hiding this comment

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

We must always do this, it's not compile time enforced, I can't find a good way to do that right now, but higher levels of code can Box<dyn ChromaError> this way and rely on codes.

@HammadB HammadB changed the title [ENH] Add rust rendezvous hasing and errors [ENH] Add rust rendezvous hashing and errors Dec 12, 2023
@HammadB HammadB changed the base branch from hammad/rust_ci to main December 12, 2023 21:05
Copy link
Contributor

@beggers beggers left a comment

Choose a reason for hiding this comment

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

Looks good! One small comment nit but that's it :)

rust/worker/src/assignment/rendezvous_hash.rs Show resolved Hide resolved
let mut max_member = None;

for member in members {
if !iterated {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to myself: we need this because count() on a rust Iterator consumes the iterator and size_hint() explicitly states that iterators don't have to implement it correctly. So there's no way to check the size of members at the top of the function.

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.

2 participants