[PATCH] D136565: [clang] Instantiate alias templates with sugar

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 8 04:26:43 PST 2022


alexfh added a comment.

In D136565#3913932 <https://reviews.llvm.org/D136565#3913932>, @mizvekov wrote:

> @alexfh Thanks!
>
> While there is a huge increase in the amount of UsingTypes, it seems the total amount is still reasonable and does not explain the perf hit.
>
> Perhaps this is a case of bad hashing and they are all falling into the same bucket?
>
> cc @sam.mcall for awareness of UsingType issue.
> It may be some very simple problem, I just can't even look at the code right now.

I've reduced the test case to an initializer with a few thousand std::variant elements (F25231339: q2.cc <https://reviews.llvm.org/F25231339>), which is compiled around 2 times slower with the clang with this patch vs clang before the patch:

  $ ../clang-base -fsyntax-only q2.cc  -ftime-report ; ../clang-exp -fsyntax-only q2.cc  -ftime-report
  ===-------------------------------------------------------------------------===
                            Clang front-end time report
  ===-------------------------------------------------------------------------===
    Total Execution Time: 7.4495 seconds (7.4498 wall clock)
  
     ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
     7.2215 (100.0%)   0.2280 (100.0%)   7.4495 (100.0%)   7.4498 (100.0%)  Clang front-end timer
     7.2215 (100.0%)   0.2280 (100.0%)   7.4495 (100.0%)   7.4498 (100.0%)  Total
  
  ===-------------------------------------------------------------------------===
                            Clang front-end time report
  ===-------------------------------------------------------------------------===
    Total Execution Time: 13.7677 seconds (13.7686 wall clock)
  
     ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
    13.5666 (100.0%)   0.2011 (100.0%)  13.7677 (100.0%)  13.7686 (100.0%)  Clang front-end timer
    13.5666 (100.0%)   0.2011 (100.0%)  13.7677 (100.0%)  13.7686 (100.0%)  Total

When I duplicate the number of array elements, the parsing time after the patch grows by a larger factor:

  $ ../clang-base -fsyntax-only q2.cc  -ftime-report ; ../clang-exp -fsyntax-only q2.cc  -ftime-report
  ===-------------------------------------------------------------------------===
                            Clang front-end time report
  ===-------------------------------------------------------------------------===
    Total Execution Time: 14.1165 seconds (14.1173 wall clock)
  
     ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
    13.7642 (100.0%)   0.3523 (100.0%)  14.1165 (100.0%)  14.1173 (100.0%)  Clang front-end timer
    13.7642 (100.0%)   0.3523 (100.0%)  14.1165 (100.0%)  14.1173 (100.0%)  Total
  
  ===-------------------------------------------------------------------------===
                            Clang front-end time report
  ===-------------------------------------------------------------------------===
    Total Execution Time: 41.6697 seconds (41.6729 wall clock)
  
     ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
    41.2583 (100.0%)   0.4114 (100.0%)  41.6697 (100.0%)  41.6729 (100.0%)  Clang front-end timer
    41.2583 (100.0%)   0.4114 (100.0%)  41.6697 (100.0%)  41.6729 (100.0%)  Total

Thus, the patch introduces non-linear dependency of compilation times from the number of certain elements in the AST.

I'm going to revert the patch for now and let you figure out this when it's convenient to you. Have a nice vacation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136565



More information about the cfe-commits mailing list