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
Performance problems #24
Comments
I would like to reproduce your build. I tried The bundling is a complex process, but your case should be below a second.
I'm trying to optimize preformance. So there are some features planed:
You may send me your flame graph, that would be cool :) The most time consuming part of webpack compiling are:
error for
|
Thanks for investigating. I will try to provide you with a flame graph so we can sort it out if we're responsible for this mess 😉. Also I will try the caching feature to improve loader performance. You could take a look at fs.realpath. I think it's better than |
Ah btw: I'm not sure what the current development state of alamid/core is but in order to run the bundle tests you can just try |
Why do you always use |
I thought that loaders may be used in another module system which do not support |
your nodeclass loader is really slow. removing it gives 30% speedup :-| It |
In my recent profiling tests
|
All modules are cachable so using watch mode should be very fast at the second compilation. You should integrate some kind to dev-server into alamid, which recompiles on change (i. e. use webpack-dev-middleware). You compilation is cpu bound so there are no big issues which blocking stuff. Multi process compilation should give a big speedup (next version). |
Is caching also applied when using webpack without watch mode (with the node process still running)? |
Not by default. But you can pass a |
There is info in the |
Made performance improvements in 0.6.x and there is webpack@0.7.0-beta7. Also multi process building is availible, but only recommended for bigger projects. (there is a process fork overhead of ~100-200ms) Also check var formatOutput = require("webpack/lib/formatOutput");
console.log(formatOutput(stats, {
colors: true,
context: options.context
}); or use the command line |
Nice! Looks good, I'll try it 😄 |
It seems like the raw-loader is somehow influencing the resolving time. Don't know what's going on but if a module is yellow or red the raw-loader is involved in 80%.
I'm using a postprocessor (which could influence the resolving time), but when I'm profiling it it doesn't take more than 1ms. |
Webpack has to check many module folders to find it:
(see Each time it has to check Than it has to check and read the Than it has to check That's a bit slow... (TODO optimize it) You can try to add |
You can also try to reduce to lookup dirs/extensions/postfixes to that you want to use. That are the defaults (see README) options.resolve.extensions = ["", ".webpack.js", ".web.js", ".js"];
options.resolve.postfixes = ["", "-webpack", "-web"];
options.resolve.loaderExtensions = [".webpack-web-loader.js", ".webpack-loader.js", ".web-loader.js", ".loader.js", "", ".js"];
options.resolve.loaderPostfixes = ["-webpack-web-loader", "-webpack-loader", "-web-loader", "-loader", ""];
options.resolve.modulesDirectorys = ["web_modules", "jam", "node_modules"]; |
Performance checklist: (ordered by priority)
I'll close that issue for now... |
@sokra I'm trying to get the cache working without using watch mode. All of my loaders are cacheable. Passing in an empty object in Is the CachePlugin supposed to be used in conjunction with this? |
Yes, I think so. A lot has changed since then. Reading from the source code you could try this: // webpack.config.js
var CachePlugin = require("webpack/lib/CachePlugin")
var myCache = {};
module.exports = {
...
plugins: [
new CachePlugin(myCache);
]
}; However, it is still important that the node.js process keeps running. You need to keep a reference on the |
It looks like all I need to provide in the config is an empty object in if(options.cache === undefined ? options.watch : options.cache) {
var CachePlugin = require("./CachePlugin");
compiler.apply(new CachePlugin(typeof options.cache === "object" ? options.cache : null));
} I tested both adding the CachePlugin instance to the list of plugins as well as just passing in an empty object (and both) but the On a side note, it looks like the Webpack module exports the CachePlugin. |
It turns out I was using gulp-webpack which creates a new compiler instance every time thus ignoring whatever was put in the cache. Solved by simply using webpack and using the same compiler every run. Thanks for the help! |
A new compiler instance every time should be just fine according to the docs as long as you store the cache object somewhere where it remains alive between compiler instantiations. |
I think there are some serious performance problems with webpack. Currently we're generating first bundles with alamid. The basic bundle (without application logic) contains about 50-60 modules. This is fine because we like modularity and prefer writing many short modules than a single long one.
Right now webpack takes about 2 secs (!) to compile the file. This is way too long. I don't know if you have any performance tests yet, but I think it is a good idea to spend some time on improving it. Maybe you can use flame graphs for it.
We (at alamid) surely haven't done everything right and could reduce some file system calls. But I think the main problem lies in webpack.
One performance gain could be achieved by replacing all asynchronous file system tasks to synchronous ones. Since you're not bundling for every HTTP-request in production it's a good idea to make it synchronous.
The text was updated successfully, but these errors were encountered: