Showing posts with label project. Show all posts
Showing posts with label project. Show all posts

Tuesday, December 9, 2008

0.3 Release

So this is my last contribution to the OSD 600 Course but not my last contribution to my project. With this release I will be slowing down my activity but I hope I find the time to finish what I have started.

0.3 Release Details
My 0.3 Release project release can be found here.

The summary is I have landed a patch that keeps PGO for Thunderbird breaking on Windows. A module in the mozilla-core called lcms breaks when it is not linked into the xul library. The patch basically disables pgo for that module if it is not being linked into the library otherwise pgo is enabled for it.

As I was trying to enable pgo for Thunderbird related modules I discovered that PGO gets enabled for all modules. This was good news until I noticed that only 5 modules were getting optimized out of 74.

As I looked into this it turned out that the folder that most of the profile data was in was being deleted before used to optimize the modules. I created a new bug for this problem.

I have added my proposed patch and using that patch and doing some simple profiling 69 of 74 modules were optimized.

And that is my 0.3 Release.

I have learned about using Make and Python and compiler options for PGO. I still don't understand PGO entirely and don't understand why it does what it does. Example would be when using the option to optimize for size the compile spits out that the module was optimized for speed. I guess at some point I should make an inquiry on the Microsoft forums.

I plan on taking the OSD700 class but am looking at working with Eclipse.

Monday, December 8, 2008

Thunderbird components getting Optimized

So the problem I ran into with optimizing Thunderbird was all the profile data was getting deleted before it was used. I opened a new bug for this.

The other part of the problem was the python script, pgomerge.py, was not looking in the objdir/dist/bin/components for the profile data. So I have edited the pgomerge.py file and it does find and merge in all the profile data.

AWESOME!!!

New problem...the profile data in the dist/bin is not getting touched. I pretty sure my script is broken.

Time to look into this python stuff some more.

Saturday, December 6, 2008

New Bug for PGO

I've been trying to enable pgo on different Thunderbird components but I've been having problems.

Problem
The build output says these files are compiled with optimization flags but no optimization data is being collected.

It turns out the data is being collected and placed in the objdir/dist/bin/components directory. BUT!!!! This folder gets deleted.

I told ted about this. Here is a paraphrase of our conversation.

Basically, i need a flag to tell the make not to delete the folder when second profile build is being done and to look in the right directory for the optimization files.

I have posted a bug about this. This will be interesting to see how many components will get optimized without breaking.

Patch Landed!

My Patch has made it into mozilla-central.
Here is the patch.
Here is the bug.
Here is my happy dance.

Friday, December 5, 2008

Patch Reviewed!

Sweet! My patch was reviewed.

I just have to fix the comments in the patch and it is good to go.

I'm not sure what to do after I attach the updated patch.
This is the bug.

Optimizing the Thunderbird Address Book - cont'd.

I am still attempting to generate some optimization data for the address book.

One Success
The address book objects were compiled with the speed optimization. I must not have been hitting any xpcom calls to the c++ code. The opening and closing of windows must have been all js and xul code.

I'm looking through the c++ code to see what functions are available. I am going to try and profile to hit these functions. I also am trying to enable speed optimizations for the entire mail.dll in the Makefile in the mail.dll directory. This might not work.

Note:
I also notice that when I turn on PGO for Thunderbird that all the modules get the default optimization which is the size optimization.

I will have to build a non-pgo build of Thunderbird to see if it makes a difference.

Thursday, December 4, 2008

Optimizing the Thunderbird Address Book.

I did a quick edit for the Makefile.in file for the address book in the Thunderbird source. I was hoping this would enable pgo for this module.

Here is the diff for the changes I made.

I was able to successfully build thunderbird with these options but during the profiling no optimization data was collected. If data is collected a .pgc file is created. This library is added into the mail.dll so a mail.pgc file should have been created. None was.

I haven't looked at my build output to confirm that the library and mail.dll were compiled with the optimizations. I did notice that mail.dll library was compiled with the instrumental option. This means the mail.dll had the extra instructions to collect profile data. It is possible that my profiling did not actual affect the address book.

I hope to get some more information before my 0.3 is released.

Tuesday, December 2, 2008

Patch Review Process

I've had my patch posted for about a week and still haven't not had a review. So I decided to jump on IRC and try and ask for a review.

My Project is PGO and apparently there is only one guy who owns that sort of code, Ted Mielczarek. I sent a private message to Ted and an open message on the #maildev channel to see if I could get a review. Ted responded that he is working on his review queue and would be getting to my patch. On the #maildev channel Standard8 pointed me to Ted.

So it all rests with Ted.

I was nervous posting on IRC or messaging Ted because I still don't understand the etiquette of that sort of thing. But everyone responded nicely which makes me feel better.

This experience with IRC is helping me feel better about asking questions from people I don't know.

