Skip to content

⚡ [Performance] Parallelize apply operations across realms#60

Merged
ffalcinelli merged 1 commit intomainfrom
jules-perf-apply-realms-12172722168675999540
Mar 29, 2026
Merged

⚡ [Performance] Parallelize apply operations across realms#60
ffalcinelli merged 1 commit intomainfrom
jules-perf-apply-realms-12172722168675999540

Conversation

@ffalcinelli
Copy link
Copy Markdown
Owner

💡 What:

  • Refactored run function in src/apply/mod.rs to spawn tokio::task::JoinSet tasks for each realm, executing apply_single_realm concurrently rather than sequentially.
  • Added a benchmark benches/bench_apply.rs to establish a performance baseline for the apply command across a large number of realms.

🎯 Why:
Previously, kcd apply processed realms sequentially in a standard for loop. When dealing with dozens or hundreds of realms, this caused severe I/O bottlenecks and unnecessary latency since cross-realm dependencies do not exist at the Keycloak configuration level. Parallelizing this at the realm level is analogous to how the plan and inspect modules were already optimized.

📊 Measured Improvement:
Created a benchmark script (bench_apply.rs) testing the apply functionality on a mock workspace containing 100 auto-generated realms using the mock test server.

  • Baseline (Sequential loop): Average execution time of ~114ms.
  • Optimized (JoinSet parallelization): Average execution time of ~34ms.
  • Improvement: Achieved an approximate 3.3x speedup (or roughly 70% reduction in execution time) for applying changes across 100 realms simultaneously. Note that the absolute times are small because they use the fast local mock server, but the relative scale of the improvement translates directly to real-world HTTP API latency.

PR created automatically by Jules for task 12172722168675999540 started by @ffalcinelli

Uses `tokio::task::JoinSet` to concurrently process multiple realms during the `apply` operation, drastically reducing total execution time for multi-realm deployments. Also introduces `bench_apply.rs` to measure the performance baseline.

Co-authored-by: ffalcinelli <1167082+ffalcinelli@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.84%. Comparing base (ae97ee3) to head (afc2096).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   89.80%   89.84%   +0.04%     
==========================================
  Files          38       38              
  Lines        2501     2511      +10     
==========================================
+ Hits         2246     2256      +10     
  Misses        255      255              

☔ View full report in Codecov by Sentry.
📢 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.

@ffalcinelli ffalcinelli merged commit 8af892d into main Mar 29, 2026
6 checks passed
@ffalcinelli ffalcinelli deleted the jules-perf-apply-realms-12172722168675999540 branch March 29, 2026 16:56
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