peter-lawrey / Java-Thread-Affinity

Control thread affinity for Java
379 stars 77 forks source link

Include strategy: Same socket, different core #18

Closed akerbos closed 12 years ago

akerbos commented 12 years ago

See the title; it is impossible to model this with existing strategies but I think it is quite important for machines with multiple sockets which have multiple cores each. Therefor I think it should be included in AffinityStrategies.

  SAME_SOCKET_DIFFERENT_CORE {
    public boolean matches(int cpuId, int cpuId2) {
      CpuLayout cpuLayout = AffinityLock.cpuLayout();
      return     cpuLayout.socketId(cpuId) == cpuLayout.socketId(cpuId2)
              && cpuLayout.coreId(cpuId) != cpuLayout.coreId(cpuId2);
    }
  }
peter-lawrey commented 12 years ago

The SAME_SOCKET option now does this. You can use SAME_SOCKET, SAME_CORE or SAME_CORE, SAME_SOCKET if either is acceptable.