Skip to content

bisync: optimize --resync #5681

Closed
Closed

Description

@ivandeex

Synposis

Clearly explain in documentation whether --resync is asymmetrical.
(@cjnaz could you comment?)

Investigate whether --resync can be re-implemented by the equivalent of:

rclone copy --update Path1 Path2
rclone copy --update Path2 Path1

Prior discussions

optimize --resync

cjnaz/rclonesync-V2#66 (eric-void) -> (cjnaz)

looking at the code there is a lot of work to copy Path2 files not in Path1, and then do an "rclone sync" from Path1 to Path2. Why don't you just do and "rclone copy" from Path1 to Path2, and then an "rclone copy" from Path2 to Path1?
This is much simpler, there is no need to read 2 times LSL files and to loop for missing Path2 files, and the result should be the same. Am i missing something?

The first-sync optimization is deferred for now since its not broke and should be rarely run.

#5164 (comment) (ncw)

So --resync is asymetrical?

Perhaps it would be better implemented by the equivalent of

rclone copy --update Path1 Path2
rclone copy --update Path2 Path1

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. self-assigned this
    on Oct 8, 2021
  2. cjnaz commented on Oct 8, 2021

    @cjnaz
    Contributor

    I think the core question here is whether rclonesync's asymmetrical --first-sync solves some subtle problem. I think the answer is no, none that I can recall. When I implemented the current --first-sync method I think I was too embedded in the new algorithm (building file lists for raw copies/deletes) that I missed the simpler picture. I'd say go for this method...

    rclone copy --update Path1 Path2
    rclone copy --update Path2 Path1
    
  3. ivandeex commented on Oct 8, 2021

    @ivandeex
    MemberAuthor

    Unit tests and documentation will be updated respectively.

  4. nielash commented on Aug 21, 2023

    @nielash
    Contributor

    I had the same thought recently:

    // This preserves the original resync order for backward compatibility. It is essentially:
    // rclone copy Path2 Path1 --ignore-existing
    // rclone copy Path1 Path2 --create-empty-src-dirs
    // rclone copy Path2 Path1 --create-empty-src-dirs
    // although if we were starting from scratch, it might be cleaner and faster to just do:
    // rclone copy Path2 Path1 --create-empty-src-dirs
    // rclone copy Path1 Path2 --create-empty-src-dirs

    I tend to think it would be better to change it, as in addition to being simpler and more symmetrical, it would also make --resync substantially faster for users of --create-empty-src-dirs. However, it would be a breaking change, and I'm not sure how concerned we should be about that. It's possible that some users have come to depend on the asymmetry in some way. For instance, imagine a scenario where you're bisyncing one central server with multiple devices, and the server is the source-of-truth. The asymmetry allows you to declare that the server should take priority in the event of a --resync, even if the corresponding file on the other path is newer.

    Perhaps the best compromise is to make the behavior configurable with a flag?

  5. added this to the Known Problem milestone on Sep 5, 2023
  6. nielash commented on Sep 30, 2023

    @nielash
    Contributor

    I agree with both @ivandeex @cjnaz that the correct implementation for bisync should be:

    rclone copy --update Path1 Path2 (--create-empty-src-dirs)
    rclone copy --update Path2 Path1 (--create-empty-src-dirs)
    

    I generally agree as well, although I have a slight concern about the use of --update for the same reasons articulated in our other thread, about the potential dangers of picking winners and losers at the file level instead of the filesystem level. But I think this could be solved by just letting the user choose their desired behavior with a flag.

    This also makes a --resync far less destructive. Currently, Path1 will always take precedent which is the last thing I believe anyone would want from a bisync

    I can think of a few reasons a user might want the asymmetry -- I described one of them above. Imagine, for example, that I pull my dusty old laptop out of the closet which hasn't been synced in a long time, and I want to bring it up to date with my Google Drive which I know is totally up-to-date. In this case, I do in fact want the trusted drive side to take precedence over the untrusted local side -- even if certain local files happen to be newer (intentional reversions do sometimes happen -- maybe I restored something from a backup recently on the drive side, and now it's about to get overwritten.) An asymmetrical --resync lets you declare one side the source-of-truth; while --update prioritizes the newness of individual files, possibly at the expense of consistency at the directory-level.

    Another use case (which I've used myself) is safer preservation of metadata that rclone doesn't currently support, such as directory metadata, macOS xattrs, and permissions. An asymmetrical sync allows you to avoid overwriting that stuff on the trusted side, when possible.

    Additionally, it should be noted that bisync's current approximation of --ignore-existing does have a performance benefit, because in 1 of the 2 directions it can skip the modtime (or checksum) check for some of the files. (But that performance benefit is negated if using --create-empty-src-dirs, which requires a third operation -- unless we change that.)

    I tend to think that rclone's default (which is still slightly asymmetrical) should be bisync's default:

    rclone copy Path2 Path1 (--create-empty-src-dirs)
    rclone copy Path1 Path2 (--create-empty-src-dirs)
    

    but that this should be overridable with flags for users who think this is madness 😄

    @ncw I think this is ultimately a question for you -- what is your guiding principle for breaking changes such as this, where it's not exactly a bug, but there does seem to be consensus that a different way would be better? Is it ok to change the behavior, provided it's documented clearly? (And is the calculation different because bisync is still in beta?)

  7. 31 remaining items

  8. added a commit that references this issue on Dec 24, 2023
    b58fee3
  9. added a commit that references this issue on Jan 20, 2024
    810644e
  10. added a commit that references this issue on Jan 23, 2024
    f70a4c6
  11. moved this to Done in bisyncon Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status
    Done

Relationships

None yet

Development

No branches or pull requests

Issue actions