[Bug]: Cord causes slow builds all over project
- 主要語言
- C++
- 星號
- 18.1k
- 分支
- 3.2k
- 平均合併
- 20 小時 36 分鐘
- 30 天內合併 PR
- 1
描述
### Describe the issue
While diagnosing my slow builds in a project that depends on Abseil, I concluded that Cord is the outstanding culprit. I don't use Cord, but I do use flags, and flags depend on flat_hash_map, and flat_hash_map comes with a header that _can_ hash a Cord, and thereby depends on Cord. It would be neat if there was a way to untie this knot so that only Cord users depended on Cord and its hasher.
According to `-ftime-trace` analysis these are the top three most expensive template instantiations for a small portion of my build that really should have been trivial but actually takes 55s to compile:
```
**** Templates that took longest to instantiate:
3932 ms: std::deque::operator= (31 times, avg 126 ms)
3861 ms: std::deque::assign::__assign_wi... (31 times, avg 123 ms)
```
### Steps to reproduce the problem
Use clang's `-ftime-trace` flag in your project that needs Abseil-cpp flags, then analyze the output with ClangBuildAnalyzer.
### What version of Abseil are you using?
HEAD
### What operating system and version are you using?
Ubuntu Linux 24.04
### What compiler and version are you using?
/opt/llvm-19/bin/clang -v
clang version 19.1.7
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm-19/bin
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc/aarch64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
### What build system are you using?
Bazel 7.6.1
### Additional context
These results are seen with libc++, if that makes a difference.
貢獻指南
研究方向
The issue points to a compile-time performance problem in Abseil's Cord and flat_hash_map headers. Start by examining the header dependency chain, particularly how flat_hash_map's hasher includes Cord. Look at the Abseil source structure to understand the include relationships. Reproduce the slow build using the provided clang -ftime-trace flag and Bazel. A fix likely involves refactoring header dependencies to avoid forcing Cord compilation on non-Cord users.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- cpp
- 領域
- build-system, performance
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100