Operating System - HP-UX
1833858 Members
3944 Online
110063 Solutions
New Discussion

Re: performance problem on string usage

 
inactive account
Frequent Advisor

performance problem on string usage

I encounter great problems of performance when working on strings on HPUX. The CPU usage is far beyond all other OS and CPUS.
I join a small benchmark we did and the results on LINUX, AIX and HPUX.

As my applications deal very much with strings, does anybody knows where to look at or am I missing something?
> mode string
>
> HPISIM 17.200 (HP-UX 32 bits)
> HPISIM 64b 15.400 (HP-UX 64 bits)
> Jupiter 2.500 (Linux)
> SLElusis 8.600 (AIX)
>
>
>
> mode char *
>
>
> HPISIM 1.900
> HPISIM 64b 1.700
> Jupiter 0.400
> SLElusis 1.300
>
>
>
>
> #include
> #include
> #include
> #include
> #include
>
> using namespace std;
>
> #include
> #include
> #include
> #include
>
> int main(int a, char *b[])
> {
> int l = atoi(b[1]);
> int i;
>
>
> if (a == 2)
> {
> for (i = 0; i< l; i++)
> {
> string toto("boujour");
>
> toto += " ?? toi";
>
> if (toto.substr(2,3) == "uju")
> {
> const char * a = toto.c_str();
>
> //printf("a=%s\n", a);
> }
> else
> {
> const char * b = toto.c_str();
>
> //printf("b=%s\n", b);
> }
>
> }
> }
> else
> {
> for (i = 0; i< l; i++)
> {
> char *toto;
>
> toto = (char *)malloc( 50 );
>
> strcpy(toto,"boujour");
>
> strcat(toto , " ?? toi");
>
> if (!memcmp(toto+2 , "uju" , 3))
> {
> toto[13] = '\0';
> const char * a = toto;
>
> //printf("a=%s\n", a);
> }
> else
> {
> toto[13] = '\0';
> const char * b = toto;
>
> //printf("b=%s\n", b);
> }
>
> free (toto) ;
> }
> }
>
>
> }
>
>
12 REPLIES 12
Bill McNAMARA_1
Honored Contributor

Re: performance problem on string usage

you may be better off refering this to the hp developer site:
http://www.hp.com/go/developer

In any case you spelt bonjour wrong!!

Later,
Bill
It works for me (tm)
Stefan Farrelly
Honored Contributor

Re: performance problem on string usage

I will try it on some servers here if you give me the exact code and compile options - I cant compile what you have listed already, get lots of errors.

Im from Palmerston North, New Zealand, but somehow ended up in London...
inactive account
Frequent Advisor

Re: performance problem on string usage

You are right Bill for bonjour !
but I am not sure it's a dev issue because it seems to be a general problem with HP.
All the benches we are doing show poor results on HP against Linux and AIX

Sorry Stephan here are my compiler 's options on HPUX:

/opt/aCC/bin/aCC -D__unix__ -D__hpux__ -mt -AA -ext +DA1.1 +p +W829,921,652 -DTGVERSION=\"01.00\" -I../tg_sys/include -I../tg_sys/include -I../tg_loaddic_monp/include -I../tg_disp/include -o bin/essai_malloc EXEC/essai_malloc.cxx -L./lib -L../tg_sys/lib -L../tg_sys/lib -L../tg_loaddic_monp/lib -L../tg_disp/lib -ltg_disp -ltg_loaddic_monp -ltg_sys -ltg_disp -ltg_loaddic_monp -ltg_sys 2> EXEC/essai_malloc.out
he
Olav Baadsvik
Esteemed Contributor

Re: performance problem on string usage



Hi,

I can compile the code using this line:

aCC -AA -o string.exe string.c

Please indicate how you invoke the program
and how you measure the time etc.

Olav
inactive account
Frequent Advisor

Re: performance problem on string usage

in this case we did a check of CPU usage at first and then we use -G option and gprof.
Olav Baadsvik
Esteemed Contributor

Re: performance problem on string usage



Hi

I still do not know how you run this program
and what you measure.
If I shall be able to measure if the
results are reasonable (or the same as you get)
I need to know exactly how you perform
your test.

What kind of machine are you running on,
what version of aCC?

Olav
inactive account
Frequent Advisor

Re: performance problem on string usage

I measured CPU usage.
I run the program with one argument which is the number of loops.
Run it 1 000 000 times and
add -G as aCC directive to get a profile check the CPU usage with gprof.

The reason why we did this small test is the global poor performance whe got when porting our applications from Linux and AIX to HPUX.
It is a C++ application ensemble (multi-threaded and multiprocesses) which switches messages and applies different actions on the messages . These messages are mainly characters strings and we are using STL a lot.
We are using glance to take measurement on the real-time.
By the we constated that most of the system calls like malloc are not considered as system calls by glance.
Olav Baadsvik
Esteemed Contributor

Re: performance problem on string usage


Hi,

I advise you to check your compiler-options.
Compiling with different options give
a big difference in execution time for your
test-program.
I have performed the test by starting the
program in the following way:

time string.exe 1000000

Compiler-options time (realtime)

-AA -G +DA2.0 30.2 sec
-AA +DA1.1 21.35 sec
-AA -G +DA1.1 35.76 sec
-AA +DA2.0 15.76 sec
-AA +DA2.0 +O3 11.07 sec

The +DA2.0 tells the compiler to generate
code for a PARISC2.0 processer.
In the compile-info you gave the code is
generated for a PARISC1.1
PARISC2.0 is the PARISC-version in all new
machines.
+O3 tells the compiler to optimize the code.


Olav

inactive account
Frequent Advisor

Re: performance problem on string usage

Thanks Olav
But I can't use the optimise 3 level and I can't use PA2.0 because:
- 1) compile of my objects are rejected with the +O3 option (I'm using a lot of throws/catch and compiler says that's too much).
-2) the target system is Stratus running HPUX only in the 32bits mode...

too bad isn't it?
Olav Baadsvik
Esteemed Contributor

Re: performance problem on string usage

Hi,

The fact that you have a target machine
that is running hp-ux 32bit does not mean
that you can not use the option
+DA2.0
I used a C200 hp-ux 11.00 (32-bit)
for this test.

This means that unless your target-machine is
very old (using PARISC1.1), you should use
+DA2.0

(the option for compiling for 64-bit is
+DA2.0W )

Olav



inactive account
Frequent Advisor

Re: performance problem on string usage

I try the DA2.0 option without optimization but I don't see any improvement on the CPU usage for my real application...
I will retry with +O2 optimize level and check...

Thank you anyway Olav!
H.Merijn Brand (procura
Honored Contributor

Re: performance problem on string usage

Sometimes +Onolimit can help to raise the bar for +O3
Enjoy, Have FUN! H.Merijn