Replaces unbounded `Promise.all(relays.map(...))` calls with `pMap` using a concurrency limit of 3 for background operations like history hydration, metadata fetching, and DM sending.
This prevents network saturation and potential main-thread jank when many relays are configured.
Includes benchmark verification script `benchmarks/relay_concurrency_repro.mjs`.
Audited upload docs and confirmed accuracy.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Implements `toLightweightVideo` helper in `js/services/exploreDataService.js` to strip large fields (content, signatures, etc.) from video objects before sending to the worker.
- Updates `buildWatchHistoryTagCounts` and `buildTagIdf` to use lightweight objects.
- Adds `tests/services/exploreDataService.optimization.test.mjs` to verify correctness.
- Adds `benchmarks/worker_transfer_lightweight_bench.js` demonstrating ~40% improvement in transfer time.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Extracted `getVideoTags` to `js/feedEngine/utils.js` with `WeakMap` caching.
- Updated `js/feedEngine/stages.js` and `js/feedEngine/kidsScoring.js` to use the cached utility.
- Removed redundant `collectVideoTags` and `normalizeTagSetFromVideo` functions.
- Added `benchmarks/feed_tags.mjs` to measure performance (approx 25x speedup in tight loops).
- Updated `hasDisinterestedTag` in `utils.js` to use the new utility.
This reduces object allocation and repeated string normalization during feed processing.
Co-authored-by: PR0M3TH3AN <[email protected]>
Replaces pure JS `finalizeEvent` with `nostr-tools/wasm` implementation in `scripts/agent/load-test.mjs`.
This reduces signing time from ~6ms to ~1ms per event (5x-6x speedup), significantly increasing the event generation throughput capacity of the load test agent.
- Adds `nostr-wasm` to devDependencies.
- Updates `scripts/agent/load-test.mjs` to initialize and use WASM crypto.
- Adds `benchmarks/signing_benchmark.mjs` to verify performance gains.
Co-authored-by: PR0M3TH3AN <[email protected]>
Hoisted the timestamp hook resolution out of the inner loop in `createChronologicalSorter`.
This avoids allocating an array of candidate functions for every comparison during sorting (O(N log N)).
Benchmark shows a ~27% speedup (38ms -> 27ms for 100k items).
Co-authored-by: PR0M3TH3AN <[email protected]>
Removes the call to `app.persistWatchHistoryMetadataForVideo` in `renderChannelVideosFromList` within `js/channelProfile.js`. This function was identified as a no-op (delegating to a deprecated empty method), adding unnecessary overhead to the rendering loop.
Benchmark results (100M iterations):
- With call: ~1278ms
- Without call: ~88ms
- Improvement: ~14x speedup in the tight loop simulation.
Co-authored-by: PR0M3TH3AN <[email protected]>
Optimizes `setProfileData` to defer blocking `JSON.stringify` and `localStorage.setItem` calls to idle periods, significantly reducing main thread blocking time during profile updates (e.g., watch history).
- Adds `runIdle` helper with `requestIdleCallback` (fallback to `setTimeout`).
- Updates `setProfileData` to use `runIdle`.
- Updates `tests/profile-cache.test.mjs` to handle async persistence.
- Adds `benchmarks/profile_cache_storage_bench.js` to measure blocking time (370x improvement observed).
Co-authored-by: PR0M3TH3AN <[email protected]>
Limits the O(N^2) pairwise check in `normalizeNip46CiphertextPayload` to small arrays (<= 16 items) to prevent combinatorial explosion. This heuristic is only intended for small split-payload cases, and processing large arrays this way was unnecessary and caused performance issues.
Benchmark results (200 items, 100 iterations):
- Before: ~54.84ms per iteration
- After: ~0.12ms per iteration
- Improvement: ~457x speedup
Co-authored-by: PR0M3TH3AN <[email protected]>
- Use pMap for parallel publishing of history months
- Increase concurrency limit to 4 for better throughput
- Add benchmark script for measuring publish performance
Co-authored-by: PR0M3TH3AN <[email protected]>
- Add comments to ProfileCache constructor and clearMemoryCache explaining the nested map structure.
- Add benchmarks/profile_cache_bench.js to prove performance against a linear scan baseline.
Co-authored-by: PR0M3TH3AN <[email protected]>
Replaced the scroll event listener and `getBoundingClientRect` polling loop with `IntersectionObserver` to eliminate layout thrashing and reduce main thread work during scrolling.
Verified logic with unit tests and confirmed no regressions in frontend behavior.
Co-authored-by: PR0M3TH3AN <[email protected]>