This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: My plans on EH infrastructure


Jan Hubicka a écrit :
EH throwing is so costly (20000 cycles minimum reported in PR 6588) that,
in some cases, even if it's exceptional, like a 10^-4 probability
of throwing, you will see it show up on the profile.

Having EH delivery at reasonnable speed would really open up the design
space : it would allow to use a non-intrusive way of reporting "exceptional"
return values in many more places.  By non-intrusive, I mean that you
don't need to change the return type of your functions and manually
propagate your exceptional return values (or worse, use global or
thread-local variables).

Problem here is that EH delivery mechanizm is part of C++ ABI. The mechanizm is indeed compicated. I am sure runtime can be optimized, but probably not made something like thousdand times faster than it is now.

In PR6588, I had mentioned that, at the time, Sun CC was 10 times faster than GCC. That would already be something.

If I remember correctly, for the application that motivated the PR,
the cost of exceptions compared to propagating an error code through the
return type of functions was about 10%.  If we cut the cost of exception
delivery by a factor of 10, this makes it only an overhead of 1% overall,
which might be lost in the noise, and therefore it might become a viable
option.

So if we start optimizing special cases of EH to be fast, it will not
allow users to use it in performance critical stuff since they will
never know if they hit the fast or slow path and will only get
surprises.

Maybe, but for exceptions which are relatively local, say, inside a given library, the user can assume that GCC has switched to the "local ABI" with fast internal exceptions, since he may have compiled the library as one translation unit, so he may be able to control the possible scope of the exceptions. And so he may be able to make a good guess about what the costs will be. My application has this property, but again, maybe it's only me.

We can implement interprocedural pass that will identify EH that is
delievred locally in the unit and use alternative EH delivery mechanizm,
but it would be a lot of effort to implement faster variant of runtime
that works on so many targets as GCC has and the benefits would be IMO
quite low.

Possibly.


--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]