Replaces sequential await loop with Promise.any to resolve video timestamps in parallel.
This significantly reduces latency when multiple resolvers are present, especially if the first one is slow.
- Uses Promise.any to take the first valid finite timestamp.
- Wraps resolvers to reject on invalid values.
- Preserves error logging for genuine resolver errors.
- Benchmarks showed improvement from ~100ms to ~11ms in simulated slow scenarios.
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]>
- Introduced `NORMALIZED_ARRAY_MARKER` in `js/feedEngine/utils.js` to tag arrays that are already normalized.
- Updated `normalizeItems` in `js/feedEngine/engine.js` to skip O(N) verification if the input array is marked.
- Updated built-in stages and sorters to mark their output arrays using `markAsNormalized` when they safely construct new arrays from normalized inputs.
- This avoids redundant O(N) scans after each stage, improving pipeline performance by ~10% end-to-end and eliminating overhead for trusted stages.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Implements `hasDisinterestedTag` helper in `js/feedEngine/utils.js` to check for disinterested tags in both raw Nostr tags and NIP-71 metadata.
- Updates `createBlacklistFilterStage` in `js/feedEngine/stages.js` to filter out videos matching `context.runtime.tagPreferences` disinterests.
- Ensures existing blacklist logic remains undisturbed.
- Verified with new unit test `tests/feed-engine-tag-pref.test.mjs` and existing feed engine tests.