Bug 18414 - Performance problem in "operator new" and "operator new[]"
Summary: Performance problem in "operator new" and "operator new[]"
Status: RESOLVED DUPLICATE of bug 14563
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.3.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-10 06:06 UTC by Kenneth Duda
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-cygwin
Target: i686-pc-cygwin
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Duda 2004-11-10 06:06:14 UTC
I wrote a test to measure the basic performance of "operator new[]". 
To my surprise, it came out to 3.1 usec per new/delete pair.
malloc(), on the other hand, came out to 980 microseconds.  

How could "operator new[]" be 3.5 times slower than "malloc"?
Well, it turns out that that time is almost entirely spent 
guaranteeing that malloc() doesn't wake up one morning and 
decide to throw some random exception.  Specifically, if I 
change the declaration of "operator new" (libstdc++-3.0/libsupc++/new_op.cc)
from:

  void *
  operator new (std::size_t sz) throw (std::bad_alloc)

to simply

  void *
  operator new (std::size_t sz) 

(and likewise for "operator new[]") then performance 
is much better --- operator new[] performs almost
indistinguishably from malloc().

I suggest fixing this by removing the "throw (std::bad_alloc)" from
the definition of "operator new" and "operator new[]".

I'm curious about any reaction you might have to this bug report.
Please feel free to contact me at kjd@duda.org.

Thanks,

Kenneth Duda
Comment 1 Danny Smith 2004-11-10 06:59:26 UTC
This is a duplicate of PR 14563 
Danny
Comment 2 Giovanni Bajo 2004-11-10 08:21:27 UTC

*** This bug has been marked as a duplicate of 14563 ***