-
Notifications
You must be signed in to change notification settings - Fork 409
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
Mini-RFC: --no-pack flag #691
Comments
@Pauan can you elaborate a bit more on the motivation here as well? Are you worried about some diagnostics coming out about package.json that may be easily run into when they shouldn't? I personally would agree that we should keep the same output folder, although it seems reasonable to restructure it slightly. For example we may not need to add a |
I don't think it should use As for whether it should have a "mode style" flag or not, personally, I think
I agree that
The motivations are:
After looking into it, I don't have much of an opinion about |
This is slightly off-topic, but we should also start thinking about how to handle npm dependencies with applications. Right now wasm-pack generates a That works fine if you just publish that The issue is that there are now two That means that the So we need to somehow fix that so the This is another reason for the This should probably be filed as a different issue, but it is related to Come to think of it, given the above, maybe we should call the flag |
I don't really personally buy the argument about performance in the sense that you're not wrong but we're talking about a handful of milliseconds at most here. I do think it's compelling to cater to the use case of removing extraneous warnings or extraneous checks that users could stumble over (such as generating an error or a warning that doesn't make sense in the "no pack" context). I'm wondering if we could perhaps change a few defaults and basically cater to your use case @Pauan. I suspect we could continue to just go ahead and generate |
I have tried modifying my loader to use wasm-pack, and it has a significant performance cost:
The above numbers were taken on a tiny "hello world" project which had already been compiled, so The above is only for a single crate. It will naturally scale linearly with the number of crates. I have some projects which have 6 crates, so I expect wasm-pack will take 12600ms compared to 9780ms for wasm-bindgen, a difference of 2820ms. Now, you might be right that the An individual operation might only take a handful of milliseconds (a single disk I/O takes several ms), but when you're doing dozens or hundreds of operations, it adds up.
I'm confused: my argument is that there should be a flag to prevent it from generating |
Er ok so lemme explain a bit on the performance part. I've worked extensively on Cargo, rustc, etc, and I've worked quite a lot on those with respect to performance. When I say wasm-pack should take a handful of milliseconds, I mean it. I know disk I/O can be slow but the fact of the matter is that it basically isn't. Cargo does orders of magnitude more I/O than wasm-pack and wasm-bindgen (like, multiple orders), so there's absolutely no reason that wasm-pack/wasm-bindgen should be slow. If you're seeing 1500ms in wasm-bindgen for a hello world crate, that's bad! If you're seeing a 500ms performance overhead using wasm-pack, that's bad! What I'm asserting above is obviously modulo bugs and such, but I really want to drive home that this is something we care about and a 500ms performance difference is not acceptable. It's something that needs to be diagnosed, fixed, and upstreamed. Can you provide a sample project with reproduction steps to see the discrepancy? If wasm-bindgen takes 1500ms that almost sounds like you're doing a debug build. If wasm-pack takes 500ms extra then I have no idea where that time is going but we need to profile, figure out where it's going, and figure out how to solve it. These are all surmountable issues and we have so much to benefit by staying consistent on the same toolchain (e.g. like Cargo for Rust) so we need to not be distracted by small bugs which make it seem like the whole toolchain needs to be updated.
Sorry what I mean is that I don't believe there's a reason to avoid generating |
Great to hear! I agree that if the performance issues can be fixed, then that is ideal.
Hold on, I need to put it somewhere public, right now it's just sitting on my harddrive. It is doing a
Yes, that was my next plan.
Sure, part of the reason for this feature request was so that I would be able to use wasm-pack instead of wasm-bindgen-cli.
Ah, okay, I understand now. Assuming the performance issues can be fixed, then I agree. But performance isn't the only reason for the flag: the handling of npm dependencies for applications is another. I think we should explore that (though it's not a blocker for me using wasm-pack). |
Okay, I created a time test repo: https://github.com/Pauan/wasm-pack-perf-test After cloning it, do
So But Now I'll do some profiling to see where the issue is. |
I tried turning off the build steps and turning them on one at a time, and this is the result:
(I didn't list some build steps, because they took a negligible amount of time, less than 1ms) Even when it's not running any build steps at all, it still takes ~208ms. Checking the rustc version takes an additional ~106ms, and checking the crate config takes an additional ~128ms on top of that. Building wasm takes ~237ms, which is to be expected (as shown in my previous post). And the rest do take up some time, but only ~88ms in total. So now I need to figure out why checking the rustc version and crate config take so long, and why wasm-pack takes ~208ms even when it does nothing at all. |
I found that {
"packages": [{
"name": "wasm-pack-perf-test",
"version": "0.1.0",
"id": "wasm-pack-perf-test 0.1.0 (path+file:///C:/Users/Pauan/Shared%20Folders/NixOS/wasm-pack-perf-test)",
"license": null,
"license_file": null,
"description": null,
"source": null,
"dependencies": [{
"name": "wasm-bindgen",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"req": "^0.2.48",
"kind": null,
"rename": null,
"optional": false,
"uses_default_features": true,
"features": [],
"target": null,
"registry": null
}, {
"name": "web-sys",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"req": "^0.3.25",
"kind": null,
"rename": null,
"optional": false,
"uses_default_features": true,
"features": ["console"],
"target": null,
"registry": null
}],
"targets": [{
"kind": ["cdylib"],
"crate_types": ["cdylib"],
"name": "wasm-pack-perf-test",
"src_path": "C:\\Users\\Pauan\\Shared Folders\\NixOS\\wasm-pack-perf-test\\src\\lib.rs",
"edition": "2018"
}],
"features": {},
"manifest_path": "C:\\Users\\Pauan\\Shared Folders\\NixOS\\wasm-pack-perf-test\\Cargo.toml",
"metadata": null,
"authors": ["Pauan <pcxunlimited@gmail.com>"],
"categories": [],
"keywords": [],
"readme": null,
"repository": null,
"edition": "2018",
"links": null
}],
"workspace_members": ["wasm-pack-perf-test 0.1.0 (path+file:///C:/Users/Pauan/Shared%20Folders/NixOS/wasm-pack-perf-test)"],
"resolve": null,
"target_directory": "C:\\Users\\Pauan\\Shared Folders\\NixOS\\wasm-pack-perf-test\\target",
"version": 1,
"workspace_root": "C:\\Users\\Pauan\\Shared Folders\\NixOS\\wasm-pack-perf-test"
} |
I believe we only really need I also found that Even |
Hm yeah so I'm trying to get reproducible timings locally for me and what I get get with your
on macOS:
and on Windows
Overall except on Linux wasm-pack has a miniscule overhead (and times are relatively variable), and even on Linux it's a pretty small overhead. Note that Cargo has mechanisms for caching If Overall it does seem like you have a particularly slow system unfortunately. What OS are you on? Do you know if there's like antivirus software or something like that which would slow things down? |
I ran
I don't think we want to turn it off by default, but I could imagine that not running I think it makes sense to invest some time looking into
|
But everything except the Rust tooling is fast: it's extremely weird that running
Windows 10 Home 64-bit (version 1803)
A while ago I had completely turned off all anti-virus, including the built-in Windows Defender anti-virus, so that isn't the issue. @fitzgen I'm curious what times you get when running my perf test. I just updated it to include the timings for various simple commands, this is my result:
|
This option would make I'm trying to build a site which I can deploy with GitHub Pages. The current, unconfigurable, behavior is to deploy a whole lot of extra, unnecessary stuff, including a In contrast, if |
This comment was marked as abuse.
This comment was marked as abuse.
@Pauan I'm curious, can you try running the non-rustup wrappers and see if rustup is where the slowdown is being introduced? You'll have to poke around to find the binaries themselves but I'm basically curious what the difference between these two are:
@nic-hartley @dakom I think y'all's use cases are covered by the functionality changes that |
@alexcrichton Yeah, it's a lot faster when using the raw path:
Using the raw path to the If this discrepancy were fixed, I predict it would improve wasm-pack's performance by ~256ms, which is quite significant. |
This comment was marked as abuse.
This comment was marked as abuse.
I'm not on the machine I was on earlier, but here is my linux laptop's timings:
|
@fitzgen Thanks! |
@Pauan hm do you have experience profiling applications on Windows? A 60ms performance overhead from executing @Pauan also I'm curious, what version of Rust are you using? The stable version right now has a zillion dynamic libraries it needs to load where beta/nightly have a much smaller number of dynamic libraries to load, so I'm curious if that helps the performance at all. |
None at all. I had taken a look at some tools for Windows, but they tend to be proprietary, and none of them seem similar to Linux's
Latest stable,
My Rustup also seems to be up to date: |
Feature Description
when calling
wasm-pack build
a user can optionally pass--no-pack
and wasm-pack will build your wasm, generate js, and not build a package.jsonExample
Outstanding Questions
https://rustwasm.github.io/docs/wasm-pack/commands/build.html#mode
pkg
.. i'd... probably keep this the default for--no-pack
but it will certainly be WeirdThe text was updated successfully, but these errors were encountered: