tests/test-check-pyflakes.t
author Gregory Szorc <gregory.szorc@gmail.com>
Wed, 03 Oct 2018 09:43:01 -0700
changeset 40031 62160d3077cd
parent 37625 3ccaf995f549
child 43068 094d0f4a8edd
permissions -rw-r--r--
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 pyflakes hg10

  $ . "$TESTDIR/helpers-testrepo.sh"

run pyflakes on all tracked files ending in .py or without a file ending
(skipping binary file random-seed)

  $ cat > test.py <<EOF
  > print(undefinedname)
  > EOF
  $ pyflakes test.py 2>/dev/null | "$TESTDIR/filterpyflakes.py"
  test.py:1: undefined name 'undefinedname'
  
  $ cd "`dirname "$TESTDIR"`"

  $ testrepohg locate 'set:**.py or grep("^#!.*python")' \
  > -X hgext/fsmonitor/pywatchman \
  > -X mercurial/pycompat.py -X contrib/python-zstandard \
  > -X mercurial/thirdparty/cbor \
  > -X mercurial/thirdparty/concurrent \
  > -X mercurial/thirdparty/zope \
  > 2>/dev/null \
  > | xargs pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"