raphw / byte-buddy

Runtime code generation for the Java virtual machine.
https://bytebuddy.net
Apache License 2.0
6.22k stars 802 forks source link

Can byte-buddy modify bytecode in parallel? #1681

Open 601724080 opened 1 month ago

601724080 commented 1 month ago

There are too many classes that need to be modified, and the modification time is now about 20 minutes, Can byte-buddy modify bytecode in parallel?

raphw commented 1 month ago

Byte Buddy's public API is fully immutable and therewith thread-safe. How are you using the API?

601724080 commented 1 month ago

Sorry, My PC don‘t work until today。 It's roughly written like this:

agentBuilder.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
                .with(new RedefinitionListener())
                .type(pluginFinder.buildMatch())
                .transform(new BaseTransformer(pluginFinder))
                .with(new TransformListener())
                .installOn(instrumentation);

And the BaseTransformer implements AgentBuilder.Transformer。

raphw commented 1 month ago

Any class will be transformed in the thread loading the class. If parallel class loading is supported, Byte Buddy will also modify classes in multiple threads.

601724080 commented 1 month ago

I‘ll have a try, thank you.