Bug 1351071: Get rid of pre-generated startup cache r=glandium
authorChris AtLee <catlee@mozilla.com>
Tue, 04 Apr 2017 09:26:25 -0400
changeset 351139 0f320509eddb30fdefd00d17179670381c3b6f78
parent 351138 12afeda05d4759b67b9dc82b1f1fee7957ce77c4
child 351140 1ffea69634372b3c03d2a76d775b10ce00c7764a
push id31601
push userkwierso@gmail.com
push dateTue, 04 Apr 2017 18:18:12 +0000
treeherdermozilla-central@9cb970f15203 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1351071
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1351071: Get rid of pre-generated startup cache r=glandium MozReview-Commit-ID: BcWcqEKwGBv
python/mozbuild/mozpack/packager/formats.py
python/mozbuild/mozpack/packager/unpack.py
python/mozbuild/mozpack/test/test_packager_formats.py
toolkit/mozapps/installer/packager.py
--- a/python/mozbuild/mozpack/packager/formats.py
+++ b/python/mozbuild/mozpack/packager/formats.py
@@ -18,21 +18,16 @@ from mozpack.files import (
     XPTFile,
 )
 from mozpack.copier import (
     FileRegistry,
     FileRegistrySubtree,
     Jarrer,
 )
 
-STARTUP_CACHE_PATHS = [
-    'jsloader',
-    'jssubloader',
-]
-
 '''
 Formatters are classes receiving packaging instructions and creating the
 appropriate package layout.
 
 There are three distinct formatters, each handling one of the different chrome
 formats:
     - flat: essentially, copies files from the source with the same file system
       layout. Manifests entries are grouped in a single manifest per directory,
@@ -316,9 +311,9 @@ class OmniJarSubFormatter(PiecemealForma
             return len(path) != 3 or \
                 not (path[2] == 'channel-prefs.js' and
                      path[1] in ['pref', 'preferences'])
         return path[0] in [
             'modules',
             'greprefs.js',
             'hyphenation',
             'update.locale',
-        ] or path[0] in STARTUP_CACHE_PATHS
+        ]
--- a/python/mozbuild/mozpack/packager/unpack.py
+++ b/python/mozbuild/mozpack/packager/unpack.py
@@ -18,20 +18,17 @@ from mozpack.chrome.manifest import (
     is_manifest,
 )
 from mozpack.mozjar import JarReader
 from mozpack.copier import (
     FileRegistry,
     FileCopier,
 )
 from mozpack.packager import SimplePackager
-from mozpack.packager.formats import (
-    FlatFormatter,
-    STARTUP_CACHE_PATHS,
-)
+from mozpack.packager.formats import FlatFormatter
 from urlparse import urlparse
 
 
 class UnpackFinder(BaseFinder):
     '''
     Special Finder object that treats the source package directory as if it
     were in the flat chrome format, whatever chrome format it actually is in.
 
@@ -183,18 +180,17 @@ def unpack_to_registry(source, registry)
     '''
     Transform a jar chrome or omnijar packaged directory into a flat package.
 
     The given registry is filled with the flat package.
     '''
     finder = UnpackFinder(source)
     packager = SimplePackager(FlatFormatter(registry))
     for p, f in finder.find('*'):
-        if mozpath.split(p)[0] not in STARTUP_CACHE_PATHS:
-            packager.add(p, f)
+        packager.add(p, f)
     packager.close()
 
 
 def unpack(source):
     '''
     Transform a jar chrome or omnijar packaged directory into a flat package.
     '''
     copier = FileCopier()
--- a/python/mozbuild/mozpack/test/test_packager_formats.py
+++ b/python/mozbuild/mozpack/test/test_packager_formats.py
@@ -403,18 +403,16 @@ class TestFormatters(unittest.TestCase):
             self.assertTrue(
                 is_resource(base, 'defaults/preferences/foo.js'))
             self.assertFalse(
                 is_resource(base, 'defaults/preferences/channel-prefs.js'))
             self.assertTrue(is_resource(base, 'modules/foo.jsm'))
             self.assertTrue(is_resource(base, 'greprefs.js'))
             self.assertTrue(is_resource(base, 'hyphenation/foo'))
             self.assertTrue(is_resource(base, 'update.locale'))
-            self.assertTrue(
-                is_resource(base, 'jsloader/resource/gre/modules/foo.jsm'))
             self.assertFalse(is_resource(base, 'foo'))
             self.assertFalse(is_resource(base, 'foo/bar/greprefs.js'))
             self.assertTrue(is_resource(base, 'defaults/messenger/foo.dat'))
             self.assertFalse(
                 is_resource(base, 'defaults/messenger/mailViews.dat'))
             self.assertTrue(is_resource(base, 'defaults/pref/foo.js'))
             self.assertFalse(is_resource(base, 'defaults/foo/bar.dat'))
             self.assertFalse(is_resource(base, 'defaults/foo/bar/baz.dat'))
