Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid ClassNode construction for classes that do not get instrumented #6152

Merged
merged 1 commit into from Jan 16, 2021

Conversation

copybara-service[bot]
Copy link

Avoid ClassNode construction for classes that do not get instrumented

According to https://asm.ow2.io/performance.html, using a ClassReader is a lot
faster for reading basic class metadata than creating a ClassNode. This is
because to create a ClassNode, every single byte of the class file needs to be
visited, including method instructions. For ClassReader, a lot of the work is
done lazily. Previously, a ClassNode object was constructed for every class
loaded by SandboxClassLoaer, regardless of whether or not it was instrumented.

Instead, use a ClassReader approach to determine whether or not a class needs
to be instrumented, and then build the ClassNode if it needs to be
instrumented. This should improve performance for larger tests that load a lot
of non-Android classes.

According to https://asm.ow2.io/performance.html, using a ClassReader is a lot
faster for reading basic class metadata than creating a ClassNode. This is
because to create a ClassNode, every single byte of the class file needs to be
visited, including method instructions. For ClassReader, a lot of the work is
done lazily. Previously, a ClassNode object was constructed for every class
loaded by SandboxClassLoaer, regardless of whether or not it was instrumented.

Instead, use a ClassReader approach to determine whether or not a class needs
to be instrumented, and then build the ClassNode if it needs to be
instrumented. This should improve performance for larger tests that load a lot
of non-Android classes.

PiperOrigin-RevId: 351251828
@hoisie hoisie merged commit 98d1eca into master Jan 16, 2021
@hoisie hoisie deleted the piper_351251828 branch January 16, 2021 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant