Update boot image profile for MessageQueue
We see drastically different performance depending on what
MessageQueue is in use. Mark the whole class for AOT compilation
so we can do proper A/B comparisons between MessageQueue
implementations.
Flag: EXEMPT resource only update
Test: compile
Bug: 338098106
Change-Id: I10c60486d3cc88193bb7f3bba830cccf02212892
diff --git a/boot/boot-image-profile-extra.txt b/boot/boot-image-profile-extra.txt
index e3b187e..11ca1dc 100644
--- a/boot/boot-image-profile-extra.txt
+++ b/boot/boot-image-profile-extra.txt
@@ -19,3 +19,7 @@
# methods are latency sensitive is difficult. For example, this method is executed
# in the system server, not on the UI thread of an app.
HSPLandroid/graphics/Color;->luminance()F
+
+# For now, compile all methods in MessageQueue to avoid performance cliffs for
+# flagged/evolving hot code paths. See: b/338098106
+HSPLandroid/os/MessageQueue;->*
diff --git a/core/java/android/os/ConcurrentMessageQueue/MessageQueue.java b/core/java/android/os/ConcurrentMessageQueue/MessageQueue.java
index b2d9260..adf7966 100644
--- a/core/java/android/os/ConcurrentMessageQueue/MessageQueue.java
+++ b/core/java/android/os/ConcurrentMessageQueue/MessageQueue.java
@@ -29,6 +29,8 @@
import com.android.internal.annotations.GuardedBy;
+import dalvik.annotation.optimization.NeverCompile;
+
import java.io.FileDescriptor;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -1331,6 +1333,7 @@
mMatchAllFutureMessages, true);
}
+ @NeverCompile
private void printPriorityQueueNodes() {
Iterator<MessageNode> iterator = mPriorityQueue.iterator();
@@ -1342,6 +1345,7 @@
}
}
+ @NeverCompile
private int dumpPriorityQueue(ConcurrentSkipListSet<MessageNode> queue, Printer pw,
String prefix, Handler h, int n) {
int count = 0;
@@ -1357,6 +1361,7 @@
return count;
}
+ @NeverCompile
void dump(Printer pw, String prefix, Handler h) {
long now = SystemClock.uptimeMillis();
int n = 0;
@@ -1387,6 +1392,7 @@
+ ", quitting=" + (boolean) sQuitting.getVolatile(this) + ")");
}
+ @NeverCompile
private int dumpPriorityQueue(ConcurrentSkipListSet<MessageNode> queue,
ProtoOutputStream proto) {
int count = 0;
@@ -1399,6 +1405,7 @@
return count;
}
+ @NeverCompile
void dumpDebug(ProtoOutputStream proto, long fieldId) {
final long messageQueueToken = proto.start(fieldId);
diff --git a/core/java/android/os/LegacyMessageQueue/MessageQueue.java b/core/java/android/os/LegacyMessageQueue/MessageQueue.java
index 4474e7e..9f7b0b7 100644
--- a/core/java/android/os/LegacyMessageQueue/MessageQueue.java
+++ b/core/java/android/os/LegacyMessageQueue/MessageQueue.java
@@ -28,6 +28,8 @@
import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
+import dalvik.annotation.optimization.NeverCompile;
+
import java.io.FileDescriptor;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -1106,6 +1108,7 @@
}
}
+ @NeverCompile
void dump(Printer pw, String prefix, Handler h) {
synchronized (this) {
pw.println(prefix + "(MessageQueue is using Legacy implementation)");
@@ -1122,6 +1125,7 @@
}
}
+ @NeverCompile
void dumpDebug(ProtoOutputStream proto, long fieldId) {
final long messageQueueToken = proto.start(fieldId);
synchronized (this) {
diff --git a/core/java/android/os/LockedMessageQueue/MessageQueue.java b/core/java/android/os/LockedMessageQueue/MessageQueue.java
index f1affce..f3eec13 100644
--- a/core/java/android/os/LockedMessageQueue/MessageQueue.java
+++ b/core/java/android/os/LockedMessageQueue/MessageQueue.java
@@ -30,6 +30,8 @@
import com.android.internal.annotations.GuardedBy;
+import dalvik.annotation.optimization.NeverCompile;
+
import java.io.FileDescriptor;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -294,6 +296,7 @@
* Keep this for manual debugging. It's easier to pepper the code with this function
* than MessageQueue.dump()
*/
+ @NeverCompile
void print() {
Log.v(TAG, "heap num elem: " + mNumElements + " mHeap.length " + mHeap.length);
for (int i = 0; i < mNumElements; i++) {
@@ -1209,6 +1212,7 @@
sMatchAllFutureMessages, true);
}
+ @NeverCompile
int dumpPriorityQueue(Printer pw, String prefix, Handler h, MessageHeap priorityQueue) {
int n = 0;
long now = SystemClock.uptimeMillis();
@@ -1222,6 +1226,7 @@
return n;
}
+ @NeverCompile
void dumpPriorityQueue(ProtoOutputStream proto, MessageHeap priorityQueue) {
for (int i = 0; i < priorityQueue.numElements(); i++) {
Message m = priorityQueue.getMessageAt(i);
@@ -1229,6 +1234,7 @@
}
}
+ @NeverCompile
void dump(Printer pw, String prefix, Handler h) {
synchronized (this) {
pw.println(prefix + "(MessageQueue is using Locked implementation)");
@@ -1240,6 +1246,7 @@
}
}
+ @NeverCompile
void dumpDebug(ProtoOutputStream proto, long fieldId) {
final long messageQueueToken = proto.start(fieldId);
synchronized (this) {
diff --git a/core/java/android/os/SemiConcurrentMessageQueue/MessageQueue.java b/core/java/android/os/SemiConcurrentMessageQueue/MessageQueue.java
index 80c24a9..f45bc42 100644
--- a/core/java/android/os/SemiConcurrentMessageQueue/MessageQueue.java
+++ b/core/java/android/os/SemiConcurrentMessageQueue/MessageQueue.java
@@ -29,6 +29,8 @@
import com.android.internal.annotations.GuardedBy;
+import dalvik.annotation.optimization.NeverCompile;
+
import java.io.FileDescriptor;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -1249,6 +1251,7 @@
mMatchAllFutureMessages, true);
}
+ @NeverCompile
private void printPriorityQueueNodes() {
Iterator<MessageNode> iterator = mPriorityQueue.iterator();
@@ -1260,6 +1263,7 @@
}
}
+ @NeverCompile
private int dumpPriorityQueue(PriorityQueue<MessageNode> queue, Printer pw, String prefix,
Handler h, int n) {
int count = 0;
@@ -1275,6 +1279,7 @@
return count;
}
+ @NeverCompile
void dump(Printer pw, String prefix, Handler h) {
long now = SystemClock.uptimeMillis();
int n = 0;
@@ -1307,6 +1312,7 @@
+ ", quitting=" + (boolean) sQuitting.getVolatile(this) + ")");
}
+ @NeverCompile
private int dumpPriorityQueue(PriorityQueue<MessageNode> queue, ProtoOutputStream proto) {
int count = 0;
@@ -1318,6 +1324,7 @@
return count;
}
+ @NeverCompile
void dumpDebug(ProtoOutputStream proto, long fieldId) {
final long messageQueueToken = proto.start(fieldId);