You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Limit number of concurrent writes while syncing #6541
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
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.
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.
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.
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.
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.
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
Activity
greatroar commentedon Apr 16, 2020
It's probably simpler to protect the writes with a semaphore.
AudriusButkevicius commentedon Apr 16, 2020
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.
calmh commentedon Apr 16, 2020
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.
AudriusButkevicius commentedon Apr 16, 2020
I think the better approach for this would be to split the block list into
remoteDevice.listOfDevicesItSharesTheSameFolderWithparts 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.
lib/model: Use semaphore to limit concurrent folder writes (fixes syn…
calmh commentedon Apr 26, 2020
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.
Merge branch 'master' into custom-login-fix