-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cold start #99
Comments
There's a variety of reasons that can contribute to a slow start, mostly it comes down to the plugins being used (stuff like Babel for example can be really expensive to use for performance). How long does a rebuild take? Is there a some plugins that could be greatly contributing to delays? If there's reproduction steps I can have a look in more detail as to what's causing the delay and see if there's any quick performance wins. I'm very interested in improving the performance overall. |
Just a couple of other thoughts on this topic:
|
Thanks for the reply. Really insightful! I have no idea of Nollup's inner workings, so I have little to contribute, but I'm sure there are scenarios where source maps aren't highly necessary. If there's a good performance gain, I'd only use them when debugging. Could source maps possibly be created in a separate thread and simply be "available when they're available"? |
I think sourcemaps can't be spared for Svelters like us. I also believe the main contributing factor to slow start is silply the size of the project ¯_(ツ)_/¯ Vite somewhat escape it with just in time compilation, which Nollup can't do. Last time I checked, Snowpack was worse than Nollup despite a HDD cold cache. Interestingly, Rollup tends to be (very) marginally faster on initial build. I'm keen to take a dive into 0.12.0 to see if I can find good targets for caching... Sometime soon. Otherwise, the main optimization I can think of for cold start is a cold cache written to disk. It would get completely invalidated by any config change, and partially invalidated by files that have changed (I'd check the last modified time for that). Now there's 2 main reasons for me to restart Nollup: config change or dev server state has been corrupted by an error condition. The first one would benefit nothing from a cold cache, and I'm afraid broken state would be persisted by it 😅 ... Otherwise, for the nominal case of starting and stopping your project in day to day workflow, we could probably go from 10s of seconds to a handful of seconds. Just my 2 cents. |
For the sake of experimentation, comment out the implementation of Disk cache could be interesting, but would have to carefully determine what should be cached, and what rules determine to invalidate the cache. |
Faster implementation using a WASM version of |
Did three runs, with and without With Without |
Some research notes based on
From what I can tell at the moment, a significant factor is the number of files to be compiled. For example, a standout here is I tried a few other experiments, like minimising the amount of async/await and disabling magic-string when converting import/export statements, and while there is definitely improvement, it's no silver bullet. I think in general it would be a good idea to look at the specific implementations of functions, and prefer faster native WASM based libraries where possible. Still investigating. |
Would it be possible to compile dependencies and cache them for future use? Maybe recompile and recache in the background or add a command to Nollup which lets you clear the cache. Also, completely off topic, where about in Ireland are you located? |
Disk caching I'll have to experiment with and see what kind of results I can get. It feels like it might be feasible, and it certainly warrants investigation. I have my concerns regarding it. For example, part of Nollup's speed comes from the fact it's not writing to disk, so would have to figure out how to minimise the impact (maybe listen to CTRL + C for example and only write to disk then with the latest state). It's next on my list to investigate. Probably won't have any results on this for a couple of days though! Based in Dublin. 😎 |
Not sure if this is feasible, but could compiled packages be written to a temp folder in |
I also think a cold cache should be written just in time on ctrl-c. Totally unpsyched by the idea of Nollup constantly writing to disk data that would never be used for the most part. Mainly for disk health reasons. |
How would this work with testing where you might have 10 tests running in sequence? |
Just some updates on this. I released the fast source map branch in In regards to the disk cache, I did some experimenting with it, and while it's possible to get this working to some degree without much effort, it's not really compatible with plugins, especially those that output different assets. For example, the CSS plugin I wrote depends on the transform function to keep track of loaded CSS files. If Nollup preloads a cache, that transform function never runs, so no CSS gets outputted because the transform function never runs. This will apply to other plugins as well. I think this is a problem for plugins themselves to solve rather than Nollup. Plugins like |
For reference, this is the disk caching experiment:
|
Great job, @PepsRyuu |
Further information on this, I have updated all examples to use the newest performance best practices. All examples no longer use |
Is it possible to speed up the cold start? I often get 15s+.
The text was updated successfully, but these errors were encountered: