Repository navigation
perf(desktop): increase port scan interval and skip scan when no sessions - #3238
felixbarny wants to merge 1 commit into
Conversation
…ions Increase the periodic port scan interval from 2,500ms to 10,000ms. The hint-based scan already fires within 500ms of detecting "listening on port X" in terminal output, so the periodic sweep is just a safety net and a longer interval is fine. Also skip the scan entirely when no sessions are registered to avoid spawning ps/lsof unnecessarily on startup or after all terminals are closed. Closes ParadevAI#3235
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated port scanning in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR optimizes the desktop port scanner with two targeted performance improvements that reduce EDR (Elastic Endpoint) CPU load by decreasing the frequency of
Confidence Score: 5/5Safe to merge — focused performance optimization with no logic changes to core scanning behavior Both changes are minimal and correct. The interval increase is a straightforward constant change. The empty-sessions guard is placed at the right point in the function: after the isScanning dedup check, before acquiring the lock, and unregistration already calls removePortsForPane synchronously so no orphan ports can result. No bugs found. No files require special attention Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[setInterval fires every 10s] --> B{isScanning?}
B -- Yes --> Z[Skip]
B -- No --> C{sessions.size == 0\nAND daemonSessions.size == 0?}
C -- Yes --> Z2[Skip - no ps/lsof spawned]
C -- No --> D[isScanning = true]
D --> E[collectRegularSessionPids]
E --> F[collectDaemonSessionPids]
F --> G[buildPortsByPane - lsof call]
G --> H[updatePortsFromScan]
H --> I[clearEmptyTreePanes]
I --> J[cleanupUnregisteredPorts]
J --> K[isScanning = false]
L[Terminal output detected] --> M{containsPortHint?}
M -- No --> N[Ignore]
M -- Yes --> O[scheduleHintScan 500ms delay]
O --> P[scanPane - targeted ps/lsof]
Reviews (1): Last reviewed commit: "perf(desktop): increase port scan interv..." | Re-trigger Greptile |
|
Superseded by #3236, which covers the same fix with a better implementation. Closing in favour of that PR. |
Summary
ps/lsofspawns on startup or after all terminals are closed.Each scan spawns
ps(viapidtree) per session plus onelsofcall. These process spawns are intercepted by kernel-level security agents (e.g. Elastic Endpoint), which inspect every file those processes open. Reducing scan frequency directly reduces EDR CPU load.Part of #3235
Summary by cubic
Increase the desktop port scan interval to 10s and skip scans when no sessions exist. The hint-based scan still triggers within 500ms; this reduces background
ps/lsofspawns and CPU load with security agents, addressing Linear #3235.Written for commit a4431b2. Summary will update on new commits.
Summary by CodeRabbit