Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor pulling #2540

Closed
wants to merge 1 commit into from
Closed

Refactor pulling #2540

wants to merge 1 commit into from

Conversation

calmh
Copy link
Member

@calmh calmh commented Nov 30, 2015

Current progress

  • Files
  • Symlinks
  • Directories
  • Permissions
  • Modification times
  • Forcing rescan (interface)
  • Forcing rescan (actual implementation)
  • Versioning
  • Virtual mtimes (interface)
  • Virtual mtimes (actual implementation)
  • Progress updates
  • Database updates (via Progresser interface)
  • Network pulling parallellization
  • Conflict handling
  • Tricky test cases!
  • Integrate with rwfolder
  • Benchmark to ensure we don't regress too badly
  • Proper queue status / progress in GUI
  • Manual queue reordering

Issues

  • We need the entire set of files to change in memory. We need this in order to properly sort stuff, but it may require large amounts of memory. Perhaps we can get away with doing it in segments anyway, and retrying failures...
  • Manual reordering of the pull queue is no longer allowed. The reason is that we enforce an ordering on the entire change set so that we can properly do things like reuse blocks while renaming, make sure to delete a directory that is in the way for a file, and so on. However we retain as much as possible of the original ordering so newest-first, smallest-first etc still work mostly as you'd expect.

}

type Source interface {
Request(file string, offset int64, hash []byte, buf []byte) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs flags opts, as I plan to use that.

@AudriusButkevicius
Copy link
Member

👍 so far.

@AudriusButkevicius
Copy link
Member

Manual reordering of the pull queue is no longer allowed

We should still support that, but only for files?

@calmh
Copy link
Member Author

calmh commented Jan 15, 2016

Is there a good use case for this? Has anyone ever used it in practice, now that we have the sort ordering config available? The UI for it is kind of cumbersome and you need to be fairly quick to get in there and reorder the queue so I'm skeptical it's in wide use...

@AudriusButkevicius
Copy link
Member

Well I didn't come up with the feature myself, it was requested on the tracker. Your argument about fairly fast only applies to many dmall files. Picking which VM image to pull first is perfectly viable.

Is there a lot of complexity involved in this? I though the graph is only used to work out what needs doing before we can pull the file? I don't think asking to pull a specific file is essentially no extra complexity?

@calmh
Copy link
Member Author

calmh commented Jan 15, 2016

As it works right now (in this change), we schedule all the needed items, sort them based on the selected sort criteria, then reorder based on dependencies. Changing the order manually after really also requires redoing the dependency sort, which can change the order back. For example moving a file to the top may require creating the directory it's supposed to be in, which in turn may require renaming a file that's in the way for that directory, etc recursively.

To avoid completely reshuffling the list while sorting, the current sort algorithm just switches the places of two items when the dependency requires inverting the order. The alternative would be to place all the items with explicit dependencies at the head of the queue, and then do all the rest - but then we move further away from the requested sort order, potentially...

All this while we're already working of the queue that we're reordering, and we need the GUI to be able to reach all the way into the changeset which is a few levels away. It's certainly not impossible, but I'm unsure if it's worth it.

Part of this is to simplify and streamline the pulling process - the dependency thing is somewhat complex, but it's isolated into a single "sort()" method that's just called once at the moment.

For sure someone wanted the feature, but ... we didn't have the preset "newest first", "largest first" etc options at that time either I think.

// that the Progresser is called appropriately before and after.
func (c *Changeset) progressAccount(fn func(protocol.FileInfo) *opError, f fileInfo) *opError {
if !f.synthetic && c.Progresser != nil {
c.Progresser.Started(f.FileInfo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could replace 3 synthetic if branches with one early one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fixed.

@AudriusButkevicius
Copy link
Member

So I've read the code on a small screen, and I don't understand why it's an issue apart from code which has to reach into the queue in a changeset. I understand that moving a file to the top will break the chosen sort order, especially it has deps to satisfy, but I think this is expected, and nobody would complain about that?

I guess lets get this in without that feature, but I do feel that we'll have requests for it to comeback.

@plouj plouj mentioned this pull request Jan 16, 2016
@calmh
Copy link
Member Author

calmh commented Jan 17, 2016

I think you're right. I have some stuff to explore here anyway, will look into it again and maybe not worry too much about the consequences as it's what the user asked for and we'll retry anyway when we failed (and we need to keep the retry logic, because there are still situations when we'll fail which I'll document some time...).

This now passes the normal integration tests, i.e. "works" for some values of works. :)

@calmh
Copy link
Member Author

calmh commented Mar 4, 2016

@calmh
Copy link
Member Author

calmh commented Mar 9, 2016

@st-jenkins retest this please

@calmh
Copy link
Member Author

calmh commented Mar 9, 2016

@st-jenkins retest this please, once more with feeling!

@calmh
Copy link
Member Author

calmh commented Mar 9, 2016

@st-jenkins retest this please asdkjaslkdj asldkja ldkasj dalskdj asd

@calmh
Copy link
Member Author

calmh commented Mar 20, 2016

@st-jenkins retest this please

@lkwg82
Copy link
Contributor

lkwg82 commented Mar 30, 2016

I just checked out and checked the UI. You need to remove the "file pull order" setting from the advanced folder dialog. If this is meant by "dissallow manual reorder".

@calmh
Copy link
Member Author

calmh commented Apr 6, 2016

I'll split this up and post some smaller PRs

https://media2.giphy.com/media/JDKxRN0Bvmm2c/200_s.gif

@calmh calmh closed this Apr 6, 2016
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jun 16, 2017
@syncthing syncthing locked and limited conversation to collaborators Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants