Skip to content

Commit fa4bdbf

Browse files
committed
Merge branch 'main' of https://github.com/Ygg01/simd-json
2 parents 8a88c7f + dfaa68b commit fa4bdbf

14 files changed

Lines changed: 48 additions & 41 deletions

File tree

.github/workflows/pr-perf.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ jobs:
55
name: run benchmark
66
runs-on: ubuntu-latest
77
permissions:
8-
contents: write
9-
pull-requests: write
10-
repository-projects: write
8+
contents: write
9+
pull-requests: write
10+
repository-projects: write
1111
steps:
1212
- uses: actions/checkout@v3
13+
14+
- name: Check Rust Version
15+
run: rustc --version
16+
1317
- uses: boa-dev/criterion-compare-action@v3 # https://github.com/marketplace/actions/criterion-compare-prs
1418
env:
15-
RUSTFLAGS: "-C target-cpu=native"
19+
RUSTFLAGS: "-C target-cpu=native"
1620
with:
1721
# Optional. Compare only this benchmark target
1822
benchName: "to_tape"
1923
features: "bench-all"
2024
# Needed. The name of the branch to compare with. This default uses the branch which is being pulled against
21-
branchName: ${{ github.base_ref }}
25+
branchName: ${{ github.base_ref }}

.github/workflows/quality.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v3
2020

21-
- uses: dtolnay/rust-toolchain@1.85 # do clippy chekcs with the minimum supported version
21+
- uses: dtolnay/rust-toolchain@1.88 # do clippy chekcs with the minimum supported version
2222
with:
2323
components: rustfmt, clippy
2424

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626

27-
- uses: dtolnay/rust-toolchain@1.85
27+
- uses: dtolnay/rust-toolchain@1.88
2828
with:
2929
components: llvm-tools-preview
3030

@@ -120,7 +120,7 @@ jobs:
120120
steps:
121121
- uses: actions/checkout@v3
122122

123-
- uses: dtolnay/rust-toolchain@1.85
123+
- uses: dtolnay/rust-toolchain@1.88
124124
with:
125125
targets: wasm32-wasip1
126126

Cargo.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "simd-json"
3-
version = "0.15.1"
3+
version = "0.16.0"
44
authors = ["Heinz N. Gies <heinz@licenser.net>", "Sunny Gleason"]
55
edition = "2024"
66
exclude = ["data/*", "fuzz/*"]
@@ -9,10 +9,7 @@ description = "High performance JSON parser based on a port of simdjson"
99
repository = "https://github.com/simd-lite/simd-json"
1010
readme = "README.md"
1111
documentation = "https://docs.rs/simd-json"
12-
rust-version = "1.85"
13-
14-
[target.'cfg(target_family = "wasm")'.dependencies]
15-
getrandom = { version = "0.3", features = ["wasm_js"] }
12+
rust-version = "1.88"
1613

1714
[dependencies]
1815
simdutf8 = { version = "0.1.4", features = ["public_imp", "aarch64_neon"] }
@@ -33,6 +30,8 @@ alloc_counter = { version = "0.0.4", optional = true }
3330
colored = { version = "3.0", optional = true }
3431
getopts = { version = "0.2", optional = true }
3532
jemallocator = { version = "0.5", optional = true }
33+
34+
[target.'cfg(target_arch = "x86_64")'.dependencies]
3635
perfcnt = { version = "0.8", optional = true }
3736

3837
ref-cast = "1.0"
@@ -44,7 +43,7 @@ core_affinity = { version = "0.8" }
4443

4544

4645
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
47-
criterion = { version = "0.5" }
46+
criterion = { version = "0.7" }
4847
proptest = "1.0"
4948

5049
[lib]

examples/perf.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::env;
22

3-
#[cfg(feature = "perf")]
3+
#[cfg(all(feature = "perf", target_arch = "x86_64", target_os = "linux"))]
44
mod int {
55
const ROUNDS: usize = 2000;
66
const WARMUP: usize = 200;
@@ -216,10 +216,14 @@ mod int {
216216
}
217217
}
218218

219-
#[cfg(not(feature = "perf"))]
219+
#[cfg(not(all(feature = "perf", target_arch = "x86_64", target_os = "linux")))]
220220
mod int {
221221
pub fn bench(_name: &str, _baseline: bool) {
222-
println!("Perf requires linux to run and the perf feature to be enabled")
222+
if std::env::consts::ARCH != "x86_64" {
223+
println!("This Perf example only supports x86_64 for now.");
224+
} else if std::env::consts::OS != "linux" {
225+
println!("Perf requires linux to run and the perf feature to be enabled");
226+
}
223227
}
224228
}
225229

src/error.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ pub struct Error {
158158
/// Current character
159159
character: Option<char>,
160160
/// Type of error
161-
error: ErrorType,
161+
err_type: ErrorType,
162162
}
163163

