Skip to content

Commit

Permalink
Update dependencies (#81)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ghuls committed Jan 15, 2022
1 parent d81eae3 commit f14797c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 71 deletions.
40 changes: 20 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ build = "build.rs"


[dependencies]
petgraph = "0.4.13"
smallvec = "1.6"
hashbrown = "0.9"
petgraph = "0.6"
smallvec = "1.7"
hashbrown = "0.11"
lazy_static = "1.4.0"
regex = "1.3"
regex-syntax = "0.6.22"
itoa = "0.4"
regex = "1.5"
regex-syntax = "0.6.25"
itoa = "1.0"
ryu = "1.0"
libc = "0.2"
jemallocator = { version = "0.3", optional = true }
rand = "0.8.3"
tikv-jemallocator = { version = "0.4", optional = true }
rand = "0.8.4"
lalrpop-util = "0.19.6"
unicode-xid = "0.2.0"
unicode-xid = "0.2.2"
llvm-sys = {version = "120", optional = true }
clap = "3.0.0-beta.4"
crossbeam-channel = "0.4"
crossbeam = "0.7.3"
num_cpus = "1.13.0"
cfg-if = "0.1"
clap = "3.0"
crossbeam-channel = "0.5"
crossbeam = "0.8.1"
num_cpus = "1.13.1"
cfg-if = "1.0"
memchr = "2.4"
grep-cli = "0.1"
termcolor = "1.1"
itertools = "0.9.0"
assert_cmd = "1.0.2"
itertools = "0.10"
assert_cmd = "2.0.3"
paste = "1.0"
cranelift = "0.75.0"
cranelift-codegen = "0.75.0"
Expand All @@ -46,16 +46,16 @@ cranelift-module = "0.75.0"
cranelift-jit = "0.75.0"
fast-float = "0.2"
bumpalo = { version = "3.6", features = ["collections"] }
target-lexicon = "0.12.1"
target-lexicon = "0.12.2"

[dev-dependencies]
assert_cmd = "1.0.2"
tempfile = "3.1.0"
assert_cmd = "2.0.3"
tempfile = "3.3"


[features]
default = ["use_jemalloc", "allow_avx2", "llvm_backend", "unstable"]
use_jemalloc = ["jemallocator"]
use_jemalloc = ["tikv-jemallocator"]
# Certain features leverage the AVX2 instruction set, but AVX2 can often make
# the entire application slightly slower, even on chips that support it. For
# those cases, consider disabling allow_avx2.
Expand Down
89 changes: 56 additions & 33 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use std::mem;

#[cfg(feature = "use_jemalloc")]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

macro_rules! fail {
($($t:tt)*) => {{
Expand Down Expand Up @@ -313,73 +313,96 @@ fn main() {
.long("program-file")
.short('f')
.takes_value(true)
.multiple_occurrences(true))
.multiple_occurrences(true)
.help("Read the program source from the file program-file, instead of from the command line. Multiple '-f' options may be used"))
.arg(Arg::new("opt-level")
.long("opt-level")
.short('O')
.about("the optimization level for the program. Positive levels determine the optimization level for LLVM. Level -1 forces bytecode interpretation")
.possible_values(&["0", "1", "2", "3"]))
.arg("--out-file=[FILE] 'the output file used in place of standard input'")
.arg("--utf8 'validate all input as UTF-8, returning an error if it is invalid'")
.arg("--dump-cfg 'print untyped SSA form for input program'")
.arg("--dump-bytecode 'print bytecode for input program'")
.takes_value(true)
.allow_hyphen_values(true)
.help("The optimization level for the program. Positive levels determine the optimization level for LLVM. Level `-1` forces bytecode interpretation")
.possible_values(&["-1", "0", "1", "2", "3"]))
.arg(Arg::new("out-file")
.long("out-file")
.takes_value(true)
.value_name("FILE")
.help("Write to specified output file instead of standard output"))
.arg(Arg::new("utf8")
.long("utf8")
.takes_value(false)
.help("Validate all input as UTF-8, returning an error if it is invalid"))
.arg(Arg::new("dump-cfg")
.long("dump-cfg")
.takes_value(false)
.help("Print untyped SSA form for input program"))
.arg(Arg::new("dump-bytecode")
.long("dump-bytecode")
.takes_value(false)
.help("Print bytecode for input program"))
.arg(Arg::new("parse-header")
.long("parse-header")
.short('H')
.takes_value(false)
.about("consume the first line of input and populate the `FI` variable with column names mapping to column indexes"))
.help("Consume the first line of input and populate the `FI` variable with column names mapping to column indexes"))
.arg(Arg::new("input-format")
.long("input-format")
.short('i')
.possible_values(&["csv", "tsv"])
.about("Input is split according to the rules of (csv|tsv). $0 contains the unescaped line. Assigning to columns does nothing."))
.value_name("csv|tsv")
.conflicts_with("field-separator")
.help("Input is split according to the rules of (csv|tsv). $0 contains the unescaped line. Assigning to columns does nothing")
.possible_values(&["csv", "tsv"]))
.arg(Arg::new("var")
.short('v')
.takes_value(true)
.multiple_occurrences(true)
.multiple_values(true)
.value_name("var=val")
.help("Assign the value <val> to the variable <var>, before execution of the frawk program begins. Multiple '-v' options may be used"))
.arg(Arg::new("field-separator")
.long("field-separator")
.short('F')
.takes_value(true)
.min_values(1)
.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."))
.arg("-F, --field-separator=[SEPARATOR] 'Field separator for frawk program.'")
.value_name("FS")
.conflicts_with("input-format")
.help("Field separator `FS` for frawk program"))
.arg(Arg::new("backend")
.long("backend")
.short('b')
.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")
.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")
.possible_values(&["interp", "cranelift", "llvm"]))
.arg(Arg::new("output-format")
.long("output-format")
.short('o')
.possible_values(&["csv", "tsv"])
.about("If set, records output via print are escaped according to the rules of the corresponding format"))
.value_name("csv|tsv")
.help("If set, records output via print are escaped according to the rules of the corresponding format")
.possible_values(&["csv", "tsv"]))
.arg(Arg::new("program")
.about("The frawk program to execute")
.index(1))
.index(1)
.help("The frawk program to execute"))
.arg(Arg::new("input-files")
.about("Input files to be read by frawk program")
.index(2)
.multiple_values(true))
.multiple_values(true)
.help("Input files to be read by frawk program"))
.arg(Arg::new("parallel-strategy")
.about("Attempt to execute the script in parallel. Strategy r[ecord] parallelizes within the current input file. Strategy f[ile] parallelizes between input files.")
.short('p')
.help("Attempt to execute the script in parallel. Strategy r[ecord] parallelizes within the current input file. Strategy f[ile] parallelizes between input files")
.possible_values(&["r", "record", "f", "file"]))
.arg(Arg::new("chunk-size")
.long("chunk-size")
.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.")
.takes_value(true))
.takes_value(true)
.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"))
.arg(Arg::new("arbitrary-shell")
.about("")
.short('A')
.long("arbitrary-shell")
.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.")
.takes_value(false))
.takes_value(false)
.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"))
.arg(Arg::new("jobs")
.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.")
.short('j')
.requires("parallel-strategy")
.takes_value(true));
.short('j')
.requires("parallel-strategy")
.takes_value(true)
.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"));
cfg_if::cfg_if! {
if #[cfg(feature = "llvm_backend")] {
app = app.arg("--dump-llvm 'print LLVM-IR for the input program'");
app = app.arg("--dump-llvm 'Print LLVM-IR for the input program'");
}
}
let matches = app.get_matches();
Expand Down
21 changes: 3 additions & 18 deletions src/runtime/str_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,6 @@ impl Inline {
)
}
}

#[inline(always)]
fn itoa(i: Int) -> Option<Inline> {
if i > 999999999999999 || i < -99999999999999 {
return None;
}
let mut res = 0u128;
let buf =
unsafe { slice::from_raw_parts_mut((&mut res as *mut _ as *mut u8).offset(1), 15) };
let len = itoa::write(buf, i).unwrap();
Some(Inline(res | ((len << 3) | StrTag::Inline as usize) as u128))
}
}

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

impl<'a> From<Int> for Str<'a> {
fn from(i: Int) -> Str<'a> {
if let Some(i) = Inline::itoa(i) {
return Str::from_rep(i.into());
}
let mut buf = [0u8; 21];
let n = itoa::write(&mut buf[..], i).unwrap();
Buf::read_from_bytes(&buf[..n]).into_str()
let mut itoabuf = itoa::Buffer::new();
let s = itoabuf.format(i);
Buf::read_from_bytes(&s.as_bytes()).into_str()
}
}

Expand Down

0 comments on commit f14797c

Please sign in to comment.