perf(image-api): parallelize bulk image upload#962
Open
jnatten wants to merge 1 commit into
Open
Conversation
Process bulk upload items with parallelism (4 in flight) instead of sequentially, and replace the per-call variant generation pool with a service-wide shared executor. Variant work mixes CPU (resize/webp encode) with IO (S3), so a single shared pool keeps cores busy while bounding total threads across concurrent requests. State transitions and their Redis writes are serialized through a small AtomicReference + monitor so SSE consumers never observe an older snapshot arrive after a newer one. Failure semantics are unchanged: once any item fails, items not yet picked up are skipped, in-flight items finish and are included in the rollback, and the session is marked Failed with all previously stored images deleted.
9fb974b to
cb61d4c
Compare
gunnarvelle
approved these changes
May 20, 2026
Member
gunnarvelle
left a comment
There was a problem hiding this comment.
Testa funksjonalitet og opplasting av seks bilder gikk veldig fort lokalt i det minste. @amatho kan sikkert vurdere koden bedre enn meg!
amatho
reviewed
May 20, 2026
Comment on lines
+317
to
+318
| logger.error(s"Bulk upload $uploadId: unexpected error processing item ${idx + 1}/$total", ex) | ||
| transitionAndPersist(uploadId, progressRef, p => p.copy(failure = p.failure.orElse(Some(ex)))) |
Contributor
There was a problem hiding this comment.
Gjør vi ikke uansett dette i slutten av processBulkItem?
Contributor
There was a problem hiding this comment.
Eller ser nå at det fordi vi wrapper kallet til processBulkItem i en Try, men kan processBulkItem kaste exceptions?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Har ikke noen målinger, men mangedobler ytelsen på bulk vha parallellisering på lokal maskin i alle fall 😄