Skip to content

[Feature] Make bytebuddy ignore some classes to speed up startup time #13063

@SunJiFengPlus

Description

@SunJiFengPlus

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Description

In our company's promotion of Skywalking, we found that some project team feedback after adding Skywalking-java will make the application startup time longer (35s -> 60s). The way to verify this is to use JMeter to continuously send Http requests to the application, then record the time and start the application again, until JMeter's request no longer return error, then calculate the time gap.

I've hardcoded the time spent on the following methods

  • SkyWalkingAgent#premian
  • SkyWalkingAgent.Transformer#transform
  • ProtectiveShieldMatcher#matches

like this

    @Override
    public boolean matches(T target) {
        try {
            if (LOGGER.isDebugEnable()) {
                long start = System.currentTimeMillis();
                boolean matches = this.matcher.matches(target);
                COST.addAndGet(System.currentTimeMillis() - start);
                LOGGER.debug("So far the Byte-buddy matches has took : {} ms", COST.get());
                return matches;
            } else {
                return this.matcher.matches(target);
            }
        } catch (Throwable t) {
            if (LOGGER.isDebugEnable()) {
                LOGGER.debug(t, "Byte-buddy occurs exception when match type.");
            }
            return false;
        }
    }

Until the application is able to handle http requests correctly, the most time-consuming method is ProtectiveShieldMatcher#matches, it cost 16s+. The application contains a large number of classes, mostly prefixed with com.our.company, which do not need to be enhanced. I got a huge reduction in startup time by ignoring this prefixed class in Bytebuddy.

Use case

For applications that are sensitive to startup time and require fast deployment and scaling, applications are less tolerant of increased startup time. Reduce the startup time increase by ignoring classes that enhance the specified prefix. This prefix can probably be configured in agent.config

Related issues

No response

Are you willing to submit a pull request to implement this on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions