Is lifecycle-aware state management worth the extra complexity in an operating system? #213687
Replies: 1 comment 1 reply
|
Your instinct is good, but I'd reframe the goal: what you're describing isn't really "lifecycle-aware state management", it's provenance — knowing where a piece of state came from and what it's allowed to do. The systems that do this well (NixOS, Android's app data model, macOS bundles) don't have a universal registry either. They attach identity to the unit that owns state: an app, a package, a service. The key design decision is that ownership is established at creation and enforced by the system, not reconstructed later. A few things worth deciding early, because they're hard to retrofit:
The trap I'd watch: it's tempting to make the metadata rich — origin, purpose, owner, lifecycle, expiry, etc. But every field you add is something the OS must keep accurate, and stale provenance is worse than none. Start with the minimum that lets you answer "can I delete this safely?" and grow only when a real case demands it. One more thought on your "sustainable by design" goal: the best payoff probably isn't cleanup at all. It's debugging. When something breaks, being able to ask "what owns this file and why is it here" is enormously valuable, and it falls out of the same provenance model for free. |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Question
Body
I'm working on an experimental operating system and I'm currently thinking about how system and application state should be structured.
One architecture decision I've made is to avoid a single generic registry-style state store.
Instead, the idea is that managed state should be domain-specific and lifecycle-aware.
A piece of state should carry information such as its origin, purpose, owner and lifecycle. Application state, package metadata, permissions, service state, hardware state and security state would therefore not all be treated as anonymous entries in one universal store.
The motivation is mainly cleanup, uninstall, maintenance and recovery.
A lot of systems seem to deal with old state retrospectively: files, cache entries or configuration values exist, and later some tool has to determine whether they are still needed.
I'd like to approach that from the other direction:
Know what data is when it is created, instead of trying to rediscover what it used to be later.
For example, instead of a cleanup tool having to guess whether some file is disposable, the system could already know that it belongs to a specific application, exists for a specific purpose and has a lifecycle that allows it to be removed under defined conditions.
There is also a broader design goal behind this.
I'm trying to make the OS sustainable by design, in the sense that it should remain understandable, maintainable and operable over a long period of time without depending too heavily on external cleanup tools, repair utilities or additional layers that compensate for missing lifecycle information.
Where possible, I'd prefer the OS itself to have a more holistic understanding of the state it manages rather than leaving that knowledge scattered across unrelated tools.
That does not mean every subsystem has to use the same storage mechanism. A subsystem could still use files, a database, a key/value store or another representation internally.
The goal is not one universal implementation, but a coherent system-level model of ownership and lifecycle.
Another part of the motivation is local system overhead.
The lifecycle tracking would run locally and preferably be event- and metadata-driven, rather than relying on repeated full-system scans.
The idea is to spend a small amount of work when state is created or changes, so that cleanup, maintenance and recovery later do not have to repeatedly rediscover what that state represents.
So part of the trade-off I'm trying to evaluate is whether more structured bookkeeping up front is worth it if it reduces heuristic scanning, CPU/I/O work, external maintenance tooling and ambiguity later.
What I'm unsure about is whether the benefit actually justifies the work.
Explicit lifecycle information also means additional metadata, consistency rules and bookkeeping. That metadata can itself become stale or incorrect. Shared state may not have one obvious owner, and some state may not have a predictable lifecycle when it is created.
So the question I'm mainly interested in is:
At what point does explicit lifecycle-aware state management pay for itself, and when does it become architectural overhead?
I'm especially interested in practical experience with:
Linux seems to solve part of this through conventions and domain-specific locations rather than one universal registry, but that still doesn't necessarily mean the OS explicitly knows the lifecycle of everything stored there.
I'm trying to understand whether making that lifecycle explicit is a useful long-term system property, or whether I'm creating a lot of machinery to solve a problem that simpler conventions and external tools already solve well enough.
I'm mainly interested in trade-offs, failure modes and cases where this approach breaks down in practice.
Guidelines
All reactions