Fork me on GitHub
#core-async
<
2017-07-03
>
naartjie10:07:28

(def ch (async/chan 10))
(go (async/>! ch data))
I've been trying to figure out: how many of these non-blocking calls you can make before things start to clog up/blow up? What happens, and what is a good way to get to the answer myself, should I be looking at the state machine that is the expanded go macro?

mpenet10:07:57

you have 1024 pending puts per unbuffered channel, no matter the number of go blocks & co, if buffered add the buffer size to that, otherwise if sliding/dropping etc, it doesn't really matter. It's quite easy to test

mpenet10:07:51

(put! ch x) and (go (async/>! ch x)) are equivalent with regards to pending tasks number

mpenet10:07:56

if you go over the pending put queue size it will throw fyi

naartjie12:07:03

@mpenet Thanks! Is there any way to get a count of how many of the 1024 we've used up (and possibly what those pending messages are)? I'm debugging a production server, I created a /health endpoint which basically does a sub, and a (go (async/>! ch :test-message)) and after about 30-45min this stops working.

naartjie13:07:18

@mpenet got it, figured out how to print the put queue size: (.size (.puts ch)). Thanks for your help again. And wish me luck debugging, this is someone else's code. Yikes.

noisesmith16:07:44

1) that go block is better written as (put! ch :test-message) 2) make sure all the topics have consumers, and check that the messages have the topics you think they do

noisesmith16:07:21

(that is, all the topics generated by the pub that you sub to)

tbaldridge16:07:50

Right, if you ever hit the limit of 1024 pending puts on a channel, chances are really high that you have a bug in your code. The limit is artificial and is designed to provide quicker feedback in the case of an unbounded queue.

mpenet17:07:12

Couldnt agree more

mpenet17:07:55

@noisesmith I guess (hope) the go example is a slimmed down example

noisesmith17:07:39

in my experience, core.async code that uses go blocks for a single channel put is common - but of course if they are doing more than that it won’t translate to put! and the suggestion is moot