Bug #25469 Patch: Realtime scheduler for NDB Cluster
Submitted: 8 Jan 2007 17:38 Modified: 6 Nov 2009 11:02
Reporter: Lenz Grimmer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S4 (Feature request)
Version:mysql-5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[8 Jan 2007 17:38] Lenz Grimmer
Description:
The following patch was written and contributed by Mikael Ronström.

Description:

This patch introduces 3 new configuration parameters in MySQL Cluster:

 - RealtimeScheduler
 - LockExecuteThreadToCPU
 - LockMaintenanceThreadsToCPU

It also fixes an existing configuration parameter LockPagesInMainMemory, this parameter was effectively a no-op due to a bug in the NDB Data Node SW.

These parameters together with the usage of Dolphin SuperSockets turn MySQL Cluster into a real-time DBMS. They will be of benefit also to other users of MySQL Cluster.

Description of new parameters:
Realtime Scheduler means that the NDB Data Node will run in real-time scheduling priority. It will set the priority of the main thread to low + 1 and the priority of the other threads to low + 3 to ensure that the main thread can be interrupted by the other threads in the NDB data node. It is also set to lower values to avoid interaction with OS processes running at very high RT prios. It can be either 0 (off) or 1 (on).

LockExecuteThreadToCPU means that the main thread of the NDB Data Node will be locked to a CPU, the CPU is given by the cpu_id.

LockMaintenanceThreadToCPU means that the other threads of the NDB Data Node will be locked to a CPU, the CPU is given by the cpu_id.

RealtimeScheduler can be set also while MySQL Cluster is running through the
management client command. This command will set real-time scheduling off (1 will set it to on)

LockExecuteThreadToCPU can be set also while MySQL Cluster is running through the management client command. This command will set LockExecuteThreadToCPU to cpu_id 0 in all Data Nodes.

LockMaintenanceThreadToCPU can be set also while MySQL Cluster is running
through the management client command. This command will set LockMaintenaceThreadToCPU to cpu_id 1 in all Data Nodes.

Locking to CPU's and setting realtime scheduling mode is OS dependent. The patch includes a patch for Linux and Solaris. This includes handling of autoconf. It has been tested and verified on a cluster of Linux boxes using Fedora Core 5.

The patches have been fairly heavily used in benchmarking DBT2 so should be tested at a fairly high level.

How to repeat:
Review and apply the patch, observe speed improvement.
[8 Jan 2007 17:39] Lenz Grimmer
dolphin_rt.patch

Attachment: dolphin_rt.patch (text/x-patch), 34.03 KiB.

[6 Nov 2009 10:57] Gustaf Thorslund
With help of 

shell> bzr annotate --long ConfigInfo.cpp | less

and

shell> bzr log --long -n0 | less

this appears to have been fixed awhile back.

            revno: 2476.941.66
            committer: tomas@whalegate.ndb.mysql.com
            timestamp: Sat 2007-10-13 09:09:28 +0200
            message:
              WL#4096
              Real time settings and perf improvements in ndb kernel
              Add 5 new configuration variable:
              1) Boolean to set threads in real-time priority
              2) Lock main thread to a CPU (parameter is cpu id)
              3) Lock other threads to a CPU (parameter is cpu id) all these requires ndbd started as root to have any effect
              4) Spin timer in scheduler loop, number of microseconds we'll spin in loop waiting for messages to arrive before going to sleep
              5) Execution timer in scheduler loop, number of microseconds we'll execute in loop before we send messages gathered during execution