Repository navigation
Conversation
|
Interesting! Btw, I think you can make this PR be intended to be merged into the PR it depends on (instead of incoming). Then the diff here is more meaningful (doesn't contain the other PR). And then after the other PR lands you can just change the branch target here (which may be simpler than what you'd need to do otherwise to disentangle it from the already-landed changes). |
|
Diff can be found at quantum5#1. |
|
I see, thanks! Ok, so this makes I love this, but I do worry a little about user-noticeable side effects, in particular around error logging. If more than one of those files has an error, the logging would get mixed up in a racy way, it seems? That's probably a rare case. Maybe to reduce the risk, if more than one invocation returns an error code, we could log a warning to use build source files separately or to use EMCC_CORES=1 or EMCC_DEBUG=1 to avoid racing? |
|
Changed it so that LLVM output is buffered and then output in order. Coloured output is preserved by passing |
|
Sounds good! Would be good to add a test of that in |
|
Added a test to make sure multiple processes don't print at once, and added a test to run emcc on a fake terminal to see if it actually generates the ANSI colour escapes. |
|
Seems like when compiling many large C++ files, this is not necessarily faster than before in terms of wall clock time, while less user/system time is used. For now, this is on hold. |
tlively
left a comment
There was a problem hiding this comment.
We decided to table this change because there was only a benefit when building libraries composed of many tiny source files, and performs slightly worse for other libraries composed of large files. If we maintained both code paths we could save roughly three minutes per run of the emscripten CI, but we are not convinced that this is worth the additional complexity.
|
I think a 3x speedup in libc building is worth looking more into. Yeah, maybe this PR's approach is too risky, but maybe the system library code could have an option to auto-unify source files (it should be ok to generate a smaller number of larger |
|
I'd be interested in seeing a rebased version of this if its easy to produce? IIUC much of this landed as part of the the system library refactor? |
|
@sbc100 rebased onto incoming. |
|
@quantum5 did you have a chance to measure this on windows? hopefully the speedup is even bigger there. (We just got another bug report on the mailing list about the slowness there, we should really fix it.) |
|
I also wonder if emcc could simply construct a single clang command line, and have clang take care of the parallelism internally? Presumably clang does this? |
|
On Windows, this appears to build |
|
The IIUC this is not because we are increasing parallelism but because we are running N * clang.exe rather than N * emcc.py? So the overhead is the python startup time and the python code than runs before emcc forks clang? |
Yes. On libc that is very noticeable since musl has many many tiny C files. Loading a python VM (even with no code) is noticeably a slowdown on such a file. Another option here is to make the library building code "unify" those tiny files into bigger ones. That should be fine for files with no static constructors etc., although it could make linking a little bit slower. |
|
I'm going back and forth on this. It could make debugging a little a harder since you'd end up with one giant failing build command in the case that something went wrong (it would be thousands of chars long presumably?). On the other hand we don't often debug issues with system libraries. Also, most users should be using emsdk so won't be building system libraries themselves. Also, what about the case of "foo/bar.c" + "baz/bar.c" won't they clobber each other? |
|
On Windows, this also appears to be slightly slower for building large C++ libraries. |
|
...sorry for the drive-by comment, but attempting to build musl as a unity build sounds like the most simple option to me, IF it is guaranteed that linking with the resulting obj-file drops unused functions even if LTO is not used (aka function level linking). ...also: what about the other idea that was floating around to offer prebuilt packages for the things that are built under the hood on first emcc invocation? (so instead of compiling, download precompiled libs, maybe move the whole "magic" into emsdk too). |
|
Yes, most users should get prebuilt libraries since they use emsdk. Even for users who do not use emsdk it s one-time cost and the results are caches, so build speed is not a huge issue. I think attempting unity build would be overkill for these reasons. |
So far just libc, to start with. See emscripten-core/emscripten#8795 for background discussion
|
The deletion of the Re-opening and re-targeting to master. |
|
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
|
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
|
I wonder if we can use bare clang to compile (but not link) the system library sources these days to remove the Python startup overhead. |
I like this idea |
emcc.emcc: use a thread pool to build all arguments in parallel.We have to use a thread pool because the function depends on a lot of unpicklable internal state.
This appears to build libc 3 times faster than before.