Operating System - OpenVMS
1753895 Members
7551 Online
108809 Solutions
New Discussion

Small C Quick sort program ran on OpenVMS Blade Server much slower than on Windows or Linux

 
kanchimo
Occasional Visitor

Small C Quick sort program ran on OpenVMS Blade Server much slower than on Windows or Linux

Dear everybody,

We try to run a simple C program as below:

#include <stdio.h>
#include <stdlib.h>  // qsort
#include <time.h>
int uint64cmpfunc ( const void * a, const void * b ) {
   return ( *(unsigned long long int*)a - *(unsigned long long int*)b );
}

unsigned long long int *uint64random( unsigned long int sizw ) {
    
    unsigned long int n;
    unsigned long long int *p;
    long int val1, val2;
    
    p = malloc( sizeof(unsigned long long int) * sizw );
    if( p == NULL )
    {
        fprintf( stderr, "could not alloc memory\n" );
        return NULL;
    }
    
    for( n = 0; n < sizw; ++n ) {
        val1 = random();
        val2 = random();
        p[n] = val2 + val1;
    }
    
    return p;
}

int main( int argc, char *argv[] )
{
    unsigned long int n = 50000000;
    unsigned long int i;
    unsigned long long int *vals = NULL;
    time_t begin, end;
    
    srand( time(NULL) );
    
    begin = time(NULL);
    vals = uint64random( n );
    end = time(NULL);
    
    fprintf( stdout, "random tooked: %ld seconds\n", end - begin );
    
    if( vals == NULL )
        return (-1);
    
 
    begin = time(NULL);
    qsort( vals, n, sizeof(unsigned long long int), uint64cmpfunc );
    end = time(NULL);
    
    fprintf( stdout, "sort tooked: %ld seconds\n", end - begin );
    
    free(vals);
    
    return 0;
}

It took us around 30s to finish qsort on our BL860c i2 with 96 GB RAM. However, on my Windows 10 laptop (4 GRAM), just take less than 1 second.

Do you have any idea about that?

Thanks,

Kanchimo

2 REPLIES 2
Hein van den Heuvel
Honored Contributor

Re: Small C Quick sort program ran on OpenVMS Blade Server much slower than on Windows or Linux

- check compiler options notably for optimizer and architecture settings.  OpenVMS tools default are typically on the safe and slow side.

- Where is the time going, and if CPU time which 'mode'  ($ MONI MODE) it should be 100% User-mode, but cosidering the size of the array there may be soft pagefaulting to access the whole array through a limites workgin set (again, openVMS starts with a safe but slow setting to make sure a user, out-of-the-box, cannot impact the whole server with other users too much.

50,000,000 elements of 64 bytes, that's 400MB right? So that could be bigger that your workingset(extend)

$ SHOW WORK

Hope this helps some,

And... it might just be slower.

If it is critical, then you may need a CPU profiler to see where the time is spend (moving, comparing,...)

Hein

 

 

Steven Schweda
Honored Contributor

Re: Small C Quick sort program ran on OpenVMS Blade Server much slower than on Windows or Linux

> - check compiler options notably for optimizer and architecture
> settings. [...]

   Around here, /OPTIMIZE=LEVEL=5 made approximately no difference.

its $ tcpip show version

  HP TCP/IP Services for OpenVMS Industry Standard 64 Version V5.7 - ECO 2
  on an HP rx2660  (1.59GHz/9.0MB) running OpenVMS V8.4

its $ cc /version
HP C V7.3-020 on OpenVMS IA64 V8.4    

its $ show work
  Working Set (pagelets)  /Limit=133600  /Quota=267200  /Extent=2103296
  Adjustment enabled      Authorized Quota=267200  Authorized Extent=2103296

  Working Set (8Kb pages) /Limit=8350  /Quota=16700  /Extent=131456
                          Authorized Quota=16700  Authorized Extent=131456

its $ cc qsort1 /obj = qsort1id
its $ link qsort1id

its $ cc qsort1 /obj = qsort1io /optimize=level=5
its $ link qsort1io

its $ r qsort1id
random tooked: 2 seconds
sort tooked: 32 seconds

its $ r qsort1io
random tooked: 1 seconds        (The random() loop may get little better.)
sort tooked: 32 seconds


> If it is critical, then you may need a CPU profiler to see where the
> time is spend (moving, comparing,...)

   Practically all the execution is in the CRTL: HELP CRTL qsort

> And... it might just be slower.

   Looks that way (to a casual observer).