Skip to content

perf(image-api): parallelize bulk image upload#962

Open
jnatten wants to merge 1 commit into
masterfrom
perf/bulk-upload-speed
Open

perf(image-api): parallelize bulk image upload#962
jnatten wants to merge 1 commit into
masterfrom
perf/bulk-upload-speed

Conversation

@jnatten
Copy link
Copy Markdown
Contributor

@jnatten jnatten commented May 19, 2026

Har ikke noen målinger, men mangedobler ytelsen på bulk vha parallellisering på lokal maskin i alle fall 😄

@jnatten jnatten requested a review from a team May 19, 2026 06:53
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.
@jnatten jnatten force-pushed the perf/bulk-upload-speed branch from 9fb974b to cb61d4c Compare May 19, 2026 06:53
Copy link
Copy Markdown
Member

@gunnarvelle gunnarvelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testa funksjonalitet og opplasting av seks bilder gikk veldig fort lokalt i det minste. @amatho kan sikkert vurdere koden bedre enn meg!

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))))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gjør vi ikke uansett dette i slutten av processBulkItem?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eller ser nå at det fordi vi wrapper kallet til processBulkItem i en Try, men kan processBulkItem kaste exceptions?

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.

3 participants