[lld] r228968 - [ELF] Insert wrap symbols into a set.

Shankar Easwaran shankare at codeaurora.org
Fri Feb 13 12:46:31 PST 2015


On 2/13/2015 2:37 PM, Chandler Carruth wrote:
> On Fri, Feb 13, 2015 at 12:10 PM, Shankar Easwaran <shankare at codeaurora.org>
> wrote:
>
>> Honestly, std::set is the wrong data type here no matter what.
>> Why ? Order is less important for me but is nice to have too, I want the
>> data structure to contain only unique values.
>>
>>  From cppreference, http://www.cplusplus.com/reference/set/set/
>>
>> Sets are containers that store unique elements following a specific order.
>>
> I know what sets are, and I know what std::set is. ;]
:)
>
> It may correctly model the API you want, but that doesn't mean it is the
> correct data structure to use.
>
> Fundamentally std::set is abysmally slow on modern computers. The
> fundamental structure of it *requires* it to be implemented in terms of a
> balanced tree of nodes, each heap allocated and connected via pointers. The
> result is that traversals of the tree are extremely cache hostile and slow.
> This is in turn magnified by the performance problems of constantly
> rebalancing, as the rebalancing operations require significant traversals
> of the structure.
>
> In essentially every case where std::set is used, there is a better data
> structure to express the same core concept but with significantly faster
> operations, and in many cases using significantly less memory. I've already
> listed the alternatives that seem strictly superior.
>
>
> Also, you should never make data structure decisions based on what would be
> "nice to have". Either you traverse the structure and require the ordering
> to be there, or it isn't required and shouldn't be relevant.
Sure, I will change this to DenseSet.

Shankar Easwaran


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation




More information about the llvm-commits mailing list