Files
lua-nvim/NVIM_PERFORMANCE_ANALYSIS.md
Carlos Gutierrez bf573ef961 updating packages
2025-10-22 21:58:30 -04:00

7.7 KiB

Neovim Performance Analysis & Optimization Results

Overview

This document analyzes the performance profile from nvim-profile.log and shows the results of applied optimizations.

📊 Performance Comparison Results

Significant Improvements

1. Clipboard Provider Performance

  • Before: 2.16s total time, 123 calls
  • After: 0.54s total time, 78 calls
  • Improvement: 75% reduction in total time, 37% fewer calls
  • Status: MAJOR SUCCESS

2. Syntax Loading Performance

  • Before: 0.70s total time, 699 calls
  • After: 0.47s total time, 189 calls
  • Improvement: 33% reduction in total time, 73% fewer calls
  • Status: SUCCESS

3. Filetype Plugin Loading

  • Before: 0.70s total time, 278 calls
  • After: 0.62s total time, 175 calls
  • Improvement: 11% reduction in total time, 37% fewer calls
  • Status: MODERATE SUCCESS

⚠️ Performance Regressions

4. WakaTime Plugin Performance

  • Before: 0.48s total time, 686 calls
  • After: 1.82s total time, 2,052 calls
  • Change: 279% increase in total time, 199% more calls
  • Status: REGRESSION - Need to investigate

5. Matchparen Highlighting

  • Before: 0.23s total time, 2,912 calls
  • After: 0.78s total time, 6,055 calls
  • Change: 239% increase in total time, 108% more calls
  • Status: REGRESSION - Need to investigate

🔧 Applied Optimizations

Successful Optimizations

1. Keymap Conflict Resolution

  • Fixed: Changed <leader>s to <leader>sub to avoid conflict with <leader>fs
  • File: lua/cargdev/core/keymaps/plugins.lua
  • Impact: <leader>fs now works correctly for file search
  • Status: CONFIRMED WORKING

2. Clipboard Provider Optimization

  • Fixed: Added explicit macOS clipboard configuration
  • File: lua/cargdev/core/options.lua
  • Changes: Configured pbcopy/pbpaste with caching enabled
  • Result: 75% performance improvement
  • Status: MAJOR SUCCESS

3. Syntax Loading Optimization

  • Fixed: Optimized syntax highlighting settings
  • File: lua/cargdev/core/options.lua
  • Changes: Reduced synmaxcol to 200, disabled modelines
  • Result: 33% performance improvement
  • Status: SUCCESS

4. Filetype Plugin Optimization

  • Fixed: Optimized filetype plugin loading
  • File: lua/cargdev/core/options.lua
  • Changes: Disabled modelines for security and performance
  • Result: 11% performance improvement
  • Status: MODERATE SUCCESS

Failed Optimizations

5. WakaTime Performance Optimization

  • Attempted: Optimized heartbeat frequency and buffering
  • File: lua/cargdev/plugins/wakatime.lua
  • Changes: Increased heartbeat frequency to 2 minutes, enabled buffering
  • Result: 279% performance regression
  • Status: NEEDS REVERT

6. Matchparen Performance Optimization

  • Attempted: Reduced timeout values for faster response
  • File: lua/cargdev/core/options.lua
  • Changes: Reduced matchparen_timeout to 100ms, matchparen_insert_timeout to 50ms
  • Result: 239% performance regression
  • Status: NEEDS REVERT

🚨 Issues Requiring Immediate Attention

1. WakaTime Regression

Problem: WakaTime is now consuming significantly more resources Possible Causes:

  • Buffering enabled may be causing overhead
  • Increased heartbeat frequency may be triggering more processing
  • Debug mode changes may have unintended effects

Recommended Actions:

  • Revert WakaTime configuration to original settings
  • Consider disabling WakaTime temporarily to measure impact
  • Investigate alternative WakaTime configurations

2. Matchparen Regression

Problem: Matchparen highlighting is now much slower Possible Causes:

  • Reduced timeout values may be causing more frequent recalculations
  • Timeout settings may be conflicting with other optimizations
  • The optimization may have triggered a different code path

