OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Generic utils.""" | 5 """Generic utils.""" |
6 | 6 |
7 import codecs | 7 import codecs |
8 import cStringIO | 8 import cStringIO |
9 import logging | 9 import logging |
10 import os | 10 import os |
11 import pipes | 11 import pipes |
12 import platform | |
12 import Queue | 13 import Queue |
13 import re | 14 import re |
14 import stat | 15 import stat |
15 import subprocess | 16 import subprocess |
16 import sys | 17 import sys |
17 import tempfile | 18 import tempfile |
18 import threading | 19 import threading |
19 import time | 20 import time |
20 import urlparse | 21 import urlparse |
21 | 22 |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
953 | 954 |
954 Python on OSX 10.6 raises a NotImplementedError exception. | 955 Python on OSX 10.6 raises a NotImplementedError exception. |
955 """ | 956 """ |
956 try: | 957 try: |
957 import multiprocessing | 958 import multiprocessing |
958 return multiprocessing.cpu_count() | 959 return multiprocessing.cpu_count() |
959 except: # pylint: disable=W0702 | 960 except: # pylint: disable=W0702 |
960 # Mac OS 10.6 only | 961 # Mac OS 10.6 only |
961 # pylint: disable=E1101 | 962 # pylint: disable=E1101 |
962 return int(os.sysconf('SC_NPROCESSORS_ONLN')) | 963 return int(os.sysconf('SC_NPROCESSORS_ONLN')) |
964 | |
965 def DefaultDeltaBaseCacheLimit(): | |
966 """Return a reasonable default for the git config core.deltaBaseCacheLimit. | |
967 | |
968 The primary constraint is the address space of virtual memory. The cache | |
969 size limit is per-thread, and 32-bit systems can hit OOM errors if this | |
970 parameter is set too high. | |
971 """ | |
972 if platform.architecture()[0].startswith('64'): | |
973 return '2g' | |
974 else: | |
975 return '512m' | |
iannucci
2014/03/18 20:24:27
for future: I'd really like if we could do this on
| |
976 | |
977 def DefaultIndexPackConfig(): | |
978 """Return reasonable default values for configuring git-index-pack. | |
979 | |
980 Experiments suggest that higher values for pack.threads don't improve | |
981 performance.""" | |
982 return ['-c', 'pack.threads=5', '-c', | |
983 'core.deltaBaseCacheLimit=%s' % DefaultDeltaBaseCacheLimit()] | |
OLD | NEW |