Skip to content

fix and optimize AddSectorBatch

Boris Nagaev requested to merge starius:refactor-AddSectorBatch into master

AddSectorBatch is applied to the whole list of sectors of a contract being renewed. The function started a goroutine per sector before. Each goroutine made disk access to update the sector's reference counter. This resulted is thousands of goroutines and potentially OS threads. The tool crashed when a large contract was renewed: https://github.com/NebulousLabs/Sia/issues/1775#issuecomment-330666550

This commit removes the goroutine-launching behaviour and instead groups sector updates by storage folder and merges adjacent sectors into groups writing them together in order to optimize the number of write operations issued by the tool.

Merge request reports