Linux Completely Fair Scheduler affects Java performance
Java applications that use synchronization extensively might perform poorly on Linux distributions that include the Completely Fair Scheduler. If you encounter this problem, there are two possible workarounds.
You might observe extremely high CPU usage by your Java application, and very slow progress through synchronized blocks. The application might appear to hang due to the slow progress.
The Completely Fair Scheduler (CFS) is a scheduler that was adopted into the mainline Linux kernel as of release 2.6.23. The CFS algorithm is different from previous Linux releases. It might change the performance properties of some applications. In particular, CFS implements sched_yield() differently, making it more likely that a thread that yields will be given CPU time regardless.
The new behavior of sched_yield() might adversely affect the performance of synchronization in the IBM J9 virtual machine.
This problem might affect IBM SDK, Java 2 Technology edition V5.0 and IBM SDK, Java Technology Edition, Version 6 (up to and including service refresh 4) running on Linux kernels that include the Completely Fair Scheduler.
Some Linux distributions that include the Completely Fair Scheduler are:
- Ubuntu 8.04
- SUSE Linux Enterprise Server 11
Resolving the problem
If you observe poor performance of your Java application, there are two possible workarounds:
- Invoke your Java application with the following additional argument:
- Configure the Linux kernel to use the more backward-compatible heuristic for sched_yield(), by setting the sched_compat_yield tunable kernel property to 1.
echo "1" > /proc/sys/kernel/sched_compat_yield
You should not use these workarounds unless you are experiencing poor performance.
Note: From IBM SDK, Java Technology Edition Version 6 service refresh 5 and all later SDK releases, the use of CFS in the kernel is detected and options are enabled that invoke optimizations.