Wednesday, November 26, 2008

PGO Patch

I have submitted a patch to for the bug 465592.

The Bug

Currently PGO doesn't work for Thunderbird. For Windows builds the compilation breaks in the LCMS module for the Mozilla core. If PGO is disable for this module then Thunderbird can be built with PGO enabled.

The Patch

After talking with David Humphrey and Ted Mielczarek I modified the Makefile.in in the module/lcms/src directory. To include the following lines.

ifndef MOZ_ENABLE_LIBXUL
NO_PROFILE_GUIDED_OPTIMIZE = 1
endif

The MOZ_ENABLE_LIBXUL flag is used to link libraries into a single xul.dll library. On Firefox this flag is used and a number of libraries are linked in the xul.dll, one of these libraries is the mozlcms.lib. This does not happen with Thunderbird. Instead the libraries are made into DLL's. The mozlcms.dll crashes during the optimization build for PGO.


Checking if the flag has not been set means that the mozlcms.lib will be made into a DLL. Since this will crash if PGO is enabled, the NO_PROFILE_GUIDED_OPTIMIZE is set to disable PGO for this one module.

The Result

Well, it works otherwise I would not have posted the patch. I am waiting on a review.

Monday, November 24, 2008

Understanding Thunderbird Build Process

I've been reading the Makefiles for Thunderbird to understand how it compiles. My interest is in the Mozilla core module lcms.

I'm trying to understand if it is possible to disable PGO for that module through the Thunderbird Makefiles instead of modifying the lcms Makefile.

I notice that the flag LCMS_CFLAGS=-DLCMS_DLL is set in the Makefile in the Mozilla core that gets downloaded when using the client.py file. This flag is not set in the Mozilla core when checking out Firefox.

Talking to David Humphrey he mentioned a flag MOZ_ENABLE_LIBXUL. This flag was set in my build output for the Firefox build but not in the Thunderbird build.

In the build output for Thunderbird I noticed that the lcms objs are combined into a mozlcms.dll and in the Firefox build lcms objs are combined into a lib and later it is combined with the xul.dll.

Options for disabling PGO for the LCMS module:
Option1:

A flag could be added in the makefile for the lcms module that will enable or disable PGO. But I would prefer not to modify the Mozilla Core files.

Option2:

After the mozilla core is built, could use another script to build the lcms module again but this time as a lib and re-compile the xul.dll and add the mozlcms.lib into the xul.dll. But this is kind of a hack.

I'll keep looking at it and asking the guys "who know" the best way to proceed.

Wednesday, November 19, 2008

Let's start a converation!!

I've posted a bug for Thunderbird to start a conversation on the best way to approach enabling PGO for Thunderbird.

Currently I have to modify a file in the Mozilla core to enable PGO for Thunderbird and I shouldn't have to. I am looking into how to modify the Thunderbird build process so it can successfully compile without modifying the Mozilla core.

Saturday, November 15, 2008

0.2 Release

I have released my 0.2 Release.

I am happy to say that I have successfully built Thunderbird with PGO enabled. A closed bug has been opened as I continue to for on this. The problem is that code in the Mozilla core needs to be modified for Thunderbird to compile with PGO but Firefox which uses the same code does not.

Looking Ahead
For 0.3 Release I want to figure out how to modify the Thunderbird make files to correct the pgo related issue without modifying the Mozilla core.

If I have time I want to enable PGO for modules specific to Thunderbird.

Friday, November 7, 2008

Success!!!!

I have successfully compiled Thunderbird with PGO.

I had to disable pgo for the Color Management module.
I included NO_PROFILE_GUIDED_OPTIMIZE = 1 right before the line that indicated what optimization this module is to have.

The Problem
I was receiving an internal linker error when the compiler was trying to optimize the mozlcms.dll. The error that was displayed was f:\mozilla\thunderbird\mozilla\modules\lcms\src\cmscgats.c (...) LINK : fatal error LNK1000: Internal error during IMAGE::BuildImage. I blogged about this error.

Steps to Resolve
At first I was compiling with VS 2008 which broke my original Firefox build. I figured that was the problem. I decided to create a VM of Windows 2003 and setup an environment as close as I could to the tinderboxes.

I installed Visual Studio 2005, VS 2005 SP1, and the Vista SDK. I tried to compile again and I received the same error. At this point I figured it was the Vista SDK since the environment I used with VS 2008 also had Vista SDK. So.....I have an environment that has Visual Studio 2005 without the Vista SDK.

I still got the error.

At this point I decided that I would disable that one module and hoped it all goes well.... and it DID!!!

In between I tried a bunch of other things that had no affect so I won't mention them but I have been compiling and compiling and installing and installing since Monday.

Details
A bug has been re-opened and I have posted to it.

