cborutil: change buffering strategy
Profiling revealed that we were spending a lot of time on the
line that was concatenating the old buffer with the incoming data
when attempting to decode long byte strings, such as manifest
revisions.
Essentially, we were feeding N chunks of size len(X) << len(Y) into
decode() and continuously allocating a new, larger buffer to hold
the undecoded input. This created substantial memory churn and
slowed down execution.
Changing the code to aggregate pending chunks in a list until we
have enough data to fully decode the next atom makes things much
more efficient.
I don't have exact data, but I recall the old code spending >1s
on manifest fulltexts from the mozilla-unified repo. The new code
doesn't significantly appear in profile output.
Differential Revision: https://phab.mercurial-scm.org/D4854
#require test-repo slow docker
$ . "$TESTDIR/helpers-testrepo.sh"
$ testrepohgenv
Ensure debuild doesn't run the testsuite, as that could get silly.
$ DEB_BUILD_OPTIONS=nocheck
$ export DEB_BUILD_OPTIONS
$ OUTPUTDIR=`pwd`
$ export OUTPUTDIR
$ cd "$TESTDIR"/..
$ make docker-debian-jessie > $OUTPUTDIR/build.log 2>&1
$ cd $OUTPUTDIR
$ ls *.deb
mercurial-common_*.deb (glob)
mercurial_*.deb (glob)
We check debian package contents with portable tools so that when
we're on non-debian machines we can still test the packages that are
built using docker.
main deb should have .so but no .py
$ ar x mercurial_*.deb
$ tar tf data.tar* | egrep '(localrepo|parsers)'
./usr/lib/python2.7/dist-packages/mercurial/parsers*.so (glob)
mercurial-common should have .py but no .so or .pyc
$ ar x mercurial-common_*.deb
$ tar tf data.tar* | egrep '(localrepo|parsers)'
./usr/lib/python2.7/dist-packages/mercurial/pure/parsers.py
./usr/lib/python2.7/dist-packages/mercurial/localrepo.py