How to limit the number of processors used by Denodo

Applies to: Denodo 8.0 , Denodo 7.0 , Denodo 6.0
Last modified on: 19 Nov 2021
Tags: Administration Performance

Download document

You can translate the document:

Overview

In order to limit the number of processors we have to take into account the operating system where the Denodo Platform is running.

Windows Systems

There are two ways to set the affinity of the process in Windows, the graphic way and the command line way.

Windows 8, 9, 10

In the Windows 8, 9, & 10, you could do the following steps in order to set the affinity of the process:

  1. Open the Task Manager.
  2. Click on the Details tab, then the list of processes will be shown to you. 
  3. Right-click on the process and choose the “Set Affinity” option.
  4. Then the “Processor affinitywindow will open up as next. Here you can check the cells corresponding to different CPUs.   

Windows XP , 2000 & Windows 7

We can find how to set it up on Windows XP or 2000 ONLY in a graphic mode:

  1. Open Task Manager.
  2. Right-click on the process and choose “Set Affinity”.
  3. Check the CPU IDs (example CPU0, CPU1) that you want the process to run on.      

Windows 2003 server & Windows Vista

        

In MS Windows 2003 server and MS Windows Vista you can launch a process to run on a subset of system cores from the command line as well.

To launch the process you have to run that program from a command line (or from a .bat file):

        start /affinity [n] [process name]

The 'n' parameter is the affinity mask, in hexadecimal. This value specifies which of the available CPU cores will be used to run the program.

n (Decimal)

n (Hexadecimal)

Processor(s) used

1

0x1(0001)

Core #0

2

0x2(0010)

Core #1

3

0x3(0011)

Cores #0 & #1

4

0x4(0100)

Core #2

8

0x8(1000)

Core #3

15

0xF(1111)

Cores #0,#1, #2 & #3

For instance, you could create a script with the following contents to limit the cores used by the Denodo Platform to the first 4 cores:

start "" /affinity F "DENODO_HOME/bin/denodo_platform.exe"


If instead of this you want to start the Denodo Windows services with an affinity restriction, edit the file
<DENODO_HOME>/conf/<product>/XXXservice.conf and set the wrapper.affinity property to the appropriate mask value.

Linux Systems

There are two ways of limiting the CPU in Linux systems:

  • Setting the CPU affinity, to indicate which CPU cores Denodo is allowed to use
  • Setting the CPU quota, to indicate the percentage of CPU that Denodo is allowed to use, that is converted to an equivalent number of CPU cores.

Setting CPU affinity

NOTE: On UNIX systems it is possible to limit the Denodo usage of processors. However, it will NOT be possible to apply this limitation in terms of license verification with a JRE version older than 1.8.0_121 (including the JRE 7 version embedded with the Denodo Platform 6.0). See the last section on this document for more information.

The taskset command is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new command with a given CPU affinity.

The default behavior is to run a new command with a given affinity mask:

        taskset [mask] [command [arguments]]

The masks are typically given in hexadecimal. For example, 0×00000001 is core #0, 0×00000003 is cores #0 and #1.

For example, if we want to launch Denodo VDP Server in CPU#0 we have to execute the following command in a terminal:

        taskset 0x00000001 ./vqlserver_startup.sh &

An alternative syntax for the taskset command will be to use the “-c” option to specify a numerical list of processors. The list may contain multiple items, separated by comma, and ranges. For instance:

                taskset -c 0 ./vqlserver_startup.sh &

will run the VDP server in CPU #0 and

                taskset -c 0-3 ./vqlserver_startup.sh &

will run the VDP server in 4 CPUs (#0 to #3).

Setting CPU quota

NOTE: On Linux systems it is possible to limit the Denodo usage of processors. However, it will NOT be possible to apply this limitation in terms of license verification with a JRE version older than 1.8.0_191 (including the JRE 8 version embedded with the Denodo Platform 7.0). See the last section on this document for more information.

The cgroups (abbreviated from control groups) are a Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes.

You can use cgroups to limit the number of processors available to the Denodo Platform.

To get started, you need to create a group with a subsystem and a name.

A subsystem is a computer resource that we want to control. To limit CPU the relevant subsystems are:

  • cpu: Determine the proportion of CPU to use.
  • cpuset: Allows you to assign memory cores and nodes to control groups.

The cpuset option is used to set the CPU affinity, and we have already covered that method in the previous section, so we will focus on the cpu subsystem, as it allows us to set a quota.

Use cgcreate to create the control group, indicating the cpu subsystem and a cpulimit name (or whatever you decide to use) for the control group with the parameter -g cpu:/cpulimit:

cgcreate -g cpu:/cpulimit

To configure the number and usage of the cores, there are two parameters:

  • cpu.cfs_quota_us: the total available run-time within a period (in microseconds)
  • cpu.cfs_period_us: the length of a period (in microseconds), set by default  to 100ms.

So to limit the number of cores we will have to play with these two parameters.

If we want Java to report that 4 cores are available for the process, we should have a quota value that divided by the period value results in a value (value = quota/period)  that is between 3 and 4 as the number of processors will be rounded to the next integer.

Example:

Limit a group to 2 CPUs worth of runtime (quota = 1000ms and period = 500ms):

 

cgset -r cpu.cfs_quota_us=1000000 cpulimit

cgset -r cpu.cfs_period_us=500000 cpulimit

Finally to start the VQL Server with the CPU limits that we have defined we execute the startup script with the control group created:

cgexec -g cpu:cpulimit ./vqlserver_startup.sh

Tip: The CFS period allows us to set the maximum burst time. By using a small period here we are ensuring a consistent latency response at the expense of burst capacity.

Solaris OS

Steps to modify the subset or cores associated to a process:

  1. Get root access to the machine
  2. run `mpstat` to see the processor IDs
  3. Use `psrset` command to create a set of processors. The command will return a set ID
  4. Use `psrset` command to bind the CPU set to the process
  5. Use `psrset` command to delete the CPU set.

Example:

$ mpstat
 CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
   0   25   0   41   113  101  151   12    9   11    0    50    4   1   1  93
   1   26   0  136   182  207  107   11    9   11    0    57    5   1   1  93
   2   26   0   38   171  161  131   12    9   11    0    39    4   1   1  93
   3   26   0   46   160  149  134   12   10   11    0    51    5   1   1  93
 $ psrset -C 0 1  // to create a set, where CPU IDs came from mpstat command above
 $ psrset -b 1 2325 // where 1 is the process-set ID, and 2325 is the process (e.g partition) ID.
 $ psrset -d 1   // will remove the processor set

Checking affinity in Java

It is possible to easily check using Java the number of cores a program runs on:

    Runtime runtime = Runtime.getRuntime();

    int num_cores = runtime.availableProcessors();

This is the functionality that the Denodo Platform uses to get the number of processors when there is a limitation on the number of processors in the installed license. The behavior of this operation is different from Windows to UNIX systems:

  • On Windows the availableProcessors method returns the affinity cores assigned to the process (not total machine cores).
  • On UNIX like systems the availableProcessors method will return the affinity cores assigned to the process when using a JRE version 1.8.0_121 or newer (Denodo 7 and 8 include a JRE newer than 1.8.0_121). JRE versions older than 1.8.0_121 (including the JRE 7 embedded with the Denodo Platform 6.0) will always return the total number of cores in the machine, even if they are not actually being used by any Denodo process. This means that, in order to use a Denodo License with a restriction on the maximum number of processors in Denodo 6 or previous versions using taskset, the default JRE should be changed to a JRE version 1.8.0_121 or newer.
  • On Linux systems the availableProcessors method will return the equivalent number of cores assigned based on available cpu quota to the process when using a JRE version 1.8.0_191 or newer (Denodo 8 includes a JRE newer than 1.8.0_191). JRE versions older than 1.8.0_191 (including the JRE8 embedded with the Denodo Platform 7.0 or the JRE 7 embedded with the Denodo Platform 6.0) will always return the total number of cores in the machine, even if they are not actually being used by any Denodo process. This means that, in order to use a Denodo License with a restriction on the maximum number of processors in Denodo 7 or previous versions using cgroups, the default JRE should be changed to a JRE version 1.8.0_191 or newer.

Questions

Ask a question
You must sign in to ask a question. If you do not have an account, you can register here

Featured content

DENODO TRAINING

Ready for more? Great! We offer a comprehensive set of training courses, taught by our technical instructors in small, private groups for getting a full, in-depth guided training in the usage of the Denodo Platform. Check out our training courses.

Training