delphij's Chaos
选择chaos这个词是因为~~实在很难找到一个更合适的词来形容这儿了……
From Project Cartoon. This is version 2.0.
注意:如果您熟悉RAID请不必浪费时间阅读这篇文章。
为什么用RAID-Z/RAID-Z2而不是RAID-5呢?
答案是:RAID-5有一个不可避免的问题,即它必须使用后备电源才能保证写入的正确性。这也是为什么我一直极力反对使用低档RAID卡和软件实现的RAID-5的原因。
简单地说,RAID-5在写入数据时会需要覆写整个stripe(通常需要读,然后计算parity,然后再写),由于条件限制,尽管写入操作可能只涉及两块磁盘,但整个stripe很可能在不同的磁盘上并不是同时、原子地写入。这样的结果是,磁盘上可能出现不一致、并且无法检测的数据。如果RAID-5的cache很大,这很可能会是多个stripe的数据。因此,想要确保数据的可靠性,就必须为RAID-5的写入缓冲配备后备电源,或保存在非掉电丢失的存储中。
RAID-Z和Z2是解决这个问题的一种方法。RAID-Z采用写时复制的方法,即,不覆写数据;另一方面,由于文件系统元数据中记录了checksum,使得数据的正确性能够被检测出来;最后,RAID-Z使用动态的stripe尺寸,这个优化使得RAID-Z能够获得更好的性能。在RAID-Z配置中,带后备电源的缓冲的作用是在断电时留住更多的数据,而不再是确保数据的完整性,因此,也就不再是必需的了。
Read more...1987年,菲律宾前总统访华,谈到南沙主权问题时说:“至少在地理上,那些岛屿离菲律宾更近。”
邓小平抽了口烟,说:“在地理上,菲律宾离中国也很近。”
从此,南沙再无战事。
Read more...很久没有shared chaos了,今天来一道小学数学题。
有一个水池,进水的速度恒定,提前接了一定时间的水;水池有若干出水口均在底部,假设所有出水口的出水速度一样(换言之,每多开一个出水口,速度即相应线性提高—-本人注)。同时打开3个出水口,水池水位在80秒后会下降到0;同时打开4个出水口,水池水位在50秒后会下降到0;问:如果同时打开8个出水口,水位需要多长时间下降到0?
Read more...其实是个很简单的常识,居然搞了我半个小时……
fgetc()的返回值是int,因为这个值除了返回拿到的字符之外,还兼作错误标志。由于fgetc()允许文件中包含任意内容,所以只好增大返回值的宽度来表达。
因此,很显然,(ch = (char)fgetc(fp)) == EOF是不对的。
Read more...WxClassInfo的析构函数(~WxClassInfo)死循环是什么原因?检查发现RTTI的那个链表有个环,但是不太明白这个表(从上下文看是由Register()方法维护的)为什么能出现环?
具体的案例是 MadEdit (FreeBSD port) 退出时,由于 exit() 会调用 atexit() 定义的钩子,后者调用 WxClassInfo 的析构函数,并在此时陷入死循环。
Read more...Pretty interesting project: Haiku.
It looks like that it uses a lot of FreeBSD code by creating glue between FreeBSD and BeOS API, on the other hand they are using MIT license for most of their code, making sharing code easy.
Read more...I have taken some time to rewrite memchr(3) to utilize similiar algorithm as my strlen(3) did. Two different formular, however, would have a roughly 1/3 difference.
Currently I have taken an approach that when memchr(3) is trying to match a pattern of 8-bit, then consider the string as 8-bit, which uses the first formular which is expected to have uniform O(n) time complexity by reducing unnecessary branches.
This approach, however, might be bogus since if you find 7-bit character within a 8-bit string, in that case, memchr(3) would perform poorly, if there are a lot of characters having their MSB as 1.
Read more...今年 1 月 27 日发表的 《GCC运行环境豁免条款 (英文版)》 再次狠狠地打了苹果的耳光。
原先的豁免条款如下:
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
As some of you already know, FreeBSD, along with some other Open Source projects, is moving away from GCC due to GPLv3. From a technology perspective, this also makes sense since the (likely) candidate, BSD-style licensed, LLVM based clang, a C compiler, is making reasonably good progress.
So, what should we expect from LLVM or clang?
Here is a good comparison between GCC and clang. Despite GCC is popular, considerably more mature, and supports more languages (especially C++, which clang’s support is incomplete at this moment), clang provides cleaner AST (Abstract Syntax Tree), much more modularized (if you take a look at GCC’s history, Richard Stallman intentionally made GCC’s code not reusable in other software), provided much more information for optimizer, is much faster and use much less memory, etc.
For FreeBSD, currently, clang can compile its kernel with only very few tweaks.
Read more...