Skip to content

Commit

Permalink
Update CI and benchmark/test features.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh committed Sep 8, 2024
1 parent 27ab657 commit 71271b2
Show file tree
Hide file tree
Showing 37 changed files with 150 additions and 98 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/Comprehensive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- run: ci/comprehensive.sh
- run: ALL_FEATURES=1 ci/comprehensive.sh
10 changes: 4 additions & 6 deletions .github/workflows/Cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ jobs:
- x86_64-pc-windows-gnu

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{matrix.target}}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
Expand Down Expand Up @@ -77,12 +76,11 @@ jobs:
- x86_64-unknown-netbsd

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{matrix.target}}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/Features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- run: ci/test.sh
- run: NIGHTLY=1 NO_STD=1 ci/test.sh
5 changes: 2 additions & 3 deletions .github/workflows/OSX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ jobs:
- x86_64-apple-darwin

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{matrix.target}}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
Expand Down
25 changes: 21 additions & 4 deletions .github/workflows/Simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,35 @@ on:
[push, pull_request, workflow_dispatch]

jobs:
build:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [1.63.0]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{matrix.rust}}
- run: cargo check
- run: cargo build

test:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [1.51.0, stable, beta, nightly]
rust: [1.65.0, stable, beta, nightly]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@master
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{matrix.rust}}
- run: cargo check
Expand All @@ -28,7 +45,7 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/Valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
- run: sudo apt-get update
- run: sudo apt-get install valgrind
- run: cargo +nightly install cargo-valgrind
Expand Down
2 changes: 1 addition & 1 deletion ci/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -ex

# Change to our project home.
script_dir=`dirname "${BASH_SOURCE[0]}"`
script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "$script_dir"/..

scripts/check.sh
Expand Down
5 changes: 3 additions & 2 deletions ci/comprehensive.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# shellcheck disable=SC2086,SC2236
# Run a small subset of our comprehensive test suite.

set -ex
Expand All @@ -7,8 +8,8 @@ set -ex
cargo --version

# Change to our project home.
script_dir=`dirname "${BASH_SOURCE[0]}"`
script_home=`realpath "$script_dir"`
script_dir=$(dirname "${BASH_SOURCE[0]}")
script_home=$(realpath "$script_dir")
cd "$script_home"/..

FEATURES=
Expand Down
3 changes: 2 additions & 1 deletion ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
# shellcheck disable=SC2086,SC2236
# Run main test suite.

set -ex

# Change to our project home.
script_dir=`dirname "${BASH_SOURCE[0]}"`
script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "$script_dir"/..

# Print our cargo version, for debugging.
Expand Down
1 change: 1 addition & 0 deletions lexical-asm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub struct ParseIntError {
pub kind: IntErrorKind,
}

