Memory backpressure: pause ingress when system RAM is high#3040
Closed
liquidsec wants to merge 7 commits into
Closed
Memory backpressure: pause ingress when system RAM is high#3040liquidsec wants to merge 7 commits into
liquidsec wants to merge 7 commits into
Conversation
Contributor
📊 Performance Benchmark Report
📈 Detailed Results (All Benchmarks)
🎯 Performance Summary! 2 regressions ⚠️
22 unchanged ✅🔍 Significant Changes (>10%)
🐍 Python Version 3.11.15 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## blasthttp-integration-clean #3040 +/- ##
============================================================
- Coverage 91% 91% -0%
============================================================
Files 443 443
Lines 37835 38368 +533
============================================================
+ Hits 34237 34691 +454
- Misses 3598 3677 +79 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
liquidsec
marked this pull request as draft
April 16, 2026 05:22
Collaborator
Author
|
still testing this out |
Collaborator
Author
|
closing in favor of a scaled down version of this implemented in #3085 |
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.
Summary
Despite the improvements to memory use added in 38db27e (refcount-based HTTP response body stripping), BBOT scans are still ultimately unbounded when it comes to memory, and CAN fill up the entire volume of system memory in some cases. To address that reality, this PR creates a memory backpressure system, which will pause ingress of new events once memory passes a threshold. This gives existing events time to finish processing and have their heavy payloads (HTTP response bodies, headers, etc.) stripped via
_minimize(), freeing memory before more work piles on.How it works
modules_status()tick (every 15s) already checked memory and logged a warning — but did nothing. Now it acts on it.asyncio.Event(_memory_ok) is set by default (= proceed). When system memory exceedsmax_mem_percent(default 90%), the event is cleared, which pausesScanIngress.get_incoming_event()— the single chokepoint where new events enter the pipeline._minimize()on finished events, which is what actually frees memory.Config
One new setting:
max_mem_percent(default90). Can be overridden via CLI:Files changed
bbot/scanner/scanner.py—_memory_okevent, pause/resume/force-resume logic inmodules_status()bbot/scanner/manager.py—await _memory_okinScanIngress.get_incoming_event()bbot/defaults.yml+docs/scanning/configuration.md— newmax_mem_percentsettingbbot/test/test_step_1/test_scan.py— tests for all state transitions (pause, stay paused in gap, resume, force-resume)