Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: build/toolchain/get_concurrent_links.py

Issue 1492843006: get_concurrent_links.py: give more RAM per job in LTO builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/gcc_toolchain.gni ('k') | build/toolchain/win/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # This script computs the number of concurrent links we want to run in the build 5 # This script computs the number of concurrent links we want to run in the build
6 # as a function of machine spec. It's based on GetDefaultConcurrentLinks in GYP. 6 # as a function of machine spec. It's based on GetDefaultConcurrentLinks in GYP.
7 7
8 import optparse
8 import os 9 import os
9 import re 10 import re
10 import subprocess 11 import subprocess
11 import sys 12 import sys
12 13
13 def GetDefaultConcurrentLinks(): 14 def _GetDefaultConcurrentLinks(is_lto):
14 # Inherit the legacy environment variable for people that have set it in GYP. 15 # Inherit the legacy environment variable for people that have set it in GYP.
15 pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0)) 16 pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0))
16 if pool_size: 17 if pool_size:
17 return pool_size 18 return pool_size
18 19
19 if sys.platform in ('win32', 'cygwin'): 20 if sys.platform in ('win32', 'cygwin'):
20 import ctypes 21 import ctypes
21 22
22 class MEMORYSTATUSEX(ctypes.Structure): 23 class MEMORYSTATUSEX(ctypes.Structure):
23 _fields_ = [ 24 _fields_ = [
(...skipping 18 matching lines...) Expand all
42 return min(mem_limit, hard_cap) 43 return min(mem_limit, hard_cap)
43 elif sys.platform.startswith('linux'): 44 elif sys.platform.startswith('linux'):
44 if os.path.exists("/proc/meminfo"): 45 if os.path.exists("/proc/meminfo"):
45 with open("/proc/meminfo") as meminfo: 46 with open("/proc/meminfo") as meminfo:
46 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') 47 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB')
47 for line in meminfo: 48 for line in meminfo:
48 match = memtotal_re.match(line) 49 match = memtotal_re.match(line)
49 if not match: 50 if not match:
50 continue 51 continue
51 # Allow 8Gb per link on Linux because Gold is quite memory hungry 52 # Allow 8Gb per link on Linux because Gold is quite memory hungry
52 return max(1, int(match.group(1)) / (8 * (2 ** 20))) 53 # For LTO builds the RAM requirements are even higher
54 # Note: it's 15 GB for LTO build to make sure we get 4 link jobs
55 # for 64 GB, even if the system reports a couple of GBs less.
56 ram_per_link_gb = 15 if is_lto else 8
57 return max(1, int(match.group(1)) / (ram_per_link_gb * (2 ** 20)))
53 return 1 58 return 1
54 elif sys.platform == 'darwin': 59 elif sys.platform == 'darwin':
55 try: 60 try:
56 avail_bytes = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize'])) 61 avail_bytes = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize']))
57 # A static library debug build of Chromium's unit_tests takes ~2.7GB, so 62 # A static library debug build of Chromium's unit_tests takes ~2.7GB, so
58 # 4GB per ld process allows for some more bloat. 63 # 4GB per ld process allows for some more bloat.
59 return max(1, avail_bytes / (4 * (2 ** 30))) # total / 4GB 64 return max(1, avail_bytes / (4 * (2 ** 30))) # total / 4GB
60 except Exception: 65 except Exception:
61 return 1 66 return 1
62 else: 67 else:
63 # TODO(scottmg): Implement this for other platforms. 68 # TODO(scottmg): Implement this for other platforms.
64 return 1 69 return 1
65 70
66 print GetDefaultConcurrentLinks() 71 def main():
72 parser = optparse.OptionParser()
73 parser.add_option('--lto', action="store_true", default=False,
74 help='This is an LTO build with higher memory requirements')
75 parser.disable_interspersed_args()
76 options, args = parser.parse_args()
77
78 print _GetDefaultConcurrentLinks(is_lto=options.lto)
79 return 0
80
81 if __name__ == '__main__':
82 sys.exit(main())
OLDNEW
« no previous file with comments | « build/toolchain/gcc_toolchain.gni ('k') | build/toolchain/win/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698