Skip to content

Commit f14797c

Browse files
authored
Update dependencies (#81)
* Update clap to 3.0 and improve argument parsing and help output. Update clap to 3.0 and improve argument parsing and help output: - Update clap from 3.0.0-beta4 to 3.0. - Update help output text. - Allow easy specifying of "-1" for -O option (allow_hyphen_values(true)). - Make -v var=value as last argument before program work without need for "--" or other argument after. - Make -i and -F mutually exclusive as specified field separator as -F is not used when parsing input files as CSV or TSV. * Update itoa from 0.4 to 1.0. Update itoa from 0.4 to 1.0. itoa::Buffer::new() allocates the necessary space on the stack automatically, and usage is similar to ryu now. * Update other dependencies. Update other dependencies. * Switch to maintained version of jemallocator. Switch to maintained version of jemallocator like rustc did in: rust-lang/rust#83152
1 parent d81eae3 commit f14797c

File tree

3 files changed

+79
-71
lines changed

3 files changed

+79
-71
lines changed

Cargo.toml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ build = "build.rs"
1414

1515

1616
[dependencies]
17-
petgraph = "0.4.13"
18-
smallvec = "1.6"
19-
hashbrown = "0.9"
17+
petgraph = "0.6"
18+
smallvec = "1.7"
19+
hashbrown = "0.11"
2020
lazy_static = "1.4.0"
21-
regex = "1.3"
22-
regex-syntax = "0.6.22"
23-
itoa = "0.4"
21+
regex = "1.5"
22+
regex-syntax = "0.6.25"
23+
itoa = "1.0"
2424
ryu = "1.0"
2525
libc = "0.2"
26-
jemallocator = { version = "0.3", optional = true }
27-
rand = "0.8.3"
26+
tikv-jemallocator = { version = "0.4", optional = true }
27+
rand = "0.8.4"
2828
lalrpop-util = "0.19.6"
29-
unicode-xid = "0.2.0"
29+
unicode-xid = "0.2.2"
3030
llvm-sys = {version = "120", optional = true }
31-
clap = "3.0.0-beta.4"
32-
crossbeam-channel = "0.4"
33-
crossbeam = "0.7.3"
34-
num_cpus = "1.13.0"
35-
cfg-if = "0.1"
31+
clap = "3.0"
32+
crossbeam-channel = "0.5"
33+
crossbeam = "0.8.1"
34+
num_cpus = "1.13.1"
35+
cfg-if = "1.0"
3636
memchr = "2.4"
3737
grep-cli = "0.1"
3838
termcolor = "1.1"
39-
itertools = "0.9.0"
40-
assert_cmd = "1.0.2"
39+
itertools = "0.10"
40+
assert_cmd = "2.0.3"
4141
paste = "1.0"
4242
cranelift = "0.75.0"
4343
cranelift-codegen = "0.75.0"
@@ -46,16 +46,16 @@ cranelift-module = "0.75.0"
4646
cranelift-jit = "0.75.0"
4747
fast-float = "0.2"
4848
bumpalo = { version = "3.6", features = ["collections"] }
49-
target-lexicon = "0.12.1"
49+
target-lexicon = "0.12.2"
5050

5151
[dev-dependencies]
52-
assert_cmd = "1.0.2"
53-
tempfile = "3.1.0"
52+
assert_cmd = "2.0.3"
53+
tempfile = "3.3"
5454

5555

5656
[features]
5757
default = ["use_jemalloc", "allow_avx2", "llvm_backend", "unstable"]
58-
use_jemalloc = ["jemallocator"]
58+
use_jemalloc = ["tikv-jemallocator"]
5959
# Certain features leverage the AVX2 instruction set, but AVX2 can often make
6060
# the entire application slightly slower, even on chips that support it. For
6161
# those cases, consider disabling allow_avx2.

src/main.rs

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use std::mem;
5252

5353
#[cfg(feature = "use_jemalloc")]
5454
#[global_allocator]
55-
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
55+
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
5656

5757
macro_rules! fail {
5858
($($t:tt)*) => {{
@@ -313,73 +313,96 @@ fn main() {
313313
.long("program-file")
314314
.short('f')
315315
.takes_value(true)
316-
.multiple_occurrences(true))
316+
.multiple_occurrences(true)
317+
.help("Read the program source from the file program-file, instead of from the command line. Multiple '-f' options may be used"))
317318
.arg(Arg::new("opt-level")
318319
.long("opt-level")
319320
.short('O')
320-
.about("the optimization level for the program. Positive levels determine the optimization level for LLVM. Level -1 forces bytecode interpretation")
321-
.possible_values(&["0", "1", "2", "3"]))
322-
.arg("--out-file=[FILE] 'the output file used in place of standard input'")
323-
.arg("--utf8 'validate all input as UTF-8, returning an error if it is invalid'")
324-
.arg("--dump-cfg 'print untyped SSA form for input program'")
325-
.arg("--dump-bytecode 'print bytecode for input program'")
321+
.takes_value(true)
322+
.allow_hyphen_values(true)
323+
.help("The optimization level for the program. Positive levels determine the optimization level for LLVM. Level `-1` forces bytecode interpretation")
324+
.possible_values(&["-1", "0", "1", "2", "3"]))
325+
.arg(Arg::new("out-file")
326+
.long("out-file")
327+
.takes_value(true)
328+
.value_name("FILE")
329+
.help("Write to specified output file instead of standard output"))
330+
.arg(Arg::new("utf8")
331+
.long("utf8")
332+
.takes_value(false)
333+
.help("Validate all input as UTF-8, returning an error if it is invalid"))
334+
.arg(Arg::new("dump-cfg")
335+
.long("dump-cfg")
336+
.takes_value(false)
337+
.help("Print untyped SSA form for input program"))
338+
.arg(Arg::new("dump-bytecode")
339+
.long("dump-bytecode")
340+
.takes_value(false)
341+
.help("Print bytecode for input program"))
326342
.arg(Arg::new("parse-header")
327343
.long("parse-header")
328344
.short('H')
329345
.takes_value(false)
330-
.about("consume the first line of input and populate the `FI` variable with column names mapping to column indexes"))
346+
.help("Consume the first line of input and populate the `FI` variable with column names mapping to column indexes"))
331347
.arg(Arg::new("input-format")
332348
.long("input-format")
333349
.short('i')
334-
.possible_values(&["csv", "tsv"])
335-
.about("Input is split according to the rules of (csv|tsv). $0 contains the unescaped line. Assigning to columns does nothing."))
350+
.value_name("csv|tsv")
351+
.conflicts_with("field-separator")
352+
.help("Input is split according to the rules of (csv|tsv). $0 contains the unescaped line. Assigning to columns does nothing")
353+
.possible_values(&["csv", "tsv"]))
336354
.arg(Arg::new("var")
337355
.short('v')
356+
.takes_value(true)
338357
.multiple_occurrences(true)
339-
.multiple_values(true)
358+
.value_name("var=val")
359+
.help("Assign the value <val> to the variable <var>, before execution of the frawk program begins. Multiple '-v' options may be used"))
360+
.arg(Arg::new("field-separator")
361+
.long("field-separator")
362+
.short('F')
340363
.takes_value(true)
341-
.min_values(1)
342-
.about("Has the form <identifier>=<chars>. A variable with the name <identifier> is assigned to an escaped string literal containing <chars> before the body of the frawk program is run."))
343-
.arg("-F, --field-separator=[SEPARATOR] 'Field separator for frawk program.'")
364+
.value_name("FS")
365+
.conflicts_with("input-format")
366+
.help("Field separator `FS` for frawk program"))
344367
.arg(Arg::new("backend")
345368
.long("backend")
346369
.short('b')
347-
.about("The backend used to run the frawk program, ranging from fastest to compile and slowest to execute, and slowest to compile and fastest to execute. Cranelift is the default")
370+
.help("The backend used to run the frawk program, ranging from fastest to compile and slowest to execute, and slowest to compile and fastest to execute. Cranelift is the default")
348371
.possible_values(&["interp", "cranelift", "llvm"]))
349372
.arg(Arg::new("output-format")
350373
.long("output-format")
351374
.short('o')
352-
.possible_values(&["csv", "tsv"])
353-
.about("If set, records output via print are escaped according to the rules of the corresponding format"))
375+
.value_name("csv|tsv")
376+
.help("If set, records output via print are escaped according to the rules of the corresponding format")
377+
.possible_values(&["csv", "tsv"]))
354378
.arg(Arg::new("program")
355-
.about("The frawk program to execute")
356-
.index(1))
379+
.index(1)
380+
.help("The frawk program to execute"))
357381
.arg(Arg::new("input-files")
358-
.about("Input files to be read by frawk program")
359382
.index(2)
360-
.multiple_values(true))
383+
.multiple_values(true)
384+
.help("Input files to be read by frawk program"))
361385
.arg(Arg::new("parallel-strategy")
362-
.about("Attempt to execute the script in parallel. Strategy r[ecord] parallelizes within the current input file. Strategy f[ile] parallelizes between input files.")
363386
.short('p')
387+
.help("Attempt to execute the script in parallel. Strategy r[ecord] parallelizes within the current input file. Strategy f[ile] parallelizes between input files")
364388
.possible_values(&["r", "record", "f", "file"]))
365389
.arg(Arg::new("chunk-size")
366390
.long("chunk-size")
367-
.about("Buffer size when reading input. This is present primarily for debugging purposes; it's possible that tuning this will help performance, but it should not be necessary.")
368-
.takes_value(true))
391+
.takes_value(true)
392+
.help("Buffer size when reading input. This is present primarily for debugging purposes; it's possible that tuning this will help performance, but it should not be necessary"))
369393
.arg(Arg::new("arbitrary-shell")
370-
.about("")
371394
.short('A')
372395
.long("arbitrary-shell")
373-
.about("By default, strings that are passed to the shell via pipes or the 'system' function are restricted from potentially containing user input. This flag bypasses that check, for the cases where such a use is known to be safe.")
374-
.takes_value(false))
396+
.takes_value(false)
397+
.help("By default, strings that are passed to the shell via pipes or the 'system' function are restricted from potentially containing user input. This flag bypasses that check, for the cases where such a use is known to be safe"))
375398
.arg(Arg::new("jobs")
376-
.about("Number or worker threads to launch when executing in parallel, requires '-p' flag to be set. When using record-level parallelism, this value is an upper bound on the number of worker threads that will be spawned; the number of active worker threads is chosen dynamically.")
377-
.short('j')
378-
.requires("parallel-strategy")
379-
.takes_value(true));
399+
.short('j')
400+
.requires("parallel-strategy")
401+
.takes_value(true)
402+
.help("Number or worker threads to launch when executing in parallel, requires '-p' flag to be set. When using record-level parallelism, this value is an upper bound on the number of worker threads that will be spawned; the number of active worker threads is chosen dynamically"));
380403
cfg_if::cfg_if! {
381404
if #[cfg(feature = "llvm_backend")] {
382-
app = app.arg("--dump-llvm 'print LLVM-IR for the input program'");
405+
app = app.arg("--dump-llvm 'Print LLVM-IR for the input program'");
383406
}
384407
}
385408
let matches = app.get_matches();

