Tage Johansson
2023-Sep-04 15:21 UTC
[Libguestfs] [libnbd PATCH] rust: Cleanups in examples/concurrent-read-write.rs.
This patch makes some small cleanups in
rust/examples/concurrent-read-write.rs. Specificly, it refrases one
comment, removes some outcommented code, and removes a completely
redundent if statement. It also replaces a hard coded number with the
index of the task as seed to an RNG.
---
rust/examples/concurrent-read-write.rs | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/rust/examples/concurrent-read-write.rs
b/rust/examples/concurrent-read-write.rs
index 4858f76..589cefd 100644
--- a/rust/examples/concurrent-read-write.rs
+++ b/rust/examples/concurrent-read-write.rs
@@ -3,11 +3,10 @@
//! --run 'cargo run --example concurrent-read-write --
$unixsocket'
//! Or connect over a URI:
//! nbdkit -U - memory 100M \
-//! --run 'cargo run --example concurrent-read-write -- $uri'
+//! --run 'cargo run --example concurrent-read-write --
"$uri"'
//!
-//! This will read and write randomly over the first megabyte of the
-//! plugin using multi-conn, multiple threads and multiple requests in
-//! flight on each thread.
+//! This will read and write randomly over the plugin using multi-conn,
+//! multiple threads and multiple requests in flight on each thread.
#![deny(warnings)]
use rand::prelude::*;
@@ -111,12 +110,11 @@ async fn run_thread(
nbd.connect_unix(socket_or_uri).await?;
}
- let mut rng = SmallRng::seed_from_u64(44 as u64);
+ let mut rng = SmallRng::seed_from_u64(task_idx as u64);
// Issue commands.
let mut stats = Stats::default();
let mut join_set = JoinSet::new();
- //tokio::time::sleep(std::time::Duration::from_secs(1)).await;
while stats.requests < NR_CYCLES || !join_set.is_empty() {
while stats.requests < NR_CYCLES && join_set.len() <
MAX_IN_FLIGHT {
// If we want to issue another request, do so. Note that we reuse
@@ -144,6 +142,5 @@ async fn run_thread(
join_set.join_next().await.unwrap().unwrap()?;
}
- if task_idx == 0 {}
Ok(stats)
}
base-commit: 9afb980d05d6144129c899285e44779757a380e8
prerequisite-patch-id: 8d1779610795021ed5a3d0973ddf9ef854cd6a24
prerequisite-patch-id: 1f0f333311f11ac9b1ff0be08f5aa0a9904ba4de
prerequisite-patch-id: dc4af7343c57a4f99dc82918c07470030e542747
prerequisite-patch-id: 8e8f7a043c80d6c24e883967f5bd952a64db1228
prerequisite-patch-id: ba7b3482e2e16f76b5f285daeeda30b31a841912
prerequisite-patch-id: 219a9595e550a8caf43d466dcb2b044114e1b7bf
prerequisite-patch-id: 3de46c9673221bff1d897970aa983b3f8e6cab74
prerequisite-patch-id: 4235d5e174fce05b9a947b3b838bebf968f0fa6a
prerequisite-patch-id: 07773355d5718e0593c4030a8f035fc11fea3715
prerequisite-patch-id: f023deea8b706706e3c2980403064d90a254af3c
prerequisite-patch-id: 8639c6cc4fec58f4761771c5d8a9476d538c6251
prerequisite-patch-id: 9bc660aed54a6266b014993ff0f388a26ac2982a
--
2.42.0
Richard W.M. Jones
2023-Sep-05 10:00 UTC
[Libguestfs] [libnbd PATCH] rust: Cleanups in examples/concurrent-read-write.rs.
On Mon, Sep 04, 2023 at 03:21:10PM +0000, Tage Johansson wrote:> This patch makes some small cleanups in > rust/examples/concurrent-read-write.rs. Specificly, it refrases one > comment, removes some outcommented code, and removes a completely > redundent if statement. It also replaces a hard coded number with the > index of the task as seed to an RNG. > --- > rust/examples/concurrent-read-write.rs | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/rust/examples/concurrent-read-write.rs b/rust/examples/concurrent-read-write.rs > index 4858f76..589cefd 100644 > --- a/rust/examples/concurrent-read-write.rs > +++ b/rust/examples/concurrent-read-write.rs > @@ -3,11 +3,10 @@ > //! --run 'cargo run --example concurrent-read-write -- $unixsocket' > //! Or connect over a URI: > //! nbdkit -U - memory 100M \ > -//! --run 'cargo run --example concurrent-read-write -- $uri' > +//! --run 'cargo run --example concurrent-read-write -- "$uri"' > //! > -//! This will read and write randomly over the first megabyte of the > -//! plugin using multi-conn, multiple threads and multiple requests in > -//! flight on each thread. > +//! This will read and write randomly over the plugin using multi-conn, > +//! multiple threads and multiple requests in flight on each thread. > > #![deny(warnings)] > use rand::prelude::*; > @@ -111,12 +110,11 @@ async fn run_thread( > nbd.connect_unix(socket_or_uri).await?; > } > > - let mut rng = SmallRng::seed_from_u64(44 as u64); > + let mut rng = SmallRng::seed_from_u64(task_idx as u64); > > // Issue commands. > let mut stats = Stats::default(); > let mut join_set = JoinSet::new(); > - //tokio::time::sleep(std::time::Duration::from_secs(1)).await; > while stats.requests < NR_CYCLES || !join_set.is_empty() { > while stats.requests < NR_CYCLES && join_set.len() < MAX_IN_FLIGHT { > // If we want to issue another request, do so. Note that we reuse > @@ -144,6 +142,5 @@ async fn run_thread( > join_set.join_next().await.unwrap().unwrap()?; > } > > - if task_idx == 0 {} > Ok(stats) > } > > base-commit: 9afb980d05d6144129c899285e44779757a380e8 > prerequisite-patch-id: 8d1779610795021ed5a3d0973ddf9ef854cd6a24 > prerequisite-patch-id: 1f0f333311f11ac9b1ff0be08f5aa0a9904ba4de > prerequisite-patch-id: dc4af7343c57a4f99dc82918c07470030e542747 > prerequisite-patch-id: 8e8f7a043c80d6c24e883967f5bd952a64db1228 > prerequisite-patch-id: ba7b3482e2e16f76b5f285daeeda30b31a841912 > prerequisite-patch-id: 219a9595e550a8caf43d466dcb2b044114e1b7bf > prerequisite-patch-id: 3de46c9673221bff1d897970aa983b3f8e6cab74 > prerequisite-patch-id: 4235d5e174fce05b9a947b3b838bebf968f0fa6a > prerequisite-patch-id: 07773355d5718e0593c4030a8f035fc11fea3715 > prerequisite-patch-id: f023deea8b706706e3c2980403064d90a254af3c > prerequisite-patch-id: 8639c6cc4fec58f4761771c5d8a9476d538c6251 > prerequisite-patch-id: 9bc660aed54a6266b014993ff0f388a26ac2982a > --Thanks - pushed, rebased on current HEAD. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v