[all-commits] [llvm/llvm-project] 5d8d3a: [NFC] Increase initial size of FoldingSets used in...

yurai007 via All-commits all-commits at lists.llvm.org
Tue Feb 8 08:54:29 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5d8d3a11c4d4ed8bb610f60f8fa37b8043a40acd
      https://github.com/llvm/llvm-project/commit/5d8d3a11c4d4ed8bb610f60f8fa37b8043a40acd
  Author: Dawid Jurczak <dawid_jurek at vp.pl>
  Date:   2022-02-08 (Tue, 08 Feb 2022)

  Changed paths:
    M clang/include/clang/AST/ASTContext.h
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/CodeGen/CodeGenTypes.h

  Log Message:
  -----------
  [NFC] Increase initial size of FoldingSets used in ASTContext and CodeGenTypes

Among many FoldingSet users most notable seem to be ASTContext and CodeGenTypes.
The reasons that we spend not-so-tiny amount of time in FoldingSet calls from there, are following:

  1. Default FoldingSet capacity for 2^6 items very often is not enough.
     For PointerTypes/ElaboratedTypes/ParenTypes it's not unlikely to observe growing it to 256 or 512 items.
     FunctionProtoTypes can easily exceed 1k items capacity growing up to 4k or even 8k size.

  2. FoldingSetBase::GrowBucketCount cost itself is not very bad (pure reallocations are rather cheap thanks to BumpPtrAllocator).
     What matters is high collision rate when lot of items end up in same bucket slowing down FoldingSetBase::FindNodeOrInsertPos and trashing CPU cache
     (as items with same hash are organized in intrusive linked list which need to be traversed).

This change address both issues by increasing initial size of FoldingSets used in ASTContext and CodeGenTypes.

Extracted from: https://reviews.llvm.org/D118385

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




More information about the All-commits mailing list