Files
bitvid/weekly-perf-report-2026-02-21.md
T
2026-02-21 13:12:30 +00:00

1.8 KiB

Weekly Performance Report — 2026-02-21

Summary

  • Scenario: Moderation Service lookups (Trusted Mutes).
  • Optimization: Throttled pruneTrustedMuteAggregates to 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

  1. Scenario Selection: moderationStage in the feed engine calls moderationService.isAuthorMutedByTrusted for every video. Profiling revealed that getActiveTrustedMutersForAuthor was eagerly pruning expired mutes on every read.
  2. 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).
  3. Optimization:
    • Modified js/services/moderationService.js to skip pruning if lastPrunedAt was less than 60 seconds ago.
  4. 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.

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 isAuthorMutedByTrusted results for a few seconds in moderationStage.

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