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 a3ce796
Show file tree
Hide file tree
Showing 48 changed files with 177 additions and 123 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
27 changes: 14 additions & 13 deletions .github/workflows/Cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Cross
on:
[pull_request, workflow_dispatch]

# NOTE: Use older toolchains since there's bugs cross-compiling
# for some more recent architectures.
jobs:
cross:
name: Rust ${{matrix.target}}
Expand All @@ -24,26 +26,26 @@ jobs:
- armv7-unknown-linux-gnueabihf
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- mips-unknown-linux-gnu
- mips64-unknown-linux-gnuabi64
- mips64el-unknown-linux-gnuabi64
- mipsel-unknown-linux-gnu
#- mips-unknown-linux-gnu
#- mips64-unknown-linux-gnuabi64
#- mips64el-unknown-linux-gnuabi64
#- mipsel-unknown-linux-gnu
# NOTE: This fails on cross v0.2.1, which is unusual since
# manually invoking the failing tests with qemu-5.1.0 passes.
#- powerpc64le-unknown-linux-gnu
- x86_64-unknown-linux-gnu
# NOTE: This has glibc linker issues. Restore later.
#- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl

# Windows
- 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
toolchain: 1.65.0
target: ${{matrix.target}}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
Expand Down Expand Up @@ -77,12 +79,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
toolchain: 1.65.0
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
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Updated the MSRV to 1.63.0 (1.65.0 for development).

### Removed
- Support for mips (MIPS), mipsel (MIPS LE), mips64 (MIPS64 BE), and mips64el (MIPS64 LE) on Linux.

## [0.8.5] 2022-06-06
### Changed
- Fixed the partial integer parser to correctly return negative values if parsing partial input.
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@ lexical-core is tested on a wide variety of platforms, including big and small-e
- aarch64 (ARM8v8-A) Linux, Android, and iOS.
- armv7 (ARMv7-A) Linux, Android, and iOS.
- arm (ARMv6) Linux, and Android.
- mips (MIPS) Linux.
- mipsel (MIPS LE) Linux.
- mips64 (MIPS64 BE) Linux.
- mips64el (MIPS64 LE) Linux.
- powerpc (PowerPC) Linux.
- powerpc64 (PPC64) Linux.
- powerpc64le (PPC64LE) Linux.
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
4 changes: 2 additions & 2 deletions docs/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ In addition, the following non-Rust dependencies must be installed:

# Development Process

The [scripts](https://github.com/Alexhuszagh/rust-lexical/tree/main/scripts) directory contains numerous scripts for testing, fuzzing, analyzing, and formatting code. Since many development features are nightly-only, this ensures the proper compiler features are used. This requires a recent version of a nightly compiler (1.51.0+) installed via Rustup, which can be invoked as `cargo +nightly`.
The [scripts](https://github.com/Alexhuszagh/rust-lexical/tree/main/scripts) directory contains numerous scripts for testing, fuzzing, analyzing, and formatting code. Since many development features are nightly-only, this ensures the proper compiler features are used. This requires a recent version of a nightly compiler (1.65.0+) installed via Rustup, which can be invoked as `cargo +nightly`.

- [asm.sh](https://github.com/Alexhuszagh/rust-lexical/blob/main/scripts/asm.sh): Emit assembly for numeric conversion routines, to identify performance regression.
- [bench.sh](https://github.com/Alexhuszagh/rust-lexical/blob/main/scripts/bench.sh): Check the benchmarks compile and run.
Expand All @@ -82,7 +82,7 @@ All PRs must pass the following checks:
RUSTFLAGS="--deny warnings" cargo +nightly build --features=lint
# Ensure all rustfmt and clippy checks pass.
scripts/check.sh
# Ensure all tests pass with common feature combinations.
# Ensure all tests pass with common feature combinations.
# Miri is too slow, so skip those tests for most commits.
SKIP_MIRI=1 scripts/test.sh
```
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
12 changes: 8 additions & 4 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 = []
integers = ["lexical-util/integers"]
floats = ["lexical-util/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
Loading

0 comments on commit a3ce796

Please sign in to comment.