ByteBuffer - Reduce Allocations for Serialization Path
@LeeCampbell ya está trabajando en esto.
Desde el 24/3/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- csharp
- Área
- performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 185
- Forks
- 31
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de HdrHistogram/HdrHistogram.NET
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
HdrHistogram/HdrHistogram.NET#167 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
HdrHistogram/HdrHistogram.NET#166 ·
-
WriterReaderPhaser.FlipPhase - Task.Yield().GetAwaiter().GetResult() is a Thread Pool Anti-PatternAbiertoagent enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
HdrHistogram/HdrHistogram.NET#144 ·
-
agent enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
HdrHistogram/HdrHistogram.NET#142 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
HdrHistogram/HdrHistogram.NET#156 ·
Todos los issues de HdrHistogram/HdrHistogram.NET
Issues similares
-
:watch: Not Triaged async-task-programming/subsvc dotnet-csharp/svc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Python: Bug: AnnotationContent and StreamingAnnotationContent to_element writes CitationType.X, so annotations in a rendered chat history fail to parsePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertopython triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/semantic-kernel#14590 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
Needs-Triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
PowerShell/PowerShell#28194 ·
Los mantenedores suelen responder en 1 día
-
AI Projects Client customer-reported needs-team-attention question Service Attention
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Azure/azure-sdk-for-net#63804 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día