2.6 kernel is slow as compared to 3.10 kernel

Solution In Progress - Updated -

Issue

1) Testing performance of a 2.6 kernel (RHEL-6.7) kernel and 3.10 kernel (unsupported kernel from elrepo.org).

2) Please see below for testing programs (Java and C) where running the test on a to a 3.10 kernel (elrepo.org) it takes about 1.5 seconds to create +/- 32,000 threads while on RedHat 6.7 with the default kernel 2.6 it takes more than 40 seconds.

To compile and run:

# javac ThreadTest.java
# java ThreadTest 

# gcc -pthread -lpthread threadtest.c -o threads_c
# chmod 755 threads_c ;  ./threads_c


----BEGIN JAVA  ----------------------------------------------------------------------------------
public class ThreadTest {
   public static void main(String[] pArgs) throws Exception {
      try {
         // keep spawning new threads forever
         while (true) {
            new TestThread().start();
         }
      }
      // when out of memory error is reached, print out the number of
      // successful threads spawned and exit
      catch ( OutOfMemoryError e ) {
         System.out.println("Threads created " + TestThread.CREATE_COUNT);
         System.exit(-1);
      }
   }
   static class TestThread extends Thread {
      private static int CREATE_COUNT = 0;
      public TestThread() {
         CREATE_COUNT++;
      }
      // make the thread wait for eternity after being spawned
      public void run() {
         try {
            sleep(Integer.MAX_VALUE);
         }
         // even if there is an interruption, dont do anything
         catch (InterruptedException e) {
         }
      }
   }
}

----END JAVA -------------------------------------------------------------------------------------


----BEGIN C  ----------------------------------------------------------------------------------
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
void *keep_busy(void *);
int main()
{
   int result, i = 0;
   pthread_t thread_id;
   while ((result = pthread_create( &thread_id, NULL, keep_busy, NULL)) == 0) {
        printf ("Create thread %10d\r", ++i);
   }
   return result;
}
void *keep_busy(void *dummyPtr)
{
   while (1) {
      sleep(1);
   }
}
----END C  ------------------------------------------------------------------------------------

3) From a attached perf tool output its clearly visible that find_vma is eating the CPU in 2.6 kernel.

Environment

  • Red Hat Enterprise Linux 6.7
  • kernel-2.6.32-504.el6.x86_64
  • kernel-lt-3.10.94-1.el6.elrepo.x86_64

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content