Skip to content

Remove redundant fsyncs

Sami Hiltunen requested to merge smh-optimize-fsync into master

Begin used to be the place where a partition was started. As it was responsible for setting up a partition, it created its state directory and fsynced it. Partition starting logic has since been moved to startPartition, which also creates the partition's state directory and fsyncs it. Doing this twice is redundant, and affects performance with file systems that flush out more writes than just the fsynced file itself.

The other problem with the current logic is that the state directory is fsynced every time a partition handle is retrieved. This leads to every request fsyncing which has a major performance hit. Only the goroutine starting the partition should set up its state directory and fsync it.

As fsyncing may take a relatively long time, we add additional synchronization logic start partitions without holding the lock while fsyncing.

Edited by Sami Hiltunen

Merge request reports

Loading