Skip to content

v4.7.2 - Performance Optimization: Faster Hook Execution

Latest

Choose a tag to compare

@ChanMeng666 ChanMeng666 released this 23 Mar 10:41
· 2 commits to master since this release

Performance Optimization

Optimizes hook_runner.py critical path to reduce execution overhead, especially for disabled hooks (18 of 22 by default).

Changes

  • Config caching: load_config() reads disk once per invocation instead of 3× — eliminates redundant JSON parsing
  • Lazy queue directory: QUEUE_DIR.mkdir() deferred from module import to first actual use
  • Deferred auto-update: check_and_self_update() moved after enabled/snoozed/debounced/filtered gates — disabled hooks skip it entirely
  • Context caching: get_notification_context() called once, reused for desktop notification, TTS, and webhook channels
  • Webhook guard: send_webhook() only called when webhook_settings.enabled is true

Performance Impact

Scenario Before After Improvement
Disabled hook ~25-35ms ~5-10ms 3-5× faster
Enabled hook (audio only) ~40-60ms ~30-45ms ~25% faster
Enabled hook (all channels) ~50-80ms ~45-70ms ~10% faster

Zero Functional Changes

All 22 hooks, all config options, all platforms, all features (audio, notifications, TTS, webhooks, Focus Flow, filters, snooze, debounce) work exactly as before. This is a pure performance optimization with no behavioral changes.

Full Changelog: v4.7.1...v4.7.2