BufferInitial gets into loop if timeout is less than 1 ms

Abierto
#1,170 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
57/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
csharp
Área
backend

Línea de trabajo

The issue provides a reproduction test for BufferInitial using 999- and 1000-microsecond timeouts, but names no source or test file. Start by locating the BufferInitial implementation and running the supplied test in the project’s test suite. Done means the sub-millisecond case no longer spins or allocates excessively, or it throws ArgumentException if such timeouts are unsupported.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Describe the bug 🐞

BufferInitial gets into loop if timeout is less than 1 ms.

Take a look at the test below.

It works ok if timeout is 1ms, but it starts spinning 1 CPU core to 100% and allocate piles of garbage if the timeout is 999us.

For the 999us case values of the variables:
allocatedBefore: 5842280
allocatedAfter: 142591816

Step to reproduce
    [Theory]
    [InlineData(999)]
    [InlineData(1000)]
    public async Task Test_BufferInitial(int microseconds)
    {
        using SourceCache<Item, int> cache = new(x => x.Id);

        long allocatedBefore = GC.GetTotalAllocatedBytes();

        using (cache.Connect().BufferInitial(TimeSpan.FromMicroseconds(microseconds)).Subscribe())
            await Task.Delay(TimeSpan.FromSeconds(1), TestContext.Current.CancellationToken);

        long allocatedAfter = GC.GetTotalAllocatedBytes();

        Assert.True(allocatedAfter - allocatedBefore < 10 * 1024 * 1024);
    }
Expected behavior

If the operator does not expect such small values, it should throw ArgumentException

Lenguaje dominante
C#
Estrellas
1.9k
Forks
194
Merge medio
12 min
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de reactivemarbles/DynamicData

Todos los issues de reactivemarbles/DynamicData

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.