ifesdjeen / hashed-wheel-timer

High Performance Timer / Scheduler Library compatible with ScheduledExecutorService
Eclipse Public License 1.0
223 stars 43 forks source link

add pluggable ThreadFactory #3

Closed 0xg0nz0 closed 7 years ago

0xg0nz0 commented 7 years ago

Great library, and just what I was looking for today ....

Right now the loop thread provides a fixed ThreadFactory. It would be useful performance-wise to make this pluggable, e.g. to use Peter Lawrey's Java-Thread-Affinity library and

https://github.com/OpenHFT/Java-Thread-Affinity/blob/master/affinity/src/main/java/net/openhft/affinity/AffinityThreadFactory.java

You can dedicate a core to the busy-spin loop, and use the Linux isolcpus command to exclude operating system calls from it. You'll thus get a guaranteed 100% of the core for high-precision scheduling, with no kernel scheduling jitter.

    this.loop = Executors.newSingleThreadExecutor(new ThreadFactory() {
      AtomicInteger i = new AtomicInteger();

      @Override
      public Thread newThread(Runnable r) {
        Thread thread = new Thread(r, name + "-" + i.getAndIncrement());
        thread.setDaemon(true);
        return thread;
      }
    });
ifesdjeen commented 7 years ago

Closed by 500ef7e0eedf08023c6118445c170cbe593afe85