Add parEvalMapPartitioned - concurrent eval with per-key ordering

Aperta
#3,800 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
scala

Direzione di ricerca

Read the prototype linked in the issue and compare it with fs2's existing parEvalMap implementation and tests. The proposed operation needs per-key ordering, concurrency and buffering limits, and ordered result emission; the issue also raises unresolved API choices around key equality, overloads, naming, and aliases. Done means those semantics and API questions are resolved and the implementation is covered by tests, including the stated ordered-mode hang.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Elements with the same key run one at a time, in arrival order. Other keys run concurrently, and results are emitted in input order. Akka and Pekko have this as mapAsyncPartitioned.

records
  .parEvalMapPartitioned(maxConcurrent = 32, maxBuffered = 512)(_.record.key) {
    (committable, _) => processRecord(committable.record).as(committable.offset)
  }
  .through(commitBatchWithin(500, 15.seconds))

maxConcurrent limits running effects, for example to a connection pool's size. maxBuffered limits the elements held, including those waiting for their key or to be emitted. There is also a single-limit overload and parEvalMapPartitionedUnordered.

I have a prototype built on parEvalMap here. If an effect fails, later elements with that key are skipped. If an effect fails, the stream terminates with that error, as with parEvalMap. Until then, later elements with the same key aren't evaluated.
It inherits the hang from #3486 in ordered mode.

Questions:

  1. Would you want this in fs2 (I personally need this for processing records from kafka using fs2-kafka)?
  2. Eq or Hash for keys? The prototype uses Eq, with a linear scan over keys in progress.
  3. Is maxBuffered the right name, and should the single-limit overload stay?
  4. Should there be mapAsyncPartitioned aliases? The prototype has none, because Akka's second parameter is perPartition, so mapAsyncPartitioned(32, 40) would silently mean something different.
Lingua principale
Scala
Stelle
2.5k
Fork
633
Merge medio
3g 21h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di typelevel/fs2

Tutte le issue di typelevel/fs2

Issue simili

Altre issue su Scala

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.