mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
1.8 KiB
1.8 KiB
Weekly Performance Report — 2026-02-21
Summary
- Scenario: Moderation Service lookups (Trusted Mutes).
- Optimization: Throttled
pruneTrustedMuteAggregatesto run at most once per minute per author. - Impact: ~43% reduction in lookup latency for authors with many muters.
- Risk: Low. Correctness is maintained; expired mutes might persist in memory for up to 1 extra minute, which is acceptable for a 60-day window.
Methodology
- Scenario Selection:
moderationStagein the feed engine callsmoderationService.isAuthorMutedByTrustedfor every video. Profiling revealed thatgetActiveTrustedMutersForAuthorwas eagerly pruning expired mutes on every read. - Baseline Measurement:
- Script:
benchmarks/moderation_service_bench.js - Setup: 100 authors, 500 muters each (10% expired).
- 10,000 read operations.
- Baseline: ~39.13ms total (3.91µs/op).
- Script:
- Optimization:
- Modified
js/services/moderationService.jsto skip pruning iflastPrunedAtwas less than 60 seconds ago.
- Modified
- Verification:
- Re-ran
benchmarks/moderation_service_bench.js. - After: ~22.16ms total (2.21µs/op).
- Improvement: 43% faster.
- Ran
tests/moderation/to ensure no regressions.
- Re-ran
PRs & Issues
- PR: (This commit)
perf: throttle trusted mute pruning - Follow-ups:
- Consider moving pruning entirely to a background interval if the mute list grows significantly.
- Explore caching
isAuthorMutedByTrustedresults for a few seconds inmoderationStage.
Commands Run
node benchmarks/moderation_stage_bench.js # Feed stage macro-benchmark
node benchmarks/moderation_service_bench.js # Service micro-benchmark
npm run test:unit:shard1 # General unit tests
node scripts/run-targeted-tests.mjs tests/moderation/*.test.mjs # Moderation tests