[BUG] DoNotOptimize build break with GCC
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- cpp
- 領域
- testing-qa, tooling
調査の方向性
sdk/test/trace/sampler_benchmark.cc、特に49行目と58行目のコンストラクターのベンチマークから始め、GCC 7.4.1、7.5.0、または12.3.0と、benchmark 1.8.2または1.8.3を使ってビルドを再現してください。benchmark.hの540行目付近にあるGCC固有のDoNotOptimize実装を調べ、その動作をClangと比較してください。両方のコンパイラーでベンチマークのビルドが正常に成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
See downstream bug:
When building the following code:
void BM_ParentBasedSamplerConstruction(benchmark::State &state)
{
while (state.KeepRunning())
{
benchmark::DoNotOptimize(ParentBasedSampler(std::make_shared<AlwaysOnSampler>())); // line 49
}
}
and
void BM_TraceIdRatioBasedSamplerConstruction(benchmark::State &state)
{
while (state.KeepRunning())
{
benchmark::DoNotOptimize(TraceIdRatioBasedSampler(0.01)); // line 58
}
}
the build fails with GCC 7.4.1, GCC 7.5.0, GCC 12.3.0.
The error reported is:
[ 56%] Building CXX object sdk/test/trace/CMakeFiles/sampler_benchmark.dir/sampler_benchmark.cc.o
In file included from /home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc:17:
/opt/benchmark-1.8.2/include/benchmark/benchmark.h: In instantiation of ‘typename std::enable_if<((! std::is_trivially_copyable<_Tp>::value) || (sizeof (Tp) > sizeof (Tp*)))>::type benchmark::DoNotOptimize(Tp&&) [with Tp = opentelemetry::v1::sdk::trace::ParentBasedSampler; typename std::enable_if<((! std::is_trivially_copyable<_Tp>::value) || (sizeof (Tp) > sizeof (Tp*)))>::type = void]’:
/home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc:49:29: required from here
/opt/benchmark-1.8.2/include/benchmark/benchmark.h:540:3: error: read-only reference ‘value’ used as ‘asm’ output
540 | asm volatile("" : "+m"(value) : : "memory");
| ^~~
/opt/benchmark-1.8.2/include/benchmark/benchmark.h: In instantiation of ‘typename std::enable_if<((! std::is_trivially_copyable<_Tp>::value) || (sizeof (Tp) > sizeof (Tp*)))>::type benchmark::DoNotOptimize(Tp&&) [with Tp = opentelemetry::v1::sdk::trace::TraceIdRatioBasedSampler; typename std::enable_if<((! std::is_trivially_copyable<_Tp>::value) || (sizeof (Tp) > sizeof (Tp*)))>::type = void]’:
/home/malff/CODE/MARC_GITHUB/opentelemetry-cpp/sdk/test/trace/sampler_benchmark.cc:58:29: required from here
/opt/benchmark-1.8.2/include/benchmark/benchmark.h:540:3: error: read-only reference ‘value’ used as ‘asm’ output
make[2]: *** [sdk/test/trace/CMakeFiles/sampler_benchmark.dir/build.make:76: sdk/test/trace/CMakeFiles/sampler_benchmark.dir/sampler_benchmark.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4217: sdk/test/trace/CMakeFiles/sampler_benchmark.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
Verified with benchmark 1.8.2 and 1.8.3.
Note that the same code builds fine with CLang.
If this matters, ParentBasedSampler and TraceIdRatioBasedSampler are classes: what is benchmarked here is a call to the constructor.
Note how the benchmark header file is different for GCC, with:
The build failure occurs in:
template <class Tp>
inline BENCHMARK_ALWAYS_INLINE
typename std::enable_if<!std::is_trivially_copyable<Tp>::value ||
(sizeof(Tp) > sizeof(Tp*))>::type
DoNotOptimize(Tp&& value) {
asm volatile("" : "+m"(value) : : "memory"); // line 540
}
Expected result is a successful build with both GCC and Clang.
- 主要言語
- C++
- スター
- 10.5k
- フォーク
- 1.8k
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 30
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/benchmark のほかの issue
-
[BUG] Confusing title in docs/platform_specific_build_instructions.md対応中かも @skryabae が 28 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Memory manager counts allocations not part of benchmark再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
google/benchmark#2149 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
Three small hardening notes from a security review: CSV formula-prefix neutralization, full C0 escaping in the JSON reporter, and type diagnostics in gbench/compare.py対応中かも @Aryan9891 が 7 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 64/100
google/benchmark#2299 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
[FR] Add native Zig bindings via top-level `bindings/zig`再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
google/benchmark#2266 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
google/benchmark#2235 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
google/benchmark の issue をすべて見る
似ている issue
-
documentation enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
QuantStack/git2cpp#203 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
BaptisteHudyma/Lamp-Da#588 ·
メンテナーはふだん 1 日以内に返信
-
bug macOS networking
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
docling-project/docling-parse#448 ·
メンテナーはふだん 5 日以内に返信