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

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 143473002: De-hardcode link concurrency for Windows. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« 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 (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. 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 import copy 5 import copy
6 import hashlib 6 import hashlib
7 import json 7 import json
8 import multiprocessing 8 import multiprocessing
9 import os.path 9 import os.path
10 import re 10 import re
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 ("ullAvailVirtual", ctypes.c_ulonglong), 1550 ("ullAvailVirtual", ctypes.c_ulonglong),
1551 ("sullAvailExtendedVirtual", ctypes.c_ulonglong), 1551 ("sullAvailExtendedVirtual", ctypes.c_ulonglong),
1552 ] 1552 ]
1553 1553
1554 stat = MEMORYSTATUSEX() 1554 stat = MEMORYSTATUSEX()
1555 stat.dwLength = ctypes.sizeof(stat) 1555 stat.dwLength = ctypes.sizeof(stat)
1556 ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) 1556 ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
1557 1557
1558 mem_limit = max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB 1558 mem_limit = max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB
1559 hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32))) 1559 hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32)))
1560 # return min(mem_limit, hard_cap) 1560 return min(mem_limit, hard_cap)
1561 # TODO(scottmg): Temporary speculative fix for OOM on builders
1562 # See http://crbug.com/333000.
1563 return 2
1564 elif sys.platform.startswith('linux'): 1561 elif sys.platform.startswith('linux'):
1565 with open("/proc/meminfo") as meminfo: 1562 with open("/proc/meminfo") as meminfo:
1566 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') 1563 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB')
1567 for line in meminfo: 1564 for line in meminfo:
1568 match = memtotal_re.match(line) 1565 match = memtotal_re.match(line)
1569 if not match: 1566 if not match:
1570 continue 1567 continue
1571 # Allow 8Gb per link on Linux because Gold is quite memory hungry 1568 # Allow 8Gb per link on Linux because Gold is quite memory hungry
1572 return max(1, int(match.group(1)) / (8 * (2 ** 20))) 1569 return max(1, int(match.group(1)) / (8 * (2 ** 20)))
1573 return 1 1570 return 1
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 arglists.append( 2138 arglists.append(
2142 (target_list, target_dicts, data, params, config_name)) 2139 (target_list, target_dicts, data, params, config_name))
2143 pool.map(CallGenerateOutputForConfig, arglists) 2140 pool.map(CallGenerateOutputForConfig, arglists)
2144 except KeyboardInterrupt, e: 2141 except KeyboardInterrupt, e:
2145 pool.terminate() 2142 pool.terminate()
2146 raise e 2143 raise e
2147 else: 2144 else:
2148 for config_name in config_names: 2145 for config_name in config_names:
2149 GenerateOutputForConfig(target_list, target_dicts, data, params, 2146 GenerateOutputForConfig(target_list, target_dicts, data, params,
2150 config_name) 2147 config_name)
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