Remix.run Logo
kstenerud 2 hours ago

For crash resilient data, you have a few options:

- Journaling file structures (telegraph what you're about to write, then write it, then signal completion)

- memmap your important data structures to a file (they will be flushed to disk no matter how your app dies - short of a power loss)

- post-crash dump (put last-minute writers in a crash handler to save it to disk)

A journaling file structure is the most secure, because it's designed with the assumption that writing will eventually fail. memmapped structs are easy and cheap, and get you 99% of the way there (only power loss will lose your data). Crash-time writing is doable with a crash handler like KSCrash, but there are many ways an app can crash without triggering a crash handler (thermal kill, exceeding quota, memory jetsam, etc). You also need to write your data in a signal-safe manner.