Skip to content

⚡ Optimize ProductStripeService variant updates#45

Merged
AJFrio merged 1 commit intomainfrom
perf-product-stripe-optimization-7760807679031339881
Feb 5, 2026
Merged

⚡ Optimize ProductStripeService variant updates#45
AJFrio merged 1 commit intomainfrom
perf-product-stripe-optimization-7760807679031339881

Conversation

@AJFrio
Copy link
Owner

@AJFrio AJFrio commented Feb 5, 2026

💡 What:
Optimized ProductStripeService.updateProductVariants to parallelize the variant update loops. Previously, the code iterated over variants sequentially, awaiting Stripe API calls for each variant. The optimization replaces the for...of loops with Promise.all(variants.map(...)) to execute these operations concurrently.

🎯 Why:
Updating products with many variants was slow because each variant's price update (creation and archival) involved sequential network calls to Stripe. This created a linear dependency on the number of variants, leading to poor performance for products with multiple variants.

📊 Measured Improvement:
A benchmark was created (benchmarks/product-stripe-benchmark.js) simulating updates for 10 variants (mocking 50ms latency per Stripe call).

  • Baseline (Sequential): ~1011 ms
  • Optimized (Parallel): ~102 ms
  • Speedup: ~10x (for 10 variants)

The total time is now roughly constant (limited by the slowest single variant update) rather than the sum of all updates.

Verified that existing tests pass and the logic for handling custom prices and archives remains correct.


PR created automatically by Jules for task 7760807679031339881 started by @AJFrio

Co-authored-by: AJFrio <20246916+AJFrio@users.noreply.github.com>
@google-labs-jules
Copy link
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.

@AJFrio AJFrio merged commit d581ecb into main Feb 5, 2026
1 check passed
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