Bug 920765 - Reduce analysis memory usage, r=Waldo
authorSteve Fink <sfink@mozilla.com>
Thu, 26 Sep 2013 14:19:26 -0700
changeset 164379 cfebceef31082cb2466a13a55da004c1ceffb2ff
parent 164378 bca868ced51d50f3595a43f73ce208ddb96ff202
child 164380 f6b879837822bac2c4f5988a0d5d04b88625d657
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs920765
milestone27.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 920765 - Reduce analysis memory usage, r=Waldo
js/src/devtools/rootAnalysis/analyze.py
js/src/devtools/rootAnalysis/analyzeRoots.js
js/src/devtools/rootAnalysis/run_complete
js/src/jsapi.cpp
--- a/js/src/devtools/rootAnalysis/analyze.py
+++ b/js/src/devtools/rootAnalysis/analyze.py
@@ -192,17 +192,17 @@ data = config.copy()
 
 parser = argparse.ArgumentParser(description='Statically analyze build tree for rooting hazards.')
 parser.add_argument('step', metavar='STEP', type=str, nargs='?',
                     help='run starting from this step')
 parser.add_argument('--source', metavar='SOURCE', type=str, nargs='?',
                     help='source code to analyze')
 parser.add_argument('--upto', metavar='UPTO', type=str, nargs='?',
                     help='last step to execute')
