Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Save configs synchronously on shutdown #87

Merged
merged 2 commits into from
Mar 11, 2023
Merged

Conversation

zkxs
Copy link
Collaborator

@zkxs zkxs commented Mar 11, 2023

The original mod configuration implementation saved synchronously, but in #38 all config saving was switched over to a background thread. While doing some unrelated debugging I noticed that the shutdown hook saves were also asynchronous, and it struck me as incorrect and dangerous.

It's pretty typical for 10s of mods to save configs on shutdown, and I don't think there's a compelling performance benefit to doing all that IO concurrently. However, I do think there's a compelling safety benefit to doing all the saves synchronously: I believe Task.Run() uses background threads, which do not keep the managed execution environment running. In other words, there's no guarantee those background saves won't get interrupted. Doing the saves synchronously ensures they'll actually finish before Neos exits.

It's pretty typical for 10s of mods to save configs on shutdown, and I don't think there's a compelling performance benefit to doing all that IO concurrently. However, I do think there's a compelling safety benefit to doing all the saves synchronously: I believe Task.Run() uses background threads, which do not keep the managed execution environment running. In other words, there's no guarantee those saves won't get interrupted.
@zkxs zkxs merged commit 458ba47 into master Mar 11, 2023
@ljoonal ljoonal deleted the sync-config-save-on-shutdown branch March 11, 2023 11:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants