-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Optimize shim execution for faster command invocation.
Problem
The shim binary is invoked on every node, npm, python, pip command. Current issues:
- Binary size: ~10MB (same as main CLI)
- Heavy dependencies: Pulls in
net/http,progressbar,colorlibraries not needed at runtime - Expensive operations on every invocation:
- Directory tree walking to find
.dtvem/runtimes.json - JSON parsing of config files
- Multiple
os.Stat()calls per directory level - Runtime provider initialization
- Directory tree walking to find
Performance Targets
- Shim overhead: < 10ms
- Binary size: < 5MB (ideally < 3MB)
Optimization Opportunities
Quick Wins
- Strip debug symbols in builds (
-ldflags="-s -w") - reduces ~30% - Cache
os.UserHomeDir()- called multiple times - Don't import
uipackage in shim - use plainfmt.Fprintf
Medium Effort
- Create shim-specific "lite" provider interface (only needs
Name,Shims,ExecutablePath,IsInstalled,ShouldReshimAfter) - Remove HTTP/download dependencies from shim build
- Cache resolved paths with mtime invalidation
- Lazy-load providers - don't register until needed
Architecture Options (for discussion)
- Build tags to exclude heavy code from shim
- Separate lite provider package
- Bake resolved paths at reshim time
Analysis
The shim imports full runtime providers which import:
net/http(~2MB) - forListAvailable()progressbar/v3(~500KB) - viauipackagefatih/color(~200KB) - for colored outputdownloadpackage - for installation
None of these are needed for shim's core job: resolve version → find executable → exec.
Related
Split from #19 to focus specifically on shim performance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request