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

[BLD]: use cache mount in Rust Dockerfile #2779

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

codetheweb
Copy link
Contributor

@codetheweb codetheweb commented Sep 11, 2024

Description of changes

Uses Docker cache mounts to cache Rust artifacts instead of layer caching. A cache mount persists across docker builds and is not stored as a layer in the image. Using a cache mount is better because:

  • if a dependency changes, it does not require all dependencies to be rebuilt
  • only changed Chroma code will be rebuilt

I tested the savings by performing an incremental build (with target compaction_service) after touching a file in the worker crate.

Before:

  • debug: 35s
  • release: 1m8s

After:

  • debug: 14s
  • release: 58s

It doesn't seem to speed up release builds as much as I was hoping, but a 2x reduction in debug build time is a nice win. Also makes the Dockerfile easier to read. Savings may be more pronounced when running multiple builds concurrently (e.g. the query and compactor service inside Tilt).

Test plan

How are these changes tested?

Built debug & release images locally.

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?

n/a

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 (Readability, Modularity, Intuitiveness)

@codetheweb codetheweb marked this pull request as ready for review September 11, 2024 00:58
Copy link
Collaborator

@HammadB HammadB left a comment

Choose a reason for hiding this comment

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

This makes sense to me. Does sharing=locked mean that query/compaction can't build concurrently in tilt?

@codetheweb
Copy link
Contributor Author

codetheweb commented Sep 12, 2024

This makes sense to me. Does sharing=locked mean that query/compaction can't build concurrently in tilt?

Yes, but this is actually a feature, not a bug. :) Building the query and compaction services concurrently in Tilt wastes a lot of compute since they share 95%+ of their dependencies/code. So overall it should be faster now since one will build and then the other can used the cached result to finish building its delta.

@codetheweb codetheweb merged commit 0d06ee4 into main Sep 12, 2024
68 checks passed
@codetheweb codetheweb deleted the feat-rust-dockerfile-use-cache-mount branch September 12, 2024 18:01
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