Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / ipc / glue / PIdleScheduler.ipdl
blobd0b94abaa2ca359e5a562165eec5bd6e1cad543a
1 /* -*- tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 include protocol PBackground;
7 using mozilla::TimeDuration from "mozilla/TimeStamp.h";
8 [MoveOnly] using mozilla::ipc::SharedMemoryHandle from "mozilla/ipc/SharedMemory.h";
9 namespace mozilla {
10 namespace ipc {
12 /**
13  * PIdleScheduler is the protocol for cross-process idle scheduling.
14  * Only child processes participate in the scheduling and parent process
15  * can run its idle tasks whenever it needs to.
16  *
17  * The scheduler keeps track of the following things.
18  * - Activity of the main thread of each child process. A process is active
19  *   when it is running tasks. Because of performance cross-process
20  *   counters in shared memory are used for the activity tracking. There is
21  *   one counter counting the activity state of all the processes and one
22  *   counter for each process. This way if a child process crashes, the global
23  *   counter can be updated by decrementing the per process counter from it.
24  * - Child processes running prioritized operation. Top level page loads is an
25  *   example of a prioritized operation. When such is ongoing, idle tasks are
26  *   less likely to run.
27  * - Idle requests. When a child process locally has idle tasks to run, it
28  *   requests idle time from the scheduler. Initially requests go to a wait list
29  *   and the scheduler runs and if there are free logical cores for the child
30  *   processes, idle time is given to the child process, and the process goes to
31  *   the idle list. Once idle time has been consumed or there are no tasks to
32  *   process, child process informs the scheduler and the process is moved back
33  *   to the default queue.
34  */
35 async protocol PIdleScheduler {
36   manager PBackground;
38 child:
39   async IdleTime(uint64_t id, TimeDuration budget);
41 parent:
42   async InitForIdleUse() returns (SharedMemoryHandle? state, uint32_t childId);
43   async RequestIdleTime(uint64_t id, TimeDuration budget);
44   async IdleTimeUsed(uint64_t id);
46   // Child can send explicit Schedule message to parent if it thinks parent
47   // process might be able to let some other process to use idle time.
48   async Schedule();
50   // Note, these two messages can be sent even before InitForIdleUse.
51   async RunningPrioritizedOperation();
52   async PrioritizedOperationDone();
54   // Ask if now would be a good time to GC
55   async RequestGC() returns(bool may_gc);
57   // Let the parent know when we start a GC without asking first.
58   async StartedGC();
60   // Called for ending any kind of GC.
61   async DoneGC();
63   // This message is never sent. Each PIdleScheduler actor will stay alive as
64   // long as its PBackground manager.
65   async __delete__();
68 }  // namespace ipc
69 }  // namespace mozilla