Exceptions + Performance on path without exceptions

Discussion in 'C++' started by gratch06@gmail.com, Apr 16, 2007.

  1. Guest

    The application I'm working on will run on Linux, in user space. If I
    use exception handling in parts of the application, will that affect
    the performance of sections of code which do not use any exception
    handling? Basically, I'm looking at optimizing a critical path, and
    wondering if I can keep the exceptions elsewhere in code which are
    working fine.
    , Apr 16, 2007
    #1
    1. Advertising

  2. peter koch Guest

    On 16 Apr., 19:23, wrote:
    > The application I'm working on will run on Linux, in user space. If I
    > use exception handling in parts of the application, will that affect
    > the performance of sections of code which do not use any exception
    > handling? Basically, I'm looking at optimizing a critical path, and
    > wondering if I can keep the exceptions elsewhere in code which are
    > working fine.


    One common implementation of exception handling adds overhead only in
    the case that an exception is thrown, and so far as I know gcc on
    Linux uses that approach. In that case you should be safe in all the
    unexceptional cases, but you'd need to measure before knowing for
    sure, of course.

    /Peter
    peter koch, Apr 16, 2007
    #2
    1. Advertising

  3. On 2007-04-16 19:23, wrote:
    > The application I'm working on will run on Linux, in user space. If I
    > use exception handling in parts of the application, will that affect
    > the performance of sections of code which do not use any exception
    > handling? Basically, I'm looking at optimizing a critical path, and
    > wondering if I can keep the exceptions elsewhere in code which are
    > working fine.


    First of all, do you have any reason (such as measurements) to believe
    that your code is losing execution-speed due to exceptions? Don't forget
    the golden rule of optimization: measure first.

    Some compilers allow you to turn off exceptions, so if you can compile
    the critical code without exceptions and the other with it might solve
    the problem for you. But it probably means creating special rules in
    your Makefiles or whatever you are using.

    --
    Erik Wikström
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=, Apr 16, 2007
    #3
  4. writes:

    > The application I'm working on will run on Linux, in user space. If I
    > use exception handling in parts of the application, will that affect
    > the performance of sections of code which do not use any exception
    > handling? Basically, I'm looking at optimizing a critical path, and
    > wondering if I can keep the exceptions elsewhere in code which are
    > working fine.


    You must have used a profiler to identify the critical path, right? What
    did the profiler say about the code you're asking about?

    sherm--

    --
    Web Hosting by West Virginians, for West Virginians: http://wv-www.net
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Sherm Pendley, Apr 16, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jm
    Replies:
    1
    Views:
    507
    alien2_51
    Dec 12, 2003
  2. Replies:
    28
    Views:
    7,357
    Matt Atterbury
    Jul 15, 2005
  3. Michael Andersson

    Exceptions performance penalty

    Michael Andersson, Sep 2, 2003, in forum: C++
    Replies:
    7
    Views:
    546
    Oliver S.
    Sep 3, 2003
  4. Chris

    Performance and Exceptions

    Chris, Aug 9, 2006, in forum: Java
    Replies:
    4
    Views:
    413
    Chris Smith
    Aug 9, 2006
  5. Software Engineer
    Replies:
    0
    Views:
    324
    Software Engineer
    Jun 10, 2011
Loading...

Share This Page