Invictus
Invictus

Reputation: 4338

Processes of Job through GUI executes on same Virtual Processeor While through Command line Utilises Whatever VIrtual Processor is Free

I have an Application . We can run jobs on it through GUI and through command line . The server has 2 Physical CPUs and 32 processor-cores . The processor-cores on CPU1 are(0-7,16-23) While on CPU2 are (8-15,24-31). When i run the job from command line, I can see my processes run on different virtual processor-cores Which include virtual processor-cores of CPU1 and CPU2 .While When i run it through GUI only 1 virtual processor-core is utilised and that in my case is cpu31 of Physical CPU 2. This is leading to performance issue as job takes more time to complete from GUI than on the command line.

The prstat statistics for job run through command line reveal this :-

     9282 hercules   40M   27M sleep   20    0   0:00:01 0.1% process2/1
     9282 hercules   45M   33M cpu23   29    0   0:00:01 0.1% process2/2
     9282 hercules   45M   33M sleep   49    0   0:00:01 0.1% process2/2
     9359 hercules   39M   29M sleep   60    0   0:00:00 0.1% process1/1
     9282 hercules   45M   33M sleep   59    0   0:00:01 0.1% process2/2
     9359 hercules   39M   29M sleep   59    0   0:00:00 0.1% process1/1
     9282 hercules   45M   33M sleep   59    0   0:00:01 0.1% process2/2
     9282 hercules   45M   33M sleep   59    0   0:00:01 0.1% process2/2
     9282 hercules   45M   33M sleep   49    0   0:00:01 0.1% process2/2
     9282 hercules   45M   33M sleep   59    0   0:00:01 0.1% process2/2
    14945 hercules   53M   42M cpu28   50    0   0:00:04 0.6% process1/1
    14945 hercules   53M   42M cpu15   40    0   0:00:09 1.1% process1/1
    14945 hercules   53M   42M cpu8    40    0   0:00:14 1.5% process1/1
    14945 hercules   54M   42M cpu11   20    0   0:00:19 1.9% process1/1
    14945 hercules   54M   43M cpu12   10    0   0:00:24 2.1% process1/1
    14945 hercules   54M   43M cpu9    20    0   0:00:29 2.3% process1/1
    14945 hercules   54M   43M cpu8    20    0   0:00:34 2.5% process1/1
    14945 hercules   54M   43M cpu11   20    0   0:00:39 2.6% process1/1
    14945 hercules   55M   44M cpu30   10    0   0:00:44 2.7% process1/1
    14945 hercules   55M   44M cpu3    20    0   0:00:49 2.8% process1/1
    14945 hercules   55M   44M cpu8    20    0   0:00:51 2.4% process1/1
    14945 hercules   55M   44M cpu28   10    0   0:00:56 2.6% process1/1
    14945 hercules   56M   44M cpu9    10    0   0:01:01 2.7% process1/1
    14945 hercules   56M   45M cpu13    0    0   0:01:06 2.8% process1/1
    14945 hercules   56M   45M cpu25   10    0   0:01:11 2.8% process1/1
    14945 hercules   56M   45M cpu2     0    0   0:01:16 2.9% process1/1
    14945 hercules   56M   45M sleep   50    0   0:01:20 2.8% process1/1
    14945 hercules   57M   46M cpu15    0    0   0:01:25 2.8% process1/1
    14945 hercules   57M   46M cpu24    0    0   0:01:30 2.9% process1/1
    14945 hercules   57M   46M cpu29    0    0   0:01:35 2.9% process1/1
    14945 hercules   57M   46M cpu14    0    0   0:01:40 3.0% process1/1
    14945 hercules   58M   47M cpu13    0    0   0:01:45 3.0% process1/1
    14945 hercules   58M   47M cpu5    50    0   0:01:53 2.9% process1/1
    14945 hercules   58M   47M cpu8    50    0   0:01:58 2.9% process1/1
    14945 hercules   58M   47M cpu8    40    0   0:02:03 3.0% process1/1
    14945 hercules   59M   48M cpu14   30    0   0:02:08 3.0% process1/1
    14945 hercules   59M   48M cpu29   30    0   0:02:13 3.0% process1/1
    14945 hercules   59M   48M cpu11   20    0   0:02:18 3.0% process1/1
    14945 hercules   60M   49M cpu30   30    0   0:02:23 3.0% process1/1
    14945 hercules   60M   49M cpu12   20    0   0:02:28 3.1% process1/1
    14945 hercules   86M   78M cpu9    53    0   0:02:34 1.3% process1/2
    14945 hercules   91M   83M cpu31   43    0   0:02:39 0.7% process1/2
    14945 hercules   92M   83M cpu9    53    0   0:02:41 0.6% process1/2
    14945 hercules   92M   83M cpu15   45    0   0:02:42 0.6% process1/2
    14945 hercules   92M   84M sleep   32    0   0:02:43 0.6% process1/2
    14945 hercules   92M   84M sleep   33    0   0:02:44 0.6% process1/2
    14945 hercules   93M   84M sleep   32    0   0:02:45 0.6% process1/2
    14945 hercules   93M   85M sleep   43    0   0:02:46 0.6% process1/2
    14945 hercules   93M   85M cpu11   23    0   0:02:47 0.6% process1/2

