Commit Graph
19 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN 6f49a05302 feat(perf): Optimize feed tag extraction with caching
- 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]>
2026-02-10 19:44:30 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1569ce074f feat(perf): accelerate load test signing with WASM
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]>
2026-02-09 18:35:26 +00:00
thePR0M3TH3AN 5fcab6305f Merge pull request #2248 from PR0M3TH3AN/perf-sorters-optimization-11213639907851955656
⚡ Optimize chronological sorter performance
2026-02-08 13:31:49 -05:00
thePR0M3TH3AN 032bd40dbc Merge pull request #2237 from PR0M3TH3AN/dm-db-singleton-connection-6077819706812808064
⚡ Use singleton IndexedDB connection in dmDb.js
2026-02-08 13:28:25 -05:00
google-labs-jules[bot]andPR0M3TH3AN 7c1f3c9ada perf: Optimize chronological sorter hook resolution
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]>
2026-02-08 16:55:27 +00:00
google-labs-jules[bot]andPR0M3TH3AN 96dea42692 Optimize object allocation in kids scoring loop
- Replaced array allocation and loop with unrolled scalar comparisons in `kidsScorerStage`.
- Added unit tests and benchmark.
- Measured ~12% performance improvement (282ms -> 249ms for 200k items).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 03:41:50 +00:00
google-labs-jules[bot]andPR0M3TH3AN 03f4efbfeb refactor(dm-db): use singleton IndexedDB connection to avoid N+1 overhead
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 03:41:19 +00:00
google-labs-jules[bot]andPR0M3TH3AN 99d217e778 perf: remove dead code in channel profile render loop
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]>
2026-02-07 23:20:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 88cca17de0 perf: Use requestIdleCallback for ProfileCache localStorage writes
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]>
2026-02-05 22:59:50 +00:00
thePR0M3TH3AN 81c329b87d Merge pull request #2128 from PR0M3TH3AN/perf/dm-decrypt-parallel-16182845594481363623
⚡ Parallelize DM Gift Wrap Decryption
2026-02-05 15:57:34 -05:00
thePR0M3TH3AN 8269eaf6e9 Merge pull request #2126 from PR0M3TH3AN/perf/optimize-nip46-normalization-quadratic-5068119382655595013
⚡ Optimize NIP-46 payload normalization to avoid O(N^2) on large inputs
2026-02-05 15:56:17 -05:00
google-labs-jules[bot]andPR0M3TH3AN 201e0d154f Parallelize DM Gift Wrap Decryption for lower latency
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-05 20:52:35 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8dfc9a78c6 perf(nostr): optimize nip46 normalization loop for large inputs
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]>
2026-02-05 20:51:34 +00:00
google-labs-jules[bot]andPR0M3TH3AN 6672be9281 Optimize feed engine normalization loop
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-05 20:50:30 +00:00
google-labs-jules[bot]andPR0M3TH3AN ba47ae6963 Optimize watch history publishing concurrency
- 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]>
2026-02-05 20:29:58 +00:00
thePR0M3TH3AN b32c3dc39f Merge pull request #2118 from PR0M3TH3AN/perf/profile-cache-optimization-7635168706697512922
⚡ [ProfileCache] Document and verify O(1) memory cache clearing
2026-02-05 15:18:36 -05:00
google-labs-jules[bot]andPR0M3TH3AN 1296e4a06a Document and verify ProfileCache O(1) clearing optimization
- 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]>
2026-02-05 20:13:44 +00:00
google-labs-jules[bot]andPR0M3TH3AN 4c45555b26 Optimize explore diversity sorter to O(N^2)
- Replaced O(N^3) MMR algorithm with O(N^2) implementation
- Cached max similarity penalties to avoid redundant calculations
- Added benchmark script showing ~200x speedup for 1000 items

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-05 20:12:36 +00:00
google-labs-jules[bot]andPR0M3TH3AN d14e41e299 Refactor ScrollSpy to use IntersectionObserver for better performance
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]>
2026-02-05 19:56:46 +00:00