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

Improve performance for ByteBuddy rules with common intercept #551

Open
safris opened this issue Apr 21, 2020 · 3 comments
Open

Improve performance for ByteBuddy rules with common intercept #551

safris opened this issue Apr 21, 2020 · 3 comments
Assignees
Labels
core P1 Priority 1 request New feature or request
Milestone

Comments

@safris
Copy link
Collaborator

safris commented Apr 21, 2020

There are several rules in SpecialAgent that intercept the same class, such as the spring-web-* rules. These rules share the same intercept so as to allow SpecialAgent to select the correct version of a particular integration for the specific runtime. This works fine, but it costs the runtime a significant reduction in startup performance. The reason is: for ByteBuddy to apply different rules to the same intercept, it must instrument the same intercept in different layers, each on top of the pervious. This means that ByteBuddy cannot apply the intercept rules in one pass, and must do so in as many passes are there are rules for the same intercept. Currently, 68 of the 72 rules in SpecialAgent can be "globally chained" -- i.e. the rules are chained together to be loaded all in one pass. The remaining 5 rules require their own dedicated pass. Therefore, if the first 68 rules load in a time of 1, then the remaining 5 rules require a load time of 1 each (a load time of 5 total).

There are 2 ways to solve this:

  1. Rewrite the spring-web-* rules in a way that is compatible for all versions of Spring Web, which may be very challenging.
  2. Introduce an abstraction into the rule definition mechanism that would be able to "collate" rules intercepting the same class, and create a "compatibility-based routing mechanism" to use the correct rule definition based on the version of the instrumented library in the runtime, thus allowing ByteBuddy to instrument the runtime only once.
@safris safris self-assigned this Apr 21, 2020
@safris safris added core P1 Priority 1 request New feature or request labels Apr 21, 2020
@malafeev
Copy link
Contributor

I think we can remove spring-web-* rules because it's covered by HttpUrlConnection and thread/concurrent rules.
spring-web-* uses HttpUrlConnection to send requests.

@safris
Copy link
Collaborator Author

safris commented Apr 23, 2020

@malafeev, if the spring-web-* rules are providing redundant spans, then let's remove them. Removing them will also improve startup performance considerably.

@safris
Copy link
Collaborator Author

safris commented Apr 30, 2020

All rules involving unchained re/transformations have been fixed, except:

  1. dynamic
  2. grizzly-http-server
  3. mule-4-http-service

In order to switch these rules from unchained to chained re/transformation, an option is to implement an abstraction into the rule definition mechanism to "collate" rules intercepting the same class, and create a "compatibility-based routing mechanism" to use the correct rule definition based on the version of the instrumented library in the runtime, thus allowing ByteBuddy to instrument the runtime only once.

@safris safris added this to the v1.7.4 milestone May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core P1 Priority 1 request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants