2 ms·
>* Of course, if you write that software that do care about nanoseconds and channels becomes your bottleneck - congratulations, you're doing great, and you prob
by nemothekid 11y ago
>* Of course, if you write that software that do care about nanoseconds and channels becomes your bottleneck - congratulations, you're doing great, and you probably have to switch to C++, Rust or even Assembler.*
Thats ridiculous. I could switch my entire language... or I could just use a lock?
First off, looking at Tyler's post, he measured unbuffered channels taking 2200ns vs 400ns for the lock solution - a 5x speed up. That is a large gain, especially when dealing a program that may have high lock contention. Switch from Go to C++ or Rust my not even gain you that much in terms of throughput - they are both compiled code and moving to either language will only mainly alleviate of magic STW pauses - acquiring a lock likely won't be any faster.
Second, in the point of Game and Player, the logic to handle conditions where players disconnect is still simpler to implement with locks - its 2 lines, and there is no need to bring in sync.Pool, or introduce arbitrary timeouts.
Channels are slower than locks. In more complex applications, channels are easier to reason about than locks, but those tends to be in cases where you care more about message passing than state synchronization.
- pcwalton 11y ago> Switch from Go to C++ or Rust my not even gain you that much in terms of throughput - they are both compiled code and moving to either language will only mainly alleviate of magic STW pauses That is not the only performance-related difference between those language implementations. It's not even the most significant one. For instance, there is a large difference between a compiler with LLVM's optimizations and one without an SSA backend at all.
- ngrilly 11y agoThe new Go SSA backend was merged into tip a few days ago: https://groups.google.com/d/topic/golang-dev/49VaiLCDbeQ/discussion https://groups.google.com/d/topic/golang-dev/49VaiLCDbeQ/dis...