OLD | NEW |
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 collections | 5 import collections |
6 import copy | 6 import copy |
7 import hashlib | 7 import hashlib |
8 import json | 8 import json |
9 import multiprocessing | 9 import multiprocessing |
10 import os.path | 10 import os.path |
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 ("ullAvailPageFile", ctypes.c_ulonglong), | 1689 ("ullAvailPageFile", ctypes.c_ulonglong), |
1690 ("ullTotalVirtual", ctypes.c_ulonglong), | 1690 ("ullTotalVirtual", ctypes.c_ulonglong), |
1691 ("ullAvailVirtual", ctypes.c_ulonglong), | 1691 ("ullAvailVirtual", ctypes.c_ulonglong), |
1692 ("sullAvailExtendedVirtual", ctypes.c_ulonglong), | 1692 ("sullAvailExtendedVirtual", ctypes.c_ulonglong), |
1693 ] | 1693 ] |
1694 | 1694 |
1695 stat = MEMORYSTATUSEX() | 1695 stat = MEMORYSTATUSEX() |
1696 stat.dwLength = ctypes.sizeof(stat) | 1696 stat.dwLength = ctypes.sizeof(stat) |
1697 ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) | 1697 ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) |
1698 | 1698 |
1699 mem_limit = max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB | 1699 # VS 2015 uses 20% more working set than VS 2013 and can consume all RAM |
| 1700 # on a 64 GB machine. |
| 1701 mem_limit = max(1, stat.ullTotalPhys / (5 * (2 ** 30))) # total / 5GB |
1700 hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32))) | 1702 hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32))) |
1701 return min(mem_limit, hard_cap) | 1703 return min(mem_limit, hard_cap) |
1702 elif sys.platform.startswith('linux'): | 1704 elif sys.platform.startswith('linux'): |
1703 if os.path.exists("/proc/meminfo"): | 1705 if os.path.exists("/proc/meminfo"): |
1704 with open("/proc/meminfo") as meminfo: | 1706 with open("/proc/meminfo") as meminfo: |
1705 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') | 1707 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') |
1706 for line in meminfo: | 1708 for line in meminfo: |
1707 match = memtotal_re.match(line) | 1709 match = memtotal_re.match(line) |
1708 if not match: | 1710 if not match: |
1709 continue | 1711 continue |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2382 arglists.append( | 2384 arglists.append( |
2383 (target_list, target_dicts, data, params, config_name)) | 2385 (target_list, target_dicts, data, params, config_name)) |
2384 pool.map(CallGenerateOutputForConfig, arglists) | 2386 pool.map(CallGenerateOutputForConfig, arglists) |
2385 except KeyboardInterrupt, e: | 2387 except KeyboardInterrupt, e: |
2386 pool.terminate() | 2388 pool.terminate() |
2387 raise e | 2389 raise e |
2388 else: | 2390 else: |
2389 for config_name in config_names: | 2391 for config_name in config_names: |
2390 GenerateOutputForConfig(target_list, target_dicts, data, params, | 2392 GenerateOutputForConfig(target_list, target_dicts, data, params, |
2391 config_name) | 2393 config_name) |
OLD | NEW |