Skip to content
Snippets Groups Projects
Commit 73baad28 authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

Re(re-re-re) implement exchange benchmarks

Use prepare_repos.py to create partial benchmarks which are cloned, then
stripped. This use debugupdatecahce which require hg >= 4.3 (we use the system
installed hg for that).

Partial clones are then used in incoming/outgoing benchmark which can then be
switched to "time" benchmark allowing ASV to control the number of loop etc.

Since we're using subprocesses use timeit.default_timer as timer.
parent 3a8d8848
No related branches found
No related tags found
No related merge requests found
......@@ -137,47 +137,7 @@
self._execute("bundle", "--base", ":(-%d)" % (n+1), "/tmp/bundle.bundle")
class ExchangeTrackSuite(BaseTrackTestSuite):
param_names = BaseTrackTestSuite.param_names + ['revset']
# params = BaseTrackTestSuite.params + [['default~10', None]]
params = BaseTrackTestSuite.params + [[None]]
def setup(self, repo_name, revset, *args, **kwargs):
super(ExchangeTrackSuite, self).setup(repo_name, *args, **kwargs)
self.revset = revset
self.tempdir = tempfile.mkdtemp(dir=os.environ.get('ASVTEMPDIR'))
self.cachedir = os.path.join(REPOS_DIR, '.cache')
from base64 import b64encode
if revset is None:
self.cache_name = "%s.tar" % repo_name
self.cache_path = os.path.join(self.cachedir, self.cache_name)
if not os.path.isfile(self.cache_path):
tar_cmd = "tar cf %s -C %s ." % (self.cache_path, self.repo_path)
self._single_execute(shlex.split(tar_cmd))
else:
safe_range = b64encode(revset)
self.cache_name = "%s-%s.tar" % (repo_name, safe_range)
self.cache_path = os.path.join(self.cachedir, self.cache_name)
if not os.path.isfile(self.cache_path):
# First clone it
clone_path = os.path.join(self.cachedir, "%s-%s-clone" % (repo_name, safe_range))
rev = self._identify_id(revset)
cmd = [self.hgpath, '--cwd', self.repo_path,
'clone', '--noupdate', '.', clone_path,
'-r', rev]
self._single_execute(cmd)
tar_cmd = "tar cf %s -C %s ." % (self.cache_path, clone_path)
self._single_execute(shlex.split(tar_cmd))
shutil.rmtree(clone_path)
class ExchangeTimeSuite(BaseTimeTestSuite):
param_names = BaseTimeTestSuite.param_names + ['revset']
params = BaseTrackTestSuite.params + [[None, 'default']]
......@@ -183,23 +143,13 @@
def teardown(self, *args, **kwargs):
try:
shutil.rmtree(self.tempdir)
except Exception:
pass
def _identify_id(self, revset):
rev = subprocess.check_output([
self.hgpath, '--cwd', self.repo_path, 'identify', '-i', "-r", revset], env=self.environ)
return rev.strip()
@contextlib.contextmanager
def clone_from_cache(self):
try:
import time
clone_path = os.path.join(self.tempdir, 'clone-%s' % time.time())
os.mkdir(clone_path)
cmd = "tar xf %s -C %s" % (self.cache_path, clone_path)
clone_time = self._single_execute(shlex.split(cmd))
def setup(self, repo_name, revset):
self.timer = timeit.default_timer
self.sample_time = 10
super(ExchangeTimeSuite, self).setup(repo_name, revset)
self.clone_path = os.path.join(REPOS_DIR, '.cache', repo_name)
if revset is not None:
self.rev = subprocess.check_output([
self.hgpath, '--cwd', self.repo_path, 'identify', '-i', "-r", revset
], env=self.environ).strip()
else:
self.rev = None
......@@ -205,12 +155,7 @@
yield clone_path
finally:
shutil.rmtree(clone_path)
def track_incoming(self, *args, **kwargs):
with self.clone_from_cache() as clone_path:
cmd = [self.hgpath, '--cwd', clone_path, 'incoming', self.repo_path]
if self.revset:
cmd.extend(['-r', 'default'])
def time_incoming(self, repo_name, revset):
cmd = [self.hgpath, '--cwd', self.clone_path, 'incoming', self.repo_path]
if self.rev:
cmd.extend(['-r', self.rev])
self._single_execute(cmd)
......@@ -216,16 +161,9 @@
# Ignore the return code
return self._timeit(self._single_execute, (cmd, False))
def track_outgoing(self, *args, **kwargs):
with self.clone_from_cache() as clone_path:
cmd = [self.hgpath, '--cwd', self.repo_path, 'outgoing',
clone_path]
if self.revset:
cmd.extend(['-r', 'default'])
# Ignore the return code
return self._timeit(self._single_execute, (cmd, False))
def time_outgoing(self, repo_name, revset):
cmd = [self.hgpath, '--cwd', self.repo_path, 'outgoing', self.clone_path]
if self.rev:
cmd.extend(['-r', self.rev])
self._single_execute(cmd)
# def track_push(self, *args, **kwargs):
# def clone_and_push():
......
""" Ensure that all repository are cloned and at their tip
"""
import errno
import hglib
......@@ -3,4 +4,6 @@
import hglib
import os
import subprocess
from os.path import isdir, join
import yaml
......@@ -11,8 +14,14 @@
def clone_repositories(config, repos_dir):
cachedir = join(repos_dir, '.cache')
try:
os.makedirs(cachedir)
except OSError as exc:
if exc.errno != errno.EEXIST:
raise
for repo_name, repo in config['repos'].items():
clonedir = join(repos_dir, repo_name)
if not isdir(clonedir):
print("Cloning %s (%s) into %s" % (repo_name, repo['url'], clonedir))
hglib.clone(repo['url'], clonedir)
......@@ -14,8 +23,17 @@
for repo_name, repo in config['repos'].items():
clonedir = join(repos_dir, repo_name)
if not isdir(clonedir):
print("Cloning %s (%s) into %s" % (repo_name, repo['url'], clonedir))
hglib.clone(repo['url'], clonedir)
partialdir = join(cachedir, repo_name)
if not isdir(partialdir):
print("Cloning partial %s (%s) into %s (for exchange benchmarks)" % (
repo_name, clonedir, partialdir))
subprocess.check_call(['hg', 'clone', '--noupdate', clonedir,
partialdir])
subprocess.check_call(['hg', '--cwd', partialdir, 'strip', '-r',
'last(all(), 10)'])
subprocess.check_call(['hg', '--cwd', partialdir, 'debugupdatecache'])
config = read_configuration("config.yaml")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment