1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.android.startop.iorap; 18 19 import com.google.android.startop.iorap.ITaskListener; 20 21 import com.google.android.startop.iorap.AppIntentEvent; 22 import com.google.android.startop.iorap.AppLaunchEvent; 23 import com.google.android.startop.iorap.DexOptEvent; 24 import com.google.android.startop.iorap.JobScheduledEvent; 25 import com.google.android.startop.iorap.PackageEvent; 26 import com.google.android.startop.iorap.RequestId; 27 import com.google.android.startop.iorap.SystemServiceEvent; 28 import com.google.android.startop.iorap.SystemServiceUserEvent; 29 30 /** 31 * IIOrap is a client interface to the input/output readahead and pin daemon (iorapd). 32 * 33 * The aim is to speed-up the cold start-up time of certain use-cases like application startup 34 * by utilizing trace-based pinning or readahead. 35 * 36 * Programatically, the behavior of iorapd should be treated like a black box. There is no 37 * "correctness", but only performance. By sending the right events at the appropriate time, 38 * we can squeeze more performance out of the system. 39 * 40 * If some events are not appropriately wired up, system performance may (temporarily) degrade. 41 * 42 * {@hide} */ 43 oneway interface IIorap { 44 /** 45 * Set an ITaskListener which will be used to deliver notifications of in-progress/completition 46 * for the onXEvent method calls below this.<br /><br /> 47 * 48 * iorapd does all the work asynchronously and may deliver one or more onProgress events after 49 * the event begins to be processed. It will always send back one onComplete that is considered 50 * terminal.<br /><br /> 51 * 52 * onProgress/onComplete are matched to the original event by the requestId. Once an onComplete 53 * occurs for any given requestId, no further callbacks with the same requestId will occur. 54 * It is illegal for the caller to reuse the same requestId on different invocations of IIorap. 55 * <br /><br /> 56 * 57 * onXEvent(id1) must be well-ordered w.r.t. onXEvent(id2), the assumption is that later 58 * calls happen-after earlier calls and that id2 > id1. Decreasing request IDs will 59 * immediately get rejected. 60 * <br /><br /> 61 * 62 * Sequence diagram of stereotypical successful event delivery and response notification: 63 * 64 * <pre> 65 * 66 * ┌─────────────┐ ┌──────┐ 67 * │system_server│ │iorapd│ 68 * └──────┬──────┘ └──┬───┘ 69 * Request [01]: onSomeEvent ┌┴┐ 70 * │────────────────────────>│ │ 71 * │ │ │ 72 * │ │ │ ╔════════════════════════╗ 73 * │ │ │ ║start processing event ░║ 74 * │ │ │ ╚════════════════════════╝ 75 * │ │ │ 76 * ╔═══════╤════════╪═════════════════════════╪═╪══════════════════════════════╗ 77 * ║ LOOP │ 1 or more times │ │ ║ 78 * ╟───────┘ │ │ │ ║ 79 * ║ │Request [01]: onProgress │ │ ║ 80 * ║ │<────────────────────────│ │ ║ 81 * ║ │ │ │ ║ 82 * ║ │ │ │────┐ ║ 83 * ║ │ │ │ │ workload in progress ║ 84 * ║ │ │ │<───┘ ║ 85 * ╚════════════════╪═════════════════════════╪═╪══════════════════════════════╝ 86 * │ └┬┘ 87 * . . 88 * . . 89 * . . 90 * . . 91 * . . 92 * │ ┌┴┐ ╔═════════════════════════╗ 93 * │ │ │ ║finish processing event ░║ 94 * │ │ │ ╚═════════════════════════╝ 95 * │Request [01]: onComplete │ │ 96 * │<────────────────────────│ │ 97 * ┌──────┴──────┐ ┌─└┬┘──┐ 98 * │system_server│ │iorapd│ 99 * └─────────────┘ └──────┘ 100 * 101 * </pre> <!-- system/iorap/docs/binder/IIorap_setTaskListener.plantuml --> 102 */ setTaskListener(ITaskListener listener)103 void setTaskListener(ITaskListener listener); 104 105 // All callbacks will be done via the ITaskListener. 106 // The RequestId passed in is the same RequestId sent back via the ITaskListener. 107 // See above for more details. 108 109 // Note: For each ${Type}Event, see the ${Type}Event.java for more documentation 110 // in frameworks/base/startop/src/com/google/android/startop/iorap/${Type}Event.java 111 112 // void onActivityHintEvent(in RequestId request, in ActivityHintEvent event); onAppLaunchEvent(in RequestId request, in AppLaunchEvent event)113 void onAppLaunchEvent(in RequestId request, in AppLaunchEvent event); onDexOptEvent(in RequestId request, in DexOptEvent event)114 void onDexOptEvent(in RequestId request, in DexOptEvent event); onJobScheduledEvent(in RequestId request, in JobScheduledEvent event)115 void onJobScheduledEvent(in RequestId request, in JobScheduledEvent event); onPackageEvent(in RequestId request, in PackageEvent event)116 void onPackageEvent(in RequestId request, in PackageEvent event); onAppIntentEvent(in RequestId request, in AppIntentEvent event)117 void onAppIntentEvent(in RequestId request, in AppIntentEvent event); onSystemServiceEvent(in RequestId request, in SystemServiceEvent event)118 void onSystemServiceEvent(in RequestId request, in SystemServiceEvent event); onSystemServiceUserEvent(in RequestId request, in SystemServiceUserEvent event)119 void onSystemServiceUserEvent(in RequestId request, in SystemServiceUserEvent event); 120 } 121