Rationalize the git config settings for index-pack performance.
BUG=
Review URL: https://codereview.chromium.org/202753003
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@257728 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index 1801a6b..7003fc8 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -9,6 +9,7 @@
import logging
import os
import pipes
+import platform
import Queue
import re
import stat
@@ -960,3 +961,23 @@
# Mac OS 10.6 only
# pylint: disable=E1101
return int(os.sysconf('SC_NPROCESSORS_ONLN'))
+
+def DefaultDeltaBaseCacheLimit():
+ """Return a reasonable default for the git config core.deltaBaseCacheLimit.
+
+ The primary constraint is the address space of virtual memory. The cache
+ size limit is per-thread, and 32-bit systems can hit OOM errors if this
+ parameter is set too high.
+ """
+ if platform.architecture()[0].startswith('64'):
+ return '2g'
+ else:
+ return '512m'
+
+def DefaultIndexPackConfig():
+ """Return reasonable default values for configuring git-index-pack.
+
+ Experiments suggest that higher values for pack.threads don't improve
+ performance."""
+ return ['-c', 'pack.threads=5', '-c',
+ 'core.deltaBaseCacheLimit=%s' % DefaultDeltaBaseCacheLimit()]