The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
cyhone

Golang channel 源码深度剖析

  •  
  •   cyhone · Feb 11, 2020 · 3790 views
    This topic created in 2281 days ago, the information mentioned may be changed or developed.

    channel 是 Golang 中一个非常重要的特性,也是 Golang CSP 并发模型的一个重要体现。简单来说就是,goroutine 之间可以通过 channel 进行通信。

    channel 在 Golang 如此重要,在代码中使用频率非常高,以至于不得不好奇其内部实现。本文将基于go 1.13 的源码,分析 channel 的内部实现原理。

    点击查看原文

    原文链接: https://www.cyhone.com/articles/analysis-of-golang-channel/

    6 replies    2021-08-16 09:51:52 +08:00
    littlewing
        1
    littlewing  
       Feb 11, 2020
    原来是用的 mutex ....,我还以为是 lockfree
    cyhone
        2
    cyhone  
    OP
       Feb 11, 2020
    讲真我也有点吃惊,估计是 go 团队没有时间去优化这块吧。看这人的提案给出的 benchmark,性能提升有一倍左右。channel 在这块的优化还是有很大空间的
    cyhone
        3
    cyhone  
    OP
       Feb 11, 2020
    @littlewing 讲真我也有点吃惊,估计是 go 团队没有时间去优化这块吧。看这人的提案给出的 benchmark,性能提升有一倍左右。channel 在这块的优化还是有很大空间的
    janxin
        4
    janxin  
       Feb 11, 2020
    @cyhone github.com/golang/go/issues/8899 这个吧?应该没有一倍左右?
    pythonee
        5
    pythonee  
       Feb 20, 2020
    很好的代码分析思路
    Vegetable
        6
    Vegetable  
       Aug 16, 2021
    挖坟了,最近代码优化的时候发现,channel 通信居然成了性能瓶颈,一搜才发现 channel 这么慢...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   999 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 22:16 · PVG 06:16 · LAX 15:16 · JFK 18:16
    ♥ Do have faith in what you're doing.