Skip to content

Buffered-stream goes over capacity when put! and try-put! don't respect backpressure #110

@jeroenvandijk

Description

@jeroenvandijk

manifold.stream/buffered-stream allows a bigger buffer-size than what is configured when using s/put! or s/try-put! and ignoring backpressure:

(require '[manifold.stream :as s])

(let [s (s/buffered-stream 10)
   f (future
       (dotimes [i 100]
         (s/put! s i)))]


;; Wait a bit to fill up the stream
(Thread/sleep 100)

(s/description s) ;#=> {:buffer-capacity 10, :buffer-size 100, :closed? false, :drained? false, :pending-puts 0, :pending-takes 0, :permanent? false, :sink? true, :source? true, :type "manifold"}

The same happens with manifold.stream/try-put!. I've confirmed that manifold.stream/stream doesn't have this issue.

This was observed with [manifold "0.1.6-alpha1"] and [org.clojure/clojure "1.8.0"] and Java 8

Here is a complete test file with all these cases https://gist.github.com/jeroenvandijk/a753b5945b6cd1f8fa8811e4c393f974

Note that there is no limit on the buffer-size at all. In production I've seen buffers go over their configured limit times 100.

Thanks to @dm3 for narrowing down this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions