[all-commits] [llvm/llvm-project] 337228: Use a SmallPtrSet rather than a SmallVector in Clu...

jimingham via All-commits all-commits at lists.llvm.org
Thu Aug 18 09:34:45 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 33722848fcb5b569ab3a388cae15f31acf9a9c5e
  Author: Jim Ingham <jingham at apple.com>
  Date:   2022-08-18 (Thu, 18 Aug 2022)

  Changed paths:
    M lldb/include/lldb/Utility/SharedCluster.h

  Log Message:
  Use a SmallPtrSet rather than a SmallVector in ClusterManager.

The m_objects store in this class is only used to check whether
this ClusterManager already owns this pointer.  With a SmallVector
the is_contained call was non-linear in number of children, and for
instance printing all the elements of a 16M element std::vector
didn't complete in the time I was willing to wait for it (hours).

Since we are only doing insert & contains, some kind of set is a
better data structure.  In this patch I used SmallPtrSet.  With
that, the same array prints out in 30 seconds.  I also tried a
std::unordered_set but that was slightly slower and used a fair bit
more memory.

Other than performance, this is NFC.

Differential Revision: https://reviews.llvm.org/D131996

More information about the All-commits mailing list