Skip to content

Commit 662f3ca

Browse files
authored
Tweak options of tquic tools (#252)
- group different options by category and prioritize commonly used options - rename `max_requests_per_thread` to `total_requests_per_thread` - update description of some options
1 parent 898605c commit 662f3ca

File tree

2 files changed

+281
-116
lines changed

2 files changed

+281
-116
lines changed

tools/src/bin/tquic_client.rs

Lines changed: 173 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -77,157 +77,256 @@ static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
7777
#[derive(Parser, Debug, Clone)]
7878
#[clap(name = "client")]
7979
pub struct ClientOpt {
80-
/// Request URLs. The host of the first one is used as SNI in Client Hello.
80+
/// Server's address.
81+
#[clap(short, long, value_name = "ADDR")]
82+
pub connect_to: Option<SocketAddr>,
83+
84+
/// Optional local IP addresses for client. e.g 192.168.1.10,192.168.2.20
85+
#[clap(long, value_delimiter = ',', value_name = "ADDR")]
86+
pub local_addresses: Vec<IpAddr>,
87+
88+
/// Request URLs. The host of the first url is used as TLS SNI.
8189
#[clap(value_delimiter = ' ')]
8290
pub urls: Vec<Url>,
8391

8492
/// Number of threads.
85-
#[clap(short, long, default_value = "1", value_name = "NUM")]
93+
#[clap(
94+
short,
95+
long,
96+
default_value = "1",
97+
value_name = "NUM",
98+
help_heading = "Concurrency"
99+
)]
86100
pub threads: u32,
87101

88102
/// Number of concurrent connections per thread.
89-
#[clap(long, default_value = "1", value_name = "NUM")]
103+
#[clap(
104+
long,
105+
default_value = "1",
106+
value_name = "NUM",
107+
help_heading = "Concurrency"
108+
)]
90109
pub max_concurrent_conns: u32,
91110

92-
/// Number of requests per thread. "0" means infinity mode.
93-
#[clap(long, default_value = "1", value_name = "NUM")]
94-
pub max_requests_per_thread: u64,
111+
/// Number of concurrent requests per connection.
112+
#[clap(
113+
long,
114+
default_value = "1",
115+
value_name = "NUM",
116+
help_heading = "Concurrency"
117+
)]
118+
pub max_concurrent_requests: u64,
95119

96-
/// Number of max requests per connection. "0" means infinity mode.
97-
#[clap(long, default_value = "1", value_name = "NUM")]
120+
/// Number of max requests per connection before re-establishment. "0" means infinity mode.
121+
#[clap(
122+
long,
123+
default_value = "1",
124+
value_name = "NUM",
125+
help_heading = "Concurrency"
126+
)]
98127
pub max_requests_per_conn: u64,
99128

100-
/// Number of max concurrent requests per connection.
101-
#[clap(long, default_value = "1", value_name = "NUM")]
102-
pub max_concurrent_requests: u64,
129+
/// Total number of requests to send per thread. "0" means infinity mode.
130+
/// Values below number of urls will be considered as number of urls.
131+
#[clap(
132+
long,
133+
default_value = "1",
134+
value_name = "NUM",
135+
help_heading = "Concurrency"
136+
)]
137+
pub total_requests_per_thread: u64,
103138

104139
/// Benchmarking duration in seconds. "0" means infinity mode.
105-
/// Client will exit if either the max_requests or duration is reached.
106-
#[clap(short, long, default_value = "0", value_name = "TIME")]
140+
/// Client will exit upon reaching the total_requests_per_thread or duration limit.
141+
#[clap(
142+
short,
143+
long,
144+
default_value = "0",
145+
value_name = "TIME",
146+
help_heading = "Concurrency"
147+
)]
107148
pub duration: u64,
108149

109-
/// Client will exit if consecutive failure reaches the threshold at the beginning.
110-
#[clap(long, default_value = "10", value_name = "NUM")]
111-
pub connection_failure_threshold: u64,
112-
113-
/// Number of max samples per thread used for request time statistics.
114-
#[clap(long, default_value = "100000", value_name = "NUM")]
115-
pub max_sample: usize,
116-
117-
/// Print response header and body to stdout.
118-
#[clap(short, long)]
119-
pub print_res: bool,
120-
121-
/// Log level, support OFF/ERROR/WARN/INFO/DEBUG/TRACE.
122-
#[clap(long, default_value = "INFO", value_name = "STR")]
123-
pub log_level: log::LevelFilter,
124-
125-
/// Log file path. If no file is specified, logs will be written to `stderr`.
126-
#[clap(long, value_name = "FILE")]
127-
pub log_file: Option<String>,
128-
129-
/// Override server's address.
130-
#[clap(short, long, value_name = "ADDR")]
131-
pub connect_to: Option<SocketAddr>,
132-
133150
/// ALPN, separated by ",".
134151
#[clap(
135152
short,
136153
long,
137154
value_delimiter = ',',
138155
default_value = "h3,http/0.9,hq-interop",
139-
value_name = "STR"
156+
value_name = "STR",
157+
help_heading = "Protocol"
140158
)]
141159
pub alpn: Vec<ApplicationProto>,
142160

143-
/// Dump response body into the given directory.
144-
/// If the specified directory does not exist, a new directory will be created.
145-
#[clap(long, value_name = "DIR")]
146-
pub dump_dir: Option<String>,
147-
148161
/// File used for session resumption.
149-
#[clap(short, long, value_name = "FILE")]
162+
#[clap(short, long, value_name = "FILE", help_heading = "Protocol")]
150163
pub session_file: Option<String>,
151164

152165
/// Enable early data.
153-
#[clap(short, long)]
166+
#[clap(short, long, help_heading = "Protocol")]
154167
pub enable_early_data: bool,
155168

156169
/// Disable stateless reset.
157-
#[clap(long)]
170+
#[clap(long, help_heading = "Protocol")]
158171
pub disable_stateless_reset: bool,
159172

160173
/// Congestion control algorithm.
161-
#[clap(long, default_value = "BBR")]
174+
#[clap(long, default_value = "BBR", help_heading = "Protocol")]
162175
pub congestion_control_algor: CongestionControlAlgorithm,
163176

164177
/// Initial congestion window in packets.
165-
#[clap(long, default_value = "32", value_name = "NUM")]
178+
#[clap(
179+
long,
180+
default_value = "32",
181+
value_name = "NUM",
182+
help_heading = "Protocol"
183+
)]
166184
pub initial_congestion_window: u64,
167185

168186
/// Minimum congestion window in packets.
169-
#[clap(long, default_value = "4", value_name = "NUM")]
187+
#[clap(
188+
long,
189+
default_value = "4",
190+
value_name = "NUM",
191+
help_heading = "Protocol"
192+
)]
170193
pub min_congestion_window: u64,
171194

172195
/// Enable multipath transport.
173-
#[clap(long)]
196+
#[clap(long, help_heading = "Protocol")]
174197
pub enable_multipath: bool,
175198

176199
/// Multipath scheduling algorithm.
177-
#[clap(long, default_value = "MINRTT")]
200+
#[clap(long, default_value = "MINRTT", help_heading = "Protocol")]
178201
pub multipath_algor: MultipathAlgorithm,
179202

180-
/// Optional local IP addresses for client. e.g 192.168.1.10,192.168.2.20
181-
#[clap(long, value_delimiter = ',', value_name = "ADDR")]
182-
pub local_addresses: Vec<IpAddr>,
183-
184203
/// Set active_connection_id_limit transport parameter. Values lower than 2 will be ignored.
185-
#[clap(long, default_value = "2", value_name = "NUM")]
204+
#[clap(
205+
long,
206+
default_value = "2",
207+
value_name = "NUM",
208+
help_heading = "Protocol"
209+
)]
186210
pub active_cid_limit: u64,
187211

188212
/// Set max_udp_payload_size transport parameter.
189-
#[clap(long, default_value = "65527", value_name = "NUM")]
213+
#[clap(
214+
long,
215+
default_value = "65527",
216+
value_name = "NUM",
217+
help_heading = "Protocol"
218+
)]
190219
pub recv_udp_payload_size: u16,
191220

192221
/// Set the maximum outgoing UDP payload size.
193-
#[clap(long, default_value = "1200", value_name = "NUM")]
222+
#[clap(
223+
long,
224+
default_value = "1200",
225+
value_name = "NUM",
226+
help_heading = "Protocol"
227+
)]
194228
pub send_udp_payload_size: usize,
195229

196230
/// Handshake timeout in microseconds.
197-
#[clap(long, default_value = "10000", value_name = "TIME")]
231+
#[clap(
232+
long,
233+
default_value = "10000",
234+
value_name = "TIME",
235+
help_heading = "Protocol"
236+
)]
198237
pub handshake_timeout: u64,
199238

200239
/// Connection idle timeout in microseconds.
201-
#[clap(long, default_value = "30000", value_name = "TIME")]
240+
#[clap(
241+
long,
242+
default_value = "30000",
243+
value_name = "TIME",
244+
help_heading = "Protocol"
245+
)]
202246
pub idle_timeout: u64,
203247

204248
/// Initial RTT in milliseconds.
205-
#[clap(long, default_value = "333", value_name = "TIME")]
249+
#[clap(
250+
long,
251+
default_value = "333",
252+
value_name = "TIME",
253+
help_heading = "Protocol"
254+
)]
206255
pub initial_rtt: u64,
207256

208257
/// Linear factor for calculating the probe timeout.
209-
#[clap(long, default_value = "10", value_name = "NUM")]
258+
#[clap(
259+
long,
260+
default_value = "10",
261+
value_name = "NUM",
262+
help_heading = "Protocol"
263+
)]
210264
pub pto_linear_factor: u64,
211265

212266
/// Upper limit of probe timeout in microseconds.
213-
#[clap(long, default_value = "10000", value_name = "TIME")]
267+
#[clap(
268+
long,
269+
default_value = "10000",
270+
value_name = "TIME",
271+
help_heading = "Protocol"
272+
)]
214273
pub max_pto: u64,
215274

275+
/// Length of connection id in bytes.
276+
#[clap(
277+
long,
278+
default_value = "8",
279+
value_name = "NUM",
280+
help_heading = "Protocol"
281+
)]
282+
pub cid_len: usize,
283+
284+
/// Print response header and body to stdout.
285+
#[clap(short, long, help_heading = "Output")]
286+
pub print_res: bool,
287+
288+
/// Dump response body into the given directory.
289+
/// If the specified directory does not exist, a new directory will be created.
290+
#[clap(long, value_name = "DIR", help_heading = "Output")]
291+
pub dump_dir: Option<String>,
292+
293+
/// Log level, support OFF/ERROR/WARN/INFO/DEBUG/TRACE.
294+
#[clap(
295+
long,
296+
default_value = "INFO",
297+
value_name = "STR",
298+
help_heading = "Output"
299+
)]
300+
pub log_level: log::LevelFilter,
301+
302+
/// Log file path. If no file is specified, logs will be written to `stderr`.
303+
#[clap(long, value_name = "FILE", help_heading = "Output")]
304+
pub log_file: Option<String>,
305+
216306
/// Save TLS key log into the given file.
217-
#[clap(short, long, value_name = "FILE")]
307+
#[clap(short, long, value_name = "FILE", help_heading = "Output")]
218308
pub keylog_file: Option<String>,
219309

220310
/// Save qlog file (<trace_id>.qlog) into the given directory.
221-
#[clap(long, value_name = "DIR")]
311+
#[clap(long, value_name = "DIR", help_heading = "Output")]
222312
pub qlog_dir: Option<String>,
223313

224-
/// Length of connection id in bytes.
225-
#[clap(long, default_value = "8", value_name = "NUM")]
226-
pub cid_len: usize,
314+
/// Client will exit if consecutive failure reaches the threshold at the beginning.
315+
#[clap(long, default_value = "10", value_name = "NUM", help_heading = "Misc")]
316+
pub connection_failure_threshold: u64,
227317

228318
/// Batch size for sending packets.
229-
#[clap(long, default_value = "1", value_name = "NUM")]
319+
#[clap(long, default_value = "1", value_name = "NUM", help_heading = "Misc")]
230320
pub send_batch_size: usize,
321+
322+
/// Number of max samples per thread used for request time statistics.
323+
#[clap(
324+
long,
325+
default_value = "100000",
326+
value_name = "NUM",
327+
help_heading = "Misc"
328+
)]
329+
pub max_sample: usize,
231330
}
232331

233332
const MAX_BUF_SIZE: usize = 65536;
@@ -559,8 +658,8 @@ impl Worker {
559658

560659
if (self.option.duration > 0
561660
&& (Instant::now() - self.start_time).as_secs() > self.option.duration)
562-
|| (self.option.max_requests_per_thread > 0
563-
&& worker_ctx.request_done >= self.option.max_requests_per_thread)
661+
|| (self.option.total_requests_per_thread > 0
662+
&& worker_ctx.request_done >= self.option.total_requests_per_thread)
564663
{
565664
debug!(
566665
"worker should exit, concurrent conns {}, request sent {}, request done {}",
@@ -1427,9 +1526,9 @@ fn parse_option() -> std::result::Result<ClientOpt, clap::error::Error> {
14271526
option.max_requests_per_conn = max(option.max_requests_per_conn, option.urls.len() as u64);
14281527
}
14291528

1430-
if option.max_requests_per_thread != 0 {
1431-
option.max_requests_per_thread =
1432-
max(option.max_requests_per_thread, option.urls.len() as u64);
1529+
if option.total_requests_per_thread != 0 {
1530+
option.total_requests_per_thread =
1531+
max(option.total_requests_per_thread, option.urls.len() as u64);
14331532
}
14341533

14351534
Ok(option)

0 commit comments

Comments
 (0)