What are flyweight executors?
What is the difference between normal (heavyweight) executors and flyweight executors?
What is the performance impact of flyweight executors on my running controller?
Flyweight executors are just threads, running inside of the Jenkins controller’s JVM. Flyweight executors are unlimited and will be created automatically when needed, unlike heavyweight executors, which are limited based on their node’s configuration.
Every Pipeline script itself runs on the controller using a flyweight executor (i.e. Java thread). Pipeline steps such as
bat will execute on a heavyweight executor when enclosed in a
node block, so in a well-designed Pipeline where complicated logic happens only in those steps, the flyweight executor should be idling while steps run on remote agents for most of the build.
Flyweight executors are created on-demand and then removed when they are no longer needed.
The memory usage depends on the complexity of the pipeline.
To reduce the resource usage of flyweight executors, you should use shell steps for any logic in your pipeline that requires significant machine resources. For example, rather than directly calling a Java or Groovy library in your Pipeline, consider moving that logic into a standalone script and executing it via a shell step that calls Groovy from the command line. Using these steps also makes the Pipeline-specific parts easier to test and improves the stability of your Jenkins controller overall.