[all-commits] [llvm/llvm-project] 94b2ca: [pseudo] GC GSS nodes, reuse them with a freelist

Sam McCall via All-commits all-commits at lists.llvm.org
Wed Jun 8 14:44:56 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 94b2ca18c10bfb4107a850d63148fc51e65d9512
      https://github.com/llvm/llvm-project/commit/94b2ca18c10bfb4107a850d63148fc51e65d9512
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2022-06-08 (Wed, 08 Jun 2022)

  Changed paths:
    M clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
    M clang-tools-extra/pseudo/lib/GLR.cpp
    M clang-tools-extra/pseudo/tool/ClangPseudo.cpp
    M clang-tools-extra/pseudo/unittests/GLRTest.cpp

  Log Message:
  -----------
  [pseudo] GC GSS nodes, reuse them with a freelist

Most GSS nodes have short effective lifetimes, keeping them around until the
end of the parse is wasteful. Mark and sweep them every 20 tokens.

When parsing clangd/AST.cpp, this reduces the GSS memory from 1MB to 20kB.
We pay ~5% performance for this according to the glrParse benchmark.
(Parsing more tokens between GCs doesn't seem to improve this further).

Compared to the refcounting approach in https://reviews.llvm.org/D126337, this
is simpler (at least the complexity is better isolated) and has >2x less
overhead. It doesn't provide death handlers (for error-handling) but we have
an alternative solution in mind.

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




More information about the All-commits mailing list