Skip to content

Limit number of concurrent writes while syncing #6541

Closed

Description

@calmh

Currently we spawn a goroutine to pull a block, and that goroutine does the file write when it's done. The number of goroutines is limited by the puller max pending kib setting, but this can still be hundreds of goroutines if the requested blocks are small. This can result in hundreds of concurrent disk writes, in turn spawning hundreds of I/O bound threads.

We should have a couple of goroutines responsible for the writes to handle this separately from the pullers.

(https://forum.syncthing.net/t/insane-load-average/14829)

Activity

  1. added
    enhancement
    on Apr 16, 2020
  2. greatroar commented on Apr 16, 2020

    @greatroar
    Contributor

    It's probably simpler to protect the writes with a semaphore.

  3. AudriusButkevicius commented on Apr 16, 2020

    @AudriusButkevicius
    Member

    There is also the whole "shuffle order of downloads to have better distribution of data" that causes thrashing on writes which we could address as part of this.

  4. calmh commented on Apr 16, 2020

    @calmh
    MemberAuthor

    Having writer routines behind a channel allows releasing the puller routines while maintaining a small write queue, evening out bursts. It could potentially also be a point where we could do write reorders and merges in the future, if we wanted to do such a thing. 🤷 It's not an enormous amount of code either way.

  5. AudriusButkevicius commented on Apr 16, 2020

    @AudriusButkevicius
    Member

    I think the better approach for this would be to split the block list into remoteDevice.listOfDevicesItSharesTheSameFolderWith parts where a part if a continous range of blocks, see where our id lands in that list lexically, first fetch our "part", then shuffle the rest of parts and fetch them, but fetch in whole "device" parts in sequence rather than random individual blocks from different parts.

    We could also check availability of otehr parts, and work on the least available part.

  6. added a commit that references this issue on Apr 26, 2020
    21abbf9
  7. calmh commented on Apr 26, 2020

    @calmh
    MemberAuthor

    I didn't make any attempt to limit the randomness of writes in my proposed fix, just the simplest possible. Partly it's a separate issue, partly it might be mostly a non-issue with the world moving away from rotating disks plus our writes being generally quite large.

  8. added this to the v1.5.1 milestone on Apr 26, 2020
  9. added a commit that references this issue on May 1, 2020
    dd45854
  10. added
    frozen-due-to-age
    on Apr 27, 2021
  11. locked and limited conversation to collaborators on Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions