Performance Tuning
Vestig is designed for minimal overhead. This guide covers tuning strategies for different workloads.
Understanding Overhead
Logging Path
text
The hot path (steps 1-4) adds ~10-20μs per log. Transport overhead varies by type.
Transport Latency
| Transport | Latency per log | Notes |
|---|---|---|
| ConsoleTransport | 5-50μs | Fastest, no batching |
| BatchTransport | 1-5μs | Async queue, batch flush |
| HTTPTransport | 1-5μs (buffered) | Network on flush |
| FileTransport | 2-10μs (buffered) | Disk on flush |
Log Level Optimization
Production Levels
typescript
Level Check Short-Circuit
Level checks happen first, before any string formatting:
typescript
Dynamic Level Control
typescript
Sampling Strategies
Probability Sampling
Reduce log volume while maintaining visibility:
typescript
Rate Limiting
Prevent log storms:
typescript
Namespace-Based Sampling
Different rates for different subsystems:
typescript
Batching Configuration
Optimal Batch Size
typescript
Batch Size Formula
typescript
Flush Interval Tuning
typescript
Structured vs Formatted Output
Structured JSON (Production)
typescript
Pros:
- Faster parsing by log aggregators
- Consistent format
- No ANSI escape codes
Formatted Output (Development)
typescript
Pros:
- Human readable
- Colored output
- Better for debugging
Auto-Detection
typescript
Sanitization Performance
Field Matching Speed
typescript
Preset Performance
Presets are optimized for common use cases:
typescript
Disable When Not Needed
typescript
Transport Selection
ConsoleTransport
Best for: Development, debugging, low-volume production
typescript
HTTPTransport
Best for: Cloud log aggregation (Datadog, Splunk, etc.)
typescript
FileTransport
Best for: Local persistence, compliance requirements
typescript
Multiple Transports
Combine for redundancy with minimal overhead:
typescript
Async Initialization
Defer Transport Init
typescript
Parallel Initialization
typescript
Measuring Performance
Logging Overhead
typescript
Transport Benchmarks
typescript
Production Checklist
Configuration
typescript
Monitoring
typescript
Quick Wins
| Optimization | Impact | Effort |
|---|---|---|
| Set level to 'info' | High | Low |
| Enable sampling | High | Low |
| Increase batch size | Medium | Low |
| Use structured format | Medium | Low |
| Disable sanitize (if safe) | Low | Low |
| Async transport init | Low | Medium |