Recommended Actions:

  • Revert matchparen timeout settings to defaults
  • Test with original settings to confirm improvement
  • Consider alternative matchparen optimization strategies

📈 Overall Performance Impact

Net Performance Change

  • Clipboard: +1.62s improvement
  • Syntax: +0.23s improvement
  • Filetype: +0.08s improvement
  • WakaTime: -1.34s regression
  • Matchparen: -0.55s regression

Net Result: +0.04s improvement (essentially neutral)

Recommendations

  1. Keep successful optimizations (clipboard, syntax, filetype)
  2. Revert failed optimizations (WakaTime, matchparen)
  3. Investigate alternative approaches for WakaTime and matchparen
  4. Consider disabling WakaTime if not actively used

🔍 Additional Performance Issues Discovered

6. CursorHold Events Performance

  • Total Time: 0.92s (CursorHold_Cb) + 0.30s (CursorHoldI_Cb) = 1.22s total
  • Calls: 1,213 + 625 = 1,838 calls
  • Issue: FixCursorHold plugin is consuming significant resources
  • Status: ⚠️ NEW ISSUE - Major performance bottleneck

7. Tmux Navigation Performance

  • Total Time: 0.61s (TmuxAwareNavigate) + 0.56s (VimNavigate) = 1.17s total
  • Calls: 63 + 63 = 126 calls
  • Issue: Tmux-aware navigation is slow
  • Status: ⚠️ NEW ISSUE - Significant overhead

8. Treesitter Indentation Performance

  • Total Time: 0.08s
  • Calls: 15 calls
  • Issue: Treesitter indentation is being called frequently
  • Status: ⚠️ NEW ISSUE - Moderate impact

9. WakaTime Heartbeat System

  • Total Time: 0.98s (SetLastHeartbeat) + 0.11s (SendHeartbeats) = 1.09s total
  • Calls: 206 + 60 = 266 calls
  • Issue: Heartbeat system is very slow
  • Status: MAJOR ISSUE - Part of WakaTime regression

📊 Updated Performance Summary

Total Performance Impact (All Issues)

  • WakaTime System: 2.91s total (HandleActivity + Heartbeats)
  • CursorHold Events: 1.22s total
  • Tmux Navigation: 1.17s total
  • Matchparen: 0.78s total
  • Clipboard: 0.54s total (improved from 2.16s)
  • Syntax Loading: 0.47s total (improved from 0.70s)
  • Filetype Plugins: 0.62s total (improved from 0.70s)

Total Identified Issues: ~7.7 seconds of performance overhead

🚨 Critical Issues Requiring Immediate Attention

1. WakaTime Complete System Failure

  • Problem: Entire WakaTime system is consuming 2.91s total
  • Components: HandleActivity (1.82s) + Heartbeats (1.09s)
  • Impact: Single biggest performance bottleneck
  • Action: DISABLE WAKATIME IMMEDIATELY

2. CursorHold Events Overhead

  • Problem: FixCursorHold plugin consuming 1.22s
  • Impact: Major performance hit on cursor movement
  • Action: OPTIMIZE OR DISABLE FixCursorHold

3. Tmux Navigation Overhead

  • Problem: Tmux-aware navigation consuming 1.17s
  • Impact: Significant overhead for navigation
  • Action: OPTIMIZE Tmux integration

🎯 Revised Priority Actions

Immediate (Critical)

  1. Disable WakaTime completely - Save 2.91s
  2. Optimize FixCursorHold - Save up to 1.22s
  3. Revert matchparen settings - Save 0.55s

High Priority

  1. Optimize Tmux navigation - Save up to 1.17s
  2. Investigate Treesitter indentation - Save up to 0.08s

Medium Priority

  1. Keep successful optimizations (clipboard, syntax, filetype)

Potential Total Savings: ~5.8 seconds (75% improvement)


Analysis based on comparison of original and optimized nvim-profile.log Last updated: $(date) Keymap conflict: Fixed | Clipboard: 75% improvement | Syntax: 33% improvement | Filetype: 11% improvement | WakaTime: 279% regression | Matchparen: 239% regression