<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/148759>148759</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Document that ThinLTO parallelism is limited to the number of bitcode files
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nh2
</td>
</tr>
</table>
<pre>
The documentation on https://clang.llvm.org/docs/ThinLTO.html says
> all transformations, including function importing, occur later when the modules are optimized in fully parallel backends
>
> the ThinLTO link step will launch as many threads in parallel as there are cores
so I had high hopes that ThinLTO would allow to achieve very fast [unity builds](https://en.wikipedia.org/wiki/Unity_build), because optimisation would be "parallel".
However, testing it, I noticed that there is no pallelism in that case. I observed that **the linker only spawns as many threads as there were `.o` files** created during the bitcode-creation steps.
This meant that, contrary to my hopes, **ThinLTO can never compile faster than a normal non-ThinLTO build.**
Is this expected / as designed, or could it be made faster (e.g. per-function optimisation parallelism)?
If it is as designed, it would be great to document this constraint on that page.
CC @teresajohnson
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxkVE9v67YT_DT0ZRFBpvwnOuiQl_yMX4ACvaTngiJX0r5QpMCl7LqfvljJdl5awLAhUzuzM7NLw0x9QGzU_ofav23MnIeYmjDoTRvdtfkYEFy084ghm0wxQAww5Dyxql6UPil9st6EvvD-PBYx9UqfXLSs9OljoPDbx-_FkEcPbK6syhf5VP8D4z3kZAJ3MY0LLCv9ChSsnx2FHro52IWNximmTKGX82jtnMCbjAkuAwbIA8IY3eyRwSSEOGUa6W90QAG62fsrTCYZ79FDa-wnBsdrC7dGBODWJ3gKn8AZJ7iQ9-DNHOwAhmE04Qp5SGgcC_AD0rAAJFy4bUx4k8gR3mEwDgbqBxjihPKiyQ-qS5y9ExfiBXIEYwfCM8IZ0xU6wxnU_sccKF-hnck7Vvs3pZ-_246huNAnTejI3IyXZ6VPf0jln0ul0r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