davidmoten / more-executors

More performant Java Executors

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

more-executors

More performant Java Executors.

Tweaks j.u.c.ThreadPoolExecutor in particular.

  • make six frequently read volatile fields final
  • reduce volatile reads o(e.g. ctl.get() in addWorker)
  • remove volatile reads and writes of completedTasks (and associated unused methods)

Benchmark results

On Ubuntu 16.04 AWS t2.xlarge there is a 10% throughput boost on a single thread:

Benchmark                                               Mode  Cnt    Score   Error  Units
Benchmarks.executorDoNothingManyTimesSingleThreadJuc   thrpt   10  308.426 ± 2.141  ops/s
Benchmarks.executorDoNothingManyTimesSingleThreadMore  thrpt   10  338.532 ± 1.606  ops/s

About

More performant Java Executors

License:Apache License 2.0


Languages

Language:Java 100.0%