core-async

dpsutton 2024-06-27T22:32:13.218869Z

I think we are spawning a bunch of go blocks that are waiting for a signal from a promise chan to signal cancelling. We never close those channels and I suspect we are leaking those go blocks. (I’m actually tracking down an issue where we were spawning some futures for this purpose elsewhere and we were leaking those threads.) Is there a way i can get a hacky count of go blocks? Fine if it’s reaching in, just wanting to confirm hypothesis.

2024-06-28T00:46:14.431039Z

No

2024-06-28T00:47:54.823919Z

Go blocks don't really exist at runtime, they end up being either code running on an executor or callbacks waiting on a channel

2024-06-28T00:48:56.238959Z

Go blocks are not gc roots like a thread is

2024-06-28T00:50:12.583539Z

If a go block is not actively running the only thing that keeps it alive from a gc perspective is the reference to its callback the channel has. If the channel is not referenced it is gc'able regardless of if a go block is waiting on it or not

dpsutton 2024-06-28T00:54:02.066409Z

Dang. Was hoping there was some queue somewhere that I could count

dpsutton 2024-06-28T00:55:19.882639Z

But the construct (when (a/<! cancel-chan) …) in a thread will obviously not allow the thread to go away if the channel is never closed or gets a value. Will the go block hang around?

2024-06-28T01:35:07.545899Z

A go block waiting on a channel operation will get gc'ed if the channel does

2024-06-28T01:35:35.277689Z

A go block is just a callback when it is waiting on a channel operation