Jun Wu <quark@fb.com> [Wed, 01 Mar 2017 18:21:06 -0800] rev 31208
dirstate: avoid unnecessary load+dump during backup
Previously, dirstate.savebackup unconditionally dumps the dirstate map to
disk. It may require loading dirstate first to be able to dump it. Those
operations could be expensive if the dirstate is big, and could be avoided
if we know the dirstate file is up-to-date.
This patch avoids the read and write if the dirstate is clean. In that case,
we just do a plain copy without any serialization.
This should make commands which use transactions but do not touch dirstate
faster. For example, "hg bookmark -r REV NAME".
Jun Wu <quark@fb.com> [Wed, 01 Mar 2017 17:59:21 -0800] rev 31207
dirstate: try to use hardlink to backup dirstate
This should be more efficient once util.copyfile has real hardlink support.
Durham Goode <durham@fb.com> [Sun, 05 Mar 2017 16:20:07 -0800] rev 31206
dirstate: track updated files to improve write time
Previously, dirstate.write() would iterate over the entire dirstate to find any
entries that needed to be marked 'lookup' (i.e. if they have the same timestamp
as now). This was O(working copy) and slow in large repos. It was most visible
when rebasing or histediting multiple commits, since it gets executed once per
commit, even if the entire rebase/histedit is wrapped in a transaction.
The fix is to track which files have been editted, and only check those to see
if they need to be marked as 'lookup'. This saves 25% on histedit times in very
large repositories.
I tested this by adding temporary debug logic to verify that the old files
processed in the loop matched the new files processed in the loop and running
the test suite.