昨天把硬碟清的差不多了(總共清了四天 -_-,因為其中有一顆 WD 80JB 好像存活了三四年,裡面滿滿的是對我來講比較重要的資料。順便藉著這次機會把之前的 Backup 整理歸類,順便備份到 DVD-R 裡面),想說開始大開殺戒。開始把硬碟亂灌作業系統來玩,當然第一個很好奇的就是 ubench 在這台 deaktop 上的 Gentoo 能夠跑這麼高分,那在 FreeBSD 下會是多少?要嗎就是 Linux 分數偏高所以其他台機器的分數顯得比較低,要嗎就是這台機器真的特別神猛,不過我猜應該是因為 Linux 的關係。
於是我在 WD Raptor上的分割區灌了 FreeBSD 5.4 Release。不過開機的時候遇到很奇怪的問題,因為我用 Gentoo 那時候裝的 Grub 來當作開機管理員。一開進 FreeBSD 之後螢幕就花掉然後不給反應了,看起來就像是因為進了 Graphic Mode 搞得鬼, Google 了半天好像找不到該用啥 keyword 查,想說反正只是測一下 ubench ,乾脆裝到另一顆硬碟效果也一樣。忽然間心血來潮,把 KVM 切成 server 然後 ping desktop ,竟然有反應耶。可是 SSH 是爛掉的,想一想可能是因為剛灌完需要產生 RSA KEY Pair,於是胡亂按了一通然後把他重開機。等了好久,果然莫名其妙 ssh 就通了。
於是我就在 FreeBSD 5.4 下測,沒想到測出來只能用「慘不忍睹」來形容阿。
這是之前在 Gentoo 下測的:
rabbit ubench-0.32 # ./ubench
Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk <sv@phystech.com>
http://www.phystech.com/download/ubench.html
Linux 2.6.11-gentoo-r6 #1 SMP Wed May 25 09:31:04 Local time zone must be set--
ee zic i686
Ubench CPU: 159850
Ubench MEM: 215002
--------------------
Ubench AVG: 187426 (-march=prescott -msse -msse2 -msse3)
這是昨天在 FreeBSD 下測的:
> ubench
Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk <sv@phystech.com>
http://www.phystech.com/download/ubench.html
FreeBSD 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May 8 10:21:06 UTC 2005 roo
t@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
Ubench CPU: 109562
Ubench MEM: 117601
--------------------
Ubench AVG: 113581 (Tue Oct 11 06:44:21 CST 2005) (NO_HTT)
然後我忽然想到,那時 Linux 的 Kernel 是有 SMP 下去跑的 Kernel ,天曉得會不會有影響。反正就試看看。於是就很高興的去重新編 kernel 。到後來 make installkernel KERNCONF=SMP 打完的時候,看他 installation finished 之後很習慣性的就按了 alt-ctrl-del ,過了兩秒才想到「幹!!」。我現在是用 server ssh 到桌機上啊,這樣等於是我把 server 給重開了阿 -_-。果不其然,開了 37 天多的 server 就被我 alt-ctrl-del 了。 XD 真是超白痴的。後來編完之後測的結果其實還是很糟糕:
> ubench
Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk <sv@phystech.com>
http://www.phystech.com/download/ubench.html
FreeBSD 5.4-RELEASE-p7 FreeBSD 5.4-RELEASE-p7 #0: Tue Oct 11 07:01:27 CST 2005
cookys@fleebsd.iecs.us:/usr/obj/usr/src/sys/SMP i386
Ubench CPU: 109382
Ubench MEM: 113730
--------------------
Ubench AVG: 111556 (Tue Oct 11 07:30:57 CST 2005) HTT
於是我又本著好奇的心態想說,會不會是 FreeBSD 5.x 系列寫爛了,搞不好 DragonFlyBSD 從 4.xx 上來的會好一點,於是又去抓他的 LiveCD 來測,測了之後反而比 FreeBSD 還慘,不過因為那版是 1.1 ,聽說 1.2 拿掉很多 lock ..於是又抱著一線希望去抓 1.3-DEVELOPMENT。還是差不多:
> ubench
Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk <sv@phystech.com>
http://www.phystech.com/download/ubench.html
DragonFly 1.1-CURRENT DragonFly 1.1-CURRENT #10: Mon i386
Ubench CPU: 98245 99820 107728 108276
Ubench MEM: 107367 112979 135429 134525
-------------------- -------- ------ ------
Ubench AVG: 102806 106399 121578 121400
(GCC 2.95) (GCC 3.4 -O2) (GCC -O3)
(1.3-DEVELOPMENT ,April 20)
(Tue Oct 11 17:42:25 CST 2005) (GCC 2.95)
後來又很好奇為什麼 FreeBSD 在編 Kernel 的時候都會把特殊指令集給關掉,於是 Google 了一下發現
這篇和
這篇:
For speed reasons, we restrict the kernel to using integer instructions
only. This means we can avoid the considerable expense of
saving/restoring floating point context unnecessarily for syscalls,
interrupts, etc.
...
Note that we *could* concievably set aside a few xmm registers for
faster data copies inside the kernel, but we don't do it yet. I
believe linux makes %xmm0 and %xmm1 available in the kernel and saves
them with every trap into kernel mode.
Whether or not the kernel is compiled with instructions that use these
registers has absolutely no bearing on whether userland code can use
them. It's purely about trading one optimization (using optimized
opcodes in the kernel) for another (not having to save and restore
dozens of registers to the stack on each syscall). It might be
interesting to experiment with allowing a certain class of instructions
in the kernel and saving and restoring the associated registers, and
seeing if GCC will actually generate code that is better and overcomes
the save/restore expense. Any takers?
Scott
反正就是其實用了的話在 save/restore 的時候會有比較大的 overhead ,所以先關掉。然後其實還有方訪能夠去增加他的效率,那就是跟 Linux 一樣用 %xmm0 and %xmm1 來搞。不過這似乎跟上面的測試沒什麼太大關係就是了,測試數據參考就好。 Linux 在 ubench 的分數上勝出很多是事實 XD。