Closed Bug 785064 Opened 12 years ago Closed 6 years ago

pick content processes to kill based on API use

Categories

(Firefox OS Graveyard :: General, defect)

All
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-kilimanjaro:+, blocking-basecamp:-)

RESOLVED WONTFIX
blocking-kilimanjaro +
blocking-basecamp -

People

(Reporter: gal, Unassigned)

References

Details

We could easily improve the order in which content processes are killed based on API use. If an app uses the Telephony API, its likely more important to the user than the newspaper app. This way we don't have to prioritize individual applications. Priorities should be prefs, most likely. Its not entirely clear to me how to communicate the per-process priorities to the OOM killer. Will discuss that with our silicon vendor friends.
I don't think we need this for v1.
blocking-basecamp: --- → -
blocking-kilimanjaro: --- → +
So I took a look at the kernel OOM killer (mm/oom_kill.c) oom_badness is the function that determines which task gets killed.

The thing that most influences the heuristic is the amount of memory consumed by the process.

It seems that you can use /proc/<pid>/oom_score_adj (range -1000 to +1000) to influence the heuristic. Negative numbers reduce the score.

You can check the current score using "cat /proc/<pid>/oom_score"

echo -1000 > /proc/<pid>/oom_score_adj will disable OOM killing for a particular PID.

You can execute something like (from an adb shell on the phone)
for pid in /proc/[0-9]*; do s=$(cat $pid/oom_score); if [ $s -gt 1 ]; then echo $(cat $pid/comm) $s; fi; done 

to see the candidates and their scores.
(In reply to Andreas Gal :gal from comment #0)
> If an app uses the Telephony API, its likely more
> important to the user than the newspaper app. 

Are you assuming both are background?  Why do you think telephony trumps newspaper?  (I disagree.)

I do think we should extend the notion of "visibility" to include playing music, controlling radio, etc.  The user is aware of when those apps are killed.
... to be clear, with background < background-but-user-is-aware < foreground.
Sounds good. That definition of visibility makes a lot of sense.
Note that we already set oom_adj for foreground / background apps.  See bug 768832.
(In reply to Andreas Gal :gal from comment #0)
> We could easily improve the order in which content processes are killed
> based on API use.

That sounds very risky because apps might end up requesting and use APIs they don't need just to be less likely to get killed.
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.