perf: import execute processes rows sequentially — slow for large imports with TMDB lookups #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
crates/application/src/import/execute.rsprocesses each confirmed row in a sequential loop. For large imports where rows resolve to unknown movies (triggering a synchronous TMDB API call viaMovieResolver), this can take minutes.Example
500 rows, each needing a TMDB lookup (~200ms each) = ~100 seconds sequential vs ~10 seconds with concurrency 10.
Proposed fix
Process rows concurrently with a bounded semaphore (e.g.
tokio::sync::Semaphorewith limit 10), collecting per-row results intoimported,skipped_duplicates,failedas today. Error collection needs care across tasks — useJoinSetorfutures::stream::iter().buffer_unordered().Affected files
crates/application/src/import/execute.rsAlso affects:
crates/application/src/integrations/confirm.rs— same sequential loop over confirmations, each callingreview_logger.log_review()which can trigger a synchronous TMDB lookup for unknown movies. Same fix applies.