[PATCH] D115416: [lld-macho] Prevent writing map files on the critical path

Vincent Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 9 10:43:24 PST 2021


thevinster added a comment.

> Do you have a source for this?

Over at https://www.cplusplus.com/reference/future/async/ under automatic selection, it says `Automatic: The function chooses the policy automatically (at some point). This depends on the system and library implementation, which generally optimizes for the current availability of concurrency in the system.` I think this means that the system will be smart enough to know which one it should use based on its available resources.

Also in the cppreference you have linked, there's a section on Exceptions that says `Throws std::system_error with error condition std::errc::resource_unavailable_try_again if the launch policy equals std::launch::async and the implementation is unable to start a new thread (if the policy is async|deferred or has additional bits set, it will fall back to deferred or the implementation-defined policies in this case)`.

> use the parallel ...() to run writeMapFile() in parallel with { finalizeLinkEditSegment(); writeOutputFile(); }

This was my initial thought. I abandoned this approach because 1/ I didn't quite know what the right syntax is to get this particular thing working and 2/ we aren't really trying to run writeMapFile in parallel with *only* `finalizeLinkEditSegment` or `writeOutputFile`. It's more about putting things off the critical path. Let's say `finalizeLinkEditSegment` is its own thread (for whatever reason) then things gets tricky since we would have a main thread, `writeMapFile` thread, and the `finalizeLinkEditSegment` thread. With async it's easy, but how does that look like with parallel?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115416/new/

https://reviews.llvm.org/D115416



More information about the llvm-commits mailing list