Contact@itspring.com
  • Steps to Pin CPU Core With Java Thread

    While executing a program using multi-core processor, depending on its requirements it might use single core to execute or it might switch cores. Most of the times it is better option to let Operating System handle such things, but what if we want to execute particular process on particular cores to achieve better performance from system, then we can use something Linux has provided us called as 'Affinity'.

    Assigning particular CPU core to a particular process is known as 'affinity' in Linux.

    Every process while getting executed on a core creates a cache of its own. When this process gets shifted to another core this cache needs to be updated. So this updating and left over from previous process's cache cause reduction in performance.

    Instead of this if a particular core is assigned to a process there won't be such problems, no need to remove or update cache, ultimately resulting in better performance. 

    Every thread and interrupt source that belongs to system has this property. This is basically used by OS scheduler while deciding which threads to run on which cores. If processor affinity is used in a better manner, it helps to get maximum performance.

    Process Affinity:

    To assign process to a particular core we will use 'taskset'
     
    taskset:
     
    Syntax: 
     
    taskset [options] [mask | list ] [pid | command [arg]...]
     
    Taskset is used to set or retrieve the CPU affinity of a running process considering its PID(Process ID) or launching a new command with a given affinity. The Linux scheduler obeys this given CPU affinity and the process will run on that core only. While working with threads there is an alternative for taskset i.e. Java-Thread-Affinity
     
    How to use taskset
     
    The taskset tool is part of "util-linux" package in Linux, and most of Linux distros has it as pre-installed by default. If taskset is not available on Linux system, install it as follows.

    How to install taskset on CentOS, Fedora or RHEL

Most Liked Posts

Post A Comment

Your email address will not be published. Required fields are marked*

133F

0 Comments

No Record found
demo content

The Total Economic Impactâ„¢ of ServiceNow

United States Tue Jun 06 2017

Join us for a webinar where we will reveal the quantified value of the Lightspeed Enterprise for customers that are modernizing IT, eliminating service outages, and optimizing performance with real-time analytics.

Guest speakers Liz Witherspoon of Forrester, and study participant Brad Paubel, VP of Internal Technologies at Maritz, will discuss

  • The value drivers for IT and key quantified economic benefits
  • Key challenges that study customers faced and overcame
  • Focus areas and best practices you can use to drive business impact with ServiceNow

Register

Webinar Registration

Enter the characters visible in the box below

JOHV

Share

Share using

Advertise With Us