ByteBuffer - Reduce Allocations for Serialization Path
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- csharp
- 領域
- performance
調査の方向性
Start in Utilities/ByteBuffer.cs by inspecting PutInt, PutLong, GetInt, and GetLong, then review how the buffer manages its internal storage. Compare before and after allocation behavior using benchmark results. Done means the serialization paths avoid the described per-call allocations and supporting before/after benchmarks are provided; the optional Memory or Span refactor is broader scope.
索引モデルが issue の本文から書いたものです。
説明
File: Utilities/ByteBuffer.cs
PutInt and PutLong both call BitConverter.GetBytes(...) which allocates a new byte[] on every call, then immediately Array.Copy it into the buffer. This is avoidable entirely using BinaryPrimitives and MemoryMarshal from System.Buffers:
// BEFORE - allocates byte[] every call public void PutLong(long value) { var longAsBytes = BitConverter.GetBytes(IPAddress.NetworkToHostOrder(value)); Array.Copy(longAsBytes, 0, _internalBuffer, Position, longAsBytes.Length); Position += longAsBytes.Length; }// AFTER - zero allocation
public void PutLong(long value)
{
BinaryPrimitives.WriteInt64BigEndian(_internalBuffer.AsSpan(Position), value);
Position += sizeof(long);
}
public long GetLong()
{
var result = BinaryPrimitives.ReadInt64BigEndian(_internalBuffer.AsSpan(Position));
Position += sizeof(long);
return result;
}
The IPAddress.HostToNetworkOrder / NetworkToHostOrder dance exists solely to handle big-endian byte ordering — BinaryPrimitives.WriteInt64BigEndian does this directly, with no allocation. This applies equally to PutInt/GetInt. On serialization-heavy workloads this is high-impact.
The ByteBuffer itself could also be refactored to work over Memory<byte> or Span<byte> to allow callers to supply pooled or stack-allocated memory rather than always allocating internally.
Any pull requests addressing this change should provide supporting before and after benchmark results.
- 主要言語
- 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
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fluentassertions/fluentassertions#3353 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 半日 初心者へのやさしさ 78/100
unoplatform/uno#24769 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
AvaloniaUI/Avalonia#22323 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microsoft/onnxruntime-genai#2633 ·
メンテナーはふだん 1 日以内に返信