Skip to content

[1/n] [nexus-db-queries] move LookupPath to another crate #7985

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

Conversation

sunshowers
Copy link
Contributor

@sunshowers sunshowers commented Apr 16, 2025

Introduce nexus-db-lookup, a new crate that contains LookupPath and all of the corresponding resources.

This change has two advantages:

  1. While attempting to split some of omicron-nexus up into multiple crates that could potentially compile in parallel with nexus-db-queries, I ran into the issue that LookupPath, which is a fairly fundamental type, lived inside nexus-db-queries.

  2. This is an okay build speed improvement in its own right. With this change, touch nexus-db-queries/src/lib.rs && cargo check -p nexus-db-queries goes from around 2.45 seconds to 2.15 seconds (around 1.15x faster).

    That's because the lookup_resource macros in the new nexus-db-lookup crate expand to quite a lot of code: around 15k lines or so compared to the rest of nexus-db-queries' 75k lines when expanded.

In order to achieve this goal:

  • This PR provides a trait as an interface that DataStore implements. That isn't too bad, though. I'm not totally sure this will end up being the final shape of such an interface, but it works for now and can be changed later with minimal disruption.
  • This PR splits some error handling code in nexus-db-queries into its own crate as well. Relatively small but otherwise quite nice chunk of code to move out.

This PR aims to minimize ugliness at callsites (i.e. nexus.datastore() rather than &**nexus.datastore()). However I did let some churn through, specifically places where we passed in immediately-dereferenced types like &&DataStore.

Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
@sunshowers sunshowers requested a review from smklein April 16, 2025 18:36
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
@sunshowers sunshowers changed the title [nexus-db-queries] move LookupPath to another crate [1/n] [nexus-db-queries] move LookupPath to another crate Apr 18, 2025

//! Integration tests for nexus-db-lookup.
//!
//! Note: all integration tests for a crate live in a single binary for build
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's only one integration test here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but if we add more I wanted to guide folks to putting them within this binary :)

Created using spr 1.3.6-beta.1
@sunshowers sunshowers enabled auto-merge (squash) April 18, 2025 20:14
Created using spr 1.3.6-beta.1
@sunshowers sunshowers merged commit 5a75bc1 into main Apr 18, 2025
18 checks passed
@sunshowers sunshowers deleted the sunshowers/spr/nexus-db-queries-move-lookuppath-to-another-crate branch April 18, 2025 21:54
@hawkw hawkw mentioned this pull request Apr 24, 2025
7 tasks
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