Speed Up a Slow Deduplication Job Over a Product Feed
Last updated: November 29, 2026
Quick Overview
A nightly job deduplicates millions of marketplace seller records and takes hours while using huge amounts of memory. Diagnose the performance problems and rewrite it to run in a single streaming pass with bounded memory per unique product.
Walmart Labs
November 29, 20260
0
0 solved
A nightly job deduplicates millions of marketplace seller records and takes hours while using huge amounts of memory. Diagnose the performance problems and rewrite it to run in a single streaming pass with bounded memory per unique product.
Walmart Marketplace ingests large catalogs from third-party sellers, and duplicate listings hurt search quality. The Walmart Labs interviewer checks whether you can profile before guessing, spot the quadratic list membership test, and reduce memory with streaming and compact keys.
What the Interviewer Expects
- Profile first and identify the O(n) list membership inside the loop
- Replace the list with a hash set for O(1) average lookup
- Stream records with a generator instead of materializing everything
- Store a compact fixed size digest instead of full keys
- Improve the dedupe key itself with normalization
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- The set of unique keys no longer fits on one machine; what now?
- Would a Bloom filter work here, and what does a false positive mean for sellers?
- How would you parallelize this across CPU cores in Python?
- How would you measure that the rewrite did not change the output?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Input: an iterable of dict records with optional gtin, brand and title. Output: the first record for each unique product, in input order. Two records are the same product if their GTINs match af...
High-Level Design
Profiling with cProfile or py-spy would show nearly all time inside k not in seen, a linear scan of a Python list, which makes the job O(n^2). Fix one is a set. Fix two is streaming: yield recor...