Title: Ideas for faster cold compiler start-up · Issue #25658 · microsoft/TypeScript · GitHub
Open Graph Title: Ideas for faster cold compiler start-up · Issue #25658 · microsoft/TypeScript
X Title: Ideas for faster cold compiler start-up · Issue #25658 · microsoft/TypeScript
Description: Background For some users, cold compile times are getting to be a bit long - so much so that it's impacting people's non-watch-mode experience, and giving people a negative perception of the compiler. Compilation is already a hard sell f...
Open Graph Description: Background For some users, cold compile times are getting to be a bit long - so much so that it's impacting people's non-watch-mode experience, and giving people a negative perception of the compil...
X Description: Background For some users, cold compile times are getting to be a bit long - so much so that it's impacting people's non-watch-mode experience, and giving people a negative perception of th...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/25658
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Ideas for faster cold compiler start-up","articleBody":"# Background\r\n\r\nFor some users, cold compile times are getting to be a bit long - so much so that it's impacting people's non-watch-mode experience, and [giving people a negative perception of the compiler](https://twitter.com/garybernhardt/status/1007690864909529088).\r\n\r\nCompilation is already a hard sell for JavaScript users. If we can get some speed wins, I think it'd ease a lot of the pain of starting out with TypeScript.\r\n\r\n# Automatic `skipDefaultLibCheck`\r\n\r\n`lib.d.ts` is a pretty big file, and it's only going to grow. Realistically, most people don't ever declare symbols that conflict with the global scope, so we made the `skipDefaultLibCheck` (and also the `skipLibCheck` flags) for faster compilations.\r\n\r\n[We can suggest this flag to users](https://twitter.com/drosenwasser/status/1007721634193477632), but the truth is that it's not discoverable. It's also often misused, so I want to stop recommending it to people. 😄 \r\n\r\nIt'd be interesting to see if we can get the same results of `skipDefaultLibCheck` based on the code users have written. Any program that doesn't contribute a global augmentation, or a declaration in the global scope, doesn't really need to have `lib.d.ts` checked over again.\r\n\r\n@mhegazy and I have discussed this, and it sounds like we have the necessary information after the type-checker undergoes symbol-merging. If no symbols ever get merged outside of lib files, we can make the assumption that `lib` files never need to get checked. But this requires knowing that all lib files have already had symbols merged up front before any other files the compiler is given.\r\n\r\n## Pros\r\n\r\n* Running with `skipDefaultLibCheck` removes anywhere between 400-700ms on my machine from a \"Hello world\" file, so we could expect the same here.\r\n\r\n## Cons\r\n\r\n* We'd have to be careful about our assumptions with this flag.\r\n* Users who edit `lib.d.ts` wouldn't see erroneous changes in a compiler (so we'd likely need a `forceDefaultLibCheck`).\r\n* Ideally, in the absence of edited `lib.d.ts` files, only our team ever needs to run `forceDefaultLibCheck`, reducing the cost for all other TypeScript users.\r\n\r\n# V8 Snapshots\r\n\r\n~3 years ago, the V8 team introduced [custom startup snapshots](https://v8project.blogspot.com/2015/09/custom-startup-snapshots.html). In that post \r\n\r\n> Limitations aside, startup snapshots remain a great way to save time on initialization. We can shave off 100ms from the startup spent on loading the TypeScript compiler in our example above (on a regular desktop computer). We're looking forward to seeing how you might put custom snapshots to use!\r\n\r\nObviously my machine's not the same as that aforementioned desktop, but I'm getting just a bit over 200ms for running `tsc -v`, so we could possibly minimize a decent chunk of our raw startup cost. Maybe @hashseed or @bmeurer would be able to lend some insight for how difficult this would be.\r\n\r\n# Minification\r\n\r\n@RyanCavanaugh and I tried some offhand loading benchmarks with Uglify and managed\r\n\r\n1. to reduce `typescript.js`'s size by about half\r\n2. to reduce import time by about 30ms\r\n\r\nI don't know how impactful 30ms is, but the size reduction sounds appealing.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2018-07-13T23:23:11Z","url":"https://github.com/microsoft/TypeScript/issues/25658"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:886eb23e-9cf2-2455-55f0-5b75277a08f0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ADD8:161320:F40D12:1440089:6B01D93E |
| html-safe-nonce | c2ba34f94051aa129973db9dcd7fb2a165284faf20b37dfcd410915f4db1c95d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREQ4OjE2MTMyMDpGNDBEMTI6MTQ0MDA4OTo2QjAxRDkzRSIsInZpc2l0b3JfaWQiOiI4ODU0Mjk0ODk4OTI1NDkyNTQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 580a5f0e49cc54f542d6ddecce0feaa8f6db184c0a236a9ca9fed1d62464f75c |
| hovercard-subject-tag | issue:341185768 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/25658/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c5868dc2a4bc0ccaa1fa23f0f12a9fc38362378d1db56e0993dac49410124a74/microsoft/TypeScript/issues/25658 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c5868dc2a4bc0ccaa1fa23f0f12a9fc38362378d1db56e0993dac49410124a74/microsoft/TypeScript/issues/25658 |
| og:image:alt | Background For some users, cold compile times are getting to be a bit long - so much so that it's impacting people's non-watch-mode experience, and giving people a negative perception of the compil... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width