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 |
(...skipping 12 matching lines...) Expand all Loading... | |
23 import subprocess2 | 23 import subprocess2 |
24 | 24 |
25 | 25 |
26 RETRY_MAX = 3 | 26 RETRY_MAX = 3 |
27 RETRY_INITIAL_SLEEP = 0.5 | 27 RETRY_INITIAL_SLEEP = 0.5 |
28 | 28 |
29 | 29 |
30 _WARNINGS = [] | 30 _WARNINGS = [] |
31 | 31 |
32 | 32 |
33 # These repos are known to cause OOM errors on 32-bit platforms, due the the | |
mmoss
2014/03/25 00:21:44
It would be nice if this only kicked in under thos
| |
34 # very large objects they contain. It is not safe to use threaded index-pack | |
35 # when cloning/fetching them. | |
36 THREADED_INDEX_PACK_BLACKLIST = [ | |
37 'https://chromium.googlesource.com/chromium/reference_builds/chrome_win.git' | |
38 ] | |
39 | |
40 | |
33 class Error(Exception): | 41 class Error(Exception): |
34 """gclient exception class.""" | 42 """gclient exception class.""" |
35 def __init__(self, msg, *args, **kwargs): | 43 def __init__(self, msg, *args, **kwargs): |
36 index = getattr(threading.currentThread(), 'index', 0) | 44 index = getattr(threading.currentThread(), 'index', 0) |
37 if index: | 45 if index: |
38 msg = '\n'.join('%d> %s' % (index, l) for l in msg.splitlines()) | 46 msg = '\n'.join('%d> %s' % (index, l) for l in msg.splitlines()) |
39 super(Error, self).__init__(msg, *args, **kwargs) | 47 super(Error, self).__init__(msg, *args, **kwargs) |
40 | 48 |
41 | 49 |
42 def PrintWarnings(): | 50 def PrintWarnings(): |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
983 | 991 |
984 The primary constraint is the address space of virtual memory. The cache | 992 The primary constraint is the address space of virtual memory. The cache |
985 size limit is per-thread, and 32-bit systems can hit OOM errors if this | 993 size limit is per-thread, and 32-bit systems can hit OOM errors if this |
986 parameter is set too high. | 994 parameter is set too high. |
987 """ | 995 """ |
988 if platform.architecture()[0].startswith('64'): | 996 if platform.architecture()[0].startswith('64'): |
989 return '2g' | 997 return '2g' |
990 else: | 998 else: |
991 return '512m' | 999 return '512m' |
992 | 1000 |
993 def DefaultIndexPackConfig(): | 1001 def DefaultIndexPackConfig(url=''): |
994 """Return reasonable default values for configuring git-index-pack. | 1002 """Return reasonable default values for configuring git-index-pack. |
995 | 1003 |
996 Experiments suggest that higher values for pack.threads don't improve | 1004 Experiments suggest that higher values for pack.threads don't improve |
997 performance.""" | 1005 performance.""" |
998 return ['-c', 'pack.threads=5', '-c', | 1006 cache_limit = DefaultDeltaBaseCacheLimit() |
999 'core.deltaBaseCacheLimit=%s' % DefaultDeltaBaseCacheLimit()] | 1007 pack_threads = 1 if url in THREADED_INDEX_PACK_BLACKLIST else 4 |
iannucci
2014/03/24 23:45:10
Not sure about the hard-coded 4 default. What abou
szager1
2014/03/24 23:56:44
I don't have any reason to believe that 4 is more
mmoss
2014/03/25 00:21:44
Yeah, only adding the command-line arg when "neces
szager1
2014/03/25 00:40:25
OK, the code now only sets pack.threads on the com
| |
1008 return ['-c', 'pack.threads=%d' % pack_threads, | |
1009 '-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] | |
OLD | NEW |