Fork me on GitHub
#aws
<
2020-03-27
>
ghadi16:03:02

thanks for the clear repro @kenny

✔️ 4
dchelimsky18:03:29

I think that was a refactoring oversight.

4
dchelimsky18:03:41

That wasn't all inside a go block before.

kenny18:03:44

Does response-ch https://github.com/cognitect-labs/aws-api/blob/954bd3c0376d84a7defe5215b9f2dee3059e421f/src/cognitect/aws/client.clj#L82 get garbage collected if region, creds, or endpoint result an anomaly? It seems like a bunch of channels could end up getting built up due to https://github.com/cognitect-labs/aws-api/blob/954bd3c0376d84a7defe5215b9f2dee3059e421f/src/cognitect/aws/client.clj#L107-L115 running even when region/creds/endpoint fetch result in an anomaly.

hiredman18:03:34

channels are not special with regards to gc

kenny18:03:42

Then I'm pretty sure this code could result in a large amount of unused channels.

hiredman18:03:51

in this case you can think of response-ch as being a promise, which will be gc'ed when there are no references to it

hiredman18:03:11

go blocks are not gc roots like threads are

hiredman18:03:17

a go block is transformed in to a callback that is registered on a channel, so if there are no other references to a channel, a channel will get gc'ed even if a go block is waiting to put or take from it

kenny18:03:18

Ah, makes sense! Thanks for that explanation. So in this case, the gc will know immediately there will be no references to response-ch since the :else branch was not run, marking the channel for gc?

hiredman18:03:03

whenever the gc happens to run, if it decides to collect more garbage, it might eventually notice the channel is garbage

✔️ 4
kenny18:03:23

So it would follow, why is this code written this way instead of with a transducer?

hiredman18:03:29

that question makes no sense

kenny18:03:25

i.e., that second go block seems unnecessary

kenny19:03:49

Like this

kenny19:03:31

Or, perhaps even better, this.

kenny19:03:33

Easier to read a patch...

kenny19:03:50

This impl seems cleaner & more efficient.

dchelimsky19:03:28

Cleaner is subjective. For me the separation of "here's all the stuff we do to make a request" from "here's what we do with a response" is easier to reason about.

dchelimsky19:03:42

"more efficient" is less so, of course 🙂

dchelimsky19:03:59

Are you just thinking of the extra go block, or something else?

kenny19:03:26

Fair. And yes, the extra go block.

dchelimsky19:03:47

I'm going to leave it as/is for now and get out the change to the thread pool.

4
dchelimsky19:03:27

I appreciate the input, @kenny. Thanks.

kenny19:03:56

Of course! This library is great. Thanks for taking the time for discussion & maintenance.

dchelimsky19:03:36

Time well invested. I learn things.

✔️ 4