Merge pull request #2620 from PR0M3TH3AN/agents/daily/perf-agent-2026-02-18-2971228711600630410

chore: run daily perf-agent and add analysis scripts
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-18 13:50:41 -05:00
commit 195d79d95e
5 files changed
+9308

No files matched your search

@@ -0,0 +1,10 @@
# perf-agent completed
- **Date**: 2026-02-18
- **Agent**: perf-agent
- **Summary**: Ran search patterns, generated `perf/hits-2026-02-18.json` and `perf/daily-perf-report-2026-02-18.md`.
- **Files Created**:
- `scripts/agent/perf-search.mjs`
- `scripts/agent/generate-perf-report.mjs`
- `perf/hits-2026-02-18.json`
- `perf/daily-perf-report-2026-02-18.md`
+42
View File
@@ -0,0 +1,42 @@
# Daily Performance Report - 2026-02-18
## Summary
Total Hits: 1303
### Hits by Pattern
- Nostr/Relay/Auth: 257
- Promise Concurrency: 66
- WebTorrent: 771
- Timeouts/Intervals: 153
- Visibility: 19
- Workers: 37
## Top Files by Activity
- js/webtorrent.js: 100 hits
- js/services/playbackService.js: 76 hits
- js/app.js: 72 hits
- js/app/playbackCoordinator.js: 71 hits
- js/ui/components/UploadModal.js: 64 hits
- js/app/authSessionCoordinator.js: 47 hits
- js/ui/components/VideoCard.js: 34 hits
- js/ui/applicationBootstrap.js: 31 hits
- js/ui/components/EditModal.js: 30 hits
- js/nostr/client.js: 28 hits
## Potential P0/P1 Candidates (Sample)
These locations involve concurrency or heavy relay operations:
- **js/adminListStore.js:567** (Nostr/Relay/Auth): `events = await nostrClient.pool.list(relays, [normalizedFilter]);`
- **js/app.js:2828** (Nostr/Relay/Auth): `if (!nostrClient?.pool || typeof nostrClient.pool.list !== "function") {`
- **js/app.js:2833** (Nostr/Relay/Auth): `const events = await nostrClient.pool.list(relayList, [`
- **js/channelProfile.js:5402** (Nostr/Relay/Auth): `const fallbackEvents = await nostrClient.pool.list(`
- **js/channelProfile.js:5415** (Nostr/Relay/Auth): `(url) => nostrClient.pool.list([url], [filter]),`
- **js/dmDecryptor.js:456** (Promise Concurrency): `return await Promise.any(decryptors.map(attemptUnwrap));`
- **js/embed.js:274** (Nostr/Relay/Auth): `const events = await pool.list(relayList, [filter]);`
- **js/embed.js:282** (Nostr/Relay/Auth): `devLogger.warn("[embed] Failed to fetch naddr via pool.list:", error);`
- **js/feedEngine/watchHistoryFeed.js:406** (Nostr/Relay/Auth): `const events = await nostrClient.pool.list(mergedRelays, filters);`
- **js/feedEngine/watchHistoryFeed.js:514** (Nostr/Relay/Auth): `const events = await nostrClient.pool.list(relays, [filter]);`
## Actions Taken
- Ran search patterns and generated inventory.
- No automatic fixes applied in this run.
File diff suppressed because it is too large. Load diff
+63
View File
@@ -0,0 +1,63 @@
import fs from 'node:fs';
import path from 'node:path';
const DATE = new Date().toISOString().split('T')[0];
const HITS_FILE = path.join('perf', `hits-${DATE}.json`);
const REPORT_FILE = path.join('perf', `daily-perf-report-${DATE}.md`);
if (!fs.existsSync(HITS_FILE)) {
console.error(`Hits file not found: ${HITS_FILE}`);
process.exit(1);
}
const hits = JSON.parse(fs.readFileSync(HITS_FILE, 'utf8'));
// Summarize by pattern
const patternCounts = {};
hits.forEach(hit => {
patternCounts[hit.pattern] = (patternCounts[hit.pattern] || 0) + 1;
});
// Summarize by file
const fileCounts = {};
hits.forEach(hit => {
fileCounts[hit.file] = (fileCounts[hit.file] || 0) + 1;
});
// Sort files by hit count
const sortedFiles = Object.entries(fileCounts)
.sort(([, a], [, b]) => b - a)
.slice(0, 10);
// Detect potential issues
const p0Candidates = hits.filter(hit =>
(hit.pattern === 'Promise Concurrency' && hit.content.includes('.map(')) ||
(hit.pattern === 'Nostr/Relay/Auth' && hit.content.includes('pool.list'))
).slice(0, 10);
let report = `# Daily Performance Report - ${DATE}\n\n`;
report += `## Summary\n`;
report += `Total Hits: ${hits.length}\n\n`;
report += `### Hits by Pattern\n`;
Object.entries(patternCounts).forEach(([pattern, count]) => {
report += `- ${pattern}: ${count}\n`;
});
report += `\n## Top Files by Activity\n`;
sortedFiles.forEach(([file, count]) => {
report += `- ${file}: ${count} hits\n`;
});
report += `\n## Potential P0/P1 Candidates (Sample)\n`;
report += `These locations involve concurrency or heavy relay operations:\n\n`;
p0Candidates.forEach(hit => {
report += `- **${hit.file}:${hit.line}** (${hit.pattern}): \`${hit.content}\`\n`;
});
report += `\n## Actions Taken\n`;
report += `- Ran search patterns and generated inventory.\n`;
report += `- No automatic fixes applied in this run.\n`;
fs.writeFileSync(REPORT_FILE, report);
console.log(`Report generated at ${REPORT_FILE}`);
+70
View File
@@ -0,0 +1,70 @@
import fs from 'node:fs';
import path from 'node:path';
const SEARCH_DIR = 'js';
const OUTPUT_DIR = 'perf';
const DATE = new Date().toISOString().split('T')[0];
const OUTPUT_FILE = path.join(OUTPUT_DIR, `hits-${DATE}.json`);
const PATTERNS = [
{ name: 'Timeouts/Intervals', regex: /setInterval|setTimeout|requestAnimationFrame|requestIdleCallback/g },
{ name: 'Promise Concurrency', regex: /Promise\.allSettled|Promise\.all|Promise\.any|Promise\.race/g },
{ name: 'Workers', regex: /new Worker|Worker\(|postMessage\(|getDmDecryptWorkerQueueSize|decryptDmInWorker/g },
{ name: 'WebTorrent', regex: /new WebTorrent|WebTorrent|torrent|magnet|torrentHash|magnetValidators/g },
{ name: 'Nostr/Relay/Auth', regex: /nostrClient\.pool|publishEventToRelays|pool\.list|queueSignEvent|relayManager|authService|hydrateFromStorage/g },
{ name: 'Visibility', regex: /document\.hidden|visibilitychange/g }
];
function getAllFiles(dirPath, arrayOfFiles) {
const files = fs.readdirSync(dirPath);
arrayOfFiles = arrayOfFiles || [];
files.forEach(function(file) {
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles);
} else {
if (file.endsWith('.js') && !file.endsWith('.min.js')) {
arrayOfFiles.push(path.join(dirPath, "/", file));
}
}
});
return arrayOfFiles;
}
function searchInFiles() {
const files = getAllFiles(SEARCH_DIR);
const hits = [];
files.forEach(file => {
const content = fs.readFileSync(file, 'utf8');
const lines = content.split('\n');
lines.forEach((line, index) => {
PATTERNS.forEach(pattern => {
if (line.match(pattern.regex)) {
hits.push({
file: file,
line: index + 1,
content: line.trim(),
pattern: pattern.name,
match: line.match(pattern.regex)[0]
});
}
});
});
});
return hits;
}
if (!fs.existsSync(OUTPUT_DIR)){
fs.mkdirSync(OUTPUT_DIR);
}
const results = searchInFiles();
fs.writeFileSync(OUTPUT_FILE, JSON.stringify(results, null, 2));
console.log(`Search complete. Found ${results.length} hits.`);
console.log(`Results saved to ${OUTPUT_FILE}`);