Re: Anybody may help to explain the issue of the source code , next "try-throw-catch" will cost more cpu time than previous one

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



f z wrote:
> Happy New Year! Haley,

And a Happy New Year to you.

> Thanks for your help!
> 
> In your result , there isn't any variation in the time taken.
> 
> My test code can be like this :
> 
> while(1){
>  try_throw_catch_block(0); // it takes about 133xxxxx every time
>  try_throw_catch_block(1); // it takes about 148xxxxx every time
>  try_throw_catch_block(2); // it takes about 158xxxxx every time
>  try_throw_catch_block(3); // it takes about 172xxxxx every time 
> }

> In my opinion , next "try_throw_catch" in writing order will takes more cpu time than the previous one.
> 
> Then , I will use oprofile to check it. 

Yes, I see the same result as you.

I think I might know what is happening.  When a throw is caught, there
is a search for the catch region.

_Unwind_IteratePhdrCallback searches for the eh_frame that contains
the PC we're looking for.  There is a binary search for the catch
region.  Like all binary searches, this is not constant time, so I
suspect that's what we're seeing.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux