[PATCH] D158689: [llvm-profdata] Fix dangling reference after D147740

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 21:23:09 PDT 2023


wenlei added a comment.

In D158689#4615855 <https://reviews.llvm.org/D158689#4615855>, @huangjd wrote:

> In D158689#4615675 <https://reviews.llvm.org/D158689#4615675>, @davidxl wrote:
>
>> What is the root cause of unordered_map being slower?
>
> I think it is just the implementation in general, their algorithms are quite different.

The perf difference is likely directly related to reference stability. unordered_map stores pointers to values in the buckets, whereas DenseMap store the values directly in the hash buckets. DenseMap has one less indirection and better locality, at the cost of reference stability - rehash would lead to reallocation for values.

Sometimes it's okay to give up reference stability for performance, but as the container actually owning all FunctionSamples, not providing reference stability means anyone holding a reference or pointer to any FunctionSamples is prone to dangling reference issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158689



More information about the llvm-commits mailing list