This document summarizes a Pull Request (PR) that improves the performance of receiving from an empty closed channel in Go. It begins by describing the PR title and motivation to speed up non-blocking receives on closed channels. It then provides background on how channels work in Go, explaining their circular queue mechanism and how goroutines can block on channel operations. The document details how the PR implementation checks if the channel is empty and closed before locking, avoiding the overhead of locking in this common case. It concludes with a demo of the performance improvement using benchmarks and profiling tools.
2. Agenda
A PR title : runtime: speed up receive
on empty closed channel
How channel work
How the PR do to improve performance
Analysis
3. A PR title : runtime: speed up receive
on empty closed channel
4. runtime: speed up receive on empty closed channel
Currently, nonblocking receive on an open channel is about
700 times faster than nonblocking receive on a closed channel.
This change makes closed channels equally fast.