mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-01 18:32:27 +00:00
perf: parallelize timestamp resolution in feed stages
Refactor `createResolvePostedAtStage` to execute timestamp resolution tasks concurrently using `Promise.allSettled` instead of a serial loop. This significantly reduces execution time when multiple items require resolution (e.g., waiting for network or async processing). Benchmarks showed a reduction from ~1000ms to ~23ms for 50 items with a simulated 20ms delay each. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
b429b1c075
commit
c4b5f98bd7
1 file changed
+4
-5
@@ -261,11 +261,10 @@ export function createResolvePostedAtStage({
|
||||
});
|
||||
}
|
||||
|
||||
for (const task of tasks) {
|
||||
try {
|
||||
await task();
|
||||
} catch (error) {
|
||||
context?.log?.(`[${stageName}] resolution task failed`, error);
|
||||
const results = await Promise.allSettled(tasks.map((task) => task()));
|
||||
for (const result of results) {
|
||||
if (result.status === "rejected") {
|
||||
context?.log?.(`[${stageName}] resolution task failed`, result.reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user