comparison mercurial/dirstate.py @ 21810:4b2ebd3187a1

dirstate.status: assign members one by one instead of unpacking the tuple With this patch, hg status and hg diff regain their previous speed. The following tests are run against a working copy with over 270,000 files. Here, 'before' means without this or the previous patch applied. Note that in this case `hg perfstatus` isn't representative since it doesn't take dirstate parsing time into account. $ time hg status # best of 5 before: 2.03s user 1.25s system 99% cpu 3.290 total after: 2.01s user 1.25s system 99% cpu 3.261 total $ time hg diff # best of 5 before: 1.32s user 0.78s system 99% cpu 2.105 total after: 1.27s user 0.79s system 99% cpu 2.066 total
author Siddharth Agarwal <sid0@fb.com>
date Tue, 27 May 2014 21:02:16 -0700
parents e250b8300e6e
children 89b809fa6cef
comparison
equal deleted inserted replaced
21809:e250b8300e6e 21810:4b2ebd3187a1
821 iadd(fn) 821 iadd(fn)
822 else: 822 else:
823 uadd(fn) 823 uadd(fn)
824 continue 824 continue
825 825
826 state, mode, size, time = dmap[fn] 826 # This is equivalent to 'state, mode, size, time = dmap[fn]' but not
827 # written like that for performance reasons. dmap[fn] is not a
828 # Python tuple in compiled builds. The CPython UNPACK_SEQUENCE
829 # opcode has fast paths when the value to be unpacked is a tuple or
830 # a list, but falls back to creating a full-fledged iterator in
831 # general. That is much slower than simply accessing and storing the
832 # tuple members one by one.
833 t = dmap[fn]
834 state = t[0]
835 mode = t[1]
836 size = t[2]
837 time = t[3]
827 838
828 if not st and state in "nma": 839 if not st and state in "nma":
829 dadd(fn) 840 dadd(fn)
830 elif state == 'n': 841 elif state == 'n':
831 mtime = int(st.st_mtime) 842 mtime = int(st.st_mtime)