Comments (14)
now I'm using CMake to generate ninja build, and using mold -run ninja to build whole project,
mold performance is impressive during my test, I'd like to know if mold can implement
mold --preload -run ninja
it doesn't touch cmake, and mold is known to be running at first.
from mold.
@comicfans I think such feature cannot be implemented. In order to do preloading, mold has to know what ninja will do next, but it is generally not predictable.
from mold.
so if I understand correctly, this feature expected to run mold daemon (with exactly same link arguments) even before all input object compile complete, and for real link, it already preload most input? previously I misunderstood preload as 'single daemon to cache all following invocation'
from mold.
Yes, the daemon is for single-use. In order to use the preloading feature, you invoke mold twice instead of once for each linker output. The first one is invoked with --preload
to preload object files, and the second one is invoked without --preload
to tell the daemon to finish its job.
from mold.
I opened an issue in CMake's GitLab, see https://gitlab.kitware.com/cmake/cmake/-/issues/23063
from mold.
It looks not a hard task. Maybe I can implement it in CMake (if I have time). I noticed that preload code has already been removed from the latest mold, then I can firstly try with some old-version mold. If it succeeds, will you re-introduce the preload feature into master? @rui314
And I have another question after some quick experiments: I got the preload command by manually copying the link command printed by ninja -v
and appending -Wl,--preload
to it. But I didn't observe any speedup when I then run the command without preload (the generated library is 2.1GB). Is there something I missing? I have tried with mold 1.0 and 1.2.
from mold.
I removed --preload
because there's no use of it. If it's supported by a build system and proved to be useful, we can discuss resurrecting it.
If you use --preload
, you invoke the linker twice with and without --preload
. You first invoke the linker with --preload
and after a few seconds, run the same command without --preload
. If you always run mold with --preload
, it doesn't do anything but just preloading files (so no output would be created).
from mold.
If you use --preload, you invoke the linker twice with and without --preload. You first invoke the linker with --preload and after a few seconds, run the same command without --preload. If you always run mold with --preload, it doesn't do anything but just preloading files (so no output would be created).
That is actually what I did.
Here is my commands (the libraries I want to generate is named liboneflow.so
, and the time
command output is zsh format):
$ rm liboneflow.so
$ time ./link.sh
./link.sh 0.06s user 0.03s system 2% cpu 3.124 total
$ rm liboneflow.so
$ ./link_preload.sh
# after cpu becomes idle:
$ time ./link.sh
./link.sh 0.05s user 0.05s system 2% cpu 3.294 total
from mold.
0.06s is already too fast, so I don't think you can observe any improvements over it. I think it needs to take at least a few seconds to see an improvement.
from mold.
0.06s is already too fast, so I don't think you can observe any improvements over it. I think it needs to take at least a few seconds to see an improvement.
It is zsh format (which is different with bash) so I think the "total" item (3.124 and 3.294) is corresponding to the "real" item in bash time
and is the wall clock time.
from mold.
@daquexian You can add --perf
to see the breakdown of internal passes. Can you try that option?
from mold.
What I tried:
$ ./link.sh > no_preload
$ ./link_preload.sh
$ ./link.sh > preload
$ ld --version
mold 1.0.0 (ed9924895d9b9584106791247596677db8113528; compatible with GNU ld and GNU gold)
I found there is still a half-second "read_input_files" in preload
.
I uploaded the script I used and also the --perf
output. Download link:
link.sh
link_preload.sh
preload
no_preload
from mold.
I don't know why, but it looks like preloading didn't work at all for your test case. It might be a bug.
from mold.
I don't know why, but it looks like preloading didn't work at all for your test case. It might be a bug.
I see. I'll try to support preload in cmake (when I have time) anyway.
from mold.
Related Issues (20)
- VTT and discarded COMDAT error HOT 3
- x86_64-as-needed-weak (Failed) HOT 4
- Undefined reference when linking shared libraries not raised HOT 1
- mold: error: undefined symbol: OPENSSL_ia32cap_P HOT 7
- cosmic-applets, rust, out of memory when linking? HOT 6
- unknown command line option: -dynamic-list-data HOT 1
- Regarding no-execute HOT 3
- Alpinelinux 32bits build failure HOT 10
- mold 2.33.0 segfaults with --icf=all
- fatal: invalid --build-id argument: fast
- Solutions for ```__wine_spec_nt_header```? HOT 2
- gentoo-test.sh failes due to a conflict HOT 8
- Crash with `-D_GLIBCXX_ASSERTIONS` when building dtrace HOT 4
- void* sizeof ... 0 HOT 1
- Fails to build ninja with mold linker on gcc15 HOT 5
- Linking with mold breaks initialization of thread local storage in Rust under FreeBSD on AMD64 HOT 6
- Compilation Issue HOT 4
- riscv64-absolute-symbols fails with GCC 14 HOT 9
- Speed comparison with LLD of Clang program HOT 6
- `error: undefined symbol: std::__ndk1::basic_string<...>::assign(...)` when linking Firefox for Android with mold HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mold.