This report details the performance optimization strategy implemented (and subsequently reverted) for the gokill application, specifically targeting the dependency tree view. The optimization involved pre-computing process relationships to reduce rendering latency.
The core bottleneck identified was the repeated O(n) traversal of the process list to build the dependency tree and find processes by PID during every UI update.
pidMap: Amap[int32]*process.Itemwas introduced to allow O(1) lookup of processes by PID, replacing the O(n) linear scan.childrenMap: Amap[int32][]*process.Itemwas pre-computed during process data loading. This map stores the list of child processes for each PID, eliminating the need to rebuild this relationship graph on every render frame.
Benchmarks were conducted to compare the "Baseline" (unoptimized) implementation against the "Current" (optimized) implementation.
The benchmark simulated a user interacting with the dependency tree (moving cursor, expanding/collapsing nodes).
| System Size | Baseline Latency | Optimized Latency | Improvement |
|---|---|---|---|
| Medium (1k procs) | ~6.23 ms | ~0.07 ms | ~89x Faster |
| Large (5k procs) | ~37.53 ms | ~0.11 ms | ~340x Faster |
The pre-computation strategy yielded drastic performance improvements, making the UI significantly more responsive, especially on systems with a large number of processes. While the changes have been reverted for the current iteration, the data strongly supports re-applying this optimization if UI latency becomes a concern in the future.
In addition to performance analysis, the application's user interface was enhanced to improve readability and aesthetics.
- Root User Distinction: Processes owned by
rootare now highlighted in Bold Red, making security-relevant processes immediately identifiable. - Port Information: The ports pane now features a distinct header style and green port numbers for better visual separation.
- Column Styling: Process details (PID, Command, Start Time) are now rendered with distinct colors (Blue, Bold White, Gray) to improve data scannability.
