Commit fc616383 authored by szager@chromium.org's avatar szager@chromium.org

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
parent 3407103d
......@@ -109,9 +109,6 @@ class GclientGitCheckout(GclientCheckout, GitCheckout):
return os.path.exists(os.path.join(os.getcwd(), self.root))
def init(self):
# TODO(dpranke): Work around issues w/ delta compression on big repos.
self.run_git('config', '--global', 'core.deltaBaseCacheLimit', '1G')
# Configure and do the gclient checkout.
self.run_gclient('config', '--spec', self.spec['gclient_spec'])
if self.options.nohooks:
......
......@@ -230,8 +230,8 @@ class GitWrapper(SCMWrapper):
quiet = ['--quiet']
self._UpdateBranchHeads(options, fetch=False)
fetch_cmd = [
'-c', 'core.deltaBaseCacheLimit=2g', 'fetch', self.remote, '--prune']
cfg = gclient_utils.DefaultIndexPackConfig()
fetch_cmd = cfg + ['fetch', self.remote, '--prune']
self._Run(fetch_cmd + quiet, options, retry=True)
self._Run(['reset', '--hard', revision] + quiet, options)
self.UpdateSubmoduleConfig()
......@@ -700,8 +700,9 @@ class GitWrapper(SCMWrapper):
print('')
template_path = os.path.join(
os.path.dirname(THIS_FILE_PATH), 'git-templates')
clone_cmd = ['-c', 'core.deltaBaseCacheLimit=2g', 'clone', '--no-checkout',
'--progress', '--template=%s' % template_path]
cfg = gclient_utils.DefaultIndexPackConfig()
clone_cmd = cfg + [
'clone', '--no-checkout', '--progress', '--template=%s' % template_path]
if self.cache_dir:
clone_cmd.append('--shared')
if options.verbose:
......@@ -911,7 +912,8 @@ class GitWrapper(SCMWrapper):
'^\\+refs/branch-heads/\\*:.*$']
self._Run(config_cmd, options)
if fetch:
fetch_cmd = ['-c', 'core.deltaBaseCacheLimit=2g', 'fetch', self.remote]
cfg = gclient_utils.DefaultIndexPackConfig()
fetch_cmd = cfg + ['fetch', self.remote]
if options.verbose:
fetch_cmd.append('--verbose')
self._Run(fetch_cmd, options, retry=True)
......
......@@ -9,6 +9,7 @@ import cStringIO
import logging
import os
import pipes
import platform
import Queue
import re
import stat
......@@ -960,3 +961,23 @@ def NumLocalCpus():
# 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()]
......@@ -181,8 +181,8 @@ def CMDpopulate(parser, args):
d = ['--depth', '%d' % options.depth]
def _config(directory):
RunGit(['config', 'core.deltaBaseCacheLimit', '2g'],
cwd=directory)
RunGit(['config', 'core.deltaBaseCacheLimit',
gclient_utils.DefaultDeltaBaseCacheLimit()], cwd=directory)
RunGit(['config', 'remote.origin.url', url],
cwd=directory)
RunGit(['config', '--replace-all', 'remote.origin.fetch',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment