Repository navigation
Scale: 6x faster prefilter, batched ban storms, decider backpressure - #7
Merged
Merged
Conversation
Profiled with callgrind (40k flood lines: 38.0 -> 3.4 billion instructions): - signature results cached per field value (bit set of matched rules, tags rebuilt in rule order); values over 512 chars uncached, caches capped - near-known-bad: BK-tree distances bounded at MaxKid + allowance (exact wherever the search needs them), Levenshtein rows on the stack, results cached per path (capped) - clients, slow-scanner history and subnet heat in a hash map (Ban.Hash, open addressing, backward-shift delete) instead of sorted string lists - the Apache parser records token spans instead of building a string list; decode/unescape fast paths; the line time parsed once per second - summaries by concatenation, the log summary only for logged lines Every decision line is identical to main on the load files, all synthetic corpora and LogarX. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJFY41846T15QqxmGW2
…nt lists - Firewall commands run on their own thread (TActionWorker); bans queued meanwhile go in one ipset restore / nft -f / iptables-restore, a failed batch retried one by one. 2,000 instant bans: the next scanner was banned after 68-83 s, now 0.12 s, all 2,001 in the firewall within 0.17 s. - The state file is saved at most once a second, not on every ban. - decider_backlog (4): past it, new batches are decided by the rules at once and their clients go back to the model with their next flagged request. - Per-client lists created on first use: 500,000 clients in 486 MB, was 814. - Log writes locked (the action worker logs too); TStrMap randomized test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJFY41846T15QqxmGW2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I measured where jevban breaks at scale, then fixed the worst limits in order. For every CPU change, the gate was that each decision line stays identical to
main, not just the totals. I checked this with a-vdiff on the flood and typical load files, all the synthetic corpora, and LogarX. All identical.Prefilter: profiled with callgrind
On 40k flood lines, work dropped from 38.0 to 3.4 billion instructions.
mainmax_clients=500000What changed:
MaxKid + allowance, so they are still exact wherever the search needs them.Ban.Hash) instead of sorted string lists.Format.Ban storms: tested with real ipset, iptables and nftables
Before, each ban ran
/bin/shplus the firewall tool on the thread that reads the log, then rewrote the whole state file.mainHow:
ipset restore,nft -foriptables-restore. A failed batch is retried one address at a time, so every failure is still reported for its address.ufw,firewalld,netshand custom commands still run one per ban, but off the reading thread.Also checked:
Decider backpressure
A local model on a CPU takes minutes per batch, and nothing limited the worker's queue. New
decider_backlogsetting, default 4: beyond it, new batches are decided by the rules at once. Only real model verdicts are cached, so those clients go back to the model with their next flagged request.In a test with 300 password guessers at once and a mock decider taking 4 s per batch:
main: the last client was decided after 150 s. With Flash 9B on a CPU that would be about 1.5 hours.Not done
Unit tests: 153 checks, 0 failed. Three are new: a randomized 200k-operation check of the hash map against a sorted list, iteration, and clear. Iteration notes are in
bench/results/iter7-scale/README.md.Generated by Claude Code