public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "paulthomas2 at wanadoo dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/14563] octave built under Cygwin very slow
Date: Sat, 03 Apr 2004 17:54:00 -0000	[thread overview]
Message-ID: <20040403175430.32274.qmail@sources.redhat.com> (raw)
In-Reply-To: <20040312233606.14563.paulthomas2@wanadoo.fr>


------- Additional Comments From paulthomas2 at wanadoo dot fr  2004-04-03 17:54 -------
Subject: Re:  octave built under Cygwin very slow

Hi,

It's good to know that you are enagaging with this one.  I sent a 
message this morning that some how got deleted in the process of being 
sent; it's main content was not to forget that the most extreme 
manifestation of the difference is with g++ 3.3.1 (cygming special) for 
which

new/delete takes 1900ns/loop
malloc/erase          400ns/loop  

This is how we detected this in the first place.

For reference, on the same Athlon 1700, 3.2.2 20030222 (RH 3.2.2-5)

Gives

new/delete              140ns/loop
malloc/erase            100ns/loop

Unfortunately, I just this morning deleted the g++ 3.3.1 and replaced it 
with 3.2 (which does not show such aberrant behaviour, by the way) , so 
I cannot test your patch!

Paul Thomas


epanelelytha at kellertimo dot de wrote:

>------- Additional Comments From epanelelytha at kellertimo dot de  2004-04-03 17:18 -------
>I inlined all allocation operators and they inproved from 2.393s to 1.922s (C
>allocation style: 2.013s). Note that I also changed the test program to allocate
>an array of 100 unsigned ints.
>The problem with inlining them is that this can only work if <new> is included,
>so please don't understand this as a patch, but as an idea/explanation why new
>is slower than malloc.
>
>Reading specs from /usr/local/lib/gcc/i686-pc-cygwin/3.5-tree-ssa/specs
>Configured with: ./configure --disable-libmudflap --without-libbanshee
>--disable-checking --enable-languages=c,c++ --disable-threads : (reconfigured) 
>: (reconfigured) ./configure --disable-libmudflap
> --without-libbanshee --disable-checking --enable-languages=c,c++
>--disable-threads : (reconfigured)
>  : (reconfigured) ./configure --disable-libmudflap --without-libbanshee
>--disable-checking --enable-languages=c,c++ --disable-threads : (reconfigured) 
>: (reconfigured) ./configure --disable-libmudflap --without-libbanshee
>--disable-checking --enable-languages=c,c++ --disable-threads
>Thread model: single
>gcc version 3.5-tree-ssa 20040403 (merged 20040331)
>
>#include <iostream>
>#include <stdio.h>
>#include <time.h>
>using namespace std;
>
>int main()
>{
>	const size_t array_size = 100;
>	const unsigned loop_count = 1000000;
>	long t1 = clock();
>	for (unsigned iloop = 0; iloop < loop_count; iloop++)
>	{
>		unsigned *myarray = new unsigned [array_size];
>		delete [] myarray;
>	}
>	long t2 = clock();
>	double delt1 = (double)( t2 - t1 )/ (double)(CLOCKS_PER_SEC);
>	cout << "done looping time 1=" << delt1 << endl;
>	long t3 = clock();
>
>	for (unsigned iloop = 0; iloop < loop_count; iloop++)
>	{
>		unsigned *myarray = (unsigned *)malloc(array_size * sizeof(unsigned));
>		if (myarray== NULL) { printf("alloc failed\n"); exit(1); }
>		else free (myarray);
>	}
>	long t4 = clock();
>	double delt2 = (double)( t4 - t3 )/ (double)(CLOCKS_PER_SEC);
>	cout << "done looping time 2=" << delt2 << endl;
>
>	return 0;
>}
>
>
>
>Index: gcc/libstdc++-v3/libsupc++/del_op.cc
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc,v
>retrieving revision 1.2.22.1
>diff -u -r1.2.22.1 del_op.cc
>--- gcc/libstdc++-v3/libsupc++/del_op.cc	3 Jun 2003 16:53:00 -0000	1.2.22.1
>+++ gcc/libstdc++-v3/libsupc++/del_op.cc	3 Apr 2004 17:11:53 -0000
>@@ -30,11 +30,3 @@
> 
> #include "new"
> 
>-extern "C" void free (void *);
>-
>-void
>-operator delete (void *ptr) throw ()
>-{
>-  if (ptr)
>-    free (ptr);
>-}
>Index: gcc/libstdc++-v3/libsupc++/del_opnt.cc
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/del_opnt.cc,v
>retrieving revision 1.2.22.1
>diff -u -r1.2.22.1 del_opnt.cc
>--- gcc/libstdc++-v3/libsupc++/del_opnt.cc	3 Jun 2003 16:53:00 -0000	1.2.22.1
>+++ gcc/libstdc++-v3/libsupc++/del_opnt.cc	3 Apr 2004 17:11:53 -0000
>@@ -30,11 +30,3 @@
> 
> #include "new"
> 
>-extern "C" void free (void *);
>-
>-void
>-operator delete (void *ptr, const std::nothrow_t&) throw ()
>-{
>-  if (ptr)
>-    free (ptr);
>-}
>Index: gcc/libstdc++-v3/libsupc++/del_opv.cc
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/del_opv.cc,v
>retrieving revision 1.2.22.1
>diff -u -r1.2.22.1 del_opv.cc
>--- gcc/libstdc++-v3/libsupc++/del_opv.cc	3 Jun 2003 16:53:00 -0000	1.2.22.1
>+++ gcc/libstdc++-v3/libsupc++/del_opv.cc	3 Apr 2004 17:11:53 -0000
>@@ -29,9 +29,3 @@
> // the GNU General Public License.
> 
> #include "new"
>-
>-void
>-operator delete[] (void *ptr) throw ()
>-{
>-  ::operator delete (ptr);
>-}
>Index: gcc/libstdc++-v3/libsupc++/del_opvnt.cc
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/del_opvnt.cc,v
>retrieving revision 1.2.22.1
>diff -u -r1.2.22.1 del_opvnt.cc
>--- gcc/libstdc++-v3/libsupc++/del_opvnt.cc	3 Jun 2003 16:53:00 -0000	1.2.22.1
>+++ gcc/libstdc++-v3/libsupc++/del_opvnt.cc	3 Apr 2004 17:11:53 -0000
>@@ -29,9 +29,3 @@
> // the GNU General Public License.
> 
> #include "new"
>-
>-void
>-operator delete[] (void *ptr, const std::nothrow_t&) throw ()
>-{
>-  ::operator delete (ptr);
>-}
>Index: gcc/libstdc++-v3/libsupc++/new
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/new,v
>retrieving revision 1.10.2.5
>diff -u -r1.10.2.5 new
>--- gcc/libstdc++-v3/libsupc++/new	21 Jul 2003 13:54:08 -0000	1.10.2.5
>+++ gcc/libstdc++-v3/libsupc++/new	3 Apr 2004 17:11:53 -0000
>@@ -39,6 +39,7 @@
> #define _NEW
> 
> #include <cstddef>
>+#include <cstdlib>
> #include <exception>
> 
> extern "C++" {
>@@ -68,6 +69,10 @@
>   new_handler set_new_handler(new_handler) throw();
> } // namespace std
> 
>+
>+void* __operator_new(std::size_t) throw (std::bad_alloc);
>+void* __operator_new_nothrow(std::size_t) throw ();
>+
> //@{
> /** These are replaceable signatures:
>  *  - normal single new and delete (no arguments, throw @c bad_alloc on error)
>@@ -79,14 +84,55 @@
>  *  Placement new and delete signatures (take a memory address argument,
>  *  does nothing) may not be replaced by a user's program.
> */
>-void* operator new(std::size_t) throw (std::bad_alloc);
>-void* operator new[](std::size_t) throw (std::bad_alloc);
>-void operator delete(void*) throw();
>-void operator delete[](void*) throw();
>-void* operator new(std::size_t, const std::nothrow_t&) throw();
>-void* operator new[](std::size_t, const std::nothrow_t&) throw();
>-void operator delete(void*, const std::nothrow_t&) throw();
>-void operator delete[](void*, const std::nothrow_t&) throw();
>+inline void* operator new(std::size_t sz) throw (std::bad_alloc)
>+{
>+  /* malloc (0) is unpredictable; avoid it.  */
>+  if (sz == 0)
>+    sz = 1;
>+  void *p = std::malloc (sz);
>+  if (!p)
>+    p = __operator_new(sz);
>+
>+  return p;
>+}
>+inline void* operator new[] (std::size_t sz) throw (std::bad_alloc)
>+{
>+  return ::operator new(sz);
>+}
>+inline void operator delete (void *ptr) throw ()
>+{
>+  if (ptr)
>+    std::free (ptr);
>+}
>+inline void operator delete[] (void *ptr) throw ()
>+{
>+  ::operator delete (ptr);
>+}
>+
>+inline void* operator new (std::size_t sz, const std::nothrow_t&) throw()
>+{
>+  /* malloc (0) is unpredictable; avoid it.  */
>+  if (sz == 0)
>+    sz = 1;
>+  void *p = std::malloc (sz);
>+  if (!p)
>+    p = __operator_new_nothrow(sz);
>+
>+  return p;
>+}
>+inline void* operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
>+{
>+  return ::operator new(sz, nothrow);
>+}
>+inline void operator delete (void *ptr, const std::nothrow_t&) throw ()
>+{
>+  if (ptr)
>+    std::free (ptr);
>+}
>+inline void operator delete[] (void *ptr, const std::nothrow_t&) throw ()
>+{
>+  ::operator delete (ptr);
>+}
> 
> // Default placement versions of operator new.
> inline void* operator new(std::size_t, void* __p) throw() { return __p; }
>Index: gcc/libstdc++-v3/libsupc++/new_op.cc
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/new_op.cc,v
>retrieving revision 1.5.2.1
>diff -u -r1.5.2.1 new_op.cc
>--- gcc/libstdc++-v3/libsupc++/new_op.cc	3 Jun 2003 16:53:00 -0000	1.5.2.1
>+++ gcc/libstdc++-v3/libsupc++/new_op.cc	3 Apr 2004 17:11:53 -0000
>@@ -37,27 +37,22 @@
> 
> extern new_handler __new_handler;
> 
>-void *
>-operator new (std::size_t sz) throw (std::bad_alloc)
>+void* __operator_new(std::size_t sz) throw (std::bad_alloc)
> {
>   void *p;
>-
>-  /* malloc (0) is unpredictable; avoid it.  */
>-  if (sz == 0)
>-    sz = 1;
>-  p = (void *) malloc (sz);
>-  while (p == 0)
>+  do
>     {
>-      new_handler handler = __new_handler;
>+      std::new_handler handler = __new_handler;
>       if (! handler)
> #ifdef __EXCEPTIONS
>-	throw bad_alloc();
>+        throw std::bad_alloc();
> #else
>         std::abort();
> #endif
>       handler ();
>-      p = (void *) malloc (sz);
>+      p = std::malloc (sz);
>     }
>+  while (!p);
> 
>   return p;
> }
>Index: gcc/libstdc++-v3/libsupc++/new_opnt.cc
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/new_opnt.cc,v
>retrieving revision 1.3.22.1
>diff -u -r1.3.22.1 new_opnt.cc
>--- gcc/libstdc++-v3/libsupc++/new_opnt.cc	3 Jun 2003 16:53:00 -0000	1.3.22.1
>+++ gcc/libstdc++-v3/libsupc++/new_opnt.cc	3 Apr 2004 17:11:53 -0000
>@@ -36,31 +36,26 @@
> extern "C" void *malloc (std::size_t);
> extern new_handler __new_handler;
> 
>-void *
>-operator new (std::size_t sz, const std::nothrow_t&) throw()
>+void* __operator_new_nothrow(std::size_t sz) throw ()
> {
>   void *p;
>-
>-  /* malloc (0) is unpredictable; avoid it.  */
>-  if (sz == 0)
>-    sz = 1;
>-  p = (void *) malloc (sz);
>-  while (p == 0)
>+  do
>     {
>-      new_handler handler = __new_handler;
>+      std::new_handler handler = __new_handler;
>       if (! handler)
>-	return 0;
>+	    return 0;
>       try
>-	{
>-	  handler ();
>-	}
>-      catch (bad_alloc &)
>-	{
>-	  return 0;
>-	}
>+	    {
>+	      handler ();
>+	    }
>+      catch (std::bad_alloc &)
>+	    {
>+	      return 0;
>+	    }
> 
>-      p = (void *) malloc (sz);
>+      p = std::malloc (sz);
>     }
>+  while (!p);
> 
>   return p;
> }
>Index: gcc/libstdc++-v3/libsupc++/new_opv.cc
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/new_opv.cc,v
>retrieving revision 1.3.22.1
>diff -u -r1.3.22.1 new_opv.cc
>--- gcc/libstdc++-v3/libsupc++/new_opv.cc	3 Jun 2003 16:53:00 -0000	1.3.22.1
>+++ gcc/libstdc++-v3/libsupc++/new_opv.cc	3 Apr 2004 17:11:53 -0000
>@@ -30,8 +30,3 @@
> 
> #include "new"
> 
>-void *
>-operator new[] (std::size_t sz) throw (std::bad_alloc)
>-{
>-  return ::operator new(sz);
>-}
>Index: gcc/libstdc++-v3/libsupc++/new_opvnt.cc
>===================================================================
>RCS file: /cvsroot/gcc/gcc/libstdc++-v3/libsupc++/new_opvnt.cc,v
>retrieving revision 1.3.22.1
>diff -u -r1.3.22.1 new_opvnt.cc
>--- gcc/libstdc++-v3/libsupc++/new_opvnt.cc	3 Jun 2003 16:53:00 -0000	1.3.22.1
>+++ gcc/libstdc++-v3/libsupc++/new_opvnt.cc	3 Apr 2004 17:11:53 -0000
>@@ -30,8 +30,3 @@
> 
> #include "new"
> 
>-void *
>-operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
>-{
>-  return ::operator new(sz, nothrow);
>-}
>
>  
>




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14563


  parent reply	other threads:[~2004-04-03 17:54 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-12 23:36 [Bug c++/14563] New: " paulthomas2 at wanadoo dot fr
2004-03-13  7:24 ` [Bug c++/14563] " pinskia at gcc dot gnu dot org
2004-03-13  8:06 ` paulthomas2 at wanadoo dot fr
2004-03-14 20:33 ` bangerth at dealii dot org
2004-03-24  9:52 ` paulthomas2 at wanadoo dot fr
2004-03-24 15:57 ` bangerth at dealii dot org
2004-03-24 16:38 ` paulthomas2 at wanadoo dot fr
2004-03-24 17:03 ` bangerth at dealii dot org
2004-03-24 21:07 ` Ben dot Diedrich at noaa dot gov
2004-03-24 22:58 ` dannysmith at users dot sourceforge dot net
2004-03-25  6:40 ` paulthomas2 at wanadoo dot fr
2004-03-25 13:43 ` bangerth at dealii dot org
2004-03-25 14:16 ` Ben dot Diedrich at noaa dot gov
2004-03-25 14:17 ` paulthomas2 at wanadoo dot fr
2004-03-25 14:26 ` paulthomas2 at wanadoo dot fr
2004-03-25 14:37 ` bangerth at dealii dot org
2004-03-25 15:37 ` Ben dot Diedrich at noaa dot gov
2004-03-25 16:41 ` paulthomas2 at wanadoo dot fr
2004-03-28 21:19 ` paulthomas2 at wanadoo dot fr
2004-03-28 22:28 ` pkienzle at users dot sf dot net
2004-03-31  0:21 ` paulthomas2 at wanadoo dot fr
2004-04-02 17:43 ` paulthomas2 at wanadoo dot fr
2004-04-02 19:55 ` bangerth at dealii dot org
2004-04-02 20:35 ` dannysmith at users dot sourceforge dot net
2004-04-02 20:41 ` pcarlini at suse dot de
2004-04-02 20:44 ` bangerth at dealii dot org
2004-04-03  9:10 ` paulthomas2 at wanadoo dot fr
2004-04-03 17:19 ` epanelelytha at kellertimo dot de
2004-04-03 17:54 ` paulthomas2 at wanadoo dot fr [this message]
2004-04-03 18:00 ` epanelelytha at kellertimo dot de
2004-04-03 18:24 ` paulthomas2 at wanadoo dot fr
2004-07-12 14:50 ` [Bug libstdc++/14563] new/delete much slower than malloc/free pinskia at gcc dot gnu dot org
2004-07-12 19:21 ` paulthomas2 at wanadoo dot fr
2004-07-12 20:55 ` bangerth at dealii dot org
2004-07-13  4:17 ` paulthomas2 at wanadoo dot fr
2004-07-28  2:50 ` ron_hylton at hotmail dot com
2004-07-28  3:57 ` ron_hylton at hotmail dot com
2004-07-28  6:03 ` [Bug target/14563] " pinskia at gcc dot gnu dot org
2004-07-29  4:23 ` ron_hylton at hotmail dot com
2004-08-08  9:24 ` paulthomas2 at wanadoo dot fr
2004-11-10  8:21 ` [Bug target/14563] [3.3/3.4/4.0 Regression] new/delete much slower than malloc/free because of sjlj exceptions giovannibajo at libero dot it
2004-11-10  8:21 ` giovannibajo at libero dot it
2004-11-10  9:10 ` dannysmith at users dot sourceforge dot net
2004-11-10 12:46 ` [Bug target/14563] " pinskia at gcc dot gnu dot org
2004-11-10 16:20 ` ron_hylton at hotmail dot com
2004-11-10 17:05 ` kjd at duda dot org
2004-11-13 11:03 ` paulthomas2 at wanadoo dot fr
2004-11-14 17:03 ` ken dot duda at gmail dot com
2004-11-14 18:04 ` paulthomas2 at wanadoo dot fr
2004-11-14 22:40 ` ken dot duda at gmail dot com
2005-05-12 14:53 ` pinskia at gcc dot gnu dot org
2005-05-12 14:54 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040403175430.32274.qmail@sources.redhat.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).