raphw / byte-buddy

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

Can byte-buddy modify bytecode in parallel? #1681

Closed 601724080 closed 2 months ago

601724080 commented 4 months 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 4 months ago

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

601724080 commented 4 months 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 3 months 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 3 months ago

I‘ll have a try, thank you.