While i Run the job through GUI the other virtual processor-cores are not utilised and it runs on a single processor-core cpu31 in my case . I feel this is the reason Why when i run the job from command line its get completed lot Quickly than When i run the job through GUI . PRSTAT statistics When job run through GUI reveal this :-

    13555 hercules   40M   27M sleep   59    0   0:00:01 0.1% process2/1
    13555 hercules   45M   33M sleep   55    0   0:00:01 0.2% process2/2
    13555 hercules   45M   33M sleep   59    0   0:00:01 0.1% process2/2
    13652 hercules   39M   29M sleep   59    0   0:00:00 0.1% cacad_main_prin/1
    13555 hercules   45M   33M sleep   59    0   0:00:01 0.1% process2/2
    17810 hercules   38M   27M run     41    0   0:00:01 0.1% process1/1
    17810 hercules   53M   42M run     30    0   0:00:04 0.6% process1/1
    17810 hercules   53M   42M run     30    0   0:00:08 1.0% process1/1
    17810 hercules   53M   42M cpu31   30    0   0:00:12 1.3% process1/1
    17810 hercules   53M   42M run     20    0   0:00:16 1.5% process1/1
    17810 hercules   54M   42M cpu31   30    0   0:00:20 1.7% process1/1
    13545 hercules 4492K 2756K cpu31   51    0   0:00:01 0.1% process3/1
    17810 hercules   54M   43M run     20    0   0:00:24 1.8% process1/1
    17810 hercules   54M   43M cpu31   30    0   0:00:27 1.9% process1/1
    17810 hercules   54M   43M cpu31   30    0   0:00:31 2.0% process1/1
    13545 hercules 4492K 2756K cpu31   55    0   0:00:01 0.1% process3/1
    17810 hercules   54M   43M cpu31   20    0   0:00:35 2.1% process1/1
    17810 hercules   54M   43M cpu31   20    0   0:00:39 2.1% process1/1
    17810 hercules   55M   43M cpu31   20    0   0:00:43 2.2% process1/1
    17810 hercules   55M   44M run     20    0   0:00:46 2.2% process1/1
    13545 hercules 4492K 2756K cpu31   56    0   0:00:02 0.1% process3/1
    17810 hercules   55M   44M cpu31   10    0   0:00:50 2.2% process1/1
    13545 hercules 4492K 2756K sleep   42    0   0:00:03 0.1% process3/1
    17810 hercules   55M   44M cpu31   10    0   0:00:54 2.3% process1/1
    17810 hercules   55M   44M run      0    0   0:00:58 2.3% process1/1
    17810 hercules   55M   44M cpu31   10    0   0:01:02 2.3% process1/1
    17810 hercules   56M   44M cpu31   11    0   0:01:06 2.3% process1/1
    17810 hercules   56M   45M cpu31    0    0   0:01:10 2.3% process1/1
    13545 hercules 4492K 2756K sleep   59    0   0:00:04 0.1% process3/1
    17810 hercules   56M   45M cpu31    1    0   0:01:13 2.3% process1/1
    17810 hercules   56M   45M cpu31    0    0   0:01:17 2.3% process1/1
    17810 hercules   56M   45M cpu31    0    0   0:01:21 2.3% process1/1
    17810 hercules   56M   45M cpu31    0    0   0:01:25 2.3% process1/1
    17810 hercules   57M   45M cpu31    0    0   0:01:28 2.3% process1/1
    17810 hercules   57M   46M run      0    0   0:01:32 2.3% process1/1
    13545 hercules 4492K 2756K run      0    0   0:00:05 0.1% process3/1
    17810 hercules   57M   46M cpu31    0    0   0:01:36 2.3% process1/1
    17810 hercules   57M   46M cpu31    0    0   0:01:39 2.3% process1/1
    13545 hercules 4492K 2756K run     59    0   0:00:06 0.1% process3/1
    17810 hercules   57M   46M cpu31   50    0   0:01:43 2.3% process1/1
    17810 hercules   57M   46M cpu31   40    0   0:01:47 2.3% process1/1
    17810 hercules   58M   46M cpu31   40    0   0:01:51 2.3% process1/1
    17810 hercules   58M   47M run     40    0   0:01:55 2.3% process1/1
    17810 hercules   58M   47M run      0    0   0:01:58 2.3% process1/1
    17810 hercules   58M   47M cpu31   30    0   0:02:02 2.3% process1/1
    17810 hercules   58M   47M cpu31   30    0   0:02:06 2.3% process1/1
    13545 hercules 4492K 2756K sleep   59    0   0:00:07 0.1% process3/1

I have deleted the stats When my process Where in sleep mode. At that point of time java process was running on cpu31 .

I want to know if there is something in code that i needs to look through or is it something related to When process are run from command line, the various sub process can run on different virtual CPUS , While running from GUI its dedicated to a particular Virtual processor-core here in my case cpu31 . Or is it related to some SERVER CONFIGURATION , Where running through command line and running through GUI can make a difference

Upvotes: 0

Views: 85

Answers (1)

Adam Mihalcin
Adam Mihalcin

Reputation: 14468

How does you GUI application actually perform work? Does the work happen in event handlers for button presses, mouse clicks, etc, or do these event handlers kick off threads that perform the actual work? This is important because GUI frameworks are single-threaded and in some operating systems windows have thread affinity (more explanation is provided in SO questions here and here).

If your event handlers don't kick off new threads to perform the actual work, it's not surprising at all that everything runs on a single logical processor. Since all the GUI work has to run on a kernel thread, and since it's perfectly reasonable for a kernel to keep each thread running on the same processor (this helps with performance because of processor caches), the kernel schedules all the GUI work, including the event handlers, on the same processor.

The console application doesn't have the operating system limitations on threads, so the Java runtime environment is free to make itself multithreaded and then execute your bytecode however it chooses. I can only assume that the Java runtime environment ran your application over multiple processors as a speed boost.

Upvotes: 1

Related Questions