Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simd int and string parsing on aarch64 #65

Merged
merged 36 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5c2d9cb
experiment with int parsing speedups
samuelcolvin Jan 20, 2024
a605ea0
fix tess
samuelcolvin Jan 20, 2024
486097e
tweak big int parsing
samuelcolvin Jan 20, 2024
d5679fa
simd int parsing on aarch64
samuelcolvin Jan 21, 2024
b09d73a
linting
samuelcolvin Jan 21, 2024
bf5cefa
test on macos-latest-xlarge
samuelcolvin Jan 22, 2024
e02f4fd
tweaks
samuelcolvin Jan 22, 2024
f4c00aa
fix ci
samuelcolvin Jan 22, 2024
ebbbc3d
separate simd_aarch64
samuelcolvin Jan 23, 2024
72b421a
simd string parsing for aarch64
samuelcolvin Jan 23, 2024
7e6d5b3
linting
samuelcolvin Jan 24, 2024
2272c41
fix ci
samuelcolvin Jan 26, 2024
58180c0
inlining
samuelcolvin Jan 26, 2024
79de565
simplify somewhat
samuelcolvin Jan 26, 2024
320bb78
more tests
samuelcolvin Jan 26, 2024
cc9a6b3
simplify logic after end of string
samuelcolvin Feb 4, 2024
8379b9d
tweaks
samuelcolvin Feb 4, 2024
dc09f12
bump
samuelcolvin Feb 4, 2024
fb5952c
improve non-ascii checks
samuelcolvin Feb 6, 2024
764c857
fuzz on aarch64
samuelcolvin Feb 6, 2024
a896baf
simplify short int parsing
samuelcolvin Feb 6, 2024
9f976d6
fix tests, address one comment
samuelcolvin Mar 28, 2024
c09ef8a
static ONGOING_CHUNK_SIZE
samuelcolvin Mar 28, 2024
6f386fc
fix benchmarks
samuelcolvin Mar 28, 2024
3aeb18a
fix comments
samuelcolvin Mar 28, 2024
47aba14
remove on_backslash macro
samuelcolvin Mar 28, 2024
37eb734
add cargo-careful
samuelcolvin Mar 28, 2024
5bda07f
without cargo cache
samuelcolvin Mar 28, 2024
c442f2f
fixes required by careful
samuelcolvin Mar 28, 2024
74ef054
bump rust cache
samuelcolvin Mar 28, 2024
4c6e06c
clarify ONGOING_CHUNK_MULTIPLIER
samuelcolvin Apr 1, 2024
195f97d
move comment
samuelcolvin Apr 1, 2024
0f8e3c0
NumberInt::try_from(&[u8])
samuelcolvin Apr 1, 2024
2ba4502
one more test
samuelcolvin Apr 1, 2024
328f357
update README
samuelcolvin Apr 1, 2024
fc7570a
Merge branch 'main' into int-simd
samuelcolvin Apr 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 69 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ on:
pull_request: {}

jobs:
test:
name: test rust-${{ matrix.rust-version }}
test-linux:
name: test rust-${{ matrix.rust-version }} on linux
strategy:
fail-fast: false
matrix:
rust-version: [stable, nightly]

runs-on: ubuntu-latest

env:
RUNS_ON: ubuntu-latest
RUST_VERSION: ${{ matrix.rust-version }}

steps:
- uses: actions/checkout@v3

Expand All @@ -30,6 +34,55 @@ jobs:
with:
toolchain: ${{ matrix.rust-version }}

- id: cache-rust
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust"

- run: cargo install rustfilt coverage-prepare cargo-careful
if: steps.cache-rust.outputs.cache-hit != 'true'

- run: rustup component add llvm-tools-preview

- run: cargo test -F python
env:
RUST_BACKTRACE: 1
RUSTFLAGS: '-C instrument-coverage'

- run: coverage-prepare --ignore-filename-regex '/tests/' lcov $(find target/debug/deps -regex '.*/main[^.]*')

- run: cargo test --doc

- run: cargo careful t -F python
if: matrix.rust-version == 'nightly'

- uses: codecov/codecov-action@v3
with:
env_vars: RUNS_ON,RUST_VERSION

test-macos:
name: test on ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [macos-latest, macos-latest-xlarge]

runs-on: ${{ matrix.runs-on }}

env:
RUNS_ON: ${{ matrix.runs-on }}
RUST_VERSION: stable

steps:
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- uses: dtolnay/rust-toolchain@stable

- id: cache-rust
uses: Swatinem/rust-cache@v2

Expand All @@ -48,13 +101,15 @@ jobs:
- run: cargo test --doc

- uses: codecov/codecov-action@v3
with:
env_vars: RUNS_ON,RUST_VERSION

bench:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
channel: stable
cache-target: release
Expand All @@ -70,11 +125,18 @@ jobs:
token: ${{ secrets.CODSPEED_TOKEN }}

fuzz:
runs-on: ubuntu-latest
name: fuzz on ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, macos-latest-xlarge]

runs-on: ${{ matrix.runs-on }}

steps:
- uses: actions/checkout@v3

- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
channel: nightly
cache-target: release
Expand All @@ -88,7 +150,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
channel: stable
components: rustfmt, clippy
Expand All @@ -105,7 +167,7 @@ jobs:
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [test, bench, fuzz, lint]
needs: [test-linux, test-macos, bench, fuzz, lint]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
4 changes: 4 additions & 0 deletions benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ test_cases!(medium_response);
test_cases!(x100);
test_cases!(sentence);
test_cases!(unicode);
test_cases!(short_numbers);

fn string_array_jiter_value_owned(bench: &mut Bencher) {
let json = read_file("./benches/string_array.json");
Expand Down Expand Up @@ -336,5 +337,8 @@ benchmark_group!(
lazy_map_lookup_1_10,
lazy_map_lookup_2_20,
lazy_map_lookup_3_50,
short_numbers_jiter_iter,
short_numbers_jiter_value,
short_numbers_serde_value,
);
benchmark_main!(benches);
5 changes: 5 additions & 0 deletions benches/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ fn _python_parse_file(path: &str, bench: &mut Bencher, cache_mode: StringCacheMo
})
}

fn python_parse_massive_ints_array(bench: &mut Bencher) {
_python_parse_file("./benches/massive_ints_array.json", bench, StringCacheMode::All);
}

fn python_parse_medium_response_not_cached(bench: &mut Bencher) {
_python_parse_file("./benches/medium_response.json", bench, StringCacheMode::None);
}
Expand Down Expand Up @@ -111,5 +115,6 @@ benchmark_group!(
python_parse_x100,
python_parse_true_object,
python_parse_true_array,
python_parse_massive_ints_array,
);
benchmark_main!(benches);
1 change: 1 addition & 0 deletions benches/short_numbers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942, 0, 142, 242, 342, 442, 542, 642, 742, 842, 942]
1 change: 0 additions & 1 deletion src/lazy_index_map.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::borrow::{Borrow, Cow};
use std::cmp::{Eq, PartialEq};
use std::fmt;
use std::hash::Hash;
use std::slice::Iter as SliceIter;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ mod parse;
mod py_string_cache;
#[cfg(feature = "python")]
mod python;
#[cfg(target_arch = "aarch64")]
mod simd_aarch64;
mod string_decoder;
mod value;

Expand Down
Loading
Loading