Skip to content

Conversation

adriaan42
Copy link
Contributor

Currently, any changes made to the tuning via the instance_* dbus calls are lost when tuning is stopped by the service, or when the TuneD service itself is stopped/restarted, or when the service crashes.

This PR:

  • implements a sync of Plugin Instances and Profile Units that is currently missing. This way, dynamic instances and device assignments are persistent across stop/start dbus calls to TuneD.

  • calculates a hash of the current profile after loading it from disk (after processing all includes, so we have a "flat" representation)

  • creates snapshots of the current profile whenever instances or assigned devices change. the snapshot includes the hash of the profile as it was initially loaded. for each instance it stores the devices that are currently attached.

  • restores a snapshot found at startup, if the hashes match (i.e. there have been no profile switches and no changes to the profile or any of its includes on disk)

    snapshots are restored in case of

    • daemon restarts (systemctl restart/stop/start)
    • daemon crashes

    snapshots are NOT restored in case of

    • reboots (snapshots are stored in /var/run)
    • profile changes (snapshots are explicitly deleted when switching profiles,
      even when "switching" to the same/current profile)

Move the calculation if the active state of an instance from
_add_devices_nocheck() to _add_devices_process(), to make it
symmetric with device removal.

Signed-off-by: Adriaan Schmidt <[email protected]>
@adriaan42 adriaan42 force-pushed the adriaan/persistence branch 2 times, most recently from 9131940 to d6c2b69 Compare May 28, 2025 06:22
Currently, any changes made to the tuning via the `instance_*` dbus calls
are lost when tuning is stopped by the service, or when the TuneD service
itself is stopped/restarted, or when the service crashes.

This commit:

* implements a sync of Plugin Instances and Profile Units that is currently missing.
  This way, dynamic instances and device assignments are persistent across stop/start
  dbus calls to TuneD.
* calculates a hash of the current profile after loading it from disk
  (after processing all includes, so we have a "flat" representation)
* creates snapshots of the current profile whenever instances or assigned
  devices change. the snapshot includes the hash of the profile as
  it was initially loaded. for each instance it stores the devices that
  are currently attached.
* restores a snapshot found at startup, if the hashes match (i.e. there
  have been no profile switches and no changes to the profile or any of
  its includes on disk)

  snapshots are restored in case of
  - daemon restarts (systemctl restart/stop/start)
  - daemon crashes
  snapshots are NOT restored in case of
  - reboots (snapshots are stored in /var/run)
  - profile changes (snapshots are explicitly deleted when switching profiles,
    even when "switching" to the same/current profile)

Signed-off-by: Adriaan Schmidt <[email protected]>
@adriaan42 adriaan42 force-pushed the adriaan/persistence branch from d6c2b69 to f0bdfb8 Compare June 3, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant