Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Portage's firefox's performance is identical PGO's build
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Shining Arcanine
Veteran
Veteran


Joined: 24 Sep 2009
Posts: 1110

PostPosted: Sun Apr 18, 2010 3:41 am    Post subject: Portage's firefox's performance is identical PGO's build Reply with quote

I have a PC that runs Windows 7, which will be Gentoo soon (watch me still be saying that in 3 months). It also runs a virtual machine with Gentoo Linux on it. Firefox on Windows outperforms Firefox on Gentoo and the last time I looked into it, I asked on the mozillazine forums and was told that the difference was due to Profile Guided Optimization. I could not figure out how to do a PGO build of Firefox on Linux at the time to verify that, but today, I decided to try doing a PGO optimization build of Firefox. I fiddled with the build system, but did not have much luck until I found a slackware user's script for building Firefox with Profile Guided Optimization:

http://www.linuxquestions.org/questions/linux-software-2/building-firefox-3-6-a-profile-guided-optimization-pgo-automated-build-script-784164/

The script wanted some files that I downloaded from a slackware mirror:

http://linorg.usp.br/slackware-current/source/xap/mozilla-firefox/

I then ran it and it proceeded to build firefox. The PGO build worked exactly like it was supposed to work, where it built an instrumented version of Firefox, ran it so I could have it render some webpages to give GCC feedback on how it ran and then upon Firefox closing built the PGO build. The thing is that the PGO optimized build runs slightly slower than the system firefox that portage builds. It originally ran about the same, but then I decided to make a few more changes to the script to try to "optimize things". The first, which did not have much of an effect was to use the CFLAGS I used when compiling my virtual machine (yes, I know they are excessive). The second,was to modify the script to use the automated PGO script that Mozilla uses to generate its nightly builds. Prior to having it do the PGO process automatically, I had been running Dromaeo, Sunspider and Microsoft's Flying Images Platform Demo for IE9 sequentially.

The system firefox scored 2011.0ms +/- 3.9% in Sunspider while the PGO firefox with my "improvements" scored 2069.8ms +/- 4.5% in Sunspider, which is about identical. For comparison purposes, Firefox on Windows scores 760.4ms +/- 1.2%. I know that there is some overhead to running in a virtual machine, so I decided to use Chrome/Chromium as a reference point to get a rough idea of what that overhead is. Chrome on Windows scores 283.2ms +/- 3.3% while Chromium on Gentoo scores 356.4ms +/- 6.4%. Both are the development channel 5.0.375.3 builds, although the Gentoo one is compiled by portage while the Windows one is the official Chrome compiled by Google. Using them as a reference, I can say that the drop in performance due to virtualization overhead is roughly 21%, so I would expect to see a similar drop in performance between the Windows and Gentoo Linux numbers for Firefox, but the drop in performance is roughly 63%, which is huge. I cannot imagine this being entirely due to virtualization overhead, so there must be something else causing it.

Here is a patch file that reflects the changes I made to the slackware user's script:

Code:
--- original.sh 2010-04-17 22:04:38.326053209 -0500
+++ build.sh    2010-04-17 21:23:13.024037040 -0500
@@ -39,10 +39,11 @@
 fi;
 
 # my favorite compiler optimizations:
-CFLAGS="-fPIC -O3 -Wall -pipe -march=native -mtune=native -fomit-frame-pointer"
+#CFLAGS="-fPIC -O3 -Wall -pipe -march=native -mtune=native -fomit-frame-pointer"
+CFLAGS="-O3 -pipe -march=core2 -msse4.1 -mcx16 -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -floop-interchange -floop-strip-mine -floop-block -ftree-loop-linear -fgcse-sm -fgcse-las -ftree-loop-im -ftree-loop-ivcanon -fivopts -frename-registers -fweb"
 CXXFLAGS="${CFLAGS}"
 CPPFLAGS="${CFLAGS} -I/usr/include"
-MAKEFLAGS="-j3"
+MAKEFLAGS="-j5"
 
 # FF apparently won't build properly with autoconf != 2.13 so
 # in case this is still the case, I installed autoconf 2.13 in
@@ -61,11 +62,12 @@
                                  #  (stick your places.sqlite in there if you want)
 MOZAPP=browser                   # in mozconfig, which mozilla component to build
 APP=firefox                      # self evident.
-VERSION=3.6                      # self evident.
+VERSION=3.6.3                    # self evident.
 EXTENSION=en-US.linux            # FF tarball name includes this piece.
                                  #  but may change depending on your locale.
 ARCH=x86_64                      # architecture.
 BUILD=1                          #
+PYTHON=/usr/bin/python
 
 
 # Download all the parts here?
@@ -127,7 +129,8 @@
 mk_add_options MOZ_OBJDIR=$OBJDIR
 
 # startup script, for generating profile info for optimize:
-mk_add_options PROFILE_GEN_SCRIPT=$CWD/run-$APP.sh
+#mk_add_options PROFILE_GEN_SCRIPT=$CWD/run-$APP.sh
+mk_add_options PROFILE_GEN_SCRIPT='${PYTHON} ${OBJDIR}/_profile/pgo/profileserver.py'
 
 # which mozilla app to build:
 ac_add_options --enable-application=$MOZAPP
@@ -144,8 +147,8 @@
 ac_add_options --enable-svg
 ac_add_options --enable-canvas
 ac_add_options --enable-xft
-ac_add_options --enable-xinerama
-ac_add_options --enable-optimize="-fPIC -Os -Wall -pipe -march=native -mtune=native -fomit-frame-pointer"
+#ac_add_options --enable-xinerama
+ac_add_options --enable-optimize="$CFLAGS"
 ac_add_options --enable-reorder
 ac_add_options --enable-strip
 ac_add_options --enable-system-cairo           
@@ -184,7 +187,7 @@
 ac_add_options --disable-debug-modules
 ac_add_options --disable-debugger-info-modules
 ac_add_options --disable-parental-controls
-ac_add_options --disable-safe-browsing
+#ac_add_options --disable-safe-browsing
 ac_add_options --disable-startup-notification
 ########################################: Completely Experimental below..
 ########################################: Questionable/Optional stuff
@@ -204,6 +207,7 @@
 # ac_add_options --enable-prebinding # OSX only?
 # ac_add_options --enable-reflow-perf # try without.. may slow down FF for non-devel user?
 # ac_add_options --enable-glitz # this thing won't install into lib64
+ac_add_options --disable-necko-wifi
 # END of mozconfig file
 
 EOF


Does anyone have any idea why the PGO build is doing so poorly? Is it possible that the system firefox is somehow executing in place of the PGO build when I try executing the PGO firefox?
Back to top
View user's profile Send private message
Shining Arcanine
Veteran
Veteran


Joined: 24 Sep 2009
Posts: 1110

PostPosted: Sun Apr 18, 2010 4:14 am    Post subject: Reply with quote

I should search more often. It seems that trace monkey is disabled for x86_64:

https://forums.gentoo.org/viewtopic-t-821325.html

I applied the patch to the sources inside a local copy of the tarball and I am recompiling it now.

There is a patched ebuild available in that thread, so I should probably use that, but I want to do some benchmarks on the slackware build script's tracemonkey enabled PGO build so I will have a data point that should allow me to verify if the ebuild is performing as well as it could. :)

Edit: The new build is scoring 1090.6ms +/- 1.6% in sunspider, which means there is a 30% drop in performance from non-virtualized Windows to virtualized Linux, which is larger than I would like, but it is close enough. Now I am going to try setting up a PGO Tracemonkey-enabled local firefox overlay so portage will install and manage this on its own.

Edit: If anyone is interested, I posted a patch file containing the improvements I made to the slackware build script in the thread on linuxquestions.org. I thought it would be nice to share. :)
Back to top
View user's profile Send private message
lightvhawk0
Guru
Guru


Joined: 07 Nov 2003
Posts: 388

PostPosted: Sun Apr 18, 2010 9:34 pm    Post subject: Reply with quote