-parser.add_argument('--jobs', '-j', default=4, metavar='JOBS', type=int,
+parser.add_argument('--jobs', '-j', default=None, metavar='JOBS', type=int,
                     help='number of simultaneous analyzeRoots.js jobs')
 parser.add_argument('--list', const=True, nargs='?', type=bool,
                     help='display available steps')
 parser.add_argument('--buildcommand', '--build', '-b', type=str, nargs='?',
                     help='command to build the tree being analyzed')
 parser.add_argument('--tag', '-t', type=str, nargs='?',
                     help='name of job, also sets build command to "build.<tag>"')
 
--- a/js/src/devtools/rootAnalysis/analyzeRoots.js
+++ b/js/src/devtools/rootAnalysis/analyzeRoots.js
@@ -551,21 +551,21 @@ var N = (maxStream - minStream) + 1;
 var each = Math.floor(N/numBatches);
 var start = minStream + each * (batch - 1);
 var end = Math.min(minStream + each * batch - 1, maxStream);
 
 for (var nameIndex = start; nameIndex <= end; nameIndex++) {
     var name = xdb.read_key(nameIndex);
     var functionName = name.readString();
     var data = xdb.read_entry(name);
-    functionBodies = JSON.parse(data.readString());
+    xdb.free_string(name);
+    var json = data.readString();
+    xdb.free_string(data);
+    functionBodies = JSON.parse(json);
 
     for (var body of functionBodies)
         body.suppressed = [];
     for (var body of functionBodies) {
         for (var [pbody, id] of allRAIIGuardedCallPoints(body, isSuppressConstructor))
             pbody.suppressed[id] = true;
     }
     processBodies(functionName);
-
-    xdb.free_string(name);
-    xdb.free_string(data);
 }
--- a/js/src/devtools/rootAnalysis/run_complete
+++ b/js/src/devtools/rootAnalysis/run_complete
@@ -19,16 +19,17 @@
 
 # do a complete run of the system from raw source to reports. this requires
 # various run_monitor processes to be running in the background (maybe on other
 # machines) and watching a shared poll_file for jobs. if the output directory
 # for this script already exists then an incremental analysis will be performed
 # and the reports will only reflect the changes since the earlier run.
 
 use strict;
+use warnings;
 use IO::Handle;
 use File::Basename qw(dirname);
 use Getopt::Long;
 use Cwd;
 
 #################################
 # environment specific settings #
 #################################
@@ -188,17 +189,17 @@ sub get_manager_address
     my $log_file = shift or die;
 
     # give the manager one second to start, any longer and something's broken.
     sleep(1);
 
     my $log_data = `cat $log_file`;
     my ($port) = $log_data =~ /Listening on ([\.\:0-9]*)/
       or die "no manager found";
-    print OUT "Connecting to manager on port $port\n";
+    print OUT "Connecting to manager on port $port\n" unless $suppress_logs;
     print "Connecting to manager on port $port.\n";
     return $1;
 }
 
 sub run_build
 {
     print "build started: ";
     print scalar(localtime());
@@ -305,17 +306,17 @@ sub run_pass
     unlink($poll_file);
 
     print "$name finished: ";
     print scalar(localtime());
     print "\n";
 
     # collate the worker's output into a single file. make this asynchronous
     # so we can wait a bit and make sure we get all worker output.
-    defined(my $pid = fork) or die;
+    defined($pid = fork) or die;
 
     if (!$pid) {
         sleep(20);
         exec("cat $name.*.log > $name.log");
     }
 
     push(@waitpids, $pid);
 }
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -611,49 +611,68 @@ JS_IsBuiltinFunctionConstructor(JSFuncti
  * Initializing that subsystem from JS_Init eliminates the problem, but
  * initialization can take a comparatively long time (15ms or so), so we
  * really don't want to do it in JS_Init, and we really do want to do it only
  * when PRMJ_Now is eventually called.
  */
 enum InitState { Uninitialized, Running, ShutDown };
 static InitState jsInitState = Uninitialized;
 
+#ifdef DEBUG
+static void
+CheckMessageNumbering()
+{
+    // Assert that the numbers associated with the error names in js.msg are
+    // monotonically increasing.  It's not a compile-time check, but it's
+    // better than nothing.
+    int errorNumber = 0;
+# define MSG_DEF(name, number, count, exception, format)                      \
+    JS_ASSERT(name == errorNumber++);
+# include "js.msg"
+# undef MSG_DEF
+}
+
+static unsigned
+MessageParameterCount(const char *format)
+{
+    unsigned numfmtspecs = 0;
+    for (const char *fmt = format; *fmt != '\0'; fmt++) {
+        if (*fmt == '{' && isdigit(fmt[1]))
+            ++numfmtspecs;
+    }
+    return numfmtspecs;
+}
+
+static void
+CheckMessageParameterCounts()
+{
+    // Assert that each message format has the correct number of braced
+    // parameters.
+# define MSG_DEF(name, number, count, exception, format)                      \
+    JS_BEGIN_MACRO                                                            \
+        JS_ASSERT(MessageParameterCount(format) == count);                    \
+    JS_END_MACRO;
+# include "js.msg"
+# undef MSG_DEF
+}
+#endif /* DEBUG */
+
 JS_PUBLIC_API(bool)
 JS_Init(void)
 {
     MOZ_ASSERT(jsInitState == Uninitialized,
                "must call JS_Init once before any JSAPI operation except "
                "JS_SetICUMemoryFunctions");
     MOZ_ASSERT(!JSRuntime::hasLiveRuntimes(),
                "how do we have live runtimes before JS_Init?");
 
 #ifdef DEBUG
-    // Assert that the numbers associated with the error names in js.msg are
-    // monotonically increasing.  It's not a compile-time check, but it's
-    // better than nothing.
-    int errorNumber = 0;
-#define MSG_DEF(name, number, count, exception, format)                       \
-    JS_ASSERT(name == errorNumber++);
-#include "js.msg"
-#undef MSG_DEF
-
-    // Assert that each message format has the correct number of braced
-    // parameters.
-#define MSG_DEF(name, number, count, exception, format)                       \
-    JS_BEGIN_MACRO                                                            \
-        unsigned numfmtspecs = 0;                                             \
-        for (const char *fmt = format; *fmt != '\0'; fmt++) {                 \
-            if (*fmt == '{' && isdigit(fmt[1]))                               \
-                ++numfmtspecs;                                                \
-        }                                                                     \
-        JS_ASSERT(count == numfmtspecs);                                      \
-    JS_END_MACRO;
-#include "js.msg"
-#undef MSG_DEF
-#endif /* DEBUG */
+    CheckMessageNumbering();
+    CheckMessageParameterCounts();
+#endif
 
     using js::TlsPerThreadData;
     if (!TlsPerThreadData.initialized() && !TlsPerThreadData.init())
         return false;
 
 #if defined(JS_ION)
     if (!jit::InitializeIon())
         return false;