一个解决方案真正经过分析了那段代码干什么的为什么的,另一个是“随机数字可以让其在一台机器上运转”,如果你不能看到和理解他们之间的不同,那我不知道要和你说什么了。
然后,Linus Torvalds进行了谆谆教导——(相当的受用啊)
Let me repeat my point one more time.
让我再一次重复一下我的观点
You have TWO choices. Not more, not less:
你有两个选择,不多也不少:
- choice #1: go back to the old allocation model. It’s tested. It doesn’t regress. Admittedly we may not know exactly _why_ it works, and it might not work on all machines, but it doesn’t cause regressions (ie the machines it doesn’t work on it _never_ worked on).
- 选择一:回滚到老的分配模式。那是测试过的。它过了回归测试。诚然,我们也许不知道为什么那样能行,并且,即使是那样也不一定能在所有的机器上工作,但是其没有让回归测试有问题(这个代码永不可能在不能运行的系统上运行)
And this doesn’t mean “old value for that _one_ machine”. It means “old value for _every_ machine”. So it means we revert the whole bottom-down thing entirely. Not just “change one random number so that the totally different allocation pattern happens to give the same result on one particular machine”.
这并不代表“老的值只能在一台机器上工作”。这代表“老的值可以工作在每一台机器上”。所以,我们需要回滚整个代码改动。而不只是“为了一个特别的机器去修改一个和以前完全不一样的随机数”。
- Choice #2: understand exactly _what_ goes wrong, and fix it analytically (ie by _understanding_ the problem, and being able to solve it exactly, and in a way you can argue about without having to resort to “magic happens”).
- 选择二:真正搞清楚为什么会错,并且有分析地修改他(理解问题才能真正解决之,并且,只有没有“魔法发生”的时候你才可以来争论)
Now, the whole analytic approach (aka “computer sciency” approach), where you can actually think about the problem without having any pesky “reality” impact the solution is obviously the one we tend to prefer. Sadly, it’s seldom the one we can use in reality when it comes to things like resource allocation, since we end up starting off with often buggy approximations of what the actual hardware is all about (ie broken firmware tables).
现在,整个分析方法(亦称作“计算机科学”的方法)应该是你可以在没有在外界干扰下真正思考这个问题而得到的解决方案,这很明显是我们推崇的。只有在极罕见地情况下我们可以在有外界干扰下分析这种资源分配的事,因为我们只有了解倒底是什么样的硬件,我们才能最终远离bug(如:错误的固件表)
So I’d love to know exactly why one random number works, and why another one doesn’t. But as long as we do _not_ know the “Why” of it, we will have to revert.
所以,我希望你能知道为什么一个随机数能行,而另一个不行。只要我们不知道,那么我们就不得和回滚整个改动。
It really is that simple. It’s _always_ that simple.
这真的是很简单,而且这一直是那么简单。
So the numbers shouldn’t be “magic”, they should have real explanations. And in the absense of real explanation, the model that works is “this is what we’ve always done”. Including, very much, the whole allocation order. Not just one random number on one random machine.
所以,那些数不应该是“magic”的,他们应该有真正的说明。在有真正的说明的情况下,我们的开发模式才会工作。其包括了整个分配顺序。不只是那个在任意机器上的随机数。
Linus
后面的事不用说了。真没有想到Linux 内核组会有Yinghai这样的人,是不是面试官面试的时候喝醉了。我不知道Yinghai Lu会怎么样想,他/她会像我在“程序员那些悲催的事儿”中谈我经历那样知耻而后勇吗?能得到Linus的教导真是一件很不错的事。虽然,Linus教导的这些东西,在我看来,都应该是程序员最最最基本的技能。fix bug一定要fix在root cause上啊,了解一个问题,不但要知其然,还要知其所以然啊,这都是老生长谈了。有空看看本质的若干提高程序员能力的文章,比如,这篇,这篇,还有这篇。
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|