Skip to content

Commit ddd9719

Browse files
authored
feat: enhance parsers with validation, performance, and safety improvements
chore: bump version to 0.2.4 fix: skip consecutive invalid bytes and file size validation feat: parser shutdown handling and message count estimation feat: validation in parsers and concurrent components feat: unchecked read methods enhance: memcpy_nontemporal with alignment check feat: Direct Listing (O) message support fix: prevent integer overflow in ZeroCopyParser fix: replace swap_bytes with to_be feat: message type validation in ZeroCopyParser feat: input availability tracking to SpscParser refactor: replaced atomic status with OnceLock fix: prevent data loss in compact_buffer refactor: remove manual padding refactor: safe pointer arithmetic in zerocopy_types refactor: Default derive for ParserBuilder perf: cache SIMD level at startup refactor: replace manual byte search with memchr refactor: reorder tempfile dependency refactor: error handling in SpscParser, ParallelParser, and WorkStealingParser refactor: remove duplicated WorkUnit slice extraction refactor: simplify work unit handling refactor: remove UTF-8 validation in hot path
2 parents 725f4a3 + 9a15665 commit ddd9719

21 files changed

Lines changed: 792 additions & 343 deletions

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lunary"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
authors = ["Lunyn <contact@lunyn.com>"]
55
edition = "2024"
66
license = "AGPL-3.0-or-later"
@@ -27,7 +27,6 @@ crossbeam-channel = "0.5"
2727
crossbeam-utils = "0.8"
2828
crossbeam-deque = "0.8"
2929
core_affinity = { version = "0.8", optional = true }
30-
tempfile = "3.23.0"
3130
zerocopy = { version = "0.8", features = ["derive"] }
3231
memchr = "2.7"
3332
clap = "4.0"
@@ -43,6 +42,7 @@ mimalloc = { version = "0.1", optional = true }
4342
criterion = { version = "0.5", default-features = false }
4443
arbitrary = "1"
4544
libfuzzer-sys = "0.4"
45+
tempfile = "3.23.0"
4646

4747
[features]
4848
default = ["simd"]

src/bench/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ pub fn run_feature_comparison(data: &[u8]) -> Result<()> {
288288
}
289289
}
290290
let parallel_time = t0.elapsed();
291-
parser.shutdown();
291+
let _ = parser.shutdown();
292292
let parallel_mps = parallel_count as f64 / parallel_time.as_secs_f64() / 1_000_000.0;
293293

294294
println!(

src/bench/parallel.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ pub fn bench_worksteal(data: &[u8]) -> Result<(u64, f64, f64)> {
5151
let chunks = split_into_chunks(data, chunk_size);
5252

5353
for (start, end) in &chunks {
54-
parser.submit_arc(Arc::clone(&data_arc), *start, *end);
54+
parser
55+
.submit_arc(Arc::clone(&data_arc), *start, *end)
56+
.unwrap();
5557
}
5658

5759
let mut total_messages = 0;
@@ -62,7 +64,7 @@ pub fn bench_worksteal(data: &[u8]) -> Result<(u64, f64, f64)> {
6264
}
6365

6466
let wall = t0.elapsed();
65-
parser.shutdown();
67+
let _ = parser.shutdown();
6668

6769
let (elapsed_ms, mps) = calculate_throughput(total_messages as u64, wall);
6870
Ok((total_messages as u64, elapsed_ms, mps))
@@ -206,7 +208,7 @@ pub fn run_worksteal(data: &[u8]) -> Result<()> {
206208
stats.errors()
207209
);
208210

209-
parser.shutdown();
211+
let _ = parser.shutdown();
210212
Ok(())
211213
}
212214

@@ -353,6 +355,6 @@ pub fn run_worker_stats(data: &[u8]) -> Result<()> {
353355
println!("Load balance: {:.1}% (100% = perfect)", balance);
354356
}
355357

356-
parser.shutdown();
358+
let _ = parser.shutdown();
357359
Ok(())
358360
}

src/bench/single.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,5 +238,6 @@ fn get_message_type_name(msg: &Message) -> &'static str {
238238
Message::NetOrderImbalance(_) => "NetOrderImbalance",
239239
Message::RetailPriceImprovement(_) => "RetailPriceImprovement",
240240
Message::LuldAuctionCollar(_) => "LuldAuctionCollar",
241+
Message::DirectListing(_) => "DirectListing",
241242
}
242243
}

src/builder.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl Default for ParserConfig {
5151
}
5252
}
5353

54+
#[derive(Default)]
5455
pub struct ParserBuilder {
5556
config: ParserConfig,
5657
}
@@ -198,12 +199,6 @@ impl ParserBuilder {
198199
}
199200
}
200201

201-
impl Default for ParserBuilder {
202-
fn default() -> Self {
203-
Self::new()
204-
}
205-
}
206-
207202
pub enum AnyParser<'a> {
208203
Simple(Box<Parser>),
209204
Batch(Box<BatchProcessor>),

0 commit comments

Comments
 (0)