mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
Cut down number of sys calls during filelog reads
When the cache is stored on a filesystem, excessive stat calls can slow mercurial updates down dramatically. This reduces it to a single open call for the cache location and if that fails, a single open call for the local location.
This commit is contained in:
parent
c17ec690c9
commit
3619a1911d
@ -56,9 +56,6 @@ class remotefilelog(object):
|
||||
self.repo = repo
|
||||
self.localpath = os.path.join(opener.vfs.base, 'data')
|
||||
|
||||
if not os.path.exists(self.localpath):
|
||||
os.makedirs(self.localpath)
|
||||
|
||||
self.version = 1
|
||||
|
||||
def read(self, node):
|
||||
@ -253,17 +250,23 @@ class remotefilelog(object):
|
||||
"""reads the raw file blob from disk, cache, or server"""
|
||||
cachekey = fileserverclient.getcachekey(self.filename, id)
|
||||
cachepath = os.path.join(fileserverclient.client.cachepath, cachekey)
|
||||
if os.path.exists(cachepath):
|
||||
try:
|
||||
return _readfile(cachepath)
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
localkey = fileserverclient.getlocalkey(self.filename, id)
|
||||
localpath = os.path.join(self.localpath, localkey)
|
||||
if os.path.exists(localpath):
|
||||
try:
|
||||
return _readfile(localpath)
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
fileserverclient.client.prefetch(self.repo, [(self.filename, id)])
|
||||
if os.path.exists(cachepath):
|
||||
try:
|
||||
return _readfile(cachepath)
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
raise error.LookupError(id, self.filename, _('no node'))
|
||||
|
||||
|
@ -9,9 +9,7 @@ from mercurial.node import hex, nullid, bin
|
||||
from mercurial.i18n import _
|
||||
from mercurial import localrepo, context, mdiff, util
|
||||
from mercurial.extensions import wrapfunction
|
||||
import remotefilelog
|
||||
import remotefilectx
|
||||
import fileserverclient
|
||||
import remotefilelog, remotefilectx, fileserverclient, os
|
||||
|
||||
def wraprepo(repo):
|
||||
class shallowrepository(repo.__class__):
|
||||
@ -143,3 +141,7 @@ def wraprepo(repo):
|
||||
wrapfunction(repo.dirstate, 'status', status)
|
||||
|
||||
repo.__class__ = shallowrepository
|
||||
|
||||
localpath = os.path.join(repo.sopener.vfs.base, 'data')
|
||||
if not os.path.exists(localpath):
|
||||
os.makedirs(localpath)
|
||||
|
Loading…
Reference in New Issue
Block a user