Skip to main content

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
Key insight: Most hooks are non-blocking or fire at times when latency doesn’t affect user experience.

Hook-by-Hook Performance

session-start: 150ms average

Total: ~150msActual perceived: ~150ms (parallel requests optimized)

pre-tool-use:edit: 120ms average (Fastest Hook)

Total: ~120msWith cache hit: ~10ms (94% faster)

post-tool-use:edit: 80ms average (Non-Blocking)

Total: ~80ms (async)Perceived: 0ms (runs in background)

pre-compact: 200ms average (Slowest Hook)

Total: ~200msWhy slower: AI-powered context analysis requires processing

user-prompt-submit: 100ms average

Total: ~100ms

stop: 90ms average

Total: ~90ms

session-end: 110ms average (Non-Blocking)

Total: ~110ms (async)Perceived: 0ms (runs as session closes)

subagent-stop: 95ms average (Non-Blocking)

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
Impact:
  • pre-edit: 120ms → 10ms (92% faster for cached files)
  • session-start: 150ms → 90ms (40% faster for cached memories)
Tradeoff: Slightly stale data (max 30s old) Recommendation: Use for active development on stable teams

Strategy 2: Minimal Features

Use case: Solo developer, no team coordination needed
Impact:
  • session-start: 150ms → 50ms (67% faster)
  • post-edit: 80ms → 10ms (87% faster)
  • user-prompt: 100ms → 30ms (70% faster)
  • session-end: 110ms → 60ms (45% faster)
Tradeoff: Lose team coordination features, memory, obligations Recommendation: Only for solo projects with no team

Strategy 3: Memory-Focused

Use case: Complex project, context preservation critical
Impact:
  • pre-compact: 200ms → 250ms (25% slower, but saves more)
  • session-start: 150ms → 200ms (33% slower, but loads more)
Tradeoff: Higher latency, but better context preservation Recommendation: Use for long-term projects with complex architecture

Strategy 4: Team Coordination Priority

Use case: Multi-agent team, zero conflicts critical
Impact:
  • pre-edit: Cache hit rate decreases, but fresher data
  • user-prompt: Always shows urgent messages
  • session-start: Full dashboard for team awareness
Tradeoff: Slightly higher latency, but better coordination Recommendation: Use for active team development

Network Optimization

Reduce API Calls

Batch MCP tool calls when possible:
Impact:
  • session-start: 5 API calls → 2 batched calls (40% fewer requests)

Use Regional API Endpoints

Connect to closest ULPI API region:
Regions:
  • api-us-west.ulpi.io (Oregon)
  • api-us-east.ulpi.io (Virginia)
  • api-eu-west.ulpi.io (Ireland)
  • api-ap-south.ulpi.io (Singapore)
Impact: 60ms → 30ms (50% faster API calls from regional proximity)

Performance Monitoring

Track Hook Execution


Enable Performance Logging

Logs:

Troubleshooting Slow Hooks

Diagnosis Steps

1

Identify Slow Hook

Find which hooks exceed threshold.
2

Enable Debug Logging

3

Check Network Latency

Output:
Switch to faster region if suggested.
4

Review Hook Configuration

Check if unnecessary features enabled.
5

Apply Optimizations

Based on findings, apply relevant optimization strategy.

Best Practices

Recommendation: Run performance analysis before making changes
Benefit: Know exactly what improved and by how much
Recommendation: Different optimizations for different workflowsSolo developer: Aggressive caching, minimal features Team coordination: Fresh data, full features Long-term project: Memory-focused, context preservation
Recommendation: Track performance trends weekly
Watch for:
  • Increasing latency (API degradation)
  • Decreasing cache hit rate (changing patterns)
  • Slow hooks (network issues)
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)
Rationale: Larger teams change state more frequently

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