This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

2012年4月8日 星期日

縮減 QEMU ,KERNEL code base



荒廢很久的blog今天心血來潮 ,就來個一篇吧 .
最近無聊在縮減code base,其實也不是很厲害的工作,就是看到很多project被移植到各種平台所以code base的大小明顯很大,當然那些開發團隊也會寫出很強大的building system,問題如果只是一個業餘喜者好來玩玩看,各種平台的code反而會造成困擾,所以我的目標很簡單就是把跟自己想看架構相關的code留著就好,其他都刪除,這個目標很容易實現不是在做最佳化的工作只是在做苦工...

這邊我以QEMU for i386為例:
1.先用官方QEMU 1.0.1 編譯出一個i386的執行檔,然後把過程都紀錄下來
./configure --target-list="i386-softmmu" --enable-debug-tcg --disable-user --disable-pie --disable-smartcard --disable-libiscsi --disable-smartcard-nss --disable-guest-agent --enable-debug --disable-kvm --disable-blobs --disable-linux-user --disable-xen
make V=1 > trace.txt
2.慢慢 parse trace.txt的內容把每的檔案的編譯,連結都過程都搞定在另外寫一個makefile,就可以收工了
3.測試工具用 cloc [
http://cloc.sourceforge.net/]
有圖有真像
改造前:











改造後:









可以看到結果減少了70萬左右的程式碼,所以改造大成功 !! XD
我的成果放在 :https://github.com/wayling/i386QEMU 可以參考一下摟!!


目前kernel還沒完成但初步結果很嚇人,大概是從1000萬降到100萬左右吧~我的測試平台是beaglebone.
這結果很正常,有時聽到別人說kernel幾百萬行,別被嚇到了,因為有九成的程式碼都跟你無關的 !!不過如果你是維護者可能就另當別論了 XD


ps.現在大概一年一篇文章,所以明年見摟...Orz