Performance Commands

The nself perf command provides comprehensive performance profiling and analysis for your ɳSelf infrastructure. It includes system profiling, slow query detection, and optimization recommendations.

Updated for ɳSelf v0.4.8

Performance Profiling (v0.4.6+)

  • - System Profiling: CPU, memory, and I/O profiling
  • - Slow Query Analysis: Detect slow queries using pg_stat_statements
  • - Dashboard: Real-time terminal performance dashboard
  • - Suggestions: Optimization recommendations

Profiling

nself perf profile

Run full system profile or service-specific profiling.

nself perf profile              # Full system profile
nself perf profile postgres     # Profile PostgreSQL
nself perf profile hasura       # Profile Hasura GraphQL

# Output:
#   ➞ Performance Profile
#
#   SERVICE         CPU%    MEMORY       RESPONSE
#   postgres        2.3%    512MB/1GB    5ms
#   hasura          4.1%    256MB/512MB  12ms
#   auth            1.0%    128MB/256MB  8ms

Analysis

nself perf analyze

Analyze system performance with specific focus areas.

nself perf analyze                  # General analysis
nself perf analyze --slow-queries   # Focus on slow queries
nself perf analyze --memory         # Memory analysis
nself perf analyze --cpu            # CPU analysis

Slow Query Detection

nself perf slow-queries

Detailed analysis of slow database queries using pg_stat_statements.

nself perf slow-queries           # Show top slow queries
nself perf slow-queries --limit 20 # Top 20 queries

# Output:
# RANK  TIME      CALLS   AVG(ms)   QUERY
# 1     2.3s      1,234   150       SELECT * FROM orders WHERE...
# 2     1.8s      456     95        SELECT * FROM users JOIN...
# 3     1.2s      789     85        UPDATE products SET...

Note: Requires pg_stat_statements extension enabled in PostgreSQL.

Reports

nself perf report

Generate a performance report.

nself perf report              # Table format
nself perf report --json       # JSON output

JSON Output Format

{
  "timestamp": "2026-01-23T10:30:00Z",
  "services": [
    {"name": "postgres", "cpu": "2.3%", "memory": "512MB", "response_ms": 5}
  ]
}

Real-Time Dashboard

nself perf dashboard

Real-time terminal dashboard showing performance metrics.

nself perf dashboard           # Launch dashboard

# Dashboard shows:
# - CPU/Memory per service
# - Request latency
# - Database query times
# - Cache hit rates
#
# Press Ctrl+C to exit

Optimization Suggestions

nself perf suggest

Get optimization recommendations based on current performance.

nself perf suggest             # Show suggestions
nself perf suggest --json      # JSON output

# Output:
# Performance Suggestions:
#
# HIGH PRIORITY:
# 1. Add index on orders.customer_id (85% query improvement)
# 2. Increase Redis memory to 512MB (cache evictions detected)
#
# MEDIUM PRIORITY:
# 3. Enable query caching in Hasura
# 4. Consider connection pooling (45 concurrent connections)
#
# LOW PRIORITY:
# 5. Upgrade to larger instance for 20% headroom

Options Reference

OptionDescription
--jsonOutput in JSON format
--output FILESave results to file
-h, --helpShow help message

Subcommands Reference

SubcommandDescription
profile [service]System/service profiling
analyzeAnalyze performance
slow-queriesSlow query analysis
reportGenerate report
dashboardReal-time dashboard
suggestOptimization tips

Usage Examples

# Quick system health check
nself perf profile

# Find slow queries
nself perf slow-queries

# Get optimization tips
nself perf suggest

# Export performance report
nself perf report --json > perf-report.json

# Monitor in real-time
nself perf dashboard

Prerequisites

Next Steps