[Feature]: Batch/Throttle operators

Đang mở
#1,019 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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Start by comparing the existing cache-side .Batch() and .BatchIf() operators with the list-side .BufferIf(), .BufferInitial(), and .FlattenBufferResult() described here. The issue names no files or tests, so first locate those operators and the benchmarks behind the table. Done means resolving whether to add or rename operators, and whether the measured performance or discoverability benefits justify the API change.

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

Mô tả

Shoutout to David Hopkins for bringing this up in Slack. He was looking to efficiently create snapshots of a collection, at regular intervals, and deduced that the effective way to do this would be with .Throttle() followed by .ToCollection(), except that there's no DD-native .Throttle() and the RX-native version would throw away changesets.

After looking around, we do have some support for doing this kinda thing, but it's rather disjointed. To summarize:

The cache side of the house has...

  • .Batch() accepting a TimeSpan
  • .BatchIf() accepting IObservable<bool>
  • .BufferInitial() accepting a TimeSpan, which is equivalent to .Batch() but only batches once, during an initial startup window
  • .FlattenBufferResult() that can follow an RX-native .Buffer()

The list side of the house has...

  • No .Batch()
  • .BufferIf() equivalent to .BatchIf() on the cache side
  • .BufferInitial() equivalent to the cache side
  • .FlattenBufferResult() equivalent to the cache side

With .FlattenBufferResult() available, it looks like we don't really have any functional holes in our API, but I was curious whether a custom operator might be able to improve performance.

Method Mean Ratio Allocated Alloc Ratio
NativeBufferFlattened 2.208 ms 1.00 4.26 MB 1.00
CustomBatch_UnitBufferBoundary 2.266 ms 1.03 4.04 MB 0.95
CustomBatch_AnyBufferBoundary 2.277 ms 1.03 4.04 MB 0.95
CustomBatch_Optimized 2.057 ms 0.93 4.04 MB 0.95

Not terribly significant, but measurable.

So, outstanding questions:

  1. Do we want to add a .Batch() to the list side, to match the cache side?
  2. Do we want to try and clean up the naming discrepancies between the other list and cache operators?
  3. Do we want to add more variations on the .Batch() operator, or just stick with the functionality given by .FlattenBufferResult()?
    • Is it worth it for the performance boost?
    • Is it worth it for better discoverability in the API?
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.