https://blog.golang.org/ismmkeynote
栈多, 几w到几m
go scheduler 管理
每个gc safepoint都会抢占
go scheduler 通过goroutine多路复用os thread
go是面向值而非引用的
容易控制内存布局
cache局部性好
有一个比较快的ffi
go支持interior pointers
b = &r.blk, 则blk指向的r整个都存活
有static of time compilation, 没有jit recompilation
没法做feedback optimization
两个gc控制参数
SetGCPercent
控制用在gc上的cpu和memory
默认值为100
一半内存用来存放活对象, 另一半用来分配
SetMaxHeap
gc latency
latency 是累积的, 99分位低于一定值没有意义
tyranny of 9s
2014年前怎么解决gc延时
一关掉gc, 一台机器复内存完了, 负载切到其它机器, 完全释放旧的机器
2014~2015
tri-color concurrent algorithm
Size-segregated spans
The garbage collector needs to efficiently find the start of the object. If it knows the size of the objects in a span it simply rounds down to that size and that will be the start of the object.
几点好处
碎片少
参考Google's TCMalloc, Intel's Scalable Malloc
内部结构容易理解
速度
无拷贝, 分配虽然慢, 速度量级和c差不多
Object meta-data
没有对象头(对比java)
使用on-the-side mark bit
每个字(Word), 有两个bits, 主要存:
是指针还是标量
对象里是否有内部指针
一些辅助debug的信息