#[allow(dead_code)]
trait FromStrRadixHelper: PartialOrd + Copy {
fn min_value() -> Self;
fn max_value() -> Self;
Expand Down
10 changes: 7 additions & 3 deletions lexical-benchmark/algorithm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ default-features = false
features = []

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
fastrand = "1.4"
criterion = { version = "0.5.0", features = ["html_reports"] }
fastrand = "2.1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[features]
default = ["std", "integers"]
default = ["std", "integers", "floats", "json"]
std = ["lexical-util/std", "lexical-parse-float/std"]
integers = []
floats = []
json = []

[[bench]]
name = "bigint"
Expand Down
12 changes: 6 additions & 6 deletions lexical-benchmark/algorithm/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fn karatsuba_mul_algo(big: &mut bigint::Bigint, y: &[bigint::Limb]) {
// GENERATOR

#[inline(always)]
fn new_limb(rng: &Rng) -> bigint::Limb {
fn new_limb(rng: &mut Rng) -> bigint::Limb {
if bigint::LIMB_BITS == 32 {
rng.u32(..) as bigint::Limb
} else {
Expand All @@ -200,10 +200,10 @@ macro_rules! generator {
$group.bench_function($name, |bench| {
let mut big = bigint::Bigint::new();
let seed = fastrand::u64(..);
let rng = Rng::with_seed(seed);
let mut rng = Rng::with_seed(seed);
bench.iter(|| {
unsafe { big.data.set_len(0) };
big.data.try_push(new_limb(&rng)).unwrap();
big.data.try_push(new_limb(&mut rng)).unwrap();
// Don't go any higher than 300.
$cb(&mut big, rng.u32(1..300));
black_box(&big);
Expand All @@ -220,18 +220,18 @@ macro_rules! generator {
$group.bench_function($name, |bench| {
let mut big = bigint::Bigint::new();
let seed = fastrand::u64(..);
let rng = Rng::with_seed(seed);
let mut rng = Rng::with_seed(seed);
bench.iter(|| {
unsafe { big.data.set_len(0) };
// Don't go higher than 20, since we a minimum of 60 limbs.
let count = rng.usize(1..20);
for _ in 0..count {
big.data.try_push(new_limb(&rng)).unwrap();
big.data.try_push(new_limb(&mut rng)).unwrap();
}
let count = rng.usize(1..20);
let mut vec: Vec<bigint::Limb> = Vec::new();
for _ in 0..count {
vec.push(new_limb(&rng));
vec.push(new_limb(&mut rng));
}

// Don't go any higher than 300.
Expand Down
2 changes: 1 addition & 1 deletion lexical-benchmark/algorithm/division.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn fast_div(v: u32) -> (u32, u32) {
let max_precision = 14;
let additional_precision = 5;

let left_end = (((1 << (max_precision + additional_precision)) + divisor - 1) / divisor) as u32;
let left_end = ((1 << (max_precision + additional_precision)) + divisor - 1) / divisor;
let quotient = (v.wrapping_mul(left_end)) >> (max_precision + additional_precision);
let remainder = v - divisor * quotient;

Expand Down
11 changes: 4 additions & 7 deletions lexical-benchmark/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,12 @@ macro_rules! to_lexical_generator {

macro_rules! dtoa_generator {
($group:ident, $name:expr, $iter:expr) => {{
use lexical_util::constants::BUFFER_SIZE;
let mut buffer = vec![b'0'; BUFFER_SIZE];
let mut buffer = dtoa::Buffer::new();
$group.bench_function($name, |bench| {
bench.iter(|| {
$iter.for_each(|x| {
dtoa::write(&mut buffer, *x).unwrap();
dtoa::format(&mut buffer, *x).unwrap();
black_box(&buffer);
unsafe {
buffer.set_len(0);
} // Way faster than Vec::clear().
})
})
});
Expand Down Expand Up @@ -502,7 +498,8 @@ macro_rules! parse_integer_generator {
macro_rules! write_float_generator {
($group:ident, $type:expr, $iter:expr, $fmt:ident) => {{
to_lexical_generator!($group, concat!("write_", $type, "_lexical"), $iter);
dtoa_generator!($group, concat!("write_", $type, "_dtoa"), $iter);
// FIXME: Restore dtoa format later
//dtoa_generator!($group, concat!("write_", $type, "_dtoa"), $iter);
ryu_generator!($group, concat!("write_", $type, "_ryu"), $iter, $fmt);
fmt_generator!($group, concat!("write_", $type, "_fmt"), $iter);
}};
Expand Down
8 changes: 5 additions & 3 deletions lexical-benchmark/parse-float/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ default-features = false
features = []

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
fastrand = "1.4"
criterion = { version = "0.5", features = ["html_reports"] }
fastrand = "2.1.0"
lazy_static = "1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -30,7 +30,9 @@ power-of-two = ["lexical-util/power-of-two", "lexical-parse-float/power-of-two"]
format = ["lexical-util/format", "lexical-parse-float/format"]
compact = ["lexical-util/compact", "lexical-parse-float/compact"]
asm = []
floats = []
nightly = ["lexical-parse-float/nightly"]
integers = ["lexical-util/integers"]
floats = ["lexical-util/floats"]
json = []

[[bench]]
Expand Down
1 change: 1 addition & 0 deletions lexical-benchmark/parse-float/black_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub fn black_box(mut dummy: f64) -> f64 {

// Optimized black box using the nicer assembly syntax.
#[cfg(not(feature = "asm"))]
#[allow(forgetting_copy_types)]
pub fn black_box(dummy: f64) -> f64 {
unsafe {
let x = core::ptr::read_volatile(&dummy);
Expand Down
5 changes: 3 additions & 2 deletions lexical-benchmark/parse-integer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ default-features = false
features = []

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
fastrand = "1.4"
criterion = { version = "0.5.0", features = ["html_reports"] }
fastrand = "2.1.0"
lazy_static = "1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -30,6 +30,7 @@ power-of-two = ["lexical-util/power-of-two", "lexical-parse-integer/power-of-two
format = ["lexical-util/format", "lexical-parse-integer/format"]
compact = ["lexical-util/compact", "lexical-parse-integer/compact"]
integers = []
floats = []
json = []

[[bench]]
Expand Down
3 changes: 2 additions & 1 deletion lexical-benchmark/write-float/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ features = []
[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
dtoa = "1.0.9"
fastrand = "2.1.1"
fastrand = "2.1.0"
lazy_static = "1"
ryu = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -31,6 +31,7 @@ radix = ["lexical-util/radix", "lexical-write-float/radix"]
power-of-two = ["lexical-util/power-of-two", "lexical-write-float/power-of-two"]
format = ["lexical-util/format", "lexical-write-float/format"]
compact = ["lexical-util/compact", "lexical-write-float/compact"]
integers = []
floats = []
json = []

Expand Down
5 changes: 3 additions & 2 deletions lexical-benchmark/write-integer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ default-features = false
features = []

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
criterion = { version = "0.5.0", features = ["html_reports"] }
itoa = { version = "0.4", features = ["i128"] }
fastrand = "1.4"
fastrand = "2.1.0"
lazy_static = "1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -31,6 +31,7 @@ power-of-two = ["lexical-util/power-of-two", "lexical-write-integer/power-of-two
format = ["lexical-util/format", "lexical-write-integer/format"]
compact = ["lexical-util/compact", "lexical-write-integer/compact"]
integers = []
floats = []
json = []

[[bench]]
Expand Down
2 changes: 1 addition & 1 deletion lexical-parse-float/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static_assertions = "1"
# Issue: https://github.com/BurntSushi/quickcheck/issues/295
# Fix: https://github.com/BurntSushi/quickcheck/pull/296
quickcheck = { git = "https://github.com/neithernut/quickcheck/", branch = "i32min-shrink-bound" }
proptest = "1.5.0"
proptest = ">=1.5.0"

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion lexical-parse-integer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ features = ["parse-integers"]
# Issue: https://github.com/BurntSushi/quickcheck/issues/295
# Fix: https://github.com/BurntSushi/quickcheck/pull/296
quickcheck = { git = "https://github.com/neithernut/quickcheck/", branch = "i32min-shrink-bound" }
proptest = "1.5.0"
proptest = ">=1.5.0"

[features]
default = ["std"]
Expand Down
Loading

0 comments on commit 71271b2

Please sign in to comment.