// Path: falchion-container/src/main/java/net/unit8/falchion/supplier/AutoOptimizableProcessSupplier.java
// public class AutoOptimizableProcessSupplier implements Supplier<JvmProcess> {
//     private static final Logger LOG = LoggerFactory.getLogger(AutoOptimizableProcessSupplier.class);
// 
//     private StandardOptionProvider standardOptionProvider;
//     private Evaluator evaluator;
//     private Supplier<JvmProcess> baseSupplier;
//     private double variance = 0.1;
// 
//     public AutoOptimizableProcessSupplier(Supplier<JvmProcess> baseSupplier, Evaluator evaluator) {
//         this.baseSupplier = baseSupplier;
//         this.evaluator = evaluator;
//         standardOptionProvider = new StandardOptionProvider(128, 128, variance);
//     }
// 
//     @Override
//     public JvmProcess get() {
//         JvmProcess process = baseSupplier.get();
//         List<String> options = new ArrayList<>(standardOptionProvider.getOptions());
//         process.setJvmOptions(options);
//         return process;
//     }
// 
//     public void feedback(Collection<JvmProcess> processes) {
//         JvmProcess best = evaluator.evaluate(processes);
//         LOG.info("best param {}", best.getJvmOptions());
//         standardOptionProvider = new StandardOptionProvider(String.join(" ", best.getJvmOptions()), variance);
//     }
// }


import net.unit8.falchion.supplier.AutoOptimizableProcessSupplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
                if (autofill) fill();
            }
        });
    }

    public JvmProcess create() {
        JvmProcess process = processSupplier.get();
        if (Objects.nonNull(classpath)) {
            process.setClasspath(classpath);
        }
        Future<JvmResult> future = jvmCompletionService.submit(process);
        processes.put(process.getId(), new ProcessHolder(process, future));
        LOG.info("create new JVM (id={}, pid={})", process.getId(), process.getPid());
        return process;
    }

    public void fill() {
        while (processes.size() < poolSize) {
            create();
        }
    }

    public void refresh() throws IOException {
        Set<JvmProcess> oldProcesses = processes.values().stream()
                .map(ProcessHolder::getProcess)
                .collect(Collectors.toSet());

        // If process supplier is instance of AutoOptimizableProcessSupplier,
        // feedback current monitoring value to supplier.
        Stream.of(processSupplier)
// Path: falchion-container/src/main/java/net/unit8/falchion/supplier/AutoOptimizableProcessSupplier.java
// public class AutoOptimizableProcessSupplier implements Supplier<JvmProcess> {
//     private static final Logger LOG = LoggerFactory.getLogger(AutoOptimizableProcessSupplier.class);
// 
//     private StandardOptionProvider standardOptionProvider;
//     private Evaluator evaluator;
//     private Supplier<JvmProcess> baseSupplier;
//     private double variance = 0.1;
// 
//     public AutoOptimizableProcessSupplier(Supplier<JvmProcess> baseSupplier, Evaluator evaluator) {
//         this.baseSupplier = baseSupplier;
//         this.evaluator = evaluator;
//         standardOptionProvider = new StandardOptionProvider(128, 128, variance);
//     }
// 
//     @Override
//     public JvmProcess get() {
//         JvmProcess process = baseSupplier.get();
//         List<String> options = new ArrayList<>(standardOptionProvider.getOptions());
//         process.setJvmOptions(options);
//         return process;
//     }
// 
//     public void feedback(Collection<JvmProcess> processes) {
//         JvmProcess best = evaluator.evaluate(processes);
//         LOG.info("best param {}", best.getJvmOptions());
//         standardOptionProvider = new StandardOptionProvider(String.join(" ", best.getJvmOptions()), variance);
//     }
// }


// Path: falchion-container/src/main/java/net/unit8/falchion/JvmPool.java
import net.unit8.falchion.supplier.AutoOptimizableProcessSupplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

                if (autofill) fill();
            }
        });
    }

    public JvmProcess create() {
        JvmProcess process = processSupplier.get();
        if (Objects.nonNull(classpath)) {
            process.setClasspath(classpath);
        }
        Future<JvmResult> future = jvmCompletionService.submit(process);
        processes.put(process.getId(), new ProcessHolder(process, future));
        LOG.info("create new JVM (id={}, pid={})", process.getId(), process.getPid());
        return process;
    }

    public void fill() {
        while (processes.size() < poolSize) {
            create();
        }
    }

    public void refresh() throws IOException {
        Set<JvmProcess> oldProcesses = processes.values().stream()
                .map(ProcessHolder::getProcess)
                .collect(Collectors.toSet());

        // If process supplier is instance of AutoOptimizableProcessSupplier,
        // feedback current monitoring value to supplier.
        Stream.of(processSupplier)
                .filter(AutoOptimizableProcessSupplier.class::isInstance)