--- a/toolkit/mozapps/installer/packager.py
+++ b/toolkit/mozapps/installer/packager.py
@@ -24,17 +24,16 @@ from mozpack.copier import (
 )
 from mozpack.errors import errors
 import mozpack.path as mozpath
 import buildconfig
 from argparse import ArgumentParser
 import os
 from StringIO import StringIO
 import subprocess
-import platform
 import mozinfo
 
 # List of libraries to shlibsign.
 SIGN_LIBS = [
     'softokn3',
     'nssdbm3',
     'freebl3',
     'freeblpriv3',
@@ -119,70 +118,16 @@ class LibSignFile(File):
         if os.path.exists(dest) and skip_if_older and \
                 int(os.path.getmtime(self.path) * 1000) <= \
                 int(os.path.getmtime(dest) * 1000):
             return False
         if launcher.launch(['shlibsign', '-v', '-o', dest, '-i', self.path]):
             errors.fatal('Error while signing %s' % self.path)
 
 
-def precompile_cache(registry, source_path, gre_path, app_path):
-    '''
-    Create startup cache for the given application directory, using the
-    given GRE path.
-    - registry is a FileRegistry-like instance where to add the startup cache.
-    - source_path is the base path of the package.
-    - gre_path is the GRE path, relative to source_path.
-    - app_path is the application path, relative to source_path.
-    Startup cache for all resources under resource://app/ are generated,
-    except when gre_path == app_path, in which case it's under
-    resource://gre/.
-    '''
-    from tempfile import mkstemp
-    source_path = os.path.abspath(source_path)
-    if app_path != gre_path:
-        resource = 'app'
-    else:
-        resource = 'gre'
-    app_path = os.path.join(source_path, app_path)
-    gre_path = os.path.join(source_path, gre_path)
-
-    fd, cache = mkstemp('.zip')
-    os.close(fd)
-    os.remove(cache)
-
-    try:
-        extra_env = {'MOZ_STARTUP_CACHE': cache}
-        if buildconfig.substs.get('MOZ_TSAN'):
-            extra_env['TSAN_OPTIONS'] = 'report_bugs=0'
-        if buildconfig.substs.get('MOZ_ASAN'):
-            extra_env['ASAN_OPTIONS'] = 'detect_leaks=0'
-        if launcher.launch(['xpcshell', '-g', gre_path, '-a', app_path,
-                            '-f', os.path.join(os.path.dirname(__file__),
-                            'precompile_cache.js'),
-                            '-e', 'precompile_startupcache("resource://%s/");'
-                                  % resource],
-                           extra_linker_path=gre_path,
-                           extra_env=extra_env):
-            errors.fatal('Error while running startup cache precompilation')
-            return
-        from mozpack.mozjar import JarReader
-        jar = JarReader(cache)
-        resource = '/resource/%s/' % resource
-        for f in jar:
-            if resource in f.filename:
-                path = f.filename[f.filename.index(resource) + len(resource):]
-                if registry.contains(path):
-                    registry.add(f.filename, GeneratedFile(f.read()))
-        jar.close()
-    finally:
-        if os.path.exists(cache):
-            os.remove(cache)
-
-
 class RemovedFiles(GeneratedFile):
     '''
     File class for removed-files. Is used as a preprocessor parser.
     '''
     def __init__(self, copier):
         self.copier = copier
         GeneratedFile.__init__(self, '')
 
@@ -366,32 +311,13 @@ def main():
         log = JarLog(args.jarlog)
         for p, f in copier:
             if not isinstance(f, Jarrer):
                 continue
             key = JarLog.canonicalize(os.path.join(args.destination, p))
             if key in log:
                 f.preload(log[key])
 
-    # Fill startup cache
-    if isinstance(formatter, OmniJarFormatter) and launcher.can_launch() \
-      and buildconfig.substs['MOZ_DISABLE_STARTUPCACHE'] != '1':
-        gre_path = None
-        def get_bases():
-            for b in sink.packager.get_bases(addons=False):
-                for p in (mozpath.join('bin', b), b):
-                    if os.path.exists(os.path.join(args.source, p)):
-                        yield p
-                        break
-        for base in sorted(get_bases()):
-            if not gre_path:
-                gre_path = base
-            omnijar_path = mozpath.join(sink.normalize_path(base),
-                                        buildconfig.substs['OMNIJAR_NAME'])
-            if formatter.contains(omnijar_path):
-                precompile_cache(formatter.copier[omnijar_path],
-                                 args.source, gre_path, base)
-
     copier.copy(args.destination)
 
 
 if __name__ == '__main__':
     main()