edge-bench-rs: libdeflate for chunks, memchr for lines and tabs

libdeflate inflates a chunk whole, in half the time of zlib-rs (1.09 ->
0.51 s per boneless range); memchr finds line ends and tabs with SIMD.
The per-article timers are gone. Boneless 2026 ~700k headers/s, ath 2013
~920k; all three captures still identical to the TypeScript.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-09 09:34:38 +02:00
1 parent b1c2db5984
commit c7b4ebe470
4 files changed
+47 -25

No files matched your search

+7 -15
View File
@@ -195,9 +195,7 @@ impl Scanner {
let file = match self.files.get(self.key.as_str()) {
Some(f) => f.clone(),
None => {
let t = std::time::Instant::now();
let f = describe(subject, name_end, &counter, from, xref, group).map(Rc::new);
unsafe { PROF[0] += t.elapsed().as_nanos() as u64; PROF[1] += 1; }
self.files.insert(self.key.clone(), f.clone());
f
}
@@ -212,7 +210,7 @@ impl Scanner {
message_id: id.to_string(),
bytes: js::parse_int(bytes).unwrap_or(0),
article,
posted_at: { let t = std::time::Instant::now(); let d = js::parse_date(date); unsafe { PROF[2] += t.elapsed().as_nanos() as u64; } d },
posted_at: js::parse_date(date),
file,
})
}
@@ -244,20 +242,18 @@ fn scan_overview_text(text: &str, mut line: impl FnMut(Option<i64>, &str, &str,
let b = text.as_bytes();
let mut start = 0;
while start < b.len() {
let end = memchr(b'\n', &b[start..]).map(|i| i + start).unwrap_or(b.len());
let end = memchr::memchr(b'\n', &b[start..]).map(|i| i + start).unwrap_or(b.len());
let stop = if end > start && b[end - 1] == b'\r' { end - 1 } else { end };
if stop > start {
let l = &text[start..stop];
let lb = l.as_bytes();
let mut tabs = [usize::MAX; 9];
let mut n = 0;
for (i, &c) in lb.iter().enumerate() {
if c == b'\t' {
tabs[n] = i;
n += 1;
if n == 9 {
break;
}
for i in memchr::memchr_iter(b'\t', lb) {
tabs[n] = i;
n += 1;
if n == 9 {
break;
}
}
if n >= 5 {
@@ -279,10 +275,6 @@ fn scan_overview_text(text: &str, mut line: impl FnMut(Option<i64>, &str, &str,
}
}
fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
haystack.iter().position(|&c| c == needle)
}
struct OpenFile {
parts: Vec<Seg>,
seen: FxHashSet<u32>,