[lld] r243232 - ELF2: Avoid calling std::sort to make output deterministic.

Chandler Carruth chandlerc at google.com
Mon Jul 27 16:39:20 PDT 2015


On Mon, Jul 27, 2015 at 4:38 PM Rui Ueyama <ruiu at google.com> wrote:

> On Mon, Jul 27, 2015 at 4:18 PM, Chandler Carruth <chandlerc at google.com>
> wrote:
>
>> On Mon, Jul 27, 2015 at 2:02 PM Rui Ueyama <ruiu at google.com> wrote:
>>
>>> On Mon, Jul 27, 2015 at 12:01 PM, Duncan P. N. Exon Smith <
>>> dexonsmith at apple.com> wrote:
>>>
>>>>
>>>> > On 2015-Jul-25, at 17:50, Rui Ueyama <ruiu at google.com> wrote:
>>>> >
>>>> > Author: ruiu
>>>> > Date: Sat Jul 25 19:50:15 2015
>>>> > New Revision: 243232
>>>> >
>>>> > URL: http://llvm.org/viewvc/llvm-project?rev=243232&view=rev
>>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243232-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=A7YEbZn5UiSjeArc6rLNc6OXlfY7Hm0OXfSQWGYHAns&s=wmdRPI5Lb9TNc_6lTBnZH0eo6CyF0IJSE6TQ7CrgwlU&e=>
>>>> > Log:
>>>> > ELF2: Avoid calling std::sort to make output deterministic.
>>>>
>>>> Using `std::stable_sort` should also make it deterministic.  Is that
>>>> better than switching to a `std::map`?
>>>>
>>>
>>> Yeah, I think the new code is slightly more readable than the previous
>>> one. At least it's shorter than before.
>>>
>>
>>
>> "Yeah" doesn't seem to agree with the rest of your email, so I'm left
>> confused.
>>
>> Why wouldn't switching to std::stable_sort be better?
>>
>> std::map is horribly slow in essentially every way, and so I struggle to
>> believe it is the best tool for the job even if the code using it is very
>> compact.
>>
>
> std::stable_sort would actually be slower than the new code. What we are
> doing here is bin chunks into a few sections, so putting everything into
> one array and stable-sorting them and scanning them again doesn't make much
> sense. We used std::stable_sort in COFF before but I removed that in
> r239292 for that reason.
>

Ok, *this* makes more sense, thanks for that context.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150727/94d91d5c/attachment.html>


More information about the llvm-commits mailing list