abseil / abseil/abseil-cpp

[Bug]: Cord causes slow builds all over project

未关闭
#1,868 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
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.

贡献指南

打开贡献指南

调研方向

该 issue 指向 Abseil 的 Cord 和 flat_hash_map 头文件中的编译时性能问题。首先检查头文件依赖链,特别是 flat_hash_map 的 hasher 如何包含 Cord。查看 Abseil 的源代码结构,以了解 include 关系。使用提供的 clang -ftime-trace 标志和 Bazel 重现缓慢的构建。修复可能涉及重构头文件依赖关系,以避免对不使用 Cord 的用户强制进行 Cord 编译。

由索引模型根据 Issue 内容生成。

评估

技术栈
cpp
领域
build-system, performance
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。