# Problem with AutoSave module

**URL:** <https://discourse.slicer.org/t/problem-with-autosave-module/34046>\
**Category:** Support\
**Created:** [January 30, 2024, 1:22pm UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046 "2024-01-30T13:22:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MJamal](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@MJamal](https://discourse.slicer.org/u/MJamal)\
**Post date:** [January 30, 2024, 1:22pm UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046/1 "2024-01-30T13:22:08Z")

</div>

Hello,

How can I prevent the Slicer main window from becoming unresponsive when using the autosave feature? I’ve observed significant lag in the main window after enabling autosave. Is it running on the same thread as Slicer?

Few suggestions on autosave:

1. Since CLI modules run on a separate process, and I came across a [commit](https://github.com/jcfr/Slicer/commit/2cdd5c9da49e692a463af0d80efa6b6d20ad5099) mentioning running at least two CLI modules parallely, So can we run autosave as a CLI on a separate thread to prevent the main window from getting stuck?
2. Alternatively, can we utilize the ParallelProcessing module to run autosave in a separate process? (I’m concerned about whether this handles synchronization between scene saving.)

Lastly, is there a way to integrate QtConcurrent into Slicer? I attempted to add it, but it didn’t work at all.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [January 30, 2024, 6:19pm UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046/2 "2024-01-30T18:19:21Z")

</div>

1. [AutoSave](https://github.com/PerkLab/SlicerSandbox/tree/master/AutoSave) is a Python module so it cannot make use of the methods applicable to CLI.
2. If you use ParallelProcessing you do not have access to the Slicer MRML scene, only data you may have saved yourself before starting the process. Since it is the saving itself that takes time, and causes the lag, it is not something that can be outsourced to a parallel thread. Note that I say this with my limited knowledge about both modules.

Maybe you can limit autosaving to the MRML node types you are interested in autosaving? Or limit the types of events that trigger it?

---

<div class="post-metadata">

**Author:** ![MJamal](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@MJamal](https://discourse.slicer.org/u/MJamal)\
**Post date:** [January 31, 2024, 4:20am UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046/3 "2024-01-31T04:20:20Z")

</div>

> [@cpinter](#):
>
> Maybe you can limit autosaving to the MRML node types you are interested in autosaving? Or limit the types of events that trigger it?

For my use case, I would like to save the entire scene as a bundle. Incremental saving would also be acceptable if it is applicable in the slicer.

> [@cpinter](#):
>
> [AutoSave](https://github.com/PerkLab/SlicerSandbox/tree/master/AutoSave) is a Python module so it cannot make use of the methods applicable to CLI.

How about re-implementing it as a C++ CLI or Loadable module? Is it a viable option?

> [@cpinter](#):
>
> If you use ParallelProcessing you do not have access to the Slicer MRML scene

Additionally, what are your thoughts on using shared memory for data saving?

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [January 31, 2024, 4:30am UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046/4 "2024-01-31T04:30:27Z")

</div>

> [@MJamal](#):
>
> I would like to save the entire scene as a bundle

I think a lot of the slowness is caused by the single threaded compression of the bundle, particularly if the data is large or there are many volumes in the scene. I wonder if it is possible to create the bundle without compression.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 31, 2024, 8:04am UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046/5 "2024-01-31T08:04:13Z")

</div>

It looks like the current AutoSave only saves as MRB, so it’s always saving the bulk data (and compressing it) without regard for the modified status. Someone could look into saving incremental .mrml files to avoid this overhead for cases where the bulk data isn’t actually changing and can be restored if there’s a crash.

---

<div class="post-metadata">

**Author:** ![MJamal](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@MJamal](https://discourse.slicer.org/u/MJamal)\
**Post date:** [January 31, 2024, 11:28am UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046/6 "2024-01-31T11:28:18Z")

</div>

> [@muratmaga](#):
>
> a lot of the slowness is caused by the single threaded compression of the bundle, particularly if the data is large or there are many volumes in the scene

I experimented with it, and I found that scene saving is taking place on the same thread as the slicer. That’s probably the reason for freezing.

---

<div class="post-metadata">

**Author:** ![MJamal](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@MJamal](https://discourse.slicer.org/u/MJamal)\
**Post date:** [January 31, 2024, 11:50am UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046/7 "2024-01-31T11:50:28Z")

</div>

> [@pieper](#):
>
> Someone could look into saving incremental .mrml files to avoid this overhead for cases where the bulk data isn’t actually changing and can be restored if there’s a crash.

That can probably be achieved if there is a way to determine whether a scene has been updated and also retrieve its state, including the source of the update. This would allow us to save incremental updates from the last modified state to the current state.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 31, 2024, 12:45pm UTC](https://discourse.slicer.org/t/problem-with-autosave-module/34046/8 "2024-01-31T12:45:33Z")

</div>

The `ModifiedSinceRead` property should be reliable. It’s used in the Save dialog to determine which nodes need to be enabled for saving by default.
