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:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-31 19:18:54 +00:00
1 parent b429b1c075
commit c4b5f98bd7
1 file changed
+4 -5
+4 -5
View File
@@ -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);
}
}