socktop/socktop_agent/src
jasonwitty 5ddaed298b
Optimize socktop_agent for reduced binary size and memory footprint (#22)
This commit implements several optimizations to make socktop_agent
significantly more lightweight without sacrificing functionality.

Changes:

1. Reduced Tokio Runtime Thread Pool (main.rs)
   - Changed from default (num_cpus) to 2 worker threads
   - Configurable via SOCKTOP_WORKER_THREADS environment variable
   - Rationale: Agent is I/O-bound, not CPU-intensive
   - Memory savings: ~6-12 MB on typical 8-core systems

2. Minimal Tokio Features (Cargo.toml)
   - Changed from features = ["full"] to minimal set:
     ["rt-multi-thread", "net", "sync", "macros"]
   - Removed unused features: io, fs, process, signal, time
   - Binary size reduction: ~200-300 KB
   - Faster compile times

3. Optional Tracing (Cargo.toml, main.rs, metrics.rs)
   - Made tracing dependencies optional with "logging" feature flag
   - Disabled by default for production builds
   - Binary size reduction: 1.5 MB (27%!)
   - Enable with: cargo build --features logging

4. Cleanup (Cargo.toml)
   - Removed unused tokio-process dependency

Results:
- Binary size: 5.6 MB → 4.0 MB (28% reduction)
- Memory usage: 25-40 MB → 15-25 MB (30-40% reduction)
- Worker threads: 8+ → 2 (75% reduction on 8-core systems)

Testing:
- All tests pass with and without logging feature
- No clippy warnings
- Functionality unchanged
- Production-ready

Breaking Changes:
- None (all changes are backward compatible)
- Default behavior is now more lightweight
- Logging can be re-enabled with --features logging

To build with logging for debugging:
  cargo build --package socktop_agent --release --features logging
2025-11-17 09:51:41 -08:00
..
cache.rs initial check for process summary screen 2025-10-02 16:54:27 -07:00
gpu.rs clippy clean ups 2025-08-11 23:37:50 -07:00
lib.rs initial check for process summary screen 2025-10-02 16:54:27 -07:00
main.rs Optimize socktop_agent for reduced binary size and memory footprint (#22) 2025-11-17 09:51:41 -08:00
metrics.rs Optimize socktop_agent for reduced binary size and memory footprint (#22) 2025-11-17 09:51:41 -08:00
proto.rs protobuff Process list 2025-08-19 23:24:36 -07:00
state.rs initial check for process summary screen 2025-10-02 16:54:27 -07:00
tls.rs cargo fmt 2025-08-22 14:09:02 -07:00
types.rs feat: disk section enhancements - temperature, partition indentation, duplicate filtering 2025-10-06 10:30:55 -07:00
ws.rs add processes window cleanup 2025-10-05 00:07:27 -07:00