Bug 1303227 - Wrap libxul.so linker to prevent getting the linking process killed; r=glandium draft
authorEnes Goktas <egoktas@mozilla.com>
Tue, 20 Sep 2016 17:58:34 -0700
changeset 415767 20de614af3950dd4a2bf2caa08b79ef4e7cd9199
parent 415495 62f79d676e0e11b3ad59a5425b3ebb3ec5bbefb5
child 531699 0449d7696cb27388460fbcca00d0b33f69b08aac
push id29965
push userbmo:enes.goktas@gmail.com
push dateWed, 21 Sep 2016 01:29:16 +0000
reviewersglandium
bugs1303227
milestone52.0a1
Bug 1303227 - Wrap libxul.so linker to prevent getting the linking process killed; r=glandium This patch removes the memory usage tracking in the script that wraps the linking of the xul library. This patch also generalizes the wrapping of the xul linking process to all platforms. MozReview-Commit-ID: HyncF3aVwdx
config/link.py
toolkit/library/Makefile.in
toolkit/library/gtest/Makefile.in
--- a/config/link.py
+++ b/config/link.py
@@ -2,59 +2,46 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import expandlibs_exec
 import sys
 import threading
 import time
 
-from win32 import procmem
-
-def measure_vsize_threadfunc(proc, output_file):
+def periodically_print_status(proc):
     """
-    Measure the virtual memory usage of |proc| at regular intervals
-    until it exits, then print the maximum value and write it to
-    |output_file|.  Also, print something to the console every
-    half an hour to prevent the build job from getting killed when
-    linking a large PGOed binary.
+    Print something to the console every 20 minutes to prevent the build job
+    from getting killed when linking a large binary.
+    Check status of the linker every 0.5 seconds.
     """
-    maxvsize = 0
     idleTime = 0
     while proc.returncode is None:
-        maxvsize, vsize = procmem.get_vmsize(proc._handle)
         time.sleep(0.5)
         idleTime += 0.5
-        if idleTime > 30 * 60:
-          print "Still linking, 30 minutes passed..."
+        if idleTime > 20 * 60:
+          print "Still linking, 20 minutes passed..."
           sys.stdout.flush()
           idleTime = 0
-    print "TinderboxPrint: linker max vsize: %d" % maxvsize
-    with open(output_file, "w") as f:
-        f.write("%d\n" % maxvsize)
 
-def measure_link_vsize(output_file, args):
+def wrap_linker(args):
     """
-    Execute |args|, and measure the maximum virtual memory usage of the process,
-    printing it to stdout when finished.
+    Execute |args| and pass resulting |proc| object to a second thread that
+    will track the status of the started |proc|.
     """
 
     # This needs to be a list in order for the callback to set the
     # variable properly with python-2's scoping rules.
     t = [None]
     def callback(proc):
-        t[0] = threading.Thread(target=measure_vsize_threadfunc,
-                             args=(proc, output_file))
+        t[0] = threading.Thread(target=periodically_print_status,
+                             args=(proc,))
         t[0].start()
     exitcode = expandlibs_exec.main(args, proc_callback=callback)
     # Wait for the background thread to finish.
     t[0].join()
     return exitcode
 
 if __name__ == "__main__":
-    if sys.platform != "win32":
-        print >>sys.stderr, "link.py is only for use on Windows!"
+    if len(sys.argv) < 2:
+        print >>sys.stderr, "Usage: link.py <commandline>"
         sys.exit(1)
-    if len(sys.argv) < 3:
-        print >>sys.stderr, "Usage: link.py <output filename> <commandline>"
-        sys.exit(1)
-    output_file = sys.argv.pop(1)
-    sys.exit(measure_link_vsize(output_file, sys.argv[1:]))
+    sys.exit(wrap_linker(sys.argv[1:]))
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -1,18 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 include $(topsrcdir)/toolkit/library/libxul.mk
 
 include $(topsrcdir)/config/config.mk
 
-ifeq (WINNT_1,$(OS_TARGET)_$(MOZ_PROFILE_USE))
-# Wrap linker to measure peak virtual memory usage.
-EXPAND_LIBS_EXEC := $(PYTHON) $(topsrcdir)/config/link.py linker-vsize
-endif
+# Wrap linker to print linking status periodically to prevent the linking
+# process from getting killed
+EXPAND_LIBS_EXEC := $(PYTHON) $(topsrcdir)/config/link.py
 
 include $(topsrcdir)/config/rules.mk
 
 .PHONY: gtestxul
 gtestxul:
 	$(MAKE) -C $(DEPTH) toolkit/library/gtest/target LINK_GTEST=1
--- a/toolkit/library/gtest/Makefile.in
+++ b/toolkit/library/gtest/Makefile.in
@@ -12,16 +12,22 @@ ifndef LINK_GTEST
 # Force to not include backend.mk unless LINK_GTEST is defined.
 # Not including backend.mk makes traversing this directory do nothing.
 STANDALONE_MAKEFILE = 1
 
 else
 
 include $(topsrcdir)/toolkit/library/libxul.mk
 
+include $(topsrcdir)/config/config.mk
+
+# Wrap linker to print linking status periodically to prevent the linking
+# process from getting killed
+EXPAND_LIBS_EXEC := $(PYTHON) $(topsrcdir)/config/link.py
+
 ifdef COMPILE_ENVIRONMENT
 target:: $(DIST)/bin/dependentlibs.list.gtest
 endif
 
 $(DIST)/bin/dependentlibs.list.gtest: $(DIST)/bin/dependentlibs.list
 	sed -e 's|$(SHARED_LIBRARY)|gtest/$(SHARED_LIBRARY)|' $< > $@
 
 LINK_PDBFILE = xul-gtest.pdb