知识卡片
热点字段布局依赖目标架构
Once的done位于结构体开头,使频繁完成检查在某些架构上使用更紧凑的寻址或更少指令。它说明布局应服务真实热路径;并不意味着任意结构把常用字段放第一都会可测加速,或CPU访问其他字段总需额外一条加法指令。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Go sync.Once · 查看原书依据
Placing done first allows more compact instructions on some architectures (amd64/x86), // and fewer instructions (to calculate offset) on ot
参考来源
- 位置:《Go 语言高性能编程》第19章《Go sync.Once》(来源项目book-sources;源文件:extracted/Go 语言高性能编程/_epub-src/OEBPS/Text/19.html)
- 结论依据:Once的done位于结构体开头,使频繁完成检查在某些架构上使用更紧凑的寻址或更少指令。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:Placing done first allows more compact instructions on some architectures (amd64/x86), // and fewer instructions (to calculate offset) on ot