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

RUST-2004 Benchmark client bulk write #1293

Merged
merged 8 commits into from
Feb 3, 2025

Conversation

isabelatkinson
Copy link
Contributor

@isabelatkinson isabelatkinson commented Jan 29, 2025

RUST-2004

This also includes some clippy fixes/general cleanup in the second and third commits.

@isabelatkinson isabelatkinson marked this pull request as ready for review January 30, 2025 20:16
@@ -57,6 +62,38 @@ pub static TARGET_ITERATION_COUNT: Lazy<usize> = Lazy::new(|| {
.expect("invalid TARGET_ITERATION_COUNT")
});

static SMALL_DOC: OnceCell<Document> = OnceCell::const_new();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think these statics can be moved into the scope of the get_ functions that use them.

let data_path = DATA_PATH
.join("single_and_multi_document")
.join("small_doc.json");
let mut file = spawn_blocking_and_await!(std::fs::File::open(data_path))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: It might be worth factoring out a utility function like

async fn from_json_file<T: DeserializeOwned>(path: impl AsRef<Path>) -> Result<T>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, added a util function and statics for the other json files we read

@@ -69,7 +106,7 @@ pub trait Benchmark: Sized {
Ok(())
}

async fn do_task(&self) -> Result<()>;
async fn do_task(&mut self) -> Result<()>;
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that the introduction of mut here is to support copying the write models in before_task rather than do_task (which absolutely makes sense).

Personally, I'd rather avoid the mut on do_task because I think it makes it harder to reason about; how would you feel about, instead, updating the Benchmark trait with

type TaskState = ();
async fn before_task(&mut self) -> Result<TaskState> {
    Ok(())
}
async fn do_task(&self, state: TaskState) -> Result<()>;

That avoids the need for mut and the Option/take ceremony, but might be more type-level complication than it's worth. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea - I never love an option/take hack like this. updated with your suggestion, it's a bit noisy to add type TaskState = () to all the types but hopefully associated type defaults will be stabilized sometime soon

Copy link
Contributor Author

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

let data_path = DATA_PATH
.join("single_and_multi_document")
.join("small_doc.json");
let mut file = spawn_blocking_and_await!(std::fs::File::open(data_path))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, added a util function and statics for the other json files we read

@@ -69,7 +106,7 @@ pub trait Benchmark: Sized {
Ok(())
}

async fn do_task(&self) -> Result<()>;
async fn do_task(&mut self) -> Result<()>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea - I never love an option/take hack like this. updated with your suggestion, it's a bit noisy to add type TaskState = () to all the types but hopefully associated type defaults will be stabilized sometime soon

@isabelatkinson isabelatkinson merged commit d8fb500 into mongodb:main Feb 3, 2025
11 of 16 checks passed
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