系统与数据库2019akkadia.org编辑精选
每个程序员都应该了解的内存知识(2007)
What Every Programmer Should Know About Memory (2007)
进阶 · 约 300 分钟读完前置知识:计算机体系结构基础、C/C++ 编程经验、CPU 缓存基础
导读
Ulrich Drepper 2007 年的经典长文,系统讲解程序员需要了解的内存硬件知识:CPU 缓存、缓存行、内存访问延迟与性能优化等底层原理。文章长达 114 页,在当年属于相当超前的专业知识,至今仍被广泛引用。
HN 关注点:HN 读者在争论这份 2007 年的"必读"文献在今天是否仍然必要——有人视其为奠基之作,也有人认为对普通应用开发者过于底层。
后来怎么样
成为程序员理解 CPU 缓存与内存性能的事实标准参考文献,此后多年在 C++ 社区被广泛引用和讨论,深刻影响了数据结构布局与缓存友好编程的实践。
HN 评论精选
这几条评论里:支持 1 质疑 2 补充 1
支持这篇论文在当时是开创性的专业知识,深刻影响了此后多年的 C++ 社区
这里有些刻薄的评论,但背景很重要。2008 年初我做高频交易时这篇论文传到了我手上。说大多数 CS 课程教缓存行是因为这篇论文可能有点夸张,但在它写作的年代,这些确实是非常专业的知识,对大多数软件开发者来说是开创性的。此后至少五年里,它成为 C++ 圈重要人物(Boost 维护者、STL 开发者等)博客上的热门话题。另外,如果你了解 Ulrich Drepper 的风格,这个标题非常符合他本人——纯粹的一本正经,你觉得好笑,他大概不觉得。
kevstev查看英文原文
There are some salty comments here, but I think the context is important. This paper passed across my desk in early 2008 when I was doing HFT stuff. It might be a bit of a stretch to say that the reason people are taught about cache lines in most CS programs is because of this paper, but at the time this paper was written, this was really specialized knowledge and groundbreaking to most software developers. This would go on to be a popular topic on C++ blogs from Important People (Boost maintainers, STL devs, etc) at least for the next 5 years. Also, if you know Ulrich Drepper at all, either from some of his talks or his mailing list presence, this is just a very fitting title from him. Just pure deadpan, you think its funny, he probably does not, the fact that you think its amusing is just disappointing him like a professor looking out at freshman undergrads wondering how he got stuck teaching this class.
补充希望论文能补充 Row Hammer、Spectre/Meltdown 等现代内存安全漏洞内容
我希望 Ulrich Drepper(谢谢您,Drepper 先生)能更新这篇文章,加入 Row Hammer 以及 Spectre 和 Meltdown 的内容。程序员需要了解内存,正是因为这些漏洞,尤其是后两者,以避免写出可被利用的代码。不过我也觉得《每个计算机科学家都应知道的浮点运算》应该更新加入 UNUM,但我想那也不会发生。同样感谢 Goldberg 先生。
CalChris查看英文原文
I wish Ulrich Drepper (thank you, Mr. Drepper) would update this with a section on Row Hammer and also Spectre and Meltdown. Programmer's need to know about memory because of these exploits, more so with the latter two in order avoid creating exploitable gadgets. But then I also think that What Every Computer Scientist Should Know About Floating-Point Arithmetic should be updated to include UNUMs. I don't think that will happen either. Also, thank you Mr. Goldberg.
质疑质疑标题:对绝大多数应用开发者来说这些底层硬件知识并非必需
这个标题和内容是反讽吗?我快速浏览了文章,我觉得这个链接应该改名为"99.9% 的程序员不需要知道的内存知识"。我从初级一路做到 Principal 工程师,却不知道文中 99% 的内容,很难理解一个普通的 Java、C#、Python、Rust 程序员为什么需要了解晶体管配置、电压、引脚配置,更别说 114 页的底层硬件图表和术语了。这份文档是给写内存底层驱动或做硬件的人看的,对普通软件工程师做好本职工作没有帮助。
saberience查看英文原文
Is this title and content supposed to be ironic? I quickly perused the article and I think this link should be renamed "What 99.9% of programmers don't need to know about memory." I've managed to go from Associate to Principal without knowing 99% of what's covered in this document, and I'm struggling to understand why the average Java, C#, Python, Rust, <insert language here> programmer would need to know about transistor configurations or voltages, pin configurations, etc. Let alone 114 pages of low level hardware diagrams and jargon! This document is for someone working on low level drivers for memory, or working on the hardware side. For any normal software engineer, this information is not helpful for doing your job.
质疑调侃文章篇幅过长,与"每个程序员都该知道"的定位矛盾
每个程序员应该了解的内存知识,不应该长达 114 页。
louthy查看英文原文
What every programmer should know about memory shouldn't be 114 pages long.
相关资源
从这篇论文所有 HN 讨论帖的全部评论里整理出来的链接。
历次讨论
- 2019Hacker News 讨论帖214 分 · 97 评
同领域还值得读
I/O 比 CPU 更快——让我们划分资源并消除操作系统抽象
I/O Is Faster Than CPU – Let’s Partition Resources and Eliminate OS Abstractions
指出在现代服务器硬件上 I/O 速度已接近甚至超过 CPU,传统操作系统抽象反而成为瓶颈。
系统与数据库2019 · 817 分 · 277 评进阶 · 约 30 分钟编辑精选使用 io_uring 的高效 I/O
Efficient IO with io_uring
由 Linux 内核开发者 Jens Axboe 撰写,介绍 Linux 新的异步 I/O 接口 io_uring。
系统与数据库2019 · 426 分 · 96 评进阶 · 约 45 分钟编辑精选线程对大多数用途而言是个坏主意(1995)
Threads Are a Bad Idea for Most Purposes (1995)
这篇 1995 年的文章由 John Ousterhout 撰写,讨论为什么线程对大多数用途而言是坏主意,并主张事件驱动编程通常更简单、更高效。
系统与数据库2017 · 423 分 · 382 评进阶 · 约 25 分钟编辑精选学习型索引结构之论证
The Case for Learned Index Structures
提出把索引看作一种"模型":既然 B-tree 等结构本质上是在学习数据的分布,就可以用机器学习模型(如回归模型、神经网络)来近似键到位置的映射,从而替代 B-tree、哈希索引…
系统与数据库2017 · 398 分 · 66 评 · 引用 25进阶 · 约 60 分钟编辑精选FoundationDB:一个分布式、解耦的事务型键值存储
FoundationDB: A distributed, unbundled, transactional key value store
介绍 FoundationDB:一个分布式、解耦设计的事务性键值存储。
系统与数据库2021 · 283 分 · 99 评进阶 · 约 90 分钟编辑精选