Repository navigation
Description
setup
11,265 files - 290.743MiB (90MB in ~5 files the rest are smaller and more equal in size)
Results the same regardless of Wasabi or iDrive (iDrive typically performs a little faster in every test but only ~5-10% on average)
Remote is using crypt and base32768 encoding.
BW: ~1.5MiB UP ~5MiB DOWN
default/common flags
After testing best performing filters are: --transfers 64 --checkers 128 --fast-list
Along with this (--filter-from) or (--filters-file) is also used
e.g. --transfers 64 --checkers 128 --fast-list --filter-from/--filters-file ..
check
~8s on average and between 6.8s to 9.6s
ls
(using time as no info given with -v)
ls: 0m4.088s
lsl: 7m36.975s
sync
upload:
initial: 3m57.0s
subsequent: 18.6s
download:
initial: 2m9.0s
subsequent: 17.8s
copy
upload:
initial: 4m0.0s
subsequent 18.6s
download:
initial: 2m6.5s
subsequent: 16.8s
bisync
These are some of the best and would say are usually a little longer by upto 5 mins this is likely when resync is run when data is already present vs copying the data itself.. There are no changes made to files when moving between a --resync and normal run.
defaults:
resync: 10m47.0s
normal: 6m44.7s
defaults with ignore checksum: (--ignore-listing-checksum --ignore-checksum)
resync: 10m36.5s
normal: 6m31.9s
overview
So as you can see bisync is orders of magnitude slower than copy or sync . ls is incredibly fast as is sync and copy in both directions (e.g. uses up almost 100% of bandwidth)
I only ran the test of lsl and ls at the very end and now thinking that bisync relies on lsl as this so incredibly slow (as I believe bisync does not use checksum so would need lsl info to compare?).
I can do a local to crypt (local) bisync in 15s (--resync) and 8.7s for subsequent.
Is there something I am doing wrong? If not, are there plans/options available to rclone to improve the speed of bisync so that it is more in line with 2 x sync/copy commands (e.g. one upload, one download) or is this a limitation that is unlikely to be overcome? Also, if this is due to lsl taking so long is there a way to speed up lsl?
Thanks to you all for your hard work and a special thank you @nielash for all you've been doing on bisync and continue to do. I as many others massively appreciate it and when this tool is out of experimental stages it will be a game changer for so many. If I had any free time or money right now I would help out but unfortunately the best I can do is give you some benchmarks and user feedback.
Thanks
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
nielash commentedon Sep 23, 2023
Thank you for the benchmarks and feedback! You are right --
bisyncis currently much slower thancopyorsync. This is for a few reasons, most of which I think are solvable. My multi-step plan to address this includes:v1.64.026ff813 )This should help a lot. Currently, bisync builds a full listing for Path1, then a full listing for Path2, then compares them -- and each of those tasks must finish before the next one can start. That's silly, as we could easily be doing most of these tasks concurrently, using the same March infrastructure that
checkandsyncuse. This would also solve another important issue I talked about here.Currently bisync makes its changes in a 4-step process:
copy2 to 1copy1 to 2delete2 to 1delete1 to 2I believe we can condense this to just 2 steps:
sync2 to 1sync1 to 2Both syncs would be filtered for only the individual files that need to be copied or deleted in that direction. I already have a local proof-of-concept for this that works beautifully, so I think it should be coming relatively soon. Incidentally, this change also paves the way for allowing bisync to support
--track-renames(which is supported only forsync, notcopy.)This is probably the one that will make the most difference in terms of speed. Currently, if there are changes to sync, bisync lists each directory twice: once before the sync and once after. The second one causes quite a lot of problems, in addition to making each run much slower. I am currently working on a way to eliminate it by getting the underlying sync operation to report back a list of what it changed. This project is pretty far along, and the results are very encouraging so far!
When all of the above are done,
bisyncwill probably still be slightly slower thansync(because bisync has to do an extra listing, and 2 syncs instead of 1), but the difference should be much less dramatic than it is today.For
bisyncto ever truly be as fast assync, it would have to (at minimum) merge the two sync operations together (or at least do them concurrently), and also merge the initial listing into the sync operation (similar to how checkers and transfers currently work during async-- note how the transfers are able to start working before all the checkers have completed!) These particular optimizations are not currently planned, but I do think they might be possible someday.In the meantime, one thing you might consider to speed up your runs slightly is
--check-sync=false.--check-synchas some issues anyway at the moment, so in my opinion, you might be better off disabling it and replacing it with an occasional check, until this is more properly fixed in a future release. Disabling it will make the run slightly faster, because it will skip the step of re-loading both listings into memory at the end and comparing them.Thank you also for the kind words of encouragement! 😃
nielash commentedon Sep 25, 2023
An interrupted run is tough for
bisyncto recover from cleanly, because of its bi-directional nature. Whensyncis interrupted, it can be safely retried because the source is still intact, even if the dest was left in a messy state. But withbisync, both sides could be left in a messy state, if interrupted. Beforev1.63.0, I would have said clean recovery is impossible, due to the possibility (on certain backends) of leaving a partially-written file on one path, which would then get erroneously copied to the other path on the next run. But now that we have "atomic downloads", I think this is worth another look.One challenge would be bisync's logic surrounding lock files and the saving of the "new" state for use by the next run. Currently bisync finalizes these only after a successful sync operation. Doing this after every individual transfer probably wouldn't be practical -- it would add too much overhead and too many writes to disk. The cleaner solution is probably the "retry from last successful snapshot on error" idea that I mentioned here. Essentially what this would mean is: if the most recent listing is untrusted (because, in this case, it was interrupted), and
--resilientis specified, we would look instead to the one before that, and diff the current state against the last "trusted" state. This would effectively make it possible to recover from these kinds of errors by "retrying" on the next run.We would also need some way of distinguishing between lock files left by aborted runs vs. ones that are still running. Perhaps lock files should be considered "expired" after X number of minutes (configurable with a setting)? (And, thinking ahead: perhaps they should also get "renewed" every X-1 minutes by runs that are still running.)
In the meantime, my recommendation is: try to wait to shut down your computer until you know the bisync run has completed. (FWIW: I have mine scripted to send me a push notification when it starts, and another with the exit code when it finishes.)
nielash commentedon Sep 26, 2023
This would work well if you're running bisync on only one machine. However, one of our long-term goals is to make bisync more portable by allowing any remote path to be used as the
--workdir(currently it is limited to local paths). One of the benefits of storing lock files on a non-local remote is that you could then easily use bisync to keep several devices in sync with a cloud storage provider, without the risk of syncing the same path simultaneously from different locations. The PID is less useful in this scenario, because each machine would not know the PIDs from the other machines. (They also would not be unique, but that could possibly be solved by adding some kind of machine/location identifier.)This is an interesting idea -- sort of analogous to an "autosave" feature. 30s-1m could be reasonable with a local
--workdir, but may not be for other backends -- particularly ones that charge per API call. It would also slow down the run. But perhaps the option should exist as a setting, and then each user can decide what's right for them. I'm not sure that this method would have much advantage over the "retry from last successful" method... the one scenario I can think of where it would make a difference is:Absent step 3, the results should be identical with either method. (With the "retry..." method, bisync should say "I see that the file has changed on both sides since the last successful run, but since the file currently matches on both sides, I can skip this and move on.")
I wonder if what you ultimately want here is something more like #966 (a way to tell all your running bisync processes to gracefully wrap-up early, when you want to shut down.) (See also: #1522)
nielash commentedon Sep 30, 2023
Thank you so much for this detailed feedback! It is really helping me gain insight into bisync use cases that are different from my own, which is quite valuable 🙂 (As an aside, I wonder if it might be helpful to start a "bisync user feedback" group in the forum or something -- it would be really helpful to be able to easily survey a group from time to time on these kinds of design questions.)
A few responses to your comments:
In a word: portability. This question sort of implies that at least one of the bisync paths is a
localremote, and while I agree that's probably the most common use case for bisync, it's not technically a requirement. For example, bisync could just as easily be used to sync adriveremote with adropboxremote. In this kind of scenario, it makes a little less sense to require that bisync must always be run from the same machine. Perhaps I'm traveling with my laptop and away from my main desktop machine -- if the listing files are in the cloud, I can seamlessly pick up on one machine where I left off on another. It also just strikes me as more "rclonic" -- in general, rclone is designed to be as stateless as possible, and avoid relying on sidecars, resource forks, or local databases. Bisync is currently one of the only rclone commands that does so (out of necessity, as bidirectional sync can never be completely stateless). So, in my (subjective) opinion, allowing a non-local--workdirbrings us a little bit closer to rclone's platform-agnostic core principles, and the (unreachable) goal of having full feature parity between backends.It should also be noted that adding support for non-local
--workdirdoes not mean removing any existing support forlocal-- so really nothing would change for users that wish to continue using a local--workdir. They can ignore this new feature and carry on like they did before.One of the most common complaints about bisync is that it currently refuses to operate on backends that lack modification time support. This is going to be solved soon by adding support for
--checksumand--size-only. Once this is the case, there will no longer really be a concept of "newest" in a file-conflict situation -- all we can say is whether a file changed on both paths (since the last run), and whether or not the current version on one path is equal to the version on the opposite path. So, this would present a challenge to what you are proposing -- sometimes there is no "newest", only "different". I could imagine possibly implementing what you are suggesting as an optional flag for the rest of the time (when we do have modtime available on both sides), although personally I'm not sure I would use it. To me, the..path1/..path2rename is a helpful alert that something went wrong and needs my attention to resolve, so silently skipping this for one of the paths would give me a false sense of security. That said, I have no objection to implementing features I don't personally plan to use (I much prefer giving users the choice whenever possible), so if a sizable number of users want this, I'm happy to add the option. (This is a good example of something I'd love to poll the group about!)Also worth noting: even when both paths do support modtime, "deletes" still never have a modtime, just by their nature. (All we can say is that a file used to be there and now is not -- we can't say what time it was deleted, or whether it was deleted before or after the other path's version was last modified.)
I'm not sure if I understand what you mean about this one. How does
..path1/..path2limit the number of conflicts, and how would.conflict1/.conflict2solve that? Does this question rely on the the prior suggestion (of renaming only one side) being implemented? To make sure we're on the same page about the current behavior: the first conflict for filexresults inx..path1(for the Path1 side) andx..path2(for the Path2 side). If the Path1 conflict were to have yet another conflict after that (and I'm not sure why that would happen, as it would mean openingx..path1and editing it on both sides without renaming it first -- but let's just assume it did), you would then getx..path1..path1andx..path1..path2, in addition to the pre-existingx..path2which would remain unchanged. You could repeat this any number of times (limited only by filename length limitations from your backend...eventually.) I'm guessing that maybe what you would prefer is for subsequent conflicts to be namedx..conflict3,x..conflict4,x..conflict5, etc. but my question then would be: how would you tell whetherx..conflict5came from Path1 or Path2? And how do you determine the winner when neither side can be considered "newest"?By "path" do you mean one individual file? That is certainly a concern, but I think it's also important to consider the risk at the directory level. When rclone walks directories recursively, the order can be unpredictable due to concurrency, among other things -- there's no guarantee that
bisync A Bandbisync A Cwill both list the directories ofAin the same order. (The tradeoff is that concurrency is what makes rclone so fast.) So given that, now imagine a use case where the sync needs to be atomic at not just the file level, but also the directory level. For example, something like a source code repository, where all files in the tree must be from version 1 or else all files in the tree must be from version 2. You can't end up with one subdirectory from version 1 and another from version 2 in the same repo -- the application won't work. This is the kind of problem we could miss if we only worry about conflicts between individual files and consider each file an island. So, while you're right that the chance of writing any individual file at the exact same time from two locations is fairly small, the chance of doing the same thing to a directory is much larger -- the race condition window could be even hours or days-long, if the files are particularly large. A directory-level conflict could occur without any of its containing files having a file-level conflict. Most concurrent applications solve this problem with a mutex or other kind of locking mechanism, and that is why bisync uses "lock files", although the implementation is imperfect at the moment because the mutual exclusion enforcement doesn't extend to other machines (nor does it detect tree overlaps even within the same machine.) To give credit where credit's due, though, the original designer of bisync (not me, to be clear) realized this problem and made sure to include this warning in the docs:Another common scenario where mutual exclusion matters at the directory-level is a "project folder" like the kind often created by media editing applications (Pro Tools, Adobe Premiere / Illustrator, Apple Logic Pro, etc.) These apps expect all the source media files to be from the same project version (for example, video editors often throw errors if the video file they find at a particular path doesn't match the length of the clip in the timeline.) This kind of data corruption is not something we can catch by looking solely for conflicts between individual files.
I think we may be using the word "sessions" to mean different things (I'm using it as defined here), but setting that aside, I think we generally agree on the substance -- it would be ideal for bisync to be more prepared for the possibility of an unexpected interruption, and it should require
--resyncas little as possible. I think where we might differ slightly is our preference when faced with the inevitable tradeoff between convenience and safety. While I'm no fan of being asked to--resync, I still would rather be asked than have bisync take a "best guess" on my behalf and guess wrong. One of the main reasons I chose bisync (and rclone as a whole) in the first place is because of how it prioritizes safety where other sync tools prioritize convenience or resilience. I feel comfortable entrusting important files to bisync precisely because it will err on the side of stopping and asking me for help when its only alternative is to guess. I fully acknowledge that some users will prefer a different tradeoff and may be fine settling for a standard where data corruption is just "unlikely" -- but I can't assume that every user will be ok with that. So, I plan to maintain bisync's original philosophy of being "(too) safe by default", but changeable with flags for advanced users. (My recent addition of--resilientmode is an example.)To sum up where I think I am regarding crash recovery: I think there are definitely some meaningful improvements we can and should make, and in particular I like your idea of an "autosave"-like feature that is disabled by default when
--workdiris remote (and I'd say possibly when local too -- unless careful testing finds the performance overhead to be basically negligible.) To be totally transparent, I think it will likely take me awhile to get to it, as I think bisync has several other more pressing issues, and I also don't find "don't pull the plug while it's running" to be an unreasonable or excessively burdensome expectation in the meantime (but again, that's not to say we shouldn't try to improve it -- we should.) You are also of course welcome to submit a Pull Request at any time, if you would like to. You might also consider checking out some bisync alternatives (such as syncrclone) that make some different choices with regard to some of these tradeoffs.Glad to hear that! I'd also be interested to know a little more about your use case (only if you're inclined to share) and why it requires so many different bisync processes to be running simultaneously. For example -- could it not be solved by combining the various paths into one tree and then bisyncing them all in one bisync run? Also, how frequently do you schedule the runs, and what's the longest they normally take? (I think this info may help me conceptualize why curing the interruptions would be more practical than preventing them.)
Thank you again for the thoughtful feedback! You've challenged my thinking in a good way 🙂
nielash commentedon Oct 1, 2023
You are right -- it would. This is work that would have to be done when implementing the feature.
The rest of your comments in this section describe why you personally do not wish to use a remote
--workdir, which is fine -- you don't have to. There are others who do want such a feature. I think the only way it affects you is that it means we can't rely on PIDs as our locking mechanism -- but as I've explained, there would already be problems with doing so. At most, checking PIDs could offer some protection within the same machine, but it could not protect against the risk of race conditions caused by bisync runs on other machines.I agree this is a valid point, and I think it may be worth considering a separation -- such that you can have a remote lock file and a local
--workdir. I think that might be my ideal combination.I disagree -- please read the following:
I think where we do agree is that I personally would probably not ever use a backend that didn't support modtimes (and there are many.) But that is just my personal preference. There are many other users who feel differently and do want to use such backends. There are even many users who go out of their way to avoid using modtimes, even when the backend supports it. This is popular with S3-compatible backends, for example, for performance and money reasons. Bisync should be available to them too.
Modtime is also imperfect -- it relies on the assumption that the underlying Fs is always updating it correctly, and that's not always true. It can be fooled (for example by using
touch). It is not sensitive to bit rot. And even if it were perfect, "newer" does not always equal "better". There are times when a user does intentionally revert to an older version.I think the best compromise here is a
--prefer newerflag that renames conflicts in the way you describe if modtime is available for both paths.This is a good point, and perhaps we should consider adding such a unique ID.
This is explained in the docs. In short: the non-deleted path always wins (when one path is deleted and the other is new/changed). (But note that anything else in the dir, such as
dir/file2, would still be deleted.)When there's only one run at a time, it does not change the outcome of the sync. The problem is when there's more than one run at a time. The outcome then depends on which machine gets to that directory first, and that is what cannot be predicted, because of concurrency (and potentially because of other things too, like differences in network speed, CPU/RAM, size of other jobs in the queue, etc).
It's obvious to me, but I can't assume it will be obvious to everyone 😄
But if it's obvious, then surely it is also obvious why a lock file must ideally exclude additional runs on any machine, not just the same machine.
So, it sounds to me like the reason you have so many simultaneous bisync runs is:
For 1, have you looked into the Combine backend? This is exactly what it's for.
For 2, I agree -- bisync is currently slow. I'm working on improving that.
Am I understanding correctly that if the speed issues were solved, and you combined your remotes with the Combine backend, you would no longer need multiple simultaneous bisync runs? Or is there an additional problem that I'm overlooking?
12 remaining items
bisync: generate listings concurrently with march -- fixes rclone#7332
bisync: generate listings concurrently with march -- fixes rclone#7332