Hi Ben,
sorry that your previous posting remained unanswered.
The RAM preservation feature in init is very nice; I used to have issues with init running out of memory. However, the RAM reservation applies after first reserving the RAM for all of the child processes based on their quotas. That may be fine in most cases, but it doesn't work properly when you give a child process a huge RAM quota to ensure that it gets all of the available RAM. In that situation, the RAM preservation happens after all of the available RAM has been reserved for the child processes, leaving no RAM available for init to preserve for itself. Something needs to change here.
Thanks for raising this issue. Just to make sure it does not go unresolved, would you mind to open an issue at GitHub and possibly give instructions how to reproduce it?
Changing the ordering is the simplest solution, but there may be a better solution. When we reserve all the remaining RAM for a particular process, we supply a huge RAM quota that is much larger than the process actually needs. It seems that the solution would be to split the quota numbers into a minimum (amount *reserved*) and a maximum (amount *available*). It would work very nicely for standard desktop workloads, especially when web browsers are involved. For example, I'd like to ensure that chromium has access to up to 2G of RAM, if it is available, but I don't want to reserve 2G of RAM specifically for chromium.
Would this solution work well? Or is there something that I'm missing here?
I am not convinced of this approach. Even though I can relate to the described scenario, to me, the two statements sound like a contradiction:
1. Ensure that chromium has access to up to 2G of RAM 2. Don't want to reserve 2G of RAM specifically for chromium
The proper way to deal with the situation you described would be to dynamically adjust the quota values for chromium (a "desktop manager" could do that automatically). Init supports the dynamic change of RAM quotas in the following ways:
* If the quota of a start node is increased, init transfers RAM quota from init to the component.
* If the quota is decreased, init tries to transfer RAM quota from the component to init. If this is not possible (because the component's PD has not enough unused RAM quota), init sends a 'yield' request to the component. A nice-behaving component could respond to such a request by freeing up the requested amount of RAM.
With this way, we can leave out the policy (like a softer notion of quotas) outside of init.
Norman