Closed Bug 856791 Opened 8 years ago Closed 7 years ago
Exclude unused NSS and PSM code
We include code in Fennec that isn't always used depending on the build constants. We have some definitions specified inside of #ifdefs in Makefile.in, but we removed some of these in bug 856163 to make the code cleaner. We should investigate how much we could shrink the APK using various methods (such as ProGuard or other techniques described in https://bugzilla.mozilla.org/show_bug.cgi?id=856163#c28).
See also bug 611781. ~10 days ago, I mentioned to jst that I knew of a lot of ~1MB of dead object code in NSS and PSM that could be removed without removing any functionality of B2G. I completed a limited version of my experiment in this so that I could provide some preliminary numbers. My experiment with hacking out unused code in PSM and NSS resulted in the following reductions in size (on B2G mozilla-inbound): libnss3.so reduced from 1,441,092 to 1,090,992 bytes (350,100 bytes saved) libxul.so reduced from 25,594,592 to 25,328,696 bytes (265,896 bytes saved) This is a savings of 615,996 bytes, or ~2%, just by ifdef'ing unused code out and modifying the NSS *.def files to export only symbols actually used by Gecko. I suspect that I might be able to double that savings by continuing this effort (mostly within Necko, PSM, and NSPR). Most but not all of this savings can also be applied to Android. I searched the logs for B2G opt builds on mozilla-inbound and I was surprised to not find --gc-sections anywhere in the logs. It seems like only Linux PGO builds are getting --gc-sections. If --gc-sections (or equivalent) is not working now, I think that the savings could be significantly amplified by getting it working. Unfortunately, my Linux system died right before I could experiment with this. So, I think that this could be a significant win.
(In reply to Brian Smith (:briansmith, was :email@example.com) from comment #1) > I searched the logs for B2G opt builds on mozilla-inbound and I was > surprised to not find --gc-sections anywhere in the logs. It seems like only > Linux PGO builds are getting --gc-sections. If --gc-sections (or equivalent) > is not working now, I think that the savings could be significantly > amplified by getting it working. Unfortunately, my Linux system died right > before I could experiment with this. > > So, I think that this could be a significant win. Passing --gc-sections should have been fixed by bug 887902. Deleting unused code from PSM and NSS sounds *very* interesting for Android; the space savings is particularly attractive. Are there bugs open for doing that? I didn't see anything relevant glancing at the dependencies for bug 611781.
I am not currently working on the size reduction directly. However, we are working on replacing the certificate verification logic: replacing ~90,000 lines of code with ~5,000 lines of code. That should enable us to get a lot of the savings that come from shrinking NSS. I think it would be great if we could switch to using a moz.build-based build system for our custom libnss3.so. That would make some of the NSS fat-cutting easier, and that's probably what I would take on next to make progress if I weren't busy with other things. One shorter-term fix would be to figure out how to build a custom *.def file for our combined libnss3.so that contains only the symbols that are actually used by Gecko. Note that in the NSS build system, the normally-Windows-only *.def files are converted to platform-specific configuration files that control what gets exported from each shared library. This will get you part of the space savings, though not much of the cert-verification-related changes.
Morphing this, because ProGuard work landed. Brian, do you have an update here?
Also, does this dupe to Bug 611781?
(In reply to Richard Newman [:rnewman] from comment #5) > Also, does this dupe to Bug 611781? Yes. See bug 1011229, bug 1018375, and bug 1025998 for Android-relevant work. I don't have any interest in working on this any more. It is not difficult work, but it is tedious and time consuming and I have more important things to do. If you think a ~500KB size win is important, then I suggest you ask Eric Rescorla or Martin Thompson to help instead.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 611781
You need to log in before you can comment on or make changes to this bug.