What does VerifyClass inside Systrace mean?
Asked Answered
A

2

18

I´m looking at the systrace generated by my app and I have identified a frame that is taking too long. This is caused by a RecyclerView's onCreateViewHolder when inflating my item view. The item view is as flat as posible with ConstraintLayout. But the below systrace report has a lot of VerifyClass blocks that take 17 ms each.

What does that VerifyClass blocks mean?

enter image description here

Audwin answered 12/10, 2017 at 5:6 Comment(1)
The trace logs you're seeing most likely come from here, so it's an ART issue. You might want to trying looking for logs related to dex/oat/art in your logcat to see if it points out an obvious error you can fix, but if not it might just be a framework issue and you can try filing a bug on the issue trackerPlacencia
P
4

It's hard to say what VerifyClass is exactly doing, because it's not a part of Android Java SDK or ConstraintLayout. The only mention I found is in C part of SDK:

http://www.androidpolice.com/android_aosp_changelogs/android-m-preview-2-to-android-7.0.0_r1-AOSP-changelog.html

But I have couple of suggestions:

1) Try to build your app in release mode and see if you still have issues with FPS drop. My assumption is that this VerifyClass is executed for debug builds to benchmark certain things, but that's only a guess.

2) While ConstraintLayout has convenient API, and flat hierarchy (which positively affects drawing traversals) it still has much slower measuring and layout process than other Android Layouts. The reason for this is the complexity of constraints calculation. So using it in a RecyclerView might result a significant performance hit during ViewHolder creation. If the hierarchy of list cell is simple enough, I'd suggest switching to some vanilla layouts and check the behavior.

Profuse answered 19/10, 2017 at 15:24 Comment(3)
it still has much slower measuring and layout process than other Android Layouts Which layouts (apart from FrameLayout, obviously)? I'd like to see some numbers this statement is based on.Ergo
@EugenPechanec Nested LinearLayouts (possibly with weights) and non-nested RelativeLayouts. This is based on my benchmarks and, more important, Google benchmarks: github.com/googlesamples/android-constraint-layout-performance. BUT, please note, that the "traditional" layout in this benchmark is extremely inefficient, and has multiple redundant and useless RelativeLayouts to artificially slow down the performance. If you rewrite this layout with nested LinearLayouts (even with weights), you will see a huge performance difference.Profuse
VerifyClass is part of android platform, in C++. Debug vs Release builds won't matter.Rendezvous
L
6

Not really an C++/Android Runtime internals expert to clearly explain what the VerifyClass method defined in /art/runtime/class_linker.h and implemented in /art/runtime/class_linker.cc means, but I wouldn't pay that much attention to its CPU execution time.

What I'd take into consideration is your RecyclerView items that contain ConstraintLayout and whose inflation consumes the CPU time.

Regarding the suggestion to try a release build, it won't make any difference - calls to the native VerifyClass method will be done for both debug and release builds.

Lynwoodlynx answered 21/10, 2017 at 20:50 Comment(0)
P
4

It's hard to say what VerifyClass is exactly doing, because it's not a part of Android Java SDK or ConstraintLayout. The only mention I found is in C part of SDK:

http://www.androidpolice.com/android_aosp_changelogs/android-m-preview-2-to-android-7.0.0_r1-AOSP-changelog.html

But I have couple of suggestions:

1) Try to build your app in release mode and see if you still have issues with FPS drop. My assumption is that this VerifyClass is executed for debug builds to benchmark certain things, but that's only a guess.

2) While ConstraintLayout has convenient API, and flat hierarchy (which positively affects drawing traversals) it still has much slower measuring and layout process than other Android Layouts. The reason for this is the complexity of constraints calculation. So using it in a RecyclerView might result a significant performance hit during ViewHolder creation. If the hierarchy of list cell is simple enough, I'd suggest switching to some vanilla layouts and check the behavior.

Profuse answered 19/10, 2017 at 15:24 Comment(3)
it still has much slower measuring and layout process than other Android Layouts Which layouts (apart from FrameLayout, obviously)? I'd like to see some numbers this statement is based on.Ergo
@EugenPechanec Nested LinearLayouts (possibly with weights) and non-nested RelativeLayouts. This is based on my benchmarks and, more important, Google benchmarks: github.com/googlesamples/android-constraint-layout-performance. BUT, please note, that the "traditional" layout in this benchmark is extremely inefficient, and has multiple redundant and useless RelativeLayouts to artificially slow down the performance. If you rewrite this layout with nested LinearLayouts (even with weights), you will see a huge performance difference.Profuse
VerifyClass is part of android platform, in C++. Debug vs Release builds won't matter.Rendezvous

© 2022 - 2024 — McMap. All rights reserved.