src/runtime/str_impl.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,6 @@ impl Inline {
9393
)
9494
}
9595
}
96-
97-
#[inline(always)]
98-
fn itoa(i: Int) -> Option<Inline> {
99-
if i > 999999999999999 || i < -99999999999999 {
100-
return None;
101-
}
102-
let mut res = 0u128;
103-
let buf =
104-
unsafe { slice::from_raw_parts_mut((&mut res as *mut _ as *mut u8).offset(1), 15) };
105-
let len = itoa::write(buf, i).unwrap();
106-
Some(Inline(res | ((len << 3) | StrTag::Inline as usize) as u128))
107-
}
10896
}
10997

11098
#[derive(Clone)]
@@ -926,12 +914,9 @@ impl<'a> From<String> for Str<'a> {
926914

927915
impl<'a> From<Int> for Str<'a> {
928916
fn from(i: Int) -> Str<'a> {
929-
if let Some(i) = Inline::itoa(i) {
930-
return Str::from_rep(i.into());
931-
}
932-
let mut buf = [0u8; 21];
933-
let n = itoa::write(&mut buf[..], i).unwrap();
934-
Buf::read_from_bytes(&buf[..n]).into_str()
917+
let mut itoabuf = itoa::Buffer::new();
918+
let s = itoabuf.format(i);
919+
Buf::read_from_bytes(&s.as_bytes()).into_str()
935920
}
936921
}
937922

0 commit comments

Comments
 (0)