martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.32k stars 284 forks source link

FR: Option to skip snapshotting-before-commands with automatic snapshots #4545

Open mlcui-corp opened 5 days ago

mlcui-corp commented 5 days ago

Is your feature request related to a problem? Please describe.

Snapshotting the repository before commands is noticeably slow in large repos. For example, in my colocated checkout of https://chromium.googlesource.com/chromium/src/, jj log with Watchman enabled takes ~209ms, whereas jj log --ignore-working-copy takes ~58ms.

If core.watchman.register_snapshot_trigger is enabled, snapshotting before commands should not be necessary if we assume that background snapshotting completes before any command is run.

The naive solution of adding --ignore-working-copy to every command has issues:

Describe the solution you'd like

An option to skip snapshotting when there is a mechanism in place for automatic snapshots, like core.watchman.register_snapshot_trigger or similar mechanisms from virtual file systems.

Describe alternatives you've considered

Adding --ignore-working-copy to common aliases like jj log. (I have done this!)

yuja commented 5 days ago

https://github.com/martinvonz/jj/pull/4457 could be related in a way that both features will partially disable --ignore-working-copy code paths.

mlcui-corp commented 21 hours ago

We may need to be careful with Git imports in colocated repos. It seems like (at the moment) core.watchman.register_snapshot_trigger does not automatically import changes from the underlying Git repo.

yuja commented 12 hours ago

core.watchman.register_snapshot_trigger does not automatically import changes from the underlying Git repo.

iirc, watchman doesn't monitor Git repo, so snapshot won't be triggered on ref change. If snapshot is triggered by working-copy change, Git refs will be imported as well.