Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 8 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
- simd
- check_x86
- aarch64
- msrv_x64
- msrv_aarch64
- msrv
- miri
- clippy_check
steps:
Expand All @@ -44,7 +43,7 @@ jobs:

runs-on: ${{ matrix.os }}
env:
CARGO_CFG_HTTPARSE_DISABLE_SIMD: 1
RUSTFLAGS: --cfg httparse_disable_simd

steps:
- name: Checkout
Expand Down Expand Up @@ -76,14 +75,10 @@ jobs:
- nightly

target_feature:
- "" # runtime detection
- "+sse4.2"
- "+avx2"
- "+sse4.2,+avx2"

disable_compiletime:
- 0
- 1

steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -96,7 +91,6 @@ jobs:
- name: Test
env:
RUSTFLAGS: -C target_feature=${{ matrix.target_feature }}
CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME: ${{ matrix.disable_compiletime }}
run: cargo test

check_x86:
Expand All @@ -113,48 +107,26 @@ jobs:

- name: Test without SIMD
env:
CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME: 1
RUSTFLAGS: --cfg httparse_disable_simd
run: cargo test --target i686-unknown-linux-musl

- name: Test
run: cargo test --target i686-unknown-linux-musl

msrv_x64:
name: msrv (x64)
msrv:
name: msrv
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Install Rust
uses: dtolnay/rust-toolchain@1.47.0
uses: dtolnay/rust-toolchain@1.59.0

# Only build, dev-dependencies don't compile on 1.47.0
# Only build, dev-dependencies don't compile on 1.59.0
- name: Build
run: cargo build

# This tests that aarch64 gracefully fallbacks to SWAR if neon_intrinsics aren't available (<1.59)
msrv_aarch64:
name: msrv (aarch64)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Install cross-compiling dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Setup Rust
uses: dtolnay/rust-toolchain@1.47.0
with:
target: aarch64-unknown-linux-gnu

# Only build, dev-dependencies don't compile on 1.47.0
- name: Build
run: cargo build --target aarch64-unknown-linux-gnu

clippy_check:
runs-on: ubuntu-latest
steps:
Expand Down
35 changes: 20 additions & 15 deletions .github/workflows/cibench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ on:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-C target-cpu=native"

jobs:
benchmark:
name: Run benchmarks
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C target-cpu=native"
steps:
- uses: actions/checkout@v5
with:
Expand Down Expand Up @@ -41,7 +42,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
feature: [swar, sse42, avx2]
include:
- feature: runtime
rustflags: ""
- feature: swar
rustflags: "--cfg httparse_disable_simd"
- feature: sse4.2
rustflags: "-C target-feature=+sse4.2"
- feature: avx2
rustflags: "-C target-feature=+avx2"
env:
RUSTFLAGS: ${{ matrix.rustflags }}
steps:
- uses: actions/checkout@v5
with:
Expand All @@ -57,17 +68,11 @@ jobs:
run: |
git checkout master
cargo bench --bench parse -- --save-baseline master-${{ matrix.feature }}
env:
CARGO_CFG_HTTPARSE_DISABLE_SIMD: ${{ matrix.feature == 'swar' && '1' || '0' }}
RUSTFLAGS: ${{ matrix.feature != 'swar' && format('-C target-feature=+{0}', matrix.feature) || '' }}

- name: Run benchmarks (PR)
run: |
git checkout ${{ github.event.pull_request.head.sha }}
cargo bench --bench parse -- --save-baseline pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-${{ matrix.feature }}
env:
CARGO_CFG_HTTPARSE_DISABLE_SIMD: ${{ matrix.feature == 'swar' && '1' || '0' }}
RUSTFLAGS: ${{ matrix.feature != 'swar' && format('-C target-feature=+{0}', matrix.feature) || '' }}

- name: Compare benchmarks
run: |
Expand All @@ -78,7 +83,13 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
feature: [swar, neon]
include:
- feature: swar
rustflags: "--cfg httparse_disable_simd"
- feature: neon
rustflags: "-C target-feature=+neon"
env:
RUSTFLAGS: ${{ matrix.rustflags }}
steps:
- uses: actions/checkout@v5
with:
Expand All @@ -94,17 +105,11 @@ jobs:
run: |
git checkout master
cargo bench --bench parse -- --save-baseline master-aarch64-${{ matrix.feature }}
env:
CARGO_CFG_HTTPARSE_DISABLE_SIMD: ${{ matrix.feature == 'swar' && '1' || '0' }}
RUSTFLAGS: ${{ matrix.feature == 'neon' && '-C target-feature=+neon' || '' }}

- name: Run benchmarks (PR)
run: |
git checkout ${{ github.event.pull_request.head.sha }}
cargo bench --bench parse -- --save-baseline pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-aarch64-${{ matrix.feature }}
env:
CARGO_CFG_HTTPARSE_DISABLE_SIMD: ${{ matrix.feature == 'swar' && '1' || '0' }}
RUSTFLAGS: ${{ matrix.feature == 'neon' && '-C target-feature=+neon' || '' }}

- name: Compare benchmarks
run: |
Expand Down
9 changes: 3 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ documentation = "https://docs.rs/httparse"
readme = "README.md"
keywords = ["http", "parser", "no_std"]
categories = ["network-programming", "no-std", "parser-implementations", "web-programming"]
edition = "2018"
build = "build.rs"
edition = "2021"
rust-version = "1.59"

[features]
default = ["std"]
Expand All @@ -34,8 +34,5 @@ opt-level = 3

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(httparse_simd)',
'cfg(httparse_simd_target_feature_avx2)',
'cfg(httparse_simd_target_feature_sse42)',
'cfg(httparse_simd_neon_intrinsics)',
'cfg(httparse_disable_simd)',
] }
133 changes: 0 additions & 133 deletions build.rs

This file was deleted.

1 change: 0 additions & 1 deletion clippy.toml

This file was deleted.

6 changes: 3 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ macro_rules! next {
}

macro_rules! expect {
($bytes:ident.next() == $pat:pat => $ret:expr) => {
($bytes:ident.next() == $pat:pat_param => $ret:expr) => {
expect!(next!($bytes) => $pat |? $ret)
};
($e:expr => $pat:pat |? $ret:expr) => {
($e:expr => $pat:pat_param |? $ret:expr) => {
match $e {
v@$pat => v,
_ => return $ret
Expand All @@ -31,7 +31,7 @@ macro_rules! complete {
}

macro_rules! byte_map {
($($p:pat)|+) => {{
($($p:pat_param)|+) => {{
const fn make_map() -> [bool; 256] {
let mut ret = [false; 256];
let mut i = 0;
Expand Down
Loading