Skip to content

run compute_simhash and collapse_urls in the thread executor#3331

Open
liquidsec wants to merge 1 commit into
devfrom
simhash-cpu-executor
Open

run compute_simhash and collapse_urls in the thread executor#3331
liquidsec wants to merge 1 commit into
devfrom
simhash-cpu-executor

Conversation

@liquidsec

Copy link
Copy Markdown
Collaborator

Summary

  • waf_bypass submits compute_simhash on full HTTP response bodies through the process pool. xxhash releases the GIL and compute_simhash truncates its input to 3 KB internally, so the pickle-to-worker IPC dominates the actual work.
  • More importantly, when a worker submitted this way wedges, the only recovery is helper._reset_process_pool, which fires 300 s after the stall. On a real 14 h scan against a large target set this pattern was observed to stall the pipeline for the full timeout window before the reset recovered. bevigil.collapse_urls was on the same pattern at smaller scale.
  • Neither operation needs process isolation. Both move to run_in_executor_cpu (the thread pool). kreuzberg PDF extraction and badsecrets stay on run_in_executor_mp -- crash isolation from adversarial input is the point there.

Changes

  • bbot/modules/waf_bypass.py: two run_in_executor_mp(compute_simhash, ...) sites moved to run_in_executor_cpu
  • bbot/modules/bevigil.py: run_in_executor_mp(collapse_urls, ...) moved to run_in_executor_cpu

waf_bypass was submitting compute_simhash on full response bodies
through the process pool. xxhash releases the GIL and simhash truncates
its input to 3 KB internally, so the pickle-to-worker cost dominated
the actual work, and any wedged worker could stall the whole scan for
300 s before helper._reset_process_pool recovered. bevigil.collapse_urls
had the same profile at smaller scale.

Neither operation needs process isolation. Move both to
run_in_executor_cpu so a hung callable can no longer trigger a pool
reset. Kreuzberg PDF extraction and badsecrets retain run_in_executor_mp
where crash isolation is load-bearing.
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Report

Comparing dev (baseline) vs simhash-cpu-executor (current)

📈 Detailed Results (All Benchmarks)

📋 Complete results for all benchmarks - includes both significant and insignificant changes

🧪 Test Name 📏 Base 📏 Current 📈 Change 🎯 Status
Bloom Filter Dns Mutation Tracking Performance 4.34ms 4.43ms +2.1%
Bloom Filter Large Scale Dns Brute Force 17.90ms 18.91ms +5.7%
Large Closest Match Lookup 369.30ms 369.11ms -0.1%
Realistic Closest Match Workload 195.58ms 194.34ms -0.6%
Event Memory Medium Scan 1402 B/event 1402 B/event +0.0%
Event Memory Large Scan 1527 B/event 1527 B/event +0.0%
Event Validation Full Scan Startup Small Batch 410.45ms 405.62ms -1.2%
Event Validation Full Scan Startup Large Batch 549.71ms 546.59ms -0.6%
Make Event Autodetection Small 26.26ms 26.33ms +0.3%
Make Event Autodetection Large 271.82ms 270.11ms -0.6%
Make Event Explicit Types 11.86ms 11.86ms -0.0%
Excavate Single Thread Small 4.425s 4.335s -2.0%
Excavate Single Thread Large 10.069s 10.103s +0.3%
Excavate Parallel Tasks Small 4.621s 4.513s -2.3%
Excavate Parallel Tasks Large 6.657s 6.677s +0.3%
Intercept Throughput Small 881.05ms 889.13ms +0.9%
Intercept Throughput Medium 970.32ms 984.13ms +1.4%
Dns Throughput Quiet 2.852s 2.851s -0.0%
Dns Throughput Loaded 2.020s 2.020s +0.0%
Dns Throughput Inherited 2.379s 2.458s +3.3%
Is Ip Performance 2.30ms 2.32ms +0.7%
Make Ip Type Performance 248.79µs 244.81µs -1.6%
Mixed Ip Operations 2.43ms 2.44ms +0.3%
Memory Use Web Crawl 1.0 MB 1.0 MB +1.0%
Memory Use Subdomain Enum 28.3 MB 28.3 MB +0.0%
Memory Use Deep Chain 5.0 MB 5.0 MB +0.0%
Memory Use Parallel Chains 14.3 MB 12.7 MB -11.1% 🟢🟢 🚀
Scan Throughput 100 2.937s 3.091s +5.3%
Scan Throughput 1000 22.634s 23.688s +4.7%
Typical Queue Shuffle 5.44µs 5.40µs -0.8%
Priority Queue Shuffle 26.51µs 26.13µs -1.4%

🎯 Performance Summary

+ 1 improvement 🚀
  30 unchanged ✅

🔍 Significant Changes (>10%)

  • Memory Use Parallel Chains: 11.1% 🚀 less memory

🐍 Python Version 3.11.15

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90%. Comparing base (3cf28a4) to head (aff3a5d).
⚠️ Report is 6 commits behind head on dev.

Additional details and impacted files
@@          Coverage Diff          @@
##             dev   #3331   +/-   ##
=====================================
- Coverage     90%     90%   -0%     
=====================================
  Files        450     450           
  Lines      46285   46285           
=====================================
- Hits       41547   41537   -10     
- Misses      4738    4748   +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@liquidsec

Copy link
Copy Markdown
Collaborator Author

#3329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant