From Fedora Project Wiki
(F32 system wide change proposal to enable earlyoom.service by default)
 
(Add trackers)
 
(34 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Enable EarlyOOM killing =
= Enable EarlyOOM =


== Summary ==
== Summary ==
Install earlyoom package, and enable it by default. This will cause the kernel oomkiller to trigger sooner, but will not affect which process it chooses to kill off. The idea is to recover from out of memory situations sooner, rather than the typical complete system hang in which the user has no other choice but to force power off.
Install earlyoom package, and enable it by default. If both RAM and swap go below 10% free, earlyoom issues SIGTERM to the process with the largest oom_score. If both RAM and swap go below 5% free, earlyoom issues SIGKILL to the process with the largest oom_score. The idea is to recover from out of memory situations sooner, rather than the typical complete system hang in which the user has no other choice but to force power off.
 


== Owner ==
== Owner ==
Line 26: Line 25:
CLOSED as NEXTRELEASE -> change is completed and verified and will be delivered in next release under development
CLOSED as NEXTRELEASE -> change is completed and verified and will be delivered in next release under development
-->
-->
* Tracker bug: <will be assigned by the Wrangler>
* Tracker bug: [https://bugzilla.redhat.com/show_bug.cgi?id=1801398 #1801398]
* Release notes tracker: <will be assigned by the Wrangler>
* Release notes tracker: [https://pagure.io/fedora-docs/release-notes/issue/447 #447]


== Detailed Description ==
== Detailed Description ==
Workstation working group has discussed "better interactivity in low-memory situations" for some months:
https://pagure.io/fedora-workstation/issue/98<br>
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/XUZLHJ5O32OX24LG44R7UZ2TMN6NY47N/<br>
Certain workloads have heavy memory demands, quickly consume all of RAM, and start to heavily page out to swap. (Heavy paging, is often called "swap thrashing" for added descriptive effect, probably because it's noticeable and annoying). Incidental swap usage is a good thing, it frees up memory for active pages used by a process. Heavy swap usage quickly leads to a very negative UX, because it's slow, even on modern SSDs. Due to installer defaults, the swap partition is made the same size as available memory (at install time), which can be huge. This just extends swap thrashing time.
On the one hand, we want this resource hungry job to complete. On the other hand, we want our system to be responsive while that other work is going on. But once the GUI stutters or even comes to an apparent stand still (hang), we're really wishing the kernel oom-killer would kick in and free up memory, so we can start over (maybe using memory or thread limiting options - which arguably should be more intelligently figured out, and that too is a work in progress but beyond the scope of this feature).
However, once in a heavy swap scenario, it's relatively common the system gets stuck in it, where GUI interactivity is terrible to non-existent, and also the kernel oom-killer doesn't trigger. From a certain point of view, this is working as intended. The kernel oom-killer is concerned about keeping the kernel running. It's not at all concerned about user space responsiveness.
Instead of the system becoming completely unresponsive for tens of minutes, hours or days, this feature expects that an offending process (determined by oom_score, same as the kernel oom-killer) will be killed off within seconds or a few minutes.


The kernel in Fedora editions and spins, enables the in-kernel OOM (out-of-memory) manager. Its concern is to keep the kernel itself functioning, it has no concern at all about user space function or interactivity. This change attempts to improve the user experience in the short term by triggering the same process killing mechanism, but sooner. Instead of the system becoming completely unresponsive for tens of minutes, hours or days, the expectation is an offending process (determined by oom_score, same as now) will be killed of within seconds to minutes. This is better, but admittedly still suboptimal, and there is more long term work on-going to improve the user experience in this area.
This is an incremental improvement in user experience, but admittedly still suboptimal. There is additional work on-going to improve the user experience further.


Background information on this complicated problem:
Workstation working group discussion specific to enabling earlyoom by default
https://www.kernel.org/doc/gorman/html/understand/understand016.html
https://pagure.io/fedora-workstation/issue/119
https://lwn.net/Articles/317814/


Recent discussion:
Other in-progress solutions:<br>
https://pagure.io/fedora-workstation/issue/98
https://gitlab.freedesktop.org/hadess/low-memory-monitor<br>
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/XUZLHJ5O32OX24LG44R7UZ2TMN6NY47N/


Other in-progress solutions:
Background information on this complicated problem:<br>
https://gitlab.freedesktop.org/hadess/low-memory-monitor
https://www.kernel.org/doc/gorman/html/understand/understand014.html<br>
https://www.kernel.org/doc/gorman/html/understand/understand016.html<br>
https://lwn.net/Articles/317814/<br>


Feature concerns:<br>
Suboptimal behavior if the system has no swap (this is not a default setup, but still needs improvement):
https://pagure.io/fedora-workstation/issue/119#comment-618480


== Benefit to Fedora ==
== Benefit to Fedora ==
Line 49: Line 63:
There are two major benefits to Fedora:  
There are two major benefits to Fedora:  


- improved user experience by more quickly regaining control over one's system, rather than having to force power off in low-memory situations where there's aggressive swapping. Once a system becomes unresponsive, it's completely reasonable for the user to assume the system is lost, but that includes high potential for data loss.
* improved user experience by more quickly regaining control over one's system, rather than having to force power off in low-memory situations where there's aggressive swapping. Once a system becomes unresponsive, it's completely reasonable for the user to assume the system is lost, but that includes high potential for data loss.


- reducing forced poweroff as the main work around will increase data collection, improving understanding of low memory situations and how to handle them better
* reducing forced poweroff as the main work around will increase data collection, improving understanding of low memory situations and how to handle them better


* earlyoom first sends SIGTERM to the chosen process, so it has a chance of a proper shutdown, unlike the kernel's oom-killer


== Scope ==
== Scope ==
* Proposal owners:
* Proposal owners:
Include earlyoom package and enabled it by default, both for clean installs and upgrades.
a. Modify {{code|https://pagure.io/fedora-comps/blob/master/f/comps-f32.xml.in}} to include earlyoom package for Workstation.<br>
b. Modify {{code|https://src.fedoraproject.org/rpms/fedora-release/blob/master/f/80-workstation.preset}} to include:
<pre>
# enable earlyoom by default on workstation
enable earlyoom.service
</pre>


* Other developers:
* Other developers:
Desktop spins may choose to opt-out. Server, Cloud, IoT may choose to opt-in.
Restricted to Workstation edition, unless other editions/spins want to opt-in.


* Release engineering: [https://pagure.io/releng/issues #Releng issue number] (a check of an impact with Release Engineering is needed) <!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
* Release engineering: [https://pagure.io/releng/issue/9141 #9141] (a check of an impact with Release Engineering is needed) <!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
<!-- Does this feature require coordination with release engineering (e.g. changes to installer image generation or update package delivery)?  Is a mass rebuild required?  include a link to the releng issue.
The issue is required to be filed prior to feature submission, to ensure that someone is on board to do any process development work and testing, and that all changes make it into the pipeline; a bullet point in a change is not sufficient communication -->


* Policies and guidelines: N/A
* Policies and guidelines: N/A
Line 69: Line 87:


== Upgrade/compatibility impact ==
== Upgrade/compatibility impact ==
<!-- What happens to systems that have had a previous versions of Fedora installed and are updated to the version containing this change? Will anything require manual configuration or data migration? Will any existing functionality be no longer supported? -->
earlyoom.service will be enabled on upgrade. An upgraded system should exhibit the same behaviors as a clean installed system.
 
<!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
N/A (not a System Wide Change)


== How To Test ==
== How To Test ==
<!-- This does not need to be a full-fledged document. Describe the dimensions of tests that this change implementation is expected to pass when it is done.  If it needs to be tested with different hardware or software configurations, indicate them.  The more specific you can be, the better the community testing can be.
* Fedora 30/31 users can test today, any edition or spin:<br>
{{code|sudo dnf install earlyoom}}<br>
{{code|sudo systemctl enable --now earlyoom}}


Remember that you are writing this how to for interested testers to use to check out your change implementation - documenting what you do for testing is OK, but it's much better to document what *I* can do to test your change.
And then attempt to cause an out of memory situation. Examples:<br>
{{code|tail /dev/zero}}<br>
{{code|https://lkml.org/lkml/2019/8/4/15}}


A good "how to test" should answer these four questions:
* Fedora Workstation 32 (and Rawhide) users will see this service is already enabled. It can be toggled with  {{code|sudo systemctl start/stop earlyoom}}  where start means earlyoom is running, and stop means earlyoom is not running.


0. What special hardware / data / etc. is needed (if any)?
== User Experience ==
1. How do I prepare my system to test this change? What packages
* The most egregious instances this change is trying to mitigate:<br>
need to be installed, config files edited, etc.?
a. RAM is completely used<br>
2. What specific actions do I perform to check that the change is
b. Swap is completely used<br>
working like it's supposed to?
c. System becomes unresponsive to the user as swap thrashing has ensued<br>
3. What are the expected results of those actions?
--> earlyoom disabled, the user often gives up and forces power off (in cmurf's limited testing, this condition lasts >30 minutes with no kernel triggered oom killer and no recovery)<br>
-->
--> earlyoom enabled, the system likely still becomes unresponsive but oom killer is triggered in much less time (seconds or a few minutes, in cmurf's testing, after less than 10% RAM and 10% swap is remaining)


<!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
* earlyoom starts sending SIGTERM once both memory and swap are below their respective PERCENT setting, default 10%. It sends SIGKILL once both are below their respective KILL_PERCENT setting, default 5%. The user shouldn't need to do anything differently than if the kernel oom-killer had triggered. The system journal will contain messages showing what was killed and why:
N/A (not a System Wide Change)
<pre>
Jan 04 16:05:42 fmac.local earlyoom[4896]: low memory! at or below SIGTERM limits: mem 10 %, swap 10 %
Jan 04 16:05:42 fmac.local earlyoom[4896]: sending SIGTERM to process 27421 "chrome": badness 305, VmRSS 42 MiB
</pre>


== User Experience ==
* What gets killed? The process with the highest oom_score (badness), found in {{code|/proc/<pid>/oom_score}} which is dynamically computed. This is the same metric used by the kernel oom-killer.
<!-- If this change proposal is noticeable by users, how will their experiences change as a result?


This section partially overlaps with the Benefit to Fedora section above. This section should be primarily about the User Experience, written in a way that does not assume deep technical knowledge. More detailed technical description should be left for the Benefit to Fedora section.
* The package includes configuration file /etc/default/earlyoom which sets option {{code|-r 60}} causing a memory report to be entered into the journal every minute.
 
Describe what Users will see or notice, for example:
  - Packages are compressed more efficiently, making downloads and upgrades faster by 10%.
  - Kerberos tickets can be renewed automatically. Users will now have to authenticate less and become more productive. Credential management improvements mean a user can start their work day with a single sign on and not have to pause for reauthentication during their entire day.
- Libreoffice is one of the most commonly installed applications on Fedora and it is now available by default to help users "hit the ground running".
- Green has been scientifically proven to be the most relaxing color. The move to a default background color of green with green text will result in Fedora users being the most relaxed users of any operating system.
-->


== Dependencies ==
== Dependencies ==
<!-- What other packages (RPMs) depend on this package?  Are there changes outside the developers' control on which completion of this change depends?  In other words, completion of another change owned by someone else and might cause you to not be able to finish on time or that you would need to coordinate?  Other upstream projects like the kernel (if this is not a kernel change)? -->
earlyoom package has no dependencies
 
<!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
N/A (not a System Wide Change)


== Contingency Plan ==
== Contingency Plan ==
* Contingency mechanism: Owner will revert all changes
* Contingency deadline: Final freeze
* Blocks release? No
* Blocks product? No


<!-- If you cannot complete your feature by the final development freeze, what is the backup plan?  This might be as simple as "Revert the shipped configuration".  Or it might not (e.g. rebuilding a number of dependent packages).  If you feature is not completed in time we want to assure others that other parts of Fedora will not be in jeopardy.  -->
== Documentation ==
* Contingency mechanism: (What to do?  Who will do it?) N/A (not a System Wide Change)  <!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
{{code|man earlyoom}}<br>
<!-- When is the last time the contingency mechanism can be put in place?  This will typically be the beta freeze. -->
https://github.com/rfjakob/earlyoom<br>
* Contingency deadline: N/A (not a System Wide Change)  <!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
https://www.kernel.org/doc/gorman/html/understand/understand016.html
<!-- Does finishing this feature block the release, or can we ship with the feature in incomplete state? -->
* Blocks release? N/A (not a System Wide Change), Yes/No <!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
* Blocks product? product <!-- Applicable for Changes that blocks specific product release/Fedora.next -->


== Documentation ==
== Release Notes ==
<!-- Is there upstream documentation on this change, or notes you have written yourself?  Link to that material here so other interested developers can get involved. -->
Earlyoom service is enabled by default. In low-memory situations, it will first send SIGTERM to a chosen process based on oom_score, and if the low-memory situation continues to degrade it will then send SIGKILL to a chosen process.


<!-- REQUIRED FOR SYSTEM WIDE CHANGES -->
To revert to previous behavior using the kernel oom-killer:<br> {{code|sudo systemctl disable earlyoom.service}}
N/A (not a System Wide Change)


== Release Notes ==
And to customize see {{code|man earlyoom}}.
<!-- The Fedora Release Notes inform end-users about what is new in the release.  Examples of past release notes are here: http://docs.fedoraproject.org/release-notes/ -->
<!-- The release notes also help users know how to deal with platform changes such as ABIs/APIs, configuration or data file formats, or upgrade concerns.  If there are any such changes involved in this change, indicate them here.  A link to upstream documentation will often satisfy this need.  This information forms the basis of the release notes edited by the documentation team and shipped with the release.  


Release Notes are not required for initial draft of the Change Proposal but has to be completed by the Change Freeze.
[[Category:ChangeAcceptedF32]]
-->


[[Category:ChangePageIncomplete]]
<!-- When your change proposal page is completed and ready for review and announcement -->
<!-- remove Category:ChangePageIncomplete and change it to Category:ChangeReadyForWrangler -->
<!-- The Wrangler announces the Change to the devel-announce list and changes the category to Category:ChangeAnnounced (no action required) -->
<!-- After review, the Wrangler will move your page to Category:ChangeReadyForFesco... if it still needs more work it will move back to Category:ChangePageIncomplete-->


<!-- Select proper category, default is Self Contained Change -->
<!-- Select proper category, default is Self Contained Change -->
[[Category:SelfContainedChange]]
[[Category:SystemWideChange]]
<!-- [[Category:SystemWideChange]] -->
<!-- [[Category:SystemWideChange]] -->

Latest revision as of 19:23, 10 February 2020

Enable EarlyOOM

Summary

Install earlyoom package, and enable it by default. If both RAM and swap go below 10% free, earlyoom issues SIGTERM to the process with the largest oom_score. If both RAM and swap go below 5% free, earlyoom issues SIGKILL to the process with the largest oom_score. The idea is to recover from out of memory situations sooner, rather than the typical complete system hang in which the user has no other choice but to force power off.

Owner

Current status

Detailed Description

Workstation working group has discussed "better interactivity in low-memory situations" for some months:

https://pagure.io/fedora-workstation/issue/98
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/XUZLHJ5O32OX24LG44R7UZ2TMN6NY47N/

Certain workloads have heavy memory demands, quickly consume all of RAM, and start to heavily page out to swap. (Heavy paging, is often called "swap thrashing" for added descriptive effect, probably because it's noticeable and annoying). Incidental swap usage is a good thing, it frees up memory for active pages used by a process. Heavy swap usage quickly leads to a very negative UX, because it's slow, even on modern SSDs. Due to installer defaults, the swap partition is made the same size as available memory (at install time), which can be huge. This just extends swap thrashing time.

On the one hand, we want this resource hungry job to complete. On the other hand, we want our system to be responsive while that other work is going on. But once the GUI stutters or even comes to an apparent stand still (hang), we're really wishing the kernel oom-killer would kick in and free up memory, so we can start over (maybe using memory or thread limiting options - which arguably should be more intelligently figured out, and that too is a work in progress but beyond the scope of this feature).

However, once in a heavy swap scenario, it's relatively common the system gets stuck in it, where GUI interactivity is terrible to non-existent, and also the kernel oom-killer doesn't trigger. From a certain point of view, this is working as intended. The kernel oom-killer is concerned about keeping the kernel running. It's not at all concerned about user space responsiveness.

Instead of the system becoming completely unresponsive for tens of minutes, hours or days, this feature expects that an offending process (determined by oom_score, same as the kernel oom-killer) will be killed off within seconds or a few minutes.

This is an incremental improvement in user experience, but admittedly still suboptimal. There is additional work on-going to improve the user experience further.

Workstation working group discussion specific to enabling earlyoom by default https://pagure.io/fedora-workstation/issue/119

Other in-progress solutions:
https://gitlab.freedesktop.org/hadess/low-memory-monitor

Background information on this complicated problem:
https://www.kernel.org/doc/gorman/html/understand/understand014.html
https://www.kernel.org/doc/gorman/html/understand/understand016.html
https://lwn.net/Articles/317814/

Feature concerns:
Suboptimal behavior if the system has no swap (this is not a default setup, but still needs improvement): https://pagure.io/fedora-workstation/issue/119#comment-618480

Benefit to Fedora

There are two major benefits to Fedora:

  • improved user experience by more quickly regaining control over one's system, rather than having to force power off in low-memory situations where there's aggressive swapping. Once a system becomes unresponsive, it's completely reasonable for the user to assume the system is lost, but that includes high potential for data loss.
  • reducing forced poweroff as the main work around will increase data collection, improving understanding of low memory situations and how to handle them better
  • earlyoom first sends SIGTERM to the chosen process, so it has a chance of a proper shutdown, unlike the kernel's oom-killer

Scope

  • Proposal owners:

a. Modify https://pagure.io/fedora-comps/blob/master/f/comps-f32.xml.in to include earlyoom package for Workstation.
b. Modify https://src.fedoraproject.org/rpms/fedora-release/blob/master/f/80-workstation.preset to include:

# enable earlyoom by default on workstation
enable earlyoom.service
  • Other developers:

Restricted to Workstation edition, unless other editions/spins want to opt-in.

  • Release engineering: #9141 (a check of an impact with Release Engineering is needed)
  • Policies and guidelines: N/A
  • Trademark approval: N/A

Upgrade/compatibility impact

earlyoom.service will be enabled on upgrade. An upgraded system should exhibit the same behaviors as a clean installed system.

How To Test

  • Fedora 30/31 users can test today, any edition or spin:

sudo dnf install earlyoom
sudo systemctl enable --now earlyoom

And then attempt to cause an out of memory situation. Examples:
tail /dev/zero
https://lkml.org/lkml/2019/8/4/15

  • Fedora Workstation 32 (and Rawhide) users will see this service is already enabled. It can be toggled with sudo systemctl start/stop earlyoom where start means earlyoom is running, and stop means earlyoom is not running.

User Experience

  • The most egregious instances this change is trying to mitigate:

a. RAM is completely used
b. Swap is completely used
c. System becomes unresponsive to the user as swap thrashing has ensued
--> earlyoom disabled, the user often gives up and forces power off (in cmurf's limited testing, this condition lasts >30 minutes with no kernel triggered oom killer and no recovery)
--> earlyoom enabled, the system likely still becomes unresponsive but oom killer is triggered in much less time (seconds or a few minutes, in cmurf's testing, after less than 10% RAM and 10% swap is remaining)

  • earlyoom starts sending SIGTERM once both memory and swap are below their respective PERCENT setting, default 10%. It sends SIGKILL once both are below their respective KILL_PERCENT setting, default 5%. The user shouldn't need to do anything differently than if the kernel oom-killer had triggered. The system journal will contain messages showing what was killed and why:
Jan 04 16:05:42 fmac.local earlyoom[4896]: low memory! at or below SIGTERM limits: mem 10 %, swap 10 %
Jan 04 16:05:42 fmac.local earlyoom[4896]: sending SIGTERM to process 27421 "chrome": badness 305, VmRSS 42 MiB
  • What gets killed? The process with the highest oom_score (badness), found in /proc/<pid>/oom_score which is dynamically computed. This is the same metric used by the kernel oom-killer.
  • The package includes configuration file /etc/default/earlyoom which sets option -r 60 causing a memory report to be entered into the journal every minute.

Dependencies

earlyoom package has no dependencies

Contingency Plan

  • Contingency mechanism: Owner will revert all changes
  • Contingency deadline: Final freeze
  • Blocks release? No
  • Blocks product? No

Documentation

man earlyoom
https://github.com/rfjakob/earlyoom
https://www.kernel.org/doc/gorman/html/understand/understand016.html

Release Notes

Earlyoom service is enabled by default. In low-memory situations, it will first send SIGTERM to a chosen process based on oom_score, and if the low-memory situation continues to degrade it will then send SIGKILL to a chosen process.

To revert to previous behavior using the kernel oom-killer:
sudo systemctl disable earlyoom.service

And to customize see man earlyoom.