Commit 85c2224
authored
perf: improve Windows CLI performance (#3610)
* perf: optimize Windows startup time by skipping telemetry by default
Improves Windows CLI startup performance by skipping telemetry loading:
- Skip telemetry module loading on Windows unless ENABLE_WINDOWS_TELEMETRY=true
- Use dynamic imports for telemetry in all hooks to avoid loading on Windows
- Add performance tracking support via DEBUG=oclif:perf or DEBUG=*
Changes:
- bin/run: Skip telemetry on Windows, enable performance tracking
- All analytics hooks: Use dynamic imports and check ENABLE_WINDOWS_TELEMETRY
Performance impact:
- Reduces Windows startup from ~8s to ~6s (testing showed further improvements expected)
- Eliminates loading of OpenTelemetry/Sentry modules on Windows
- No impact on non-Windows platforms
Testing:
- Set ENABLE_WINDOWS_TELEMETRY=true on Windows to enable telemetry when needed
- Use DEBUG=oclif:perf or DEBUG=* to see detailed performance metrics
* perf: implement lazy initialization in global_telemetry.ts
Refactor telemetry initialization to eliminate blocking module load and
reduce Windows performance impact.
Key changes:
- Remove top-level await that blocks module loading on every command
- Defer Sentry.init(), registerInstrumentations(), and OTEL setup until
first use via ensureInitialized() pattern
- Eliminate package.json file read by using config.version from oclif
Config object (already loaded during CLI bootstrap)
- Add early return in initializeInstrumentation() when DISABLE_TELEMETRY=true
- Add getProcessor() getter for backward compatibility
Performance impact:
- Removes ~1-2ms of blocking I/O on macOS
- Expected to save 500ms-2s on Windows where file I/O is 2-3x slower
and antivirus scanning impacts every file read
- Combined with dynamic imports, significantly reduces Windows startup time
Technical details:
- config.version = config.options.version || config.pjson.version || '0.0.0'
- setupTelemetry() stores config.version on first call (during init hook)
- ensureInitialized() called from initializeInstrumentation(), sendToHoneycomb(),
and sendToSentry() to ensure setup happens before use
- All initialization respects isTelemetryDisabled flag
* perf: avoid redundant package.json read in init/version hook
Use already-loaded config.pjson instead of reading package.json from disk
again via packageParser.
Changes:
- Remove import of getAllVersionFlags() from packageParser
- Get version flags directly from this.config.pjson.oclif.additionalVersionFlags
- Build the flags list in memory instead of triggering a file read
Performance impact:
- Eliminates 654ms file read on Windows (seen in performance testing)
- No disk I/O since oclif already loaded package.json into config.pjson
- Hook functionality remains identical
* chore: remove unused packageParser.ts
Remove packageParser.ts as it's no longer used after optimizing the
init/version hook to use config.pjson directly.
The file was only imported by init/version hook which now gets version
flags from this.config.pjson.oclif.additionalVersionFlags instead of
reading package.json from disk.
* deps: update @heroku/heroku-cli-util to 10.7.0 with granular imports
Update @heroku/heroku-cli-util from 10.6.1 to 10.7.0 which introduces
granular import paths for better tree-shaking and module loading performance.
Changes:
- Update package.json dependency to ^10.7.0
- Migrate all imports from barrel exports to granular paths:
- import {color} from '@heroku/heroku-cli-util'
→ import * as color from '@heroku/heroku-cli-util/color'
- Similar changes for prompt, confirm, action, table, etc.
This change improves module loading performance by allowing bundlers
to load only the specific modules needed rather than the entire package.
* linting fixes
* perf: make SIGINT/SIGTERM telemetry fire-and-forget
Convert signal handlers from async/await to fire-and-forget to improve exit responsiveness.
Changes:
- Remove async from SIGINT/SIGTERM handlers
- Remove await before sendTelemetry() calls
- Add .catch(() => {}) to suppress unhandled promise rejections
- Call process.exit(1) immediately without blocking
Benefits:
- Immediate exit when user hits Ctrl+C (no blocking wait)
- Better UX - responsive termination behavior
- Telemetry send initiated but doesn't delay exit
- Normal command completions still captured via beforeExit handler
* switch to modular imports for some hooks files
* perf: implement lazy initialization in colorize.ts
Move color pre-assignment from module load time to first use via ensureInitialized().
Changes:
- Add ensureInitialized() function to lazily assign colors
- Call ensureInitialized() in getColorForIdentifier() before any color lookups
- Remove module-load-time side effects (pre-assignment calls)
Benefits:
- Eliminates side effects at import time
- Same behavior - common identifiers still get consistent colors
- Defers work until actually needed
- Better for module loading performance
* refactor: improve Windows performance
- Rename bin/run to bin/run.js with symlink for compatibility
- Add --no-deprecation flag to suppress Node.js warnings
- Update bin/run.cmd to reference run.js directly
- Change terms-of-service hook to use async file I/O instead of sync
* remove spaces test. we don't want to keep spaces around just for smoke
tests.
* restore intended display order for pipelines dif1 parent 84eb648 commit 85c2224
File tree
261 files changed
+1963
-1825
lines changed- bin
- scripts/postrelease
- src
- commands
- access
- accounts
- addons
- apps
- favorites
- stacks
- authorizations
- auth
- 2fa
- autocomplete
- buildpacks
- certs
- auto
- ci
- config
- clients
- config
- container
- data
- maintenances
- pg
- domains
- drains
- features
- git
- keys
- labs
- local
- maintenance
- members
- notifications
- orgs
- pg/backups
- pipelines
- ps
- autoscale
- redis
- releases
- reviewapps
- run
- sessions
- spaces
- drains
- peerings
- trusted-ips
- vpn
- telemetry
- usage
- version
- webhooks
- events
- hooks
- command_not_found
- init
- postrun
- prerun
- preupdate
- update
- lib
- addons
- apps
- buildpacks
- certs
- ci
- container
- data
- domains
- git
- local
- members
- orgs
- pg
- pipelines
- setup
- ps-exec
- redis
- run
- spaces
- telemetry
- utils
- webhooks
- test
- helpers
- unit
- commands
- container
- pg
- credentials
- upgrade
- hooks/preupdate
- lib
- pg
- ps-exec
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
261 files changed
+1963
-1825
lines changedThis file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
19 | 27 | | |
20 | | - | |
21 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
22 | 63 | | |
23 | 64 | | |
24 | 65 | | |
| |||
65 | 106 | | |
66 | 107 | | |
67 | 108 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 109 | + | |
| 110 | + | |
111 | 111 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
0 commit comments