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

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

Issue 2289963002: build: Fix getting available memory on mac (Closed)
Patch Set: Created 4 years, 3 months 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 | « no previous file | no next file » | 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 optparse
9 import os 9 import os
10 import re 10 import re
(...skipping 24 matching lines...) Expand all
35 if os.path.exists("/proc/meminfo"): 35 if os.path.exists("/proc/meminfo"):
36 with open("/proc/meminfo") as meminfo: 36 with open("/proc/meminfo") as meminfo:
37 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') 37 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB')
38 for line in meminfo: 38 for line in meminfo:
39 match = memtotal_re.match(line) 39 match = memtotal_re.match(line)
40 if not match: 40 if not match:
41 continue 41 continue
42 return float(match.group(1)) * 2**10 42 return float(match.group(1)) * 2**10
43 elif sys.platform == 'darwin': 43 elif sys.platform == 'darwin':
44 try: 44 try:
45 avail_bytes = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize'])) 45 return int(subprocess.check_output(['sysctl', '-n', 'hw.memsize']))
46 except Exception: 46 except Exception:
47 return 0 47 return 0
48 # TODO(scottmg): Implement this for other platforms. 48 # TODO(scottmg): Implement this for other platforms.
49 return 0 49 return 0
50 50
51 51
52 def _GetDefaultConcurrentLinks(mem_per_link_gb, reserve_mem_gb): 52 def _GetDefaultConcurrentLinks(mem_per_link_gb, reserve_mem_gb):
53 # Inherit the legacy environment variable for people that have set it in GYP. 53 # Inherit the legacy environment variable for people that have set it in GYP.
54 pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0)) 54 pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0))
55 if pool_size: 55 if pool_size:
(...skipping 12 matching lines...) Expand all
68 parser.add_option('--reserve_mem_gb', action="store", type="int", default=0) 68 parser.add_option('--reserve_mem_gb', action="store", type="int", default=0)
69 parser.disable_interspersed_args() 69 parser.disable_interspersed_args()
70 options, args = parser.parse_args() 70 options, args = parser.parse_args()
71 71
72 print _GetDefaultConcurrentLinks(options.mem_per_link_gb, 72 print _GetDefaultConcurrentLinks(options.mem_per_link_gb,
73 options.reserve_mem_gb) 73 options.reserve_mem_gb)
74 return 0 74 return 0
75 75
76 if __name__ == '__main__': 76 if __name__ == '__main__':
77 sys.exit(main()) 77 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698