2 ms·
What are the performance characteristics of channels? I do some work with computer graphics, and a lot of the concurrency concerns involve operating on large c
by skohan 7y ago
What are the performance characteristics of channels? I do some work with computer graphics, and a lot of the concurrency concerns involve operating on large chunks of memory (textures, vertex buffers etc) and my mental model is that channels involve a lot of copying, so you would pay a heavy cost for sending these heavy objects back and fourth. But I have no idea if my mental model is correct.
- twic 7y agoYou'd pass pointers to the buffers over the channels, so there wouldn't be much copying. You would need to be careful that once one goroutine has sent a pointer to a channel, it doesn't touch that buffer again (until the receiver has finished with it, at least), otherwise you can get data races. You're implementing ownership semantics here, and unlike in some languages i could name, you're doing it without help from the type system.
- zamadatix 7y agoAt that point just use a mutex.