Bug 1839170 - Refactor Snap pulling, Add Firefox Snap Core22 and GNOME 42 SDK symbols...
[gecko.git] / ipc / glue / PIdleScheduler.ipdl
blob1857c12eaf0ac9e8b7b1face986020f609a746a1
1 /* -*- Mode: C++; 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 base::SharedMemoryHandle from "base/shared_memory.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
37   manager PBackground;
39 child:
40   async IdleTime(uint64_t id, TimeDuration budget);
42 parent:
43   async InitForIdleUse() returns (SharedMemoryHandle? state, uint32_t childId);
44   async RequestIdleTime(uint64_t id, TimeDuration budget);
45   async IdleTimeUsed(uint64_t id);
47   // Child can send explicit Schedule message to parent if it thinks parent process
48   // might be able to let some other process to use idle time.
49   async Schedule();
51   // Note, these two messages can be sent even before InitForIdleUse.
52   async RunningPrioritizedOperation();
53   async PrioritizedOperationDone();
55   // Ask if now would be a good time to GC
56   async RequestGC() returns (bool may_gc);
58   // Let the parent know when we start a GC without asking first.
59   async StartedGC();
61   // Called for ending any kind of GC.
62   async DoneGC();
64   // This message is never sent. Each PIdleScheduler actor will stay alive as long as
65   // its PBackground manager.
66   async __delete__();
69 } // namespace ipc
70 } // namespace mozilla