164164
impl Error {
165-
pub(crate) fn new(index: usize, character: Option<char>, error: ErrorType) -> Self {
165+
pub(crate) fn new(index: usize, character: Option<char>, err_type: ErrorType) -> Self {
166166
Self {
167167
index,
168168
character,
169-
error,
169+
err_type,
170170
}
171171
}
172172
pub(crate) fn new_c(index: usize, character: char, error: ErrorType) -> Self {
@@ -179,7 +179,7 @@ impl Error {
179179
Self {
180180
index: 0,
181181
character: None,
182-
error: t,
182+
err_type: t,
183183
}
184184
}
185185

@@ -198,7 +198,7 @@ impl Error {
198198
/// Returns the type of error that occurred.
199199
#[must_use]
200200
pub fn error(&self) -> &ErrorType {
201-
&self.error
201+
&self.err_type
202202
}
203203

204204
// These make it a bit easier to fit into a serde_json context
@@ -209,7 +209,7 @@ impl Error {
209209
#[must_use]
210210
pub fn is_io(&self) -> bool {
211211
// We have to include InternalError _somewhere_
212-
match &self.error {
212+
match &self.err_type {
213213
ErrorType::Io(_) | ErrorType::InputTooLarge => true,
214214
ErrorType::InternalError(e) if !matches!(e, crate::InternalError::TapeError) => true,
215215
_ => false,
@@ -219,7 +219,7 @@ impl Error {
219219
/// Indicates if the error that occurred was an early EOF
220220
#[must_use]
221221
pub fn is_eof(&self) -> bool {
222-
matches!(self.error, ErrorType::Eof)
222+
matches!(self.err_type, ErrorType::Eof)
223223
}
224224

225225
/// Indicates if the error that occurred was due to a data shape error
@@ -234,7 +234,7 @@ impl Error {
234234
pub fn is_syntax(&self) -> bool {
235235
// Lazy? maybe but if it aint something else...
236236
matches!(
237-
self.error,
237+
self.err_type,
238238
ErrorType::InternalError(crate::InternalError::TapeError) | //This seems to get thrown on some syntax errors
239239
ErrorType::BadKeyType |
240240
ErrorType::ExpectedArrayComma |
@@ -268,9 +268,9 @@ impl std::error::Error for Error {}
268268
impl fmt::Display for Error {
269269
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
270270
if let Some(c) = self.character {
271-
write!(f, "{:?} at character {} ('{c}')", self.error, self.index)
271+
write!(f, "{:?} at character {} ('{c}')", self.err_type, self.index)
272272
} else {
273-
write!(f, "{:?} at character {}", self.error, self.index)
273+
write!(f, "{:?} at character {}", self.err_type, self.index)
274274
}
275275
}
276276
}

src/impls/avx2/deser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub(crate) unsafe fn parse_str<'invoke, 'de>(
157157

158158
if o == 0 {
159159
return Err(Deserializer::error_c(src_i, 'u', InvalidUnicodeCodepoint));
160-
};
160+
}
161161
// We moved o steps forward at the destination and 6 on the source
162162
src_i += s;
163163
dst_i += o;

src/impls/native/stage1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl Stage1Parse for SimdInput {
445445
base.reserve(64);
446446
let final_len = l + cnt;
447447

448-
let is_unaligned = l % 4 != 0;
448+
let is_unaligned = !l.is_multiple_of(4);
449449
let write_fn = if is_unaligned {
450450
std::ptr::write_unaligned
451451
} else {

src/impls/sse42/deser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub(crate) unsafe fn parse_str<'invoke, 'de>(
148148
};
149149
if o == 0 {
150150
return Err(Deserializer::error_c(src_i, 'u', InvalidUnicodeCodepoint));
151-
};
151+
}
152152
// We moved o steps forward at the destination and 6 on the source
153153
src_i += s;
154154
dst_i += o;

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
)]
1212
#![allow(
1313
clippy::module_name_repetitions,
14-
unused_unsafe // for nightly
14+
unused_unsafe, // for nightly
1515
)]
1616
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
1717

@@ -123,7 +123,7 @@ impl Buffers {
123123
///
124124
/// Will return `Err` if `s` is invalid JSON.
125125
#[cfg_attr(not(feature = "no-inline"), inline)]
126-
pub fn to_tape(s: &mut [u8]) -> Result<Tape> {
126+
pub fn to_tape(s: &mut [u8]) -> Result<Tape<'_>> {
127127
Deserializer::from_slice(s).map(Deserializer::into_tape)
128128
}
129129

@@ -916,7 +916,7 @@ impl<'de> Deserializer<'de> {
916916
// expensive carryless multiply in the previous step with this work
917917
let mut structurals: u64 = 0;
918918

919-
let lenminus64: usize = if len < 64 { 0 } else { len - 64 };
919+
let lenminus64: usize = len.saturating_sub(64);
920920
let mut idx: usize = 0;
921921
let mut error_mask: u64 = 0; // for unescaped characters within strings (ASCII code points < 0x20)
922922

0 commit comments

Comments
 (0)