Coder Social home page Coder Social logo

Comments (14)

comicfans avatar comicfans commented on July 18, 2024 1

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.

rui314 avatar rui314 commented on July 18, 2024

@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.

comicfans avatar comicfans commented on July 18, 2024

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.

rui314 avatar rui314 commented on July 18, 2024

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.

gruenich avatar gruenich commented on July 18, 2024

I opened an issue in CMake's GitLab, see https://gitlab.kitware.com/cmake/cmake/-/issues/23063

from mold.

daquexian avatar daquexian commented on July 18, 2024

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.

rui314 avatar rui314 commented on July 18, 2024

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.

daquexian avatar daquexian commented on July 18, 2024

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.

rui314 avatar rui314 commented on July 18, 2024

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.

daquexian avatar daquexian commented on July 18, 2024

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.

rui314 avatar rui314 commented on July 18, 2024

@daquexian You can add --perf to see the breakdown of internal passes. Can you try that option?

from mold.

daquexian avatar daquexian commented on July 18, 2024

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.

rui314 avatar rui314 commented on July 18, 2024

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.

daquexian avatar daquexian commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.