Status Update
Comments
km...@google.com <km...@google.com>
ju...@google.com <ju...@google.com>
aa...@google.com <aa...@google.com> #2
Hmm
I can repro on API 33 but not on API 34
aa...@google.com <aa...@google.com> #3
Can't repro with API 24 as well.
aa...@google.com <aa...@google.com> #4
Can't repro with 21 or 32. Looks like issue is specific to API 33.
aa...@google.com <aa...@google.com> #5
And seems to have nothing to do with ByteBuffer.
fun testCpu() {
val random = Random(Date().time)
val nanoTime = measureNanoTime {
repeat(100_000) {
sin(random.nextDouble())
}
}
Log.d("SinTest", "100_000 * sin() loop took ${TimeUnit.NANOSECONDS.toMillis(nanoTime)}ms")
}
Results in:
2023-08-02 11:32:07.506 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 9ms
2023-08-02 11:32:08.417 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 2ms
2023-08-02 11:32:09.296 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 1ms
2023-08-02 11:32:09.992 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 1ms
2023-08-02 11:32:10.720 9391-9391 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 1ms
---------------------------- PROCESS ENDED (9391) for package com.alonalbert.myapplication ----------------------------
---------------------------- PROCESS STARTED (9463) for package com.alonalbert.myapplication ----------------------------
2023-08-02 11:32:27.663 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 78ms
2023-08-02 11:32:28.537 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 105ms
2023-08-02 11:32:29.262 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 103ms
2023-08-02 11:32:29.887 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 104ms
2023-08-02 11:32:30.663 9463-9463 SinTest com.alonalbert.myapplication D 100_000 * sin() loop took 104ms
aa...@google.com <aa...@google.com> #6
I can reproduce without Android Studio in the loop at all.
Do the following on an API 33 device or emulator, then on any other API level.
$ adb install -r slow-under-debugger.apk
$ # Start the app and observe
$ adb jdwp
14051
^C
$ adb forward tcp:5005 jdwp:14051
$ jdb -attach hostname=localhost,port=5005
$ Observe the app
On a API 33 device, the execution time jumps by a factor of about 50 when it's attached to the debugger.Note that when the debugger is detached, it returns to normal.
my...@google.com <my...@google.com> #7
Thanks Alon! I will take a look. There are several improvements which went into Android 34 around breakpoints. Though I am not aware of any particular regression in Android 33 when compared to Android 32.
my...@google.com <my...@google.com> #8
Actually, we had to cherrypick a fix to Android T to address slowness when debugger is attached:
I think any T release should have that fix included. So not sure if it's the same issue. I am trying to reproduce this locally.
From the initial description looks like it is also an issue with API 32?
Reproducible on Google Pixel 3a XL API 32 and API 33 x86_64 emulator.
my...@google.com <my...@google.com> #9
I can reproduce this on API 33 emulator but not on API 32 similar to what Alon observed. The extent of slowdown seems to suggest we are using the slow interpreter which was fixed by the CL I mentioned in c#8. I think the emulator image should include that CL. I am trying to verify that.
Version of the emulator:
Linux version 5.15.41-android13-8-00055-g4f5025129fe8-ab8949913 (build-user@build-host) (Android (8508608, based on r450784e) clang version 14.0.7 (
aa...@google.com <aa...@google.com> #10
From the initial description looks like it is also an issue with API 32?
I was not able to reproduce on a API 32 emulator
my...@google.com <my...@google.com> #11
Thanks Alon! I couldn't reproduce it on API 32 emulator as well. I will check on a real device tomorrow when I am in the office.
Increasing the priority since this is a regression in API 33.
la...@gmail.com <la...@gmail.com> #12
Reproducible on Google Pixel 3a XL API 32 and API 33 x86_64 emulator.
This bug no longer occurs on my Google Pixel 3a XL API 32, but still happens on API 33 x86_64 emulator as before.
My environment:
Android Studio Giraffe | 2022.3.1
Build #AI-223.8836.35.2231.10406996, built on June 29, 2023
Runtime version: 17.0.6+0-17.0.6b829.9-10027231 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.5
my...@google.com <my...@google.com> #13
Thanks for confirming!
This slowdown is coming from the method entry / exit hooks introduced in T. Several improvements related to method entry / exit hooks went into U. We need some of those changes to fix this slowdown. I will check with our release team on the process and update the bug.
my...@google.com <my...@google.com> #14
The fixes for the slowdown are already included in the August ART module update. So it should be fixed once the device is updated with the August update.
my...@google.com <my...@google.com> #15
I am closing this since the fixes are already in the next release. Please reopen if the issue exists even after the mainline update or if there is something else I missed.
Description
ByteBuffer#put
method is extremely slow when debugger is attached, close to being unusable in loops.Take this code as an example:
With debugger attached (no breakpoints are set):
Without debugger it's ~50 times faster (same debug build, no optimizations whatsoever):
Reproducible on Google Pixel 3a XL API 32 and API 33 x86_64 emulator.
Build: AI-213.7172.25.2113.9123335, 202209300301,
AI-213.7172.25.2113.9123335, JRE 11.0.13+0-b1751.21-8125866x64 JetBrains s.r.o., OS Mac OS X(x86_64) v12.6.1, screens 2560.0x1600.0, 3840.0x2160.0; Retina
AS: Dolphin | 2021.3.1 Patch 1 Kotlin plugin: 213-1.7.20-release-for-android-studio-AS6777.52 Android Gradle Plugin: 7.2.2 Gradle: 7.3.3 Gradle JDK: version 11.0.13 NDK: from local.properties: (not specified), latest from SDK: (not found) CMake: from local.properties: (not specified), latest from SDK: 3.18.1-g262b901, from PATH: 3.25.1