You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



frankengcc

Contact:
Chris Waterson (waterson@netscape.com)

As part of the overall effort to reduce the runtime footprint of Mozilla-the-browser and the Gecko layout engine, we've done some investigation into the tools that we use to build the Mozilla and its components. We identified two problems early on with the way gcc handles large C++ projects:

  1. gcc generates vacuous vtables for classes that have only pure virtual methods. Mozilla has a lot of these (one for each nsI interface), as that's how XPCOM works. See this article for details.
  2. gcc doesn't do a good job handling declarations like:
    class nsIFoo {
    public:
      static const nsIID& GetIID() {
        static const nsIID iid = { /* IID data here */ };
        return iid;
      }
    };
    
    Specifically, gcc seems to generate an iid for each interface in each translation unit, and these are not combined during the link phase. Again, we see a lot of these in Mozilla, as the static GetIID() method is used by nsCOMPtr's automatic interface-safety mechanisms. See this article for more details.

So netscape hired a contractor, Ron Guilmette (rfg@monkeys.com) to help us figure out what to do. He ended up producing a set of patches that can be applied against gcc-2.95.2. These patches cause gcc to (1) not emit a vtable for a class that has only pure virtual methods, and (2) place the iid symbols in a special link-once section that allows ld to combine redundant copies.

These two changes reduce the runtime static data size by about 36%, for an overall reduction in initial runtime footprint of about 6%. A detailed breakdown of the savings (as measured using the size command) is available here.