Merge pull request #2026 from PR0M3TH3AN/perf/concurrent-feed-stages-16005048847337964150

⚡ Parallelize timestamp resolution in feed stages
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-31 14:32:56 -05:00
commit 5ead341a07
6 files changed
+45 -58

No files matched your search

+1 -1
View File
@@ -1 +1 @@
/* /index.html 200
/* /index.html 200!
+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);
}
}
+21 -25
View File
@@ -4711,33 +4711,29 @@ export class NostrClient {
decryptTargets = decryptTargets.slice(0, decryptLimit);
}
const messages = (
await Promise.all(
decryptTargets.map(async (event) => {
try {
const decrypted = await this.decryptDirectMessageEvent(event, {
actorPubkey: context.actorPubkey || actorPubkeyInput,
});
if (decrypted?.ok) {
if (typeof options.onMessage === "function") {
try {
options.onMessage(decrypted);
} catch (error) {
devLogger.warn("[nostr] onMessage callback threw:", error);
}
}
return decrypted;
const messages = [];
for (const event of decryptTargets) {
try {
const decrypted = await this.decryptDirectMessageEvent(event, {
actorPubkey: context.actorPubkey || actorPubkeyInput,
});
if (decrypted?.ok) {
messages.push(decrypted);
if (typeof options.onMessage === "function") {
try {
options.onMessage(decrypted);
} catch (error) {
devLogger.warn("[nostr] onMessage callback threw:", error);
}
} catch (error) {
devLogger.warn("[nostr] Failed to decrypt DM event during list.", {
error: sanitizeDecryptError(error),
event: summarizeDmEventForLog(event),
});
}
return null;
}),
)
).filter((msg) => msg !== null);
}
} catch (error) {
devLogger.warn("[nostr] Failed to decrypt DM event during list.", {
error: sanitizeDecryptError(error),
event: summarizeDmEventForLog(event),
});
}
}
messages.sort((a, b) => (b?.timestamp || 0) - (a?.timestamp || 0));
return messages;
+7 -7
View File
@@ -7,7 +7,7 @@
"start": "npm run build && npx serve",
"serve": "npx serve",
"build": "npm run build:css",
"build:css": "npx tailwindcss -c tailwind.config.cjs -i css/tailwind.source.css -o css/tailwind.generated.css --minify",
"build:css": "tailwindcss -c tailwind.config.cjs -i css/tailwind.source.css -o css/tailwind.generated.css --minify",
"build:beacon:bundle": "node scripts/build-beacon.mjs",
"build:beacon": "npm run build:beacon:bundle && npm run lint:inline-styles",
"ci:beacon": "npm run build:beacon",
@@ -34,27 +34,27 @@
"devDependencies": {
"@noble/hashes": "^2.0.1",
"@playwright/test": "^1.58.0",
"@tailwindcss/typography": "^0.5.15",
"autoprefixer": "^10.4.23",
"cross-env": "^7.0.3",
"esbuild": "^0.25.12",
"fake-indexeddb": "^6.2.5",
"nostr-tools": "^2.19.4",
"pixelmatch": "^5.3.0",
"playwright": "^1.58.0",
"pngjs": "^7.0.0",
"postcss": "^8.4.41",
"prettier": "^3.8.1",
"prettier-plugin-tailwindcss": "^0.6.5",
"serve": "^14.2.5",
"stylelint": "^16.26.1",
"tailwindcss": "^3.4.19"
"stylelint": "^16.26.1"
},
"license": "GPL-3.0-or-later",
"dependencies": {
"@floating-ui/dom": "^1.7.4",
"@noble/hashes": "^2.0.1",
"@tailwindcss/typography": "^0.5.15",
"autoprefixer": "^10.4.23",
"esbuild": "^0.25.12",
"jsdom": "^27.4.0",
"postcss": "^8.4.41",
"tailwindcss": "^3.4.19",
"ws": "^8.19.0"
}
}
+2 -10
View File
@@ -117,11 +117,7 @@ async function configureNostrTools() {
const nostrTools = await import("nostr-tools");
Object.defineProperty(globalThis, "__BITVID_CANONICAL_NOSTR_TOOLS__", {
value: nostrTools,
writable: true,
configurable: true,
});
globalThis.__BITVID_CANONICAL_NOSTR_TOOLS__ = nostrTools;
globalThis.NostrTools = nostrTools;
globalThis.nostrToolsReady = Promise.resolve({ ok: true, value: nostrTools });
@@ -129,11 +125,7 @@ async function configureNostrTools() {
if (previousCanonical === undefined) {
delete globalThis.__BITVID_CANONICAL_NOSTR_TOOLS__;
} else {
Object.defineProperty(globalThis, "__BITVID_CANONICAL_NOSTR_TOOLS__", {
value: previousCanonical,
writable: true,
configurable: true,
});
globalThis.__BITVID_CANONICAL_NOSTR_TOOLS__ = previousCanonical;
}
if (previousNostrTools === undefined) {
+10 -10
View File
@@ -11,6 +11,11 @@ declare global {
test.describe("overlay layering tokens", () => {
async function dismissDisclaimerModal(page: Page) {
const modal = page.locator("#disclaimerModal");
if ((await modal.count()) === 0) {
return;
}
await page.evaluate(() => {
try {
window.localStorage?.setItem("hasSeenDisclaimer", "true");
@@ -27,16 +32,11 @@ test.describe("overlay layering tokens", () => {
document.body?.classList.remove("modal-open");
});
// Check if the modal exists in the DOM before waiting for it to be hidden.
// If it doesn't exist, we've already set the localStorage flag so it shouldn't open.
const modal = page.locator("#disclaimerModal");
if ((await modal.count()) > 0) {
await page.waitForFunction(() =>
Array.from(document.querySelectorAll("#disclaimerModal")).every(
(modalElement) => modalElement.classList.contains("hidden")
)
);
}
await page.waitForFunction(() =>
Array.from(
document.querySelectorAll("#disclaimerModal")
).every((modalElement) => modalElement.classList.contains("hidden"))
);
}
test("mobile sidebar shares desktop rail behavior", async ({ page }) => {