這幾天我在測試 cpu 優化到底有多少效果,我的理解是所謂 CPU 優化一般影響範圍應只有「迴圈」,而這只有 javascript 上會用到。
我用相同的步驟編了 三版 seamonkey 2.7.2 (無 cpu 優化、sse 優化、sse2 優化)
1.打 patch
2.編 pgi
3.跑 google v8 + sun spider 各一次
4.編 pgo
5.以 peacekeeper 測試
結果如下,很好玩的結果:
1.pgo only
v2
1453v1
5010: 4678/5122/18216/6860/4421/4344v1: Rendering/Social networking/Complex graphics/Data/Dom operations/Text parsing
2.pgo+sse
v2
1436v1
4968: 4733/5077/18408/6733/4361/42933.pgo+sse2
v2
1431v1
5022:4684/5079/18125/7018/4409/4343我的結論如下:
總的來說,針對 cpu 優化理論上來說應會較無 cpu 優化來得快上許多 -- 或至少快上幾 %。
但實際結果看來是,花那麼大功夫調解 sse2 pgo crash,但結果效能並沒有顯著增加。
所以如果要求極緻的優化,應該捨去針對 cpu 之優化,如此一來引發 pgi bug 的機會變小很多,那麼在對無 cpu 優化版本,pgo 本身將可作出更強效之優化,效果將一舉超越加入 cpu 優化之版本。
以此結論編出之版本,即 seamonkey 2.7.2-pgo-nosse-nosse2。
有興趣的朋友,可與我先前編譯之 seamonkey 2.7.2 sse2 pgo 作交互測試,即可驗證。
檔案連結代碼:
diff -urN comm-release/mozilla/security/coreconf/WIN32.mk comm-release-sm/mozilla/security/coreconf/WIN32.mk
--- comm-release/mozilla/security/coreconf/WIN32.mk 2010-05-05 03:18:33 +0800
+++ comm-release-sm/mozilla/security/coreconf/WIN32.mk 2010-06-23 23:54:06 +0800
@@ -101,11 +101,15 @@
_GEN_IMPORT_LIB=-Wl,--out-implib,$(IMPORT_LIBRARY)
DLLFLAGS += -mno-cygwin -o $@ -shared -Wl,--export-all-symbols $(if $(IMPORT_LIBRARY),$(_GEN_IMPORT_LIB))
ifdef BUILD_OPT
+ ifeq ($(MOZ_OPTIMIZE),2)
+ OPTIMIZER += $(MOZ_OPTIMIZE_FLAGS)
+ else
ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
OPTIMIZER += -Os
else
OPTIMIZER += -O2
endif
+ endif
DEFINES += -UDEBUG -U_DEBUG -DNDEBUG
else
OPTIMIZER += -g
@@ -125,11 +129,15 @@
endif
ifdef BUILD_OPT
OS_CFLAGS += -MD
+ ifeq ($(MOZ_OPTIMIZE),2)
+ OPTIMIZER += $(MOZ_OPTIMIZE_FLAGS)
+ else
ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
OPTIMIZER += -O1
else
OPTIMIZER += -O2
endif
+ endif
DEFINES += -UDEBUG -U_DEBUG -DNDEBUG
DLLFLAGS += -OUT:"$@"
ifdef MOZ_DEBUG_SYMBOLS
diff -urN comm-release/mozilla/security/coreconf/WINCE.mk comm-release-sm/mozilla/security/coreconf/WINCE.mk
--- comm-release/mozilla/security/coreconf/WINCE.mk 2010-05-05 03:18:33 +0800
+++ comm-release-sm/mozilla/security/coreconf/WINCE.mk 2010-06-23 23:54:06 +0800
@@ -87,7 +87,11 @@
ifdef BUILD_OPT
# OS_CFLAGS += -MD
+ ifeq ($(MOZ_OPTIMIZE),2)
+ OPTIMIZER += $(MOZ_OPTIMIZE_FLAGS)
+ else
OPTIMIZER += -O2
+ endif
DEFINES += -UDEBUG -U_DEBUG -DNDEBUG
DLLFLAGS += -OUT:"$@"
else
diff -urN comm-release/mozilla/security/manager/Makefile.in comm-release-sm/mozilla/security/manager/Makefile.in
--- comm-release/mozilla/security/manager/Makefile.in 2010-05-05 03:18:33 +0800
+++ comm-release-sm/mozilla/security/manager/Makefile.in 2010-06-23 23:54:07 +0800
@@ -43,6 +43,8 @@
include $(DEPTH)/config/autoconf.mk
+export MOZ_OPTIMIZE MOZ_OPTIMIZE_FLAGS MOZ_OPTIMIZE_LDFLAGS MOZ_OPTIMIZE_SIZE_TWEAK
+
MODULE = psm
ifndef MOZ_NATIVE_NSS
diff -urN comm-release/config/rules.mk comm-release-sm/config/rules.mk
--- comm-release/config/rules.mk 2010-05-05 03:14:54 +0800
+++ comm-release-sm/config/rules.mk 2010-06-23 23:54:01 +0800
@@ -963,7 +963,7 @@
$(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/$(MOZ_APP_NAME)
endif
ifdef SHARED_LIBRARY
- $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
+ $(PYTHON) $(MOZILLA_SRCDIR)/build/win32/pgomerge.py \
$(SHARED_LIBRARY_NAME) $(DIST)/$(MOZ_APP_NAME)
endif
endif # SHARED_LIBRARY || PROGRAM
diff -urN comm-release/mozilla/js/src/Makefile.in comm-release-sm/mozilla/js/src/Makefile.in
--- comm-release/mozilla/js/src/Makefile.in
+++ comm-release-sm/mozilla/js/src/Makefile.in
@@ -102,19 +102,16 @@ endif
MODULE = js
LIBRARY_NAME = mozjs
STATIC_LIBRARY_NAME = js_static
GRE_MODULE = 1
LIBS = $(NSPR_LIBS)
-ifeq ($(OS_ARCH),WINNT)
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-endif
# JavaScript must be built shared, even for static builds, as it is used by
# other modules which are always built shared. Failure to do so results in
# the js code getting copied into xpinstall and jsd as well as mozilla-bin,
# and then the static data cells used for locking no longer work.
#
# In fact, we now build both a static and a shared library, as the
# JS shell would like to link to the static library.
_________________
想讓 Internet Explorer 當掉嗎?
「方法一」 - 被 google 檔掉的樣子,開不起來
「方法二」