elastic / elastic/apm-agent-java

Optimize the IndyBootstrap#getClassNamesFromBundledPlugin method to reduce memory usage caused by package scanning

Open
#3,730 1 comment 1 reaction 0 assignees View on GitHub
agent-java community
Dominant language
Java
Stars
594
Forks
338
Avg merge
1d 13h
Merged PRs (30d)
25

Description

## Is your feature request related to a problem?
![image](https://github.com/user-attachments/assets/2fd420e4-344c-47fe-b582-988c0c75d9eb)

![image](https://github.com/user-attachments/assets/b720cb80-dadd-4031-9108-f4f3b3614126)

## Describe the solution you'd like
When the program starts executing the IndyBootstrap#bootstrap method, there will be logic to obtain the class name list of the specified plug-in. However, in this logic, I think some optimizations can be made. As shown in the figure, in the original method, multiple threads may concurrently request the data of the same pluginPackage. At this time, multiple jar packages will be scanned, and there will also be a PackageScanner global lock in it; suppose we advance this lock and based on pluginPackage distinguishes different locks, which can improve application startup performance and reduce memory usage caused by package scanning. I tested it locally and it works.

## Describe alternatives you've considered
image
image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.