You know -O3 has been known to create slower binaries
and -O2 is faster in most cases
Quote:
A higher -O does not always mean improved performance. -O3 increases the code size and may introduce cache penalties and become slower than -O2. However, -O2 is almost always faster than -O.

_________________
If God has made us in his image, we have returned him the favor. - Voltaire
Back to top
View user's profile Send private message
Shining Arcanine
Veteran
Veteran


Joined: 24 Sep 2009
Posts: 1110

PostPosted: Sun Apr 18, 2010 9:38 pm    Post subject: Reply with quote

lightvhawk0 wrote:
You know -O3 has been known to create slower binaries
and -O2 is faster in most cases
Quote:
A higher -O does not always mean improved performance. -O3 increases the code size and may introduce cache penalties and become slower than -O2. However, -O2 is almost always faster than -O.


Using -O3 was the choice of the slackware user. For what it is worth, in my experience -O3 does well on x86_64 and poorly on x86_32. That is quite possibly due to the differences in registers.

In this case, the compilation flags really do not seem to have much of an effect on performance.
Back to top
View user's profile Send private message
lightvhawk0
Guru
Guru


Joined: 07 Nov 2003
Posts: 388

PostPosted: Mon Apr 19, 2010 9:12 am    Post subject: Reply with quote

Shining Arcanine wrote:
lightvhawk0 wrote:
You know -O3 has been known to create slower binaries
and -O2 is faster in most cases
Quote:
A higher -O does not always mean improved performance. -O3 increases the code size and may introduce cache penalties and become slower than -O2. However, -O2 is almost always faster than -O.


Using -O3 was the choice of the slackware user. For what it is worth, in my experience -O3 does well on x86_64 and poorly on x86_32. That is quite possibly due to the differences in registers.

In this case, the compilation flags really do not seem to have much of an effect on performance.


Don't feel bad my firefox only scores 1919.6ms

While chromium scores 379.6ms
_________________
If God has made us in his image, we have returned him the favor. - Voltaire
Back to top
View user's profile Send private message
Thaidog
Veteran
Veteran


Joined: 19 May 2004
Posts: 1053

PostPosted: Fri Apr 23, 2010 5:44 am    Post subject: Reply with quote

Have you tried using ICC to build a PGO firefox?
_________________
Registered Linux User: 437619
"I'm a big believer in technology over politics" - Linus Torvalds
Back to top
View user's profile Send private message
broch
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jul 2005
Posts: 94

PostPosted: Fri Apr 23, 2010 1:49 pm    Post subject: Reply with quote

If I may add:
for me icc firefox is faster than GCC4.4/PGO.
However on 32-bit machine with 2GB RAM -ipo1 will fail. So you need to set -ip only. Also -O2 is faster than -O3 (again this is on 32-bit system).
Back to top
View user's profile Send private message
Thaidog
Veteran
Veteran


Joined: 19 May 2004
Posts: 1053

PostPosted: Fri Apr 23, 2010 10:52 pm    Post subject: Reply with quote

broch wrote:
If I may add:
for me icc firefox is faster than GCC4.4/PGO.
However on 32-bit machine with 2GB RAM -ipo1 will fail. So you need to set -ip only. Also -O2 is faster than -O3 (again this is on 32-bit system).


Good point... you do need a machine with lots of ram to use the ipo flag (-ipo1) It is worth it if you have a machine like that however.
_________________
Registered Linux User: 437619
"I'm a big believer in technology over politics" - Linus Torvalds
Back to top
View user's profile Send private message
simonbcn
n00b
n00b


Joined: 01 Aug 2011
Posts: 63
Location: Terrassa, Barcelona, Spain

PostPosted: Mon Oct 03, 2011 2:37 pm    Post subject: Reply with quote

I think the problem is the original script. The correct way to build Firefox with PGO is execute: "make -s -f client.mk profilebuild" directly, without "make -s -f client.mk build" before.
See the last posts here: http://groups.google.com/group/mozilla.dev.builds/browse_thread/thread/55e476cc3b50d2a3
Regards.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum