BufferInitial gets into loop if timeout is less than 1 ms

Đang mở
#1,170 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
57/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
C#
Star
1.9k
Fork
194
Merge trung bình
12 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của reactivemarbles/DynamicData

Tất cả issue của reactivemarbles/DynamicData

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.