LongConcurrentHistogram.IncrementCountAtIndex — Two Atomic Operations Where One Suffices
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- リファクタリング
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- csharp
- 領域
- performance
調査の方向性
Start in LongConcurrentHistogram.cs at IncrementCountAtIndex and inspect TotalCount, including its Interlocked.Read usage. Compare the Java original and the mentioned Recorder pattern to understand the alternatives. Done means selecting and validating one approach for reducing recording atomic operations without breaking count correctness.
索引モデルが issue の本文から書いたものです。
説明
File: LongConcurrentHistogram.cs
protected override void IncrementCountAtIndex(int index)
{
long criticalValue = _wrp.WriterCriticalSectionEnter();
try
{
_counts.IncrementAndGet(index); // Interlocked.Add
Interlocked.Increment(ref _totalCount); // second atomic op
}
finally { _wrp.WriterCriticalSectionExit(criticalValue); }
}
Every RecordValue call in the concurrent histogram pays for WriterCriticalSectionEnter (an Interlocked.Increment), Interlocked.Add on the count, Interlocked.Increment on _totalCount, and WriterCriticalSectionExit (another Interlocked.Increment). That's four atomic operations per record.
_totalCount is only read by TotalCount which already calls Interlocked.Read. Consider whether _totalCount needs to be updated atomically at all during recording, or whether it can be derived lazily by summing the array (expensive) or maintained with a Volatile.Write (cheaper). The Java original avoids this cost by using a single updater CAS. A Recorder-pattern approach (per-thread histograms merged on read) avoids the issue entirely and is the recommended usage pattern anyway.
- 主要言語
- C#
- スター
- 185
- フォーク
- 31
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
HdrHistogram/HdrHistogram.NET のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
HdrHistogram/HdrHistogram.NET#167 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
HdrHistogram/HdrHistogram.NET#166 ·
-
WriterReaderPhaser.FlipPhase - Task.Yield().GetAwaiter().GetResult() is a Thread Pool Anti-Patternオープンagent enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
HdrHistogram/HdrHistogram.NET#144 ·
-
agent enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
HdrHistogram/HdrHistogram.NET#142 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
HdrHistogram/HdrHistogram.NET#156 ·
HdrHistogram/HdrHistogram.NET の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
builtbybel/CrapFixer#112 ·
-
area-ai untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
dotnet/extensions#7790 ·
メンテナーはふだん 1 日以内に返信
-
Beginner Friendly T: Bugfix
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
space-wizards/space-station-14#46220 ·
メンテナーはふだん 1 日以内に返信
-
P2 testing
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
area-Infrastructure-coreclr os-ios os-maccatalyst os-tvos untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/runtime#134766 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信