PandABlocks / PandABlocks-server

TCP server exposing an ASCII interface to functional blocks
Apache License 2.0
2 stars 3 forks source link

Investigate writing to the persistence file #58

Open tomtrafford opened 2 weeks ago

tomtrafford commented 2 weeks ago

SD cards have a tendency to fail, can we reduce how often we write to the SD card? Do we write to it when nothings changes?

Can we investigate moving the persistence file to the QSPI.

Investigate the new SD cards, can we set up a test to see how long it takes an old SD card to fail and see if we can replicate this behaviour on the new SD card.

Araneidae commented 2 weeks ago

The server is actually quite careful not to write too often to the persistence file. The default parameters, overrideable with -t [poll][":"[holdoff][":"backoff]], are (all durations in seconds):

Parameter Default Description
poll 20 How often the state is checked for changes
holdoff 30 Delay from state change being detected to writing update to the persistence file
backoff 60 How long to wait after writing the state before resuming normal polling

This was designed to address precisely the problem you're describing: frequent writes to flash memory can cause wear. The initial delay is so that multiple writes aren't triggered after a group of changes is started, and the backoff slows things down if there are continuous changes.

Araneidae commented 2 weeks ago

@tomtrafford, does this issue need an action or can it be closed now?