-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add support for WASM_BUILD_CLEAN_TARGET
environment variable that cleans up unnecessary wasm build artifacts
#12672
Conversation
…leans up unnecessary wasm build artifacts
Hm, worked locally, but fails in CI with reason that doesn't make much sense (on Windows): https://github.com/subspace/subspace/actions/runs/3434067151/jobs/5725035860 Upstream bug report: brson/wasm-opt-rs#116 |
Maybe that's because Windows doesn't let you remove files/directories which are still used by something? Anyway, hm, I'm not entirely convinced that this is the way we should fix the problem. (: The main issue here is that every runtime we build gets its own workspace and its own On my 32-core Threadripper it takes something like ~6 minutes to run a I think a proper fix would be to just rework how we build the runtimes and have a shared namespace for building all of them. That would drastically cut down on the compile times and the storage space required. cc @paritytech/sdk-node ** - even though it is a |
As far as I see, the previous process (
I was considering to put all crates under |
The initial implementation was doing exactly this and I have then reworked this to using different target directories. The reasoning behind this was the parallelism. If all are sharing the same target directory, all runtimes would build sequentially and that is really slow ;)
To the pr in general, I'm not convinced that we should need this. If your CI requires this, you can just write some lines like |
It is more involved, I just run |
Well, not necessarily. (: We could put them in the same workspace and the same target directory, and let them still compile in parallel, and since the dependencies would be shared (so they wouldn't have to be compiled up to 14 times as it is the case in The one problem that I can see here (and which @nazar-pc noted) is that cargo will unify the dependencies' features when compiling all of the crates in the workspace, so when building the runtimes it'd have to do it in two steps: first call So in the optimal case if the feature flags are the same across all of the runtimes we'd get a significant speedup in compile times. The more feature flags differ the slower it'd get, since then it would have to compile those sequentially. Or another alternative: have a separate (And if you're wondering what we'd do when someone would like to compile only a single runtime, the answer is also feature flag abuse, but this time in a beneficial way to detect which runtime has to be compiled.) Of course, while technically doable this does have some extra complexity, so even I'm not entirely convinced that we should do it. Probably depends on how many more runtimes we'll add to |
Couldn't you just run |
This doesn't work. When you have a clean target directory, the
For sure it is doable, as I said it was this way in earlier versions. #7532 here is the pr that removed the sequential runtime builds. A much simpler solution (if it finally works, which IDK), would be to use sccache: https://github.com/mozilla/sccache Then you should get shared deps for "free" without needing to do anything special. |
Well, I mean, yeah, that's what I was assuming we'd have to do. :P But as you said, it would indeed make the thing even more complex. If we'd want to reduce complexity yet another option would be to just get rid of the most of I don't really see a perfect solution here that doesn't have at least some downsides. 🤷
Wouldn't that essentially only work only on recompilations? And AFAIK it doesn't support incremental compilation, so it'd work only in |
Crates should be directly being shared. At least I would assume so. Regarding incremental compilation, we compile wasm files always in release mode. You need to opt-in debug if you want it. |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
Resolves #12671