Open igorsol opened 2 years ago
Later I found that there is -Wl,--no-threads
parameter on the generated command line. So I tried to replace it with -Wl,--threads
. Result linking time is even longer: 4m 33s.
I also tried to add -Wl,--thread-count=8
to the g++ command line but linking time is still 4m 40s.
Thank you for you report! I have trouble with building mongodb on my machine, so I couldn't reproduce the issue, but I'll try again.
@igorsol I think you have to specify LINK
or SHLINK
to set the linker for Scons, see https://scons.org/doc/production/HTML/scons-user/apa.html
mold seems to be faster than gold on my machine. This is what I tried:
python3 buildscripts/scons.py VERBOSE=1 install-mongod | tee log
to get the command line argument to build build/opt/mongo/db/mongod
mongod
Here is the result:
ld.lld 4.546s
ldmold 3.328s
ld.gold 59.935s
I run the linker commands with taskset 0xffff
to simulate a 8-core 16-thread machine.
Are you sure you are using mold? mold leaves its identification string in a .comment
section like this:
$ readelf -p .comment build/opt/mongo/db/mongod
String dump of section '.comment':
[ 0] GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
[ 2a] GCC: (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
[ 56] mold 1.0.1 (c3466b90212e7aae10fa0480d90d1ca01875cf88; compatible with GNU ld)
Please double check you are using mold with the above command.
Yes, I'm sure I use mold. I checked this with readelf
command.
From your example I see you built mold from commit c3466b902 - I will recheck with this commit.
Did you modify linker command to remove -Wl,--no-threads
parameter?
My command line didn't have -Wl,-no-threads
.
I wonder what exactly is your command. My link time of mongod
is about 2 seconds, but you said it took 4 minutes and 33 seconds. It's very likely that your number includes something that is not linker.
While revisiting this issue https://github.com/rui314/mold/issues/730 comes to mind as a case of threading giving no advantage or even regressions.
Were you running Linux directly on your machine or relied on some kind of virtualization, including but not limited to WSL2?
In my case that was linux guest in VitualBox on the Windows host. I will try to update my tests with the latest mold version.
I'm pretty sure that that's a performance issue of VirtualBox and/or Windows. mold is also slow on WSL2. My guess is that the virtual machines on Windows does not scale well for highly multi-threaded applications.
Thanks for fixing #196. Now I can test mold with linking MongoDB binaries.
Environment: Ubuntu 20.04, 8 core intel processor, gcc 9.3.0, mold built from commit 04ad22d326d.
I failed to figure out how to use mold with scons build tool used in MongoDB builds. So I tested it this way:
Now testing results: