[Feature]: Batch/Throttle operators

オープン
#1,019 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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?
主要言語
C#
スター
1.9k
フォーク
194
平均マージ
12分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

reactivemarbles/DynamicData のほかの issue

reactivemarbles/DynamicData の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。