Merge pull request #300 from ludovic111/fix/autosave-spike
Autosave stops waiting for entity writes: no more 2 s freeze (#224)
This commit is contained in:
@@ -7957,7 +7957,7 @@ impl Game<'_> {
|
||||
if wait {
|
||||
self.save.flush();
|
||||
}
|
||||
self.save_entities()?;
|
||||
self.save_entities(wait)?;
|
||||
self.save_maps();
|
||||
self.save_random_sequences();
|
||||
self.save_raids();
|
||||
|
||||
@@ -830,7 +830,10 @@ impl Game<'_> {
|
||||
out.into_iter().collect()
|
||||
}
|
||||
/// Write the entities of every resident chunk (an autosave or quit).
|
||||
pub(super) fn save_entities(&mut self) -> Result<()> {
|
||||
/// Without `wait` (the autosave) they are written on the region writer
|
||||
/// meanwhile: `PersistentEntitySectionManager.autoSave` stores them
|
||||
/// without `saveAll`'s flush.
|
||||
pub(super) fn save_entities(&mut self, wait: bool) -> Result<()> {
|
||||
self.spawn_loaded_entities();
|
||||
let keys: HashSet<(i32, i32)> = self.world.chunks.keys().copied().collect();
|
||||
let chunks = self.entity_chunks(&keys, false);
|
||||
@@ -849,7 +852,11 @@ impl Game<'_> {
|
||||
.collect();
|
||||
self.persist.uuids.retain(|id, _| alive.contains(id));
|
||||
self.persist.raw.retain(|id, _| alive.contains(id));
|
||||
self.save.save_entities(chunks)
|
||||
if wait {
|
||||
self.save.save_entities(chunks)
|
||||
} else {
|
||||
self.save.save_entities_later(chunks)
|
||||
}
|
||||
}
|
||||
/// Save and remove the entities of chunks that unloaded.
|
||||
pub(super) fn unload_entities(&mut self, unloaded: &[Arc<Chunk>]) {
|
||||
|
||||
Reference in New Issue
Block a user