[lld] r248052 - COFF: Parallelize Writer::writeSections().

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 18 17:41:43 PDT 2015


Exactly. Each SectionChunk is assigned a unique, non-overlapping offset,
and writeTo write to that region. Except that writeTo does not mutate
anything. Maybe we should make that function const.

On Fri, Sep 18, 2015 at 4:54 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Fri, Sep 18, 2015 at 3:07 PM, Rui Ueyama via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: ruiu
>> Date: Fri Sep 18 17:07:10 2015
>> New Revision: 248052
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=248052&view=rev
>> Log:
>> COFF: Parallelize Writer::writeSections().
>>
>> Self-hosting took 801 ms on my machine. Of which this function took
>> 69 ms. Now it takes 37 ms. That is about 4% overall performance
>> improvement.
>>
>> Modified:
>>     lld/trunk/COFF/Writer.cpp
>>
>> Modified: lld/trunk/COFF/Writer.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=248052&r1=248051&r2=248052&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/COFF/Writer.cpp (original)
>> +++ lld/trunk/COFF/Writer.cpp Fri Sep 18 17:07:10 2015
>> @@ -14,6 +14,7 @@
>>  #include "SymbolTable.h"
>>  #include "Symbols.h"
>>  #include "Writer.h"
>> +#include "lld/Core/Parallel.h"
>>  #include "llvm/ADT/ArrayRef.h"
>>  #include "llvm/ADT/DenseMap.h"
>>  #include "llvm/ADT/STLExtras.h"
>> @@ -708,8 +709,8 @@ void Writer::writeSections() {
>>      // ADD instructions).
>>      if (Sec->getPermissions() & IMAGE_SCN_CNT_CODE)
>>        memset(SecBuf, 0xCC, Sec->getRawSize());
>> -    for (Chunk *C : Sec->getChunks())
>> -      C->writeTo(SecBuf);
>> +    parallel_for_each(Sec->getChunks().begin(), Sec->getChunks().end(),
>> +                      [&](Chunk *C) { C->writeTo(SecBuf); });
>>
>
> I gather this is safely parallelizable as each Chunk will write to
> distinct regions of SecBuf, without ever overlapping/racing?
>
>
>>    }
>>  }
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150918/8ac40ce2/attachment.html>


More information about the llvm-commits mailing list