abseil / abseil/abseil-cpp

[Bug]: Cord causes slow builds all over project

オープン
#1,868 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
18.1k
フォーク
3.2k
平均マージ
20時間 36分
マージ済み PR(30日)
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 を include しているかを調べてください。include 関係を理解するために、Abseil のソース構成を確認してください。提供されている clang -ftime-trace フラグと Bazel を使って、遅いビルドを再現してください。修正には、Cord を使用しないユーザーに Cord のコンパイルを強制しないよう、ヘッダーの依存関係をリファクタリングすることが含まれる可能性があります。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp
領域
build-system, performance
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。