Skip to content

Commit 8757b3f

Browse files
bcantrilljmpesp
andauthored
Eliminate some scans + store jobs in BTree (#738)
In addition to fixing #731, this also fixes #757 -- and pulls in #733. Co-authored-by: James MacMahon <james@oxide.computer>
1 parent fcec78e commit 8757b3f

File tree

8 files changed

+247
-354
lines changed

8 files changed

+247
-354
lines changed

crucible-client-types/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct CrucibleOpts {
4444
pub id: Uuid,
4545
pub target: Vec<SocketAddr>,
4646
pub lossy: bool,
47-
pub flush_timeout: Option<u32>,
47+
pub flush_timeout: Option<f32>,
4848
pub key: Option<String>,
4949
pub cert_pem: Option<String>,
5050
pub key_pem: Option<String>,

crutest/src/cli.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ pub async fn start_cli_client(attach: SocketAddr) -> Result<()> {
635635

636636
println!("cli connecting to {0}", attach);
637637

638-
let deadline = tokio::time::sleep_until(deadline_secs(100));
638+
let deadline = tokio::time::sleep_until(deadline_secs(100.0));
639639
tokio::pin!(deadline);
640640
let tcp = sock.connect(attach);
641641
tokio::pin!(tcp);
@@ -655,7 +655,7 @@ pub async fn start_cli_client(attach: SocketAddr) -> Result<()> {
655655
Err(e) => {
656656
println!("connect to {0} failure: {1:?}",
657657
attach, e);
658-
tokio::time::sleep_until(deadline_secs(10)).await;
658+
tokio::time::sleep_until(deadline_secs(10.0)).await;
659659
continue 'outer;
660660
}
661661
}

crutest/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub struct Opt {
181181

182182
/// How long to wait before the auto flush check fires
183183
#[clap(long, global = true, action)]
184-
flush_timeout: Option<u32>,
184+
flush_timeout: Option<f32>,
185185

186186
/// IP:Port for the Oximeter register address, which is Nexus.
187187
#[clap(long, global = true, default_value = "127.0.0.1:12221", action)]

measure_iops/src/main.rs

+31-18
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ pub struct Opt {
4848

4949
#[clap(long, action)]
5050
bw_limit_in_bytes: Option<usize>,
51+
52+
/// Submit all zeroes instead of random data
53+
#[clap(long, action)]
54+
all_zeroes: bool,
55+
56+
/// How long to wait before the auto flush check fires
57+
#[clap(long, action)]
58+
flush_timeout: Option<f32>,
5159
}
5260

5361
pub fn opts() -> Result<Opt> {
@@ -74,7 +82,7 @@ async fn main() -> Result<()> {
7482
id: Uuid::new_v4(),
7583
target: opt.target,
7684
lossy: false,
77-
flush_timeout: None,
85+
flush_timeout: opt.flush_timeout,
7886
key: opt.key,
7987
cert_pem: opt.cert_pem,
8088
key_pem: opt.key_pem,
@@ -128,28 +136,33 @@ async fn main() -> Result<()> {
128136
1
129137
};
130138

131-
let write_buffers: Vec<Bytes> = (0..io_depth)
132-
.map(|_| {
133-
Bytes::from(
134-
(0..io_size)
135-
.map(|_| rng.sample(rand::distributions::Standard))
136-
.collect::<Vec<u8>>(),
137-
)
138-
})
139-
.collect();
140-
141139
let read_buffers: Vec<Buffer> =
142140
(0..io_depth).map(|_| Buffer::new(io_size)).collect();
143141

144142
let mut io_operations_sent = 0;
145143
let mut bw_consumed = 0;
146-
let mut io_operation_time = Instant::now();
144+
let mut measurement_time = Instant::now();
145+
let mut total_io_time = Duration::ZERO;
147146
let mut iops: Vec<f32> = vec![];
148147
let mut bws: Vec<f32> = vec![];
149148

150149
'outer: loop {
151150
let mut futures = Vec::with_capacity(io_depth);
152151

152+
let write_buffers: Vec<Bytes> = (0..io_depth)
153+
.map(|_| {
154+
Bytes::from(if opt.all_zeroes {
155+
vec![0u8; io_size]
156+
} else {
157+
(0..io_size)
158+
.map(|_| rng.sample(rand::distributions::Standard))
159+
.collect::<Vec<u8>>()
160+
})
161+
})
162+
.collect();
163+
164+
let io_operation_time = Instant::now();
165+
153166
for i in 0..io_depth {
154167
let offset: u64 =
155168
rng.gen::<u64>() % (total_blocks - io_size as u64 / bsz);
@@ -173,15 +186,14 @@ async fn main() -> Result<()> {
173186

174187
crucible::join_all(futures).await?;
175188

189+
total_io_time += io_operation_time.elapsed();
176190
io_operations_sent +=
177191
ceiling_div!(io_size * io_depth, 16 * 1024 * 1024);
178192
bw_consumed += io_size * io_depth;
179193

180-
let diff = io_operation_time.elapsed();
181-
182-
if diff > Duration::from_secs(1) {
183-
let fractional_seconds: f32 =
184-
diff.as_secs() as f32 + (diff.subsec_nanos() as f32 / 1e9);
194+
if measurement_time.elapsed() > Duration::from_secs(1) {
195+
let fractional_seconds: f32 = total_io_time.as_secs() as f32
196+
+ (total_io_time.subsec_nanos() as f32 / 1e9);
185197

186198
iops.push(io_operations_sent as f32 / fractional_seconds);
187199
bws.push(bw_consumed as f32 / fractional_seconds);
@@ -192,7 +204,8 @@ async fn main() -> Result<()> {
192204

193205
io_operations_sent = 0;
194206
bw_consumed = 0;
195-
io_operation_time = Instant::now();
207+
measurement_time = Instant::now();
208+
total_io_time = Duration::ZERO;
196209
}
197210
}
198211

openapi/crucible-pantry.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,8 @@
481481
},
482482
"flush_timeout": {
483483
"nullable": true,
484-
"type": "integer",
485-
"format": "uint32",
486-
"minimum": 0
484+
"type": "number",
485+
"format": "float"
487486
},
488487
"id": {
489488
"type": "string",

upstairs/src/dummy_downstairs_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ pub(crate) mod protocol_test {
364364
let crucible_opts = CrucibleOpts {
365365
id: Uuid::new_v4(),
366366
target: vec![ds1.local_addr, ds2.local_addr, ds3.local_addr],
367-
flush_timeout: Some(600),
367+
flush_timeout: Some(600.0),
368368

369369
..Default::default()
370370
};

0 commit comments

Comments
 (0)