I noticed that Thunderbird creates 27 DLL's in the dist/bin directory and Firefox creates 17 DLL's in the same directory.

The xul.dll file is 10x larger for Firefox than Thunderbird.

I'll post more details about what objects were optimized and what percentages they were optimized. I accidentally blew away my last build.

Monday, November 3, 2008

So Close!

I appears that the enabling of PGO for Thunderbird might be really easy. All I had to due was change the Thunderbird client.mk file to include the profiledbuild option that is available in the Firefox client.mk file.

Thunderbird has a clone of the mozilla-central source which already has PGO enabled for individual modules.

To turn it own all that really happens is the setting of two environment variables.


####################################
# Profile-Guided Optimization
# To use this, you should set the following variables in your mozconfig
# mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
#
# The profile script should exercise the functionality to be included
# in the profile feedback.
#
# This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
# is usable in multi-pass builds, where you might not have a runnable
# application until all the build passes and postflight scripts have run.
ifdef MOZ_OBJDIR
PGO_OBJDIR = $(MOZ_OBJDIR)
else
PGO_OBJDIR := $(TOPSRCDIR)
endif

profiledbuild::
$(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_GENERATE=1
OBJDIR=${PGO_OBJDIR} $(PROFILE_GEN_SCRIPT)
$(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
$(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_USE=1



So the first build has the environment variable MOZ_PROFILE_GENERATE=1 set. This causes a instrumental build to be built. This is used for profiling and gathering performance data. Then a script is run to profile the build. After some clean up it is built again with the performance data included. The environment variable MOZ_PROFILE_USE=1 indicates that.

But alas my build failed. It created the first build and opened Thunderbird but the second build failed. It looks like a compiler error. I have seen the error before but I cannot remember what caused it.

f:\mozilla\thunderbird\mozilla\modules\lcms\src\cmscgats.c(875) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\rtm\vctools\compiler\utc\src\P2\main.c[0x10CA10D0:0x00000008]', line 182)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information

LINK : fatal error LNK1000: Internal error during IMAGE::BuildImage

Version 8.00.50727.42

ExceptionCode = C0000005
ExceptionFlags = 00000000
ExceptionAddress = 10CA10D0 (10B00000) "f:\Program Files\Microsoft Visual Studio 8\VC\BIN\c2.dll"
NumberParameters = 00000002
ExceptionInformation[ 0] = 00000000
ExceptionInformation[ 1] = 00000008

CONTEXT:
Eax = 00000000 Esp = 0012ED28
Ebx = 00000015 Ebp = 0012ED3C
Ecx = 028DDA01 Esi = 02866060
Edx = 0297AE12 Edi = 00000000
Eip = 10CA10D0 EFlags = 00010246
SegCs = 0000001B SegDs = 00000023
SegSs = 00000023 SegEs = 00000023
SegFs = 0000003B SegGs = 00000000
Dr0 = 00000000 Dr3 = 00000000
Dr1 = 00000000 Dr6 = 00000000
Dr2 = 00000000 Dr7 = 00000000
make[6]: *** [mozlcms.dll] Error 232
make[6]: *** Deleting file `mozlcms.dll'
make[6]: Leaving directory `/i/mozilla/thunderbird/tb-pgo/tb/mozilla/modules/lcms/src'
make[5]: *** [libs] Error 2
make[5]: Leaving directory `/i/mozilla/thunderbird/tb-pgo/tb/mozilla/modules/lcms'
make[4]: *** [libs_tier_external] Error 2
make[4]: Leaving directory `/i/mozilla/thunderbird/tb-pgo/tb/mozilla'
make[3]: *** [tier_external] Error 2
make[3]: Leaving directory `/i/mozilla/thunderbird/tb-pgo/tb/mozilla'
make[2]: *** [default] Error 2
make[2]: Leaving directory `/i/mozilla/thunderbird/tb-pgo/tb/mozilla'
make[1]: *** [default] Error 2
make[1]: Leaving directory `/i/mozilla/thunderbird/tb-pgo/tb'
make: *** [build] Error 2


So close....

Saturday, November 1, 2008

Thunderbird Testing Environment

I downloaded from Seneca a copy of Windows 2003 using the key provided to me through Seneca. On my XP machine using Virtual Box I have created a VM for win2k3.

I've been reading up and it looks like there is no real testing for Thunderbird. Currently the tinderboxes check to see if the code compiled and as long as it compiles everything is ok.

MailDev
I was chatting with some fella's and it turns out they have a few leak tests and Standard8 is working on the Tp tests ( performance startup tests ). Since I'll need some performance tests to verify my findings I'll probably be contributing those too.

Where I am!
I am trying to setup my win2k3 VM with the right patches and updates so I can duplicate the tinderboxes. I also need to install Visual 2005 with the Vista SDK and any patches mentioned on the Reference Platforms page on the Mozilla Wiki.

Next!
Start looking into enabling one module to use PGO for Thunderbird. The good stuff.


Time to put the nose to the grind.

Tuesday, October 28, 2008

New Focus for PGO Project

For the rest of my PGO project I'll be focusing on adding PGO to Thunderbird. So my first task is to build Thunderbird. Since I'll be building and testing a lot I have scripts to automate this task for me. I just tweaked my scripts to now build for Thunderbird.

Bash Script Problems
I don't know why but when I tried to create a bash script from scratch it would behave as if it executed, as in no bash could find command error, but nothing would happen. I could get any output. So I copied an existing working script and modified it. Works for me.

Next Steps
Now that I can build Thunderbird I am going to try and replicate the Mozilla tinderbox setup for Thunderbird on my home machine so I can duplicate the performance testing environment. Once I have a baseline of how Thunderbird performs on my machine I can then start enabling PGO and see what kind of performance boost I get.

After that I would have lots of opportunities for other Seneca students to contribute by compiling and running the tests on their machines to see if they are also seeing a performance gain.

So now to get to it.....

Friday, October 17, 2008

0.1 Release - Firefox PGO

0.1 Release is done.

I have learned:

How to implement PGO on any application.
How to turn PGO on and off for modules in Firefox.
That profiling firefox anymore than opening and closing the browser doesn't yeild better performance.
How to run xpcshell, mochitest, and reftests on a Firefox build.
How to create bash scripts to build firefox and create reports from the build output.
How to reproduce the sqlite bug as report in this bug.
How to attach my results of test to a bug.
That sqlite crashes even in a stand alone application when compiled with PGO.
That I am going to turn my focus to Thunderbird and turn on PGO for Windows/Linux/Mac.

0.1 Release more detailed look

Experience
I have found myself frustrated, upset, surprised and excited as I work my way into the Mozilla Community. I am asking questions more openly, more willing to look dumb in the hopes of getting the information I need. I always search first, of course.

It really takes time to get a feel for how Mozilla does things. I just recently discovered that the trunk has all these readme's scattered everywhere. Probably the first place to look for help.

I still find the Mozilla wiki's and documentation to be lacking for someone who is not as experienced as the folks at Mozilla. I tell my wife that "it's documentation written for people who already know it". I find I have to research and look stuff up to understand what I read on Mozilla.

Now that I have my feet wet I am excited to push forward.

Saturday, October 11, 2008

Review of PGO Data

45% increase not a result of PGO profiling of Google Maps.

I used build Firefox with only profiling of a page opening and then closing to check it against the loading times for Google Maps.

I re-ran all the tests and here is the summary of the results:



Firefox 3.0.3


Minefield PGO *


Minefield PGO **




2.15s (avg)


1.18s (avg)


1.17s (avg)




* Profiled using the Google Maps website.
** Profiled with only the browser opening then closing.

I also saved the Google Maps page on to my local server and when the pages were served from a local server the load times were all identical.

Serving Google Maps locally resulted in non of the javascript files Google Map uses being saved since they are loaded dynamically.

I have to conclude from this second performance test that minefield has some performance improvements not seen in Firefox 3.0.3 since the profiling did not improve Google Maps site loading.

Friday, October 10, 2008

Firefox PGO Details

According to the build output:
  • 2938 objects are created
  • 2246 of the 2938 objects are created with pgo optimizations
  • 2101 of the 2246 objects are optimized for size
  • 145 of the 2246 objects are optimized for speed
  • 73 objects are optimized with profile data
  • 69 of 73 objects didn't have any profile data to optimize with
  • 49 of 73 objects are tests objects
In the end only 4 objects are optimized.

Merging ..\..\dist\bin\js3250!1.pgc
882 of 2904 ( 30.37%) profiled functions will be compiled for speed

Merging ..\..\dist\bin\xul!1.pgc
3433 of 84021 ( 4.09%) profiled functions will be compiled for speed

Merging ..\..\dist\bin\xpcom!1.pgc
55 of 55 (100.00%) profiled functions will be compiled for speed

Merging ..\..\dist\bin\firefox!1.pgc
61 of 61 (100.00%) profiled functions will be compiled for speed

More PGO Testing

45% Increase in the loading of maps.google.com. I profiled Google Maps by running a few searches.

I used a website called WebWait. It calculates the load time for a webpage. Of course internet lag will play apart but the numbers were pretty close to each other.

The data I collected is here.

Google Maps - 45% faster ( was profiled )
CNN.com - 21% faster ( was profiled )
tomshardware.com - the same ( was not profiled )

I need to look into setting up talos to find out if doing profiling actually speeds up some aspects of Firefox or not.

Next
Create a script to build multiple PGO's during the night. Each PGO will do different profiling. Example. go to just cnn.com or just maps.google.com or just sunspider javascript test.