Skip to content

⚡ Bolt: Parallelize rule pushing and deduplicate hostnames#107

Merged
abhimehro merged 1 commit intomainfrom
bolt-push-rules-optimization-2918633131029543303
Jan 18, 2026
Merged

⚡ Bolt: Parallelize rule pushing and deduplicate hostnames#107
abhimehro merged 1 commit intomainfrom
bolt-push-rules-optimization-2918633131029543303

Conversation

@google-labs-jules
Copy link

💡 What:

  1. Parallel Batch Processing: Updated push_rules to send batches of rules to the API in parallel using concurrent.futures.ThreadPoolExecutor with 3 workers.
  2. Deduplication: Added logic to remove duplicate hostnames from the input list before processing, ensuring we don't waste API calls on duplicates.

🎯 Why:
The previous implementation pushed rule batches sequentially. For large blocklists, this meant the script spent most of its time waiting for API responses. By parallelizing the batches, we can utilize the network more efficiently. Deduplication further reduces the payload size.

📊 Impact:

  • Speed: Benchmarks with simulated 100ms latency showed a ~50% reduction in execution time (2x speedup) for pushing 2000 rules (4 batches).
  • Efficiency: Prevents sending duplicate rules within the same folder push.

🔬 Measurement:
Verified using a local benchmark script (benchmark_push_rules.py) mocking the httpx client with simulated latency.
Baseline (Sequential): ~0.40s
Optimized (Parallel): ~0.21s
Verified functionality using python3 main.py --help to ensure no import errors.


PR created automatically by Jules for task 2918633131029543303 started by @abhimehro

Parallelize batch pushing in `push_rules` using `ThreadPoolExecutor` (3 workers) to reduce I/O wait time.
Add hostname deduplication to prevent sending duplicate rules to the API.

Benchmarks show ~2x speedup for rule pushing (from ~0.4s to ~0.2s for 2000 rules with 100ms latency).
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@trunk-io
Copy link

trunk-io bot commented Jan 16, 2026

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

if future.result():
successful_batches += 1

if successful_batches == total_batches:

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
for i, start in enumerate(range(0, len(filtered_hostnames), BATCH_SIZE), 1):
batch = filtered_hostnames[start : start + BATCH_SIZE]
# Prepare batches
batches = []

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "h" doesn't conform to snake_case naming style Warning

Variable name "h" doesn't conform to snake_case naming style
sanitize_for_log(folder_name), i, len(batch)
sanitize_for_log(folder_name), batch_idx, len(batch_data)
)
successful_batches += 1

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning

Missing function docstring
if future.result():
successful_batches += 1

if successful_batches == total_batches:

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (124/100) Warning

Line too long (124/100)
for i, start in enumerate(range(0, len(filtered_hostnames), BATCH_SIZE), 1):
batch = filtered_hostnames[start : start + BATCH_SIZE]
# Prepare batches
batches = []

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "h" doesn't conform to snake_case naming style Warning

Variable name "h" doesn't conform to snake_case naming style
if future.result():
successful_batches += 1

if successful_batches == total_batches:

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (124/100) Warning

Line too long (124/100)
if future.result():
successful_batches += 1

if successful_batches == total_batches:

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
@abhimehro abhimehro merged commit 69c4f9b into main Jan 18, 2026
18 checks passed
@abhimehro abhimehro deleted the bolt-push-rules-optimization-2918633131029543303 branch January 18, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant