Batch kismet DB inserts into one transaction per drain #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "db-batch-writes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this PR does
Makes the kismet database writer (
src/database.rs) insert frames in batches, one transaction per batch, instead of committing every frame on its own.Why. On a Raspberry Pi 5 with an SD card, in a busy area (~600 radios in range), the per-frame commits topped out around 66 rows/s while about 220 frames/s arrived. Over a 17.5-minute capture the database held only the first 5.4 minutes of frames: it was 12 minutes behind when capture stopped, and the unbounded queue feeding it (with the frames' memory) kept growing for as long as capture ran. The pcapng writer kept up throughout.
Change.
BATCH_MAX= 2000, and inserts it in one transaction (write_batch). One commit per batch instead of per frame; under light load a batch is one frame, as before.stop(), frames still queued are written for at mostSTOP_FLUSH= 2 s, so a shutdown can't hang on a backlog and the last frames aren't lost.add_framereturns the insert'sResult; a frame that fails to insert is still skipped, and a failed commit drops that batch (as a failed insert dropped a frame before).Checks
cargo build --release --locked: builds; no warnings insrc/database.rs(the one warning in this crate,src/advancedtable/advtable.rs:659, is onmastertoo).cargo clippy --release --locked --all-targets: nothing insrc/database.rs.cargo test --release --locked: 4 passed (the 2 existing and the 2 new).Still to do before release
A hardware test: an hour of capture on a Pi in a busy area, watching rows/s written vs frames/s captured, the database's newest
ts_secvs wall clock (should stay within seconds), AngryOxide's memory (should stay flat) and a clean stop (no leftover.kismet-journal). Then tag a release so CI builds the aarch64-musl tarball, and bump Kestrel's pinned AngryOxide version (a reflash-class Kestrel release).🤖 Generated with Claude Code