fastlog: disable fastlog if graphql client cannot be constructed

Summary:
The "local log" algorithm in the fastlog extension is poorly implemented.
It can be much slower than the non-fastlog algorithm. This means, if the
"remote" fastlog thread does not work in production, then enabling fastlog
can actually seriously regress log performance.

The fastlog test (already) cannot meaningfully test the remote behavior. So it
is removed for now.

Differential Revision: D30145651

fbshipit-source-id: 601a38e03920fbcae86e23262949ae3e3a16b9af
This commit is contained in:
Jun Wu 2021-08-05 16:19:35 -07:00 committed by Facebook GitHub Bot
parent 54762c1866
commit e8a32d5216
2 changed files with 10 additions and 254 deletions

View File

@ -188,6 +188,16 @@ def fastlogfollow(orig, repo, subset, x, name, followfirst=False):
repo.ui.debug("fastlog: not used because fastlog is disabled\n")
return orig(repo, subset, x, name, followfirst)
try:
# Test that the GraphQL client can be constructed, to rule
# out configuration issues like missing `.arcrc` etc.
_graphqlclient = graphql.Client(repo=repo)
except Exception as ex:
repo.ui.debug(
"fastlog: not used because graphql client cannot be constructed: %r\n" % ex
)
return orig(repo, subset, x, name, followfirst)
path = revset.getstring(args["file"], _("%s expected a pattern") % name)
if path.startswith("path:"):
# strip "path:" prefix

View File

@ -1,254 +0,0 @@
$ enable tweakdefaults fastlog
$ setconfig fastlog.enabled=true
$ readconfig <<EOF
> [fbscmquery]
> host=our.intern.facebook.com
> protocol=http
> reponame=fbsource
> path=/intern/conduit/
> EOF
This test actually relies on scanning the local repo, unfortunately:
(When we migrate fastlog to EdenAPI protocol, we should revisit and
write proper tests exercising the remote path)
$ setconfig fastlog.scan-local-repo=true
Log on empty repo
$ hg init repo
$ cd repo
$ mkdir dir
$ hg log dir
$ hg log dir -M
Create a directory and test some log commands
$ echo "pug" > dir/a
$ hg commit -Aqm a
$ hg log dir -T '{desc}\n'
a
$ hg log dir -T '{desc}\n' -M
a
$ hg log dir -T '{desc}\n' --all
a
$ echo x >> dir/a
$ hg commit -Aqm a2
$ hg up -q 0
$ echo "dog" > dir/b
$ hg commit -Aqm b
$ hg log dir -T '{desc}\n' 2>&1 | grep -v 'Exception in'
b
a
$ hg log dir -T '{desc}\n' --all 2>&1 | grep -v 'Exception in'
b
a2
a
$ hg log dir -r 'draft()' -T '{desc}\n' 2>&1 | grep -v 'Exception in'
a
a2
b
Graphlog still works
$ hg log dir -G -T '{desc}\n'
@ b
o a
$ hg log dir -G -T '{desc}\n' --all
@ b
o a2
o a
Create a merge
$ hg merge --config ui.allowmerge=True
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg log -T '{desc}\n'
b
a
$ hg commit -Aqm merge
$ hg log -T '{desc}\n'
merge
b
a2
a
$ hg log dir -T '{desc}\n'
b
a2
a
$ hg log dir -T '{desc}\n' -M
b
a2
a
Test keywords
$ hg log dir -k 2 -T '{desc}\n'
a2
Test pruning
$ hg log dir -P 1 -T '{desc}\n'
b
$ hg log dir -P 2 -T '{desc}\n'
a2
Create a public ancestor
$ hg up 0 -q
$ hg debugmakepublic .
$ hg log dir -T '{desc}\n'
a
$ hg up 3 -q
$ hg log dir -T '{desc}\n'
b
a2
a
Test include / exclude
$ hg log dir -I 'dir/a' -T '{desc}\n'
a2
a
$ hg log dir -X 'dir/a' -T '{desc}\n'
b
Log on non-existent directory
$ hg log dir2
abort: cannot follow file not in parent revision: "dir2"
[255]
Start testing with files / multiple directories
$ mkdir dir2
$ echo "poo" > dir2/a
$ hg ci -Aqm dir2-a
$ hg log -T '{desc}\n' dir dir2
dir2-a
b
a2
a
$ echo "food" > dir2/b
$ hg ci -Aqm dir2-b
$ hg log -T '{desc}\n' dir dir2
dir2-b
dir2-a
b
a2
a
Test globbing
$ hg log -T '{desc}\n' glob:**a
dir2-a
a2
a
$ hg log -T '{desc}\n' glob:dir2/**a
dir2-a
Move directories
$ mkdir parent
$ mv dir dir2 parent
$ hg addremove -q
$ hg ci -Aqm 'major repo reorg'
$ hg log -T '{desc} {files}\n' parent
major repo reorg dir/a dir/b dir2/a dir2/b parent/dir/a parent/dir/b parent/dir2/a parent/dir2/b
File follow behavior
$ hg log -f -T '{desc}\n' parent/dir/a
major repo reorg
a2
a
Directory follow behavior - not ideal but we don't follow the directory
$ hg log -f -T '{desc}\n' parent/dir
major repo reorg
Follow many files
$ find parent -type f | sort | xargs hg log -f -T '{desc}\n'
major repo reorg
dir2-b
dir2-a
b
a2
a
Globbing with parent
$ hg log -f -T '{desc}\n' glob:parent/**a
major repo reorg
Public follow
$ hg debugmakepublic .
$ find parent -type f | sort | xargs hg log -f -T '{desc}\n'
major repo reorg
dir2-b
dir2-a
b
a2
a
Multiple public / draft directories
$ echo "cookies" > parent/dir/c
$ hg ci -Aqm 'cookies'
$ echo "treats" > parent/dir2/d
$ hg ci -Aqm 'treats'
$ echo "toys" > parent/e
$ hg ci -Aqm 'toys'
$ hg log parent/dir -T '{desc}\n'
cookies
major repo reorg
$ hg log parent/dir2 -T '{desc}\n'
treats
major repo reorg
$ hg log parent -T '{desc}\n'
toys
treats
cookies
major repo reorg
$ hg log parent/dir parent/dir2 -T '{desc}\n'
treats
cookies
major repo reorg
$ hg debugmakepublic .
$ hg log parent/dir -T '{desc}\n'
cookies
major repo reorg
$ hg log parent/dir2 -T '{desc}\n'
treats
major repo reorg
$ hg log parent -T '{desc}\n'
toys
treats
cookies
major repo reorg
$ hg log parent/dir parent/dir2 -T '{desc}\n'
treats
cookies
major repo reorg
Globbing with public parent
$ hg log -T '{desc}\n' glob:parent/*/*
treats
cookies
major repo reorg
Multi-path queries
$ hg log parent/dir parent/dir2 -T '{node}\n'
ccec33f0cb143a839f88ced542f4e5079ff8a6ed
52fcfe491094f3404c867884d06bab8dbcb7dd54
6c8e10c74f4e7e01343e2dcdc5652e361a52951d