This is an archive of the discontinued Mercurial Phabricator instance.

undo: do not run undolog for every command
ClosedPublic

Authored by quark on Sep 19 2017, 9:44 PM.
Tags
None
Subscribers

Details

Reviewers
stash
Group Reviewers
Restricted Project
Commits
rFBHGXd48e30ce2b64: undo: do not run undolog for every command
Summary

Previously, undolog runs for every command, which sometimes adds unwanted
noticeable overhead like hg status with a large obsstore. This patch makes
undo smarter to only log commands that actually write things.

This is done by making undolog only run for transactions, updates (legacy
code that does not require a transaction). Tests are changed to reflect
hg status does not trigger undolog, and the new code seems to work better
with chg.

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

quark created this revision.Sep 19 2017, 9:44 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptSep 19 2017, 9:44 PM
quark updated this revision to Diff 1908.Sep 19 2017, 9:45 PM
quark updated this revision to Diff 1910.Sep 19 2017, 10:19 PM
quark updated this revision to Diff 1911.Sep 19 2017, 10:32 PM
quark updated this revision to Diff 1912.Sep 19 2017, 10:35 PM
quark updated this revision to Diff 1913.
stash accepted this revision.Sep 21 2017, 4:17 AM
stash added a subscriber: stash.
stash added inline comments.
hgext3rd/undo.py
92

You are checking if repo is not None below, but you are not checking it here. It shouldn't cause problems, but it'd be good for consistency to check it there too. Or even check it in the beginning of _runcommandwrapper() function

tests/test-undo.t
235–238

So the idea is that previous hg noop still holding the lock while new hg noop starts?
And you test that second hg noop will wait for some time before start?

BTW, are you sure that 2 secs is always enough? Is it possible that we get sporadic failures?

434–436

Was this chg issue fixed?

This revision is now accepted and ready to land.Sep 21 2017, 4:17 AM
quark marked 2 inline comments as done.Sep 21 2017, 5:12 PM
quark added inline comments.
tests/test-undo.t
235–238

There are different locks:

  • repo.lock, not interesting to the test, but I was trying to trigger undolog by using an empty transaction
  • undolog lock, which is what being tested here

hg noop triggers both locks. But we are only interested in undolog lock here. We don't want this to be blocked by repo.lock.

In fact, since merge.update also triggers undolog, I can probably remove repo.lock. That will make this cleaner.

"sleep 2" is probably fine unless "hg status" takes around 1.8 seconds.

434–436

Yes. I ran the test with --chg.

quark marked an inline comment as done.Sep 21 2017, 5:54 PM
This revision was automatically updated to reflect the committed changes.