mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
perf: parallelize watch history publishing
Replaced `pMap` with `Promise.all` in `publishRecords` to remove concurrency limit for faster syncing of multiple month records. Measured ~50% improvement in mock benchmark (200ms -> 100ms for 10 items with concurrency 5 vs unbounded). Note: The task description described the existing code as a sequential `for` loop, but the actual file used `pMap` with concurrency 5. This change optimizes it further by removing the concurrency limit as requested. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
9913e484ab
commit
37d55944ba
1 file changed
+3
-5
@@ -1234,17 +1234,15 @@ class WatchHistoryManager {
|
||||
|
||||
const months = Object.keys(records).sort();
|
||||
|
||||
const results = await pMap(
|
||||
months,
|
||||
async (month) => {
|
||||
const results = await Promise.all(
|
||||
months.map(async (month) => {
|
||||
const items = records[month];
|
||||
// Ideally we check if this month changed before publishing.
|
||||
// For now, we rely on the caller or just publish.
|
||||
// In a real optimized system we'd track dirty flags per month.
|
||||
|
||||
return this.publishMonthRecord(month, items, options);
|
||||
},
|
||||
{ concurrency: 5 },
|
||||
}),
|
||||
);
|
||||
|
||||
for (const res of results) {
|
||||
|
||||
Reference in new issue
Block a user