Hook Performance & Optimization
Every millisecond matters in developer experience. ULPI Hooks are designed for minimal latency impact. This guide explains hook performance characteristics, optimization strategies, and how to tune hooks for your workflow.Performance Overview
Total Hook Overhead
Across all 8 hooks:- Average latency per hook: ~140ms
- Total MCP calls: 14 (distributed across hooks)
- Network requests: 14 (one per MCP call)
- Perceived user impact: Minimal to none
Hook-by-Hook Performance
session-start: 150ms average
- Latency Breakdown
- User Impact
- Optimization
Total: ~150ms
Actual perceived: ~150ms (parallel requests optimized)
pre-tool-use:edit: 120ms average (Fastest Hook)
- Latency Breakdown
- User Impact
- Caching Strategy
- Optimization
Total: ~120ms
With cache hit: ~10ms (94% faster)
post-tool-use:edit: 80ms average (Non-Blocking)
- Latency Breakdown
- User Impact
- Optimization
Total: ~80ms (async)
Perceived: 0ms (runs in background)
pre-compact: 200ms average (Slowest Hook)
- Latency Breakdown
- User Impact
- Optimization
Total: ~200ms
Why slower: AI-powered context analysis requires processing
user-prompt-submit: 100ms average
- Latency Breakdown
- User Impact
- Optimization
Total: ~100ms
stop: 90ms average
- Latency Breakdown
- User Impact
- Optimization
Total: ~90ms
session-end: 110ms average (Non-Blocking)
- Latency Breakdown
- User Impact
- Optimization
Total: ~110ms (async)
Perceived: 0ms (runs as session closes)
subagent-stop: 95ms average (Non-Blocking)
- Latency Breakdown
- User Impact
- Optimization
Total: ~95ms (async)
Perceived: 0ms (runs as subagent stops)
Performance Summary Table
Key Insights:
- Fastest: pre-edit (120ms, but 10ms with cache)
- Slowest: pre-compact (200ms, but fires rarely)
- Most frequent: pre-edit, user-prompt (every edit/prompt)
- Most optimizable: session-start (67%), post-edit (90%), user-prompt (70%)
Optimization Strategies
Strategy 1: Aggressive Caching
Use case: Rapid development with frequent edits- pre-edit: 120ms → 10ms (92% faster for cached files)
- session-start: 150ms → 90ms (40% faster for cached memories)
Strategy 2: Minimal Features
Use case: Solo developer, no team coordination needed- session-start: 150ms → 50ms (67% faster)
- post-edit: 80ms → 10ms (87% faster)
- user-prompt: 100ms → 30ms (70% faster)
- session-end: 110ms → 60ms (45% faster)
Strategy 3: Memory-Focused
Use case: Complex project, context preservation critical- pre-compact: 200ms → 250ms (25% slower, but saves more)
- session-start: 150ms → 200ms (33% slower, but loads more)
Strategy 4: Team Coordination Priority
Use case: Multi-agent team, zero conflicts critical- pre-edit: Cache hit rate decreases, but fresher data
- user-prompt: Always shows urgent messages
- session-start: Full dashboard for team awareness
Network Optimization
Reduce API Calls
Batch MCP tool calls when possible:- session-start: 5 API calls → 2 batched calls (40% fewer requests)
Use Regional API Endpoints
Connect to closest ULPI API region:api-us-west.ulpi.io(Oregon)api-us-east.ulpi.io(Virginia)api-eu-west.ulpi.io(Ireland)api-ap-south.ulpi.io(Singapore)
Performance Monitoring
Track Hook Execution
Enable Performance Logging
Troubleshooting Slow Hooks
Diagnosis Steps
1
Identify Slow Hook
2
Enable Debug Logging
3
Check Network Latency
4
Review Hook Configuration
5
Apply Optimizations
Based on findings, apply relevant optimization strategy.
Best Practices
Profile before optimizing
Profile before optimizing
Recommendation: Run performance analysis before making changesBenefit: Know exactly what improved and by how much
Optimize based on usage patterns
Optimize based on usage patterns
Recommendation: Different optimizations for different workflowsSolo developer: Aggressive caching, minimal features
Team coordination: Fresh data, full features
Long-term project: Memory-focused, context preservation
Monitor performance over time
Monitor performance over time
Recommendation: Track performance trends weeklyWatch for:
- Increasing latency (API degradation)
- Decreasing cache hit rate (changing patterns)
- Slow hooks (network issues)
Use appropriate cache TTL
Use appropriate cache TTL
Recommendation: Match cache duration to team size
- Solo: 60s (very stable)
- 2-3 people: 30s (mostly stable)
- 4-6 people: 15s (moderately dynamic)
- 7+ people: 10s (very dynamic, default)
Success Metrics
Teams optimizing hooks report:94% Cache Hit Rate
For pre-edit hooks with 30s cache TTLRapid file editing nearly instant
Average 85ms Latency
Across all hooks (vs 140ms default)40% faster with optimization
Sub-100ms P95 Latency
95% of hooks complete in under 100msConsistently fast experience
Zero User Complaints
“We never notice the hooks are there”Imperceptible in daily workflows
Next Steps
Getting Started
Install hooks and see performance firsthand
Lifecycle Events
Understand when each hook fires
Configuration Guide
Detailed configuration reference for all hooks
Troubleshooting
Solutions to common performance issues