Details
- Reviewers
quark durham - Group Reviewers
Restricted Project - Commits
- rFBHGX24df03a54d5d: treedirstate: auto-repack treedirstate once it reaches 3x its original size
Diff Detail
- Repository
- rFBHGX Facebook Mercurial Extensions
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Event Timeline
Mostly looks good. Requesting changes since wrapping runcommand is not the cleanest way to trigger cleanup.
treedirstate/__init__.py | ||
---|---|---|
602 | The cleanup logic does not look that expensive. Maybe it could be done as a post close hook of a transaction. At that time the wlock is still taken so you don't need to take another wlock (which is expensive for read-only commands). |
treedirstate/__init__.py | ||
---|---|---|
602 | It only runs if the dirstate has been modified (based on _repacked or _extended being set), so read-only commands won't trigger a repack. I based this on what infinitepush backupcommand does at @stash's recommendation. Infinitepush used to use a transaction close hook, but it caused problems for commands that contain many transactions (e.g. histedit). I think it's a good idea to keep to one technique, too. What do you think? |
treedirstate/__init__.py | ||
---|---|---|
602 | Good point about histedit. The use of a separate wlock could potentially block the command unnecessarily. A transaction hook would avoid the lock issue and save a few ms on commands with a single transaction. Infinitepush backup needs to be fired at the end of the last write operation, but this cleanup does not have to. To avoid running cleanups multiple times, I think it could be done by having a per-process state. |
I'll add some integration tests as a separate diff on top of this stack tomorrow, and include repacking in that.
treedirstate/__init__.py | ||
---|---|---|
602 | I'll change to wrapping repo.close(). We still need to get the wlock separately, but cleanup happens rarely, so this should be ok. |
treedirstate/__init__.py | ||
---|---|---|
394 | As with treedirstate_enabled, I will update this to use ui.log and sampling. |
treedirstate/__init__.py | ||
---|---|---|
527 | If the file system is not writable, this will throw an exception. We probably don't want cleanup logic to cause commands on readonly filesystems to break. Probably always a good test candidate. |
treedirstate/__init__.py | ||
---|---|---|
527 | Aside from debugtreedirstate cleanup, we only ever cleanup when we've written to the dirstate already, which means it really ought to be possible to write here. That being said, I don't mind adding some belt-and-braces handling. Should I just ignore all exceptions that come out of cleanup, or are there specific ones? |
treedirstate/__init__.py | ||
---|---|---|
527 | From the comment in wrapclose, I assumed cleanup was run on 1% of commands that read the dirstate as well? Maybe that big if statement in the wrapclose finally needs to be cleaned up to make it clearer when it runs? As for exceptions, usually IOError and OSError, but since this is the Lock class it might throw something special as well. |
treedirstate/__init__.py | ||
---|---|---|
527 | I think it throws Abort. I'll clean up the if statement and the comments to make it clear, but I think it should be ok to fail here if we make it this far and the repo is read-only. That shouldn't have happened, and I'd like to know that it did. |
As with treedirstate_enabled, I will update this to use ui.log and sampling.