core.async

mix throws assertion error when many channels are added to a mix.

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Found in core.async version 0.1.346.0-17112a-alpha
  • Patch:
    Code

Description

When a large number of channels is added to a mix simultaneously, this error is thrown:

java.lang.AssertionError: Assert failed: No more than 1024 pending puts are allowed on a single channel. Consider using a windowed buffer.

We can reproduce the issue with the following in a REPL:

user> (require '[clojure.core.async :as a])
nil
user> (defn mixtest []
(let [out (a/chan 1024)
mix (a/mix out)]
(dotimes [i 2048]
(let [chan (a/chan)]
(a/admix mix chan)
(a/put! chan i)))))

(mixtest)
#'user/mixtestAssertionError Assert failed: No more than 1024 pending puts are allowed on a single channel. Consider using a windowed buffer.
(< (.size puts) impl/MAX-QUEUE-SIZE) clojure.core.async.impl.channels.ManyToManyChannel (channels.clj:150)
user>

This is a consequence of the use of an unbuffered channel in the mix implementation. Since the channel's function is just to update the mix's internal data structure, using a windowed buffered channel appears to clear up this issue. Patch 0001-Change-channel-to-sliding-buffer.patch contains the proposed solution.

Activity

Hide
Angus Fletcher added a comment -

Update patch to include cljs fix as well.

Show
Angus Fletcher added a comment - Update patch to include cljs fix as well.
Angus Fletcher made changes -
Field Original Value New Value
Attachment 0001-Change-channel-to-sliding-buffer-090815.patch [ 15053 ]
Alex Miller made changes -
Labels mix

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: