Skip to content
Idan Sheinberg edited this page Sep 11, 2020 · 20 revisions

Needle provides a feature rich, unopinionated interface to core affinity (aka "CPU pinning").

Built on top of JNA, this library utilizes the underlying OS scheduling facilities in order to assign selected threads to utilize specific CPU cores.

Motivation

This library was written in order to address the needs of HFT platforms, similar to other affinity frameworks such as:

Differing from the aforementioned libraries, needle focuses on flexibility and extensibility, aiming to help the developer better divide compute resources between critical and non-critical application paths, with ease of use and integration in mind.

Getting Started

Just add the following maven (artifacts are hosted on maven central), and you're all set to start pinning!

<dependency>
    <groupId>org.sheinbergon</groupId>
    <!-- also retrieves the needle-core dependency  -->
    <artifactId>needle-concurrent</artifactId>
    <version>0.1.3-RELEASE</version>
    <type>jar</type>
</dependency>

Or if you're working with gradle:

 api 'org.sheinbergon:needle-concurrent:0.1.3-RELEASE'

Feature Overview

  • Linux/Windows OS support
  • Affinity aware drop-in replacements for a java thread, providing external control over a thread's affinity.
  • Minimal integration affinity control by calling affinity methods from within the execution scope of a standard thread.
  • Java concurrent extensions, either in the form thread-factory implementation or affinity aware executors
  • Basic Kotlin support

Roadmap

  • Java Fork-Join Pool drop-in replacement
  • Detailed Wiki
  • Kotlin coroutine contenxt extension
  • Affinity lock support
  • Web-based/API affinity reporting/control
  • RxJava integration extension
  • Akka integration extension
  • Vert.X integration extension
  • MacOS support