Class PoolSizeTuner

java.lang.Object
uk.ac.ebi.utils.threading.PoolSizeTuner
Direct Known Subclasses:
BatchService.BatchServiceTuner

public abstract class PoolSizeTuner extends Object

A Thread Pool Size Optimiser

Implements a simple algorithm to optimise a thread pool, based on periodic measured throughput (i.e., the no of threads that completed between one measurement step and another. See below for details.

You should start the tuning (e.g., via BatchService) with a moderate initial pool size, cause the tuning algorithm works well (i.e. converges) when it approaches the best value from the left.

date
8 Oct 2013
Author:
Marco Brandizi
  • Field Details

    • log

      protected org.slf4j.Logger log
  • Constructor Details

    • PoolSizeTuner

      public PoolSizeTuner()
  • Method Details

    • getThreadPoolSize

      public abstract int getThreadPoolSize()
    • setThreadPoolSize

      protected abstract void setThreadPoolSize(int size)
    • getCompletedTasks

      public abstract long getCompletedTasks()
    • start

      public void start()
      Starts the periodic monitoring of the thread pool and its dynamic adjustment.
    • stop

      public void stop()
      Stop the periodic monitoring of the thread pool.
    • isActive

      public boolean isActive()
      True if I was started with start() and never stop()ped.
    • getMinThreads

      public int getMinThreads()
      The minimum number of threads that the thread pool should always contain. See the source code for defaults.
    • setMinThreads

      public void setMinThreads(int minThreads)
    • getMaxThreads

      public int getMaxThreads()
      The maximum number of threads that the thread pool can contain. See the source code for defaults.
    • setMaxThreads

      public void setMaxThreads(int maxThreads)
    • getMaxThreadIncr

      public int getMaxThreadIncr()
      How much the thread pool size can be incremented at every optimisation iteration. This should be a positive value.
    • setMaxThreadIncr

      public void setMaxThreadIncr(int maxThreadIncr)
    • getMinThreadIncr

      public int getMinThreadIncr()
      How muc the thread pool size can be shrunk at every optimisation iteration. This should be a positive value.
    • setMinThreadIncr

      public void setMinThreadIncr(int minThreadIncr)
    • getPeriodMSecs

      public int getPeriodMSecs()
      The time between optimisation step executions. Should be positive.
    • setPeriodMSecs

      public void setPeriodMSecs(int periodMSecs)
    • getThreadDeltaTolerance

      public double getThreadDeltaTolerance()
      If the number of tasks between one optimisation step and another remained within this tolerance, then the thread pool throughput is considered stable and no action is taken over the pool size.
    • setThreadDeltaTolerance

      public void setThreadDeltaTolerance(double threadDeltaTolerance)