Skip to content

feat: allow list items to be processed in parallel #738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shady-canva
Copy link

This PR introduces a new setting which allows items returned by ListPager to be processed in parallel.

Currently, items are processed sequentially per resource. This is a problem if populateResourceInfoHandler is expensive. We internally have a custom resource which takes 1.5 milliseconds in the populateResourceInfoHandler function due to a custom lua healthcheck script and a few ignored labels which are removed during diff normalisation. With over 50,000 of these custom resources, that's a 75 second overhead.

With a parallelism of 8, we've seen a page of 500 items go from ~750ms to ~100ms. We've also seen the processing of a full list complete at roughly the same time as ListPager completes. Previously, processing of pages constantly lagged behind the retrieval.

gobench results:

BenchmarkSync/weight=1,overhead=100μs-12          	      68	  16072692 ns/op
BenchmarkSync/weight=2,overhead=100μs-12          	     139	   8585231 ns/op
BenchmarkSync/weight=4,overhead=100μs-12          	     242	   4905336 ns/op
BenchmarkSync/weight=8,overhead=100μs-12          	     302	   3939709 ns/op

BenchmarkSync/weight=1,overhead=500μs-12          	      19	  63097167 ns/op
BenchmarkSync/weight=2,overhead=500μs-12          	      38	  31135898 ns/op
BenchmarkSync/weight=4,overhead=500μs-12          	      75	  15546984 ns/op
BenchmarkSync/weight=8,overhead=500μs-12          	     141	   8420676 ns/op

Before and after:

image

@shady-canva shady-canva requested a review from a team as a code owner June 17, 2025 12:18
@shady-canva shady-canva force-pushed the shady-parallel-list-item-processing branch 2 times, most recently from 849c153 to 0f1cd01 Compare June 17, 2025 12:30
Signed-off-by: Shady Rafehi <shady@canva.com>
@shady-canva shady-canva force-pushed the shady-parallel-list-item-processing branch from 0f1cd01 to 4e4d254 Compare June 17, 2025 12:33
Copy link

Copy link

codecov bot commented Jun 17, 2025

Codecov Report

Attention: Patch coverage is 83.87097% with 10 lines in your changes missing coverage. Please review.

Project coverage is 47.67%. Comparing base (8849c3f) to head (4e4d254).
Report is 51 commits behind head on master.

Files with missing lines Patch % Lines
pkg/cache/cluster.go 82.75% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #738      +/-   ##
==========================================
- Coverage   54.26%   47.67%   -6.59%     
==========================================
  Files          64       64              
  Lines        6164     6611     +447     
==========================================
- Hits         3345     3152     -193     
- Misses       2549     3199     +650     
+ Partials      270      260      -10     

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

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