[all-commits] [llvm/llvm-project] 4fce7d: [clang] Add one-entry cache for ASTContext::getDec...
Nico Weber via All-commits
all-commits at lists.llvm.org
Mon Sep 28 09:25:42 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4fce7d6bfb18abfd20021e679f8fce489a6ed898
https://github.com/llvm/llvm-project/commit/4fce7d6bfb18abfd20021e679f8fce489a6ed898
Author: Nico Weber <thakis at chromium.org>
Date: 2026-09-28 (Mon, 28 Sep 2026)
Changed paths:
M clang/include/clang/AST/ASTContext.h
M clang/lib/AST/ASTContext.cpp
Log Message:
-----------
[clang] Add one-entry cache for ASTContext::getDeclAttrs() (#226610)
In libc++, almost every decl has attributes, so ASTContext::DeclAttrs
has 50k-150k entries when using libc++. But attributes are often queried
several times in a row for the same decl (e.g. `D->hasAttr<A>() ||
D->hasAttr<B>()`). Numbers for some Chromium TUs:
getDeclAttrs() same Decl as table
calls previous call size
blink logical_box_fragment.cc 19.6M 88.4% 156132
glic_webui_contents_manager.cc 16.0M 86.1% 144545
tflite kernels/conv.cc 6.1M 91.2% 52623
So add a one-element cache. AttrVecs are allocated separately, so
keeping a pointer to the result is safe.
Build time for 60 random Chromium TUs drawn with probability
proportional to their compile time:
CPU time: 240.3 s => 237.4 s, -1.20%
instructions: 2489.0e9 => 2452.9e9, -1.45%
(To check noise level, running this with the same binary twice: +-0.04%
CPU time, +-0.01% instructions.)
Every one of the 60 TUs improves, by 0.98% to 2.26% in instructions.
No behavior change.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list