Skip to content

Optimize comparisons for selected files - #1180

Open
EdwardBlair wants to merge 3 commits into
openSUSE:masterfrom
EdwardBlair:fix/undochange-selected-files
Open

Optimize comparisons for selected files#1180
EdwardBlair wants to merge 3 commits into
openSUSE:masterfrom
EdwardBlair:fix/undochange-selected-files

Conversation

@EdwardBlair

@EdwardBlair EdwardBlair commented Aug 21, 2026

Copy link
Copy Markdown

Summary

  • avoid constructing a complete snapshot-tree comparison when undochange, diff, or xadiff is given explicit paths
  • compare only the selected paths in both library and D-Bus modes while preserving status, ignore-filter, and undo behavior
  • perform D-Bus comparisons inside snapperd, with compatibility fallback for older daemons
  • reject paths outside the configured subvolume and balance comparison/mount cleanup on success and failure

Fixes #251.

Testing

  • make check in a disposable openSUSE Tumbleweed Podman container
  • focused selected-files.test coverage for modified, created, deleted, type-changed, permission-changed, ignored, duplicate, and rejected paths, plus undo execution
  • testsuite-real: all 16 tests passed against a loopback Btrfs filesystem in a privileged disposable Podman container, including permissions, ownership, error handling, xattrs, and ACL restoration
  • end-to-end A/B benchmark comparing the parent commit with this branch through the real snapper CLI, system D-Bus, snapperd, and a loopback Btrfs filesystem:
    • 100,000 baseline files
    • 20,000 unrelated endpoint differences (10,000 modified, 5,000 deleted, 5,000 created)
    • one selected file restored and correctness-checked per run
    • one warm-up followed by seven timed runs per version
    • parent median: 303.0 ms
    • optimized median: 11.3 ms
    • end-to-end speedup: 26.78x
  • manual end-to-end A/B test on an Arch Linux Btrfs /home configuration with real snapshot history:
    • snapper diff 1732..0 ~/.codex/config.toml: 36.355 s with Arch's snapper 0.13.1 / libsnapper 8.0.0, 0.011 s with this branch (~3,300x faster)
    • snapper undochange 1732..0 ~/.codex/config.toml: 21.235 s with Arch's snapper 0.13.1 / libsnapper 8.0.0, 0.011 s with this branch (~1,930x faster)
    • the undo operation reported create:0 modify:1 delete:0, confirming that it performed a real restoration
    • timings include the CLI, D-Bus, snapperd, comparison, and filesystem work

I use Arch btw 😉

Avoid constructing a complete snapshot-tree comparison when undochange is given explicit paths. Compare only those paths, while preserving status, ignore-filter, and undo semantics.

Perform selected comparisons inside snapperd so unprivileged clients do not need direct snapshot access. Add a D-Bus method for the bounded comparison and fall back to the existing full comparison when a new client is connected to an older daemon.

Balance comparison and snapshot lifetimes on success and failure, make unmount cleanup non-throwing, reject paths outside the configured subvolume, and cover comparison and undo behavior with focused tests.
@EdwardBlair

Copy link
Copy Markdown
Author

Optional automated CLI/D-Bus regression coverage is available as a stacked draft PR against this PR’s head branch: EdwardBlair#2

It runs the real snapper CLI and snapperd over an isolated D-Bus with loopback Btrfs, verifies that diff and undochange use GetFilesForPaths without falling back to CreateComparison, and checks that only the selected file is restored. I have kept it separate for now so it can be reviewed or included without expanding this PR unconditionally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

snapper diff feature extremely slow even for a single file

1 participant