This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

PATCH: Another tweak of new allocator tests


Note: We have to run the same number of iterations in threaded cases
due to container O() issues; I updated reporting to better reflect
true work done (sorry, my fault it was wrong).  I think it is now fair
to calculate reported_iterations/threads*CPU to see if scaling is ~working.

Likewise for insert_insert.cc; I made it single-threaded but reflect
the true work load in the reporting.

map_thread.cc & producer_consumer.cc are not comparable to the above
but do test another aspect of the allocator.

I lowered all iteration counts after checking that allocator
differences were still trivial to spot.  Maximum memory is now ~200MB.

As committed.  Sorry for the recent churn. I'm done playing with the
allocator tests.

Regards,
Loren

	* scripts/check_performance (CXX): Add -DNOTHREAD.
	* testsuite/performance/20_util/allocator/insert.cc: Integrate
	threaded tests from insert_insert.cc.  Tweak iterations,
	remove special cases.
	* testsuite/performance/20_util/allocator/insert_insert.cc:
	Make all tests single-threaded. Tweak iterations.
	* testsuite/performance/20_util/allocator/map_thread.cc:
	Tweak iterations.
	* testsuite/performance/20_util/allocator/producer_consumer.cc:
	Likewise.

Index: libstdc++-v3/scripts/check_performance
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/scripts/check_performance,v
retrieving revision 1.4
diff -c -r1.4 check_performance
*** libstdc++-v3/scripts/check_performance	6 Feb 2004 00:51:34 -0000	1.4
--- libstdc++-v3/scripts/check_performance	6 Feb 2004 08:00:52 -0000
***************
*** 31,37 ****
           -Wl,--rpath -Wl,$BUILD_DIR/src/.libs"
  ST_FLAG="-static"
  LINK=$SH_FLAG
! CXX="$COMPILER $INCLUDES $FLAGS $LINK"
  CXX_THREAD="$COMPILER $INCLUDES $FLAGS $THREAD_FLAG $LINK"
  
  
--- 31,37 ----
           -Wl,--rpath -Wl,$BUILD_DIR/src/.libs"
  ST_FLAG="-static"
  LINK=$SH_FLAG
! CXX="$COMPILER $INCLUDES $FLAGS -DNOTHREAD $LINK"
  CXX_THREAD="$COMPILER $INCLUDES $FLAGS $THREAD_FLAG $LINK"
  
  
Index: libstdc++-v3/testsuite/performance/20_util/allocator/insert.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/performance/20_util/allocator/insert.cc,v
retrieving revision 1.2
diff -c -r1.2 insert.cc
*** libstdc++-v3/testsuite/performance/20_util/allocator/insert.cc	5 Feb 2004 03:52:41 -0000	1.2
--- libstdc++-v3/testsuite/performance/20_util/allocator/insert.cc	6 Feb 2004 08:00:54 -0000
***************
*** 51,57 ****
  typedef int test_type;
  
  // The number of iterations to be performed.
! int iterations = 100000;
  
  // The number of values to insert in the container, 32 will cause 5
  // (re)allocations to be performed (sizes 4, 8, 16, 32 and 64)
--- 51,57 ----
  typedef int test_type;
  
  // The number of iterations to be performed.
! int iterations = 10000;
  
  // The number of values to insert in the container, 32 will cause 5
  // (re)allocations to be performed (sizes 4, 8, 16, 32 and 64)
***************
*** 71,100 ****
    };
  
  template<typename Container>
!   int
!   do_loop(Container& obj)
    {
      int test_iterations = 0;
!     try
!       {
! 	value_type<test_type> test_value;
! 	while (test_iterations < iterations)
! 	  {
! 	    for (int j = 0; j < insert_values; ++j)
! 	      obj.insert(obj.end(), ++test_value);
! 	    ++test_iterations;
! 	  }
!       }
!     catch(...)
        {
! 	// No point allocating all available memory, repeatedly.	
        }
!     return test_iterations;
    }
  
  template<typename Container>
    void
!   test_container(Container obj)
    {
      using namespace __gnu_test;
      int status;
--- 71,100 ----
    };
  
  template<typename Container>
!   void
!   do_loop()
    {
+     Container obj;
      int test_iterations = 0;
!     value_type<test_type> test_value;
!     while (test_iterations < iterations)
        {
! 	for (int j = 0; j < insert_values; ++j)
! 	  obj.insert(obj.end(), ++test_value);
! 	++test_iterations;
        }
!   }
! 
! template<typename Container>
!   void*
!   do_test(void* p = NULL)
!   {
!     do_loop<Container>();
    }
  
  template<typename Container>
    void
!   test_container(Container obj, bool run_threaded = false)
    {
      using namespace __gnu_test;
      int status;
***************
*** 103,113 ****
      resource_counter resource;
      clear_counters(time, resource);
      start_counters(time, resource);
!     int test_iterations = do_loop(obj);
      stop_counters(time, resource);
   
      std::ostringstream comment;
!     comment << "iterations: " << test_iterations << '\t';
      comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
  					       0, 0, &status);
      report_header(__FILE__, comment.str());
--- 103,138 ----
      resource_counter resource;
      clear_counters(time, resource);
      start_counters(time, resource);
! 
!     if (! run_threaded)
!       {
! 	do_loop<Container>();
!       }
!     else
!       {
! #if defined (_GLIBCXX_GCC_GTHR_POSIX_H) && !defined (NOTHREAD)
! 	pthread_t  t1, t2, t3, t4;
! 	pthread_create(&t1, 0, &do_test<Container>, 0);
! 	pthread_create(&t2, 0, &do_test<Container>, 0);
! 	pthread_create(&t3, 0, &do_test<Container>, 0);
! 	pthread_create(&t4, 0, &do_test<Container>, 0);
! 
! 	pthread_join(t1, NULL);
! 	pthread_join(t2, NULL);
! 	pthread_join(t3, NULL);
! 	pthread_join(t4, NULL);
! #else
! 	return;
! #endif
!       }
! 
      stop_counters(time, resource);
   
      std::ostringstream comment;
!     if (run_threaded)
!       comment << "4-way threaded iterations: " << iterations*4 << '\t';
!     else
!       comment << "iterations: " << iterations << '\t';
      comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
  					       0, 0, &status);
      report_header(__FILE__, comment.str());
***************
*** 154,182 ****
  
    typedef less<test_type> compare_type;
  #ifdef TEST_B9
-   iterations = 50000;
    test_container(map<test_type, test_type, compare_type, m_alloc_type>());
  #endif
  #ifdef TEST_B10
-   iterations = 50000;
    test_container(map<test_type, test_type, compare_type, n_alloc_type>());
  #endif
  #ifdef TEST_B11
-   iterations = 50000;
    test_container(map<test_type, test_type, compare_type, so_alloc_type>());
  #endif
  
  #ifdef TEST_B12
-   iterations = 50000;
    test_container(set<test_type, compare_type, m_alloc_type>());
  #endif
  #ifdef TEST_B13
-   iterations = 50000;
    test_container(set<test_type, compare_type, n_alloc_type>());
  #endif
  #ifdef TEST_B14
-   iterations = 50000;
    test_container(set<test_type, compare_type, so_alloc_type>());
  #endif
  
    return 0;
--- 179,252 ----
  
    typedef less<test_type> compare_type;
  #ifdef TEST_B9
    test_container(map<test_type, test_type, compare_type, m_alloc_type>());
  #endif
  #ifdef TEST_B10
    test_container(map<test_type, test_type, compare_type, n_alloc_type>());
  #endif
  #ifdef TEST_B11
    test_container(map<test_type, test_type, compare_type, so_alloc_type>());
  #endif
  
  #ifdef TEST_B12
    test_container(set<test_type, compare_type, m_alloc_type>());
  #endif
  #ifdef TEST_B13
    test_container(set<test_type, compare_type, n_alloc_type>());
  #endif
  #ifdef TEST_B14
    test_container(set<test_type, compare_type, so_alloc_type>());
+ #endif
+ 
+ #ifdef TEST_T0
+   test_container(vector<test_type, m_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T1
+   test_container(vector<test_type, n_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T2
+   test_container(vector<test_type, so_alloc_type>(), true);
+ #endif
+ 
+ #ifdef TEST_T3
+   test_container(list<test_type, m_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T4
+   test_container(list<test_type, n_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T5
+   test_container(list<test_type, so_alloc_type>(), true);
+ #endif
+ 
+ #ifdef TEST_T6
+   test_container(deque<test_type, m_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T7
+   test_container(deque<test_type, n_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T8
+   test_container(deque<test_type, so_alloc_type>(), true);
+ #endif
+ 
+   typedef less<test_type> compare_type;
+ #ifdef TEST_T9
+   test_container(map<test_type, test_type, compare_type, m_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T10
+   test_container(map<test_type, test_type, compare_type, n_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T11
+   test_container(map<test_type, test_type, compare_type, so_alloc_type>(), true);
+ #endif
+ 
+ #ifdef TEST_T12
+   test_container(set<test_type, compare_type, m_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T13
+   test_container(set<test_type, compare_type, n_alloc_type>(), true);
+ #endif
+ #ifdef TEST_T14
+   test_container(set<test_type, compare_type, so_alloc_type>(), true);
  #endif
  
    return 0;
Index: libstdc++-v3/testsuite/performance/20_util/allocator/insert_insert.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/performance/20_util/allocator/insert_insert.cc,v
retrieving revision 1.1
diff -c -r1.1 insert_insert.cc
*** libstdc++-v3/testsuite/performance/20_util/allocator/insert_insert.cc	5 Feb 2004 01:33:07 -0000	1.1
--- libstdc++-v3/testsuite/performance/20_util/allocator/insert_insert.cc	6 Feb 2004 08:00:54 -0000
***************
*** 40,46 ****
  #include <set>
  #include <typeinfo>
  #include <sstream>
- #include <pthread.h>
  #include <ext/mt_allocator.h>
  #include <ext/new_allocator.h>
  #include <ext/malloc_allocator.h>
--- 40,45 ----
***************
*** 52,58 ****
  typedef int test_type;
  
  // The number of iterations to be performed.
! int iterations = 25000;
  
  // The number of values to insert in the container, 32 will cause 5
  // (re)allocations to be performed (sizes 4, 8, 16, 32 and 64)
--- 51,57 ----
  typedef int test_type;
  
  // The number of iterations to be performed.
! int iterations = 10000;
  
  // The number of values to insert in the container, 32 will cause 5
  // (re)allocations to be performed (sizes 4, 8, 16, 32 and 64)
***************
*** 87,107 ****
    }
  
  template<typename Container>
-   void*
-   do_test(void* p = NULL)
-   {
-     try
-       {
- 	do_loop<Container>();
- 	do_loop<Container>();
-       }
-     catch(...)
-       {
- 	// No point allocating all available memory, repeatedly.
-       }
-   }
- 
- template<typename Container>
    void
    test_container(Container obj)
    {
--- 86,91 ----
***************
*** 110,134 ****
  
      time_counter time;
      resource_counter resource;
- 
      clear_counters(time, resource);
      start_counters(time, resource);
!     
!     pthread_t  t1, t2, t3, t4;
!     pthread_create(&t1, 0, &do_test<Container>, 0);
!     pthread_create(&t2, 0, &do_test<Container>, 0);
!     pthread_create(&t3, 0, &do_test<Container>, 0);
!     pthread_create(&t4, 0, &do_test<Container>, 0);
! 
!     pthread_join(t1, NULL);
!     pthread_join(t2, NULL);
!     pthread_join(t3, NULL);
!     pthread_join(t4, NULL);
  
      stop_counters(time, resource);
   
      std::ostringstream comment;
!     comment << "iterations: " << iterations << '\t';
      comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
  					       0, 0, &status);
      report_header(__FILE__, comment.str());
--- 94,109 ----
  
      time_counter time;
      resource_counter resource;
      clear_counters(time, resource);
      start_counters(time, resource);
! 
!     do_loop<Container>();
!     do_loop<Container>();
  
      stop_counters(time, resource);
   
      std::ostringstream comment;
!     comment << "repeated iterations: " << iterations*2 << '\t';
      comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
  					       0, 0, &status);
      report_header(__FILE__, comment.str());
***************
*** 143,196 ****
    typedef __gnu_cxx::new_allocator<test_type> n_alloc_type;
    typedef __gnu_cxx::__mt_alloc<test_type> so_alloc_type;
  
! #ifdef TEST_T0
    test_container(vector<test_type, m_alloc_type>());
  #endif
! #ifdef TEST_T1
    test_container(vector<test_type, n_alloc_type>());
  #endif
! #ifdef TEST_T2
    test_container(vector<test_type, so_alloc_type>());
  #endif
  
! #ifdef TEST_T3
    test_container(list<test_type, m_alloc_type>());
  #endif
! #ifdef TEST_T4
    test_container(list<test_type, n_alloc_type>());
  #endif
! #ifdef TEST_T5
    test_container(list<test_type, so_alloc_type>());
  #endif
  
! #ifdef TEST_T6
    test_container(deque<test_type, m_alloc_type>());
  #endif
! #ifdef TEST_T7
    test_container(deque<test_type, n_alloc_type>());
  #endif
! #ifdef TEST_T8
    test_container(deque<test_type, so_alloc_type>());
  #endif
  
    typedef less<test_type> compare_type;
! #ifdef TEST_T9
    test_container(map<test_type, test_type, compare_type, m_alloc_type>());
  #endif
! #ifdef TEST_T10
    test_container(map<test_type, test_type, compare_type, n_alloc_type>());
  #endif
! #ifdef TEST_T11
    test_container(map<test_type, test_type, compare_type, so_alloc_type>());
  #endif
  
! #ifdef TEST_T12
    test_container(set<test_type, compare_type, m_alloc_type>());
  #endif
! #ifdef TEST_T13
    test_container(set<test_type, compare_type, n_alloc_type>());
  #endif
! #ifdef TEST_T14
    test_container(set<test_type, compare_type, so_alloc_type>());
  #endif
  
--- 118,171 ----
    typedef __gnu_cxx::new_allocator<test_type> n_alloc_type;
    typedef __gnu_cxx::__mt_alloc<test_type> so_alloc_type;
  
! #ifdef TEST_S0
    test_container(vector<test_type, m_alloc_type>());
  #endif
! #ifdef TEST_S1
    test_container(vector<test_type, n_alloc_type>());
  #endif
! #ifdef TEST_S2
    test_container(vector<test_type, so_alloc_type>());
  #endif
  
! #ifdef TEST_S3
    test_container(list<test_type, m_alloc_type>());
  #endif
! #ifdef TEST_S4
    test_container(list<test_type, n_alloc_type>());
  #endif
! #ifdef TEST_S5
    test_container(list<test_type, so_alloc_type>());
  #endif
  
! #ifdef TEST_S6
    test_container(deque<test_type, m_alloc_type>());
  #endif
! #ifdef TEST_S7
    test_container(deque<test_type, n_alloc_type>());
  #endif
! #ifdef TEST_S8
    test_container(deque<test_type, so_alloc_type>());
  #endif
  
    typedef less<test_type> compare_type;
! #ifdef TEST_S9
    test_container(map<test_type, test_type, compare_type, m_alloc_type>());
  #endif
! #ifdef TEST_S10
    test_container(map<test_type, test_type, compare_type, n_alloc_type>());
  #endif
! #ifdef TEST_S11
    test_container(map<test_type, test_type, compare_type, so_alloc_type>());
  #endif
  
! #ifdef TEST_S12
    test_container(set<test_type, compare_type, m_alloc_type>());
  #endif
! #ifdef TEST_S13
    test_container(set<test_type, compare_type, n_alloc_type>());
  #endif
! #ifdef TEST_S14
    test_container(set<test_type, compare_type, so_alloc_type>());
  #endif
  
Index: libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc,v
retrieving revision 1.1
diff -c -r1.1 map_thread.cc
*** libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc	5 Feb 2004 01:33:07 -0000	1.1
--- libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc	6 Feb 2004 08:00:54 -0000
***************
*** 49,55 ****
  using __gnu_cxx::malloc_allocator;
  
  // The number of iterations to be performed.
! int iterations = 25000;
  
  template<typename Container>
    void*
--- 49,55 ----
  using __gnu_cxx::malloc_allocator;
  
  // The number of iterations to be performed.
! int iterations = 10000;
  
  template<typename Container>
    void*
Index: libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc,v
retrieving revision 1.1
diff -c -r1.1 producer_consumer.cc
*** libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc	5 Feb 2004 01:33:07 -0000	1.1
--- libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc	6 Feb 2004 08:00:54 -0000
***************
*** 58,64 ****
  typedef __mt_alloc<test_type> so_alloc_type;
  
  // The number of iterations to be performed.
! int iterations = 25000;
  
  // TODO - restore Stefan's comment?  i don't understand it.  -- fwy
  int insert_values = 128;
--- 58,64 ----
  typedef __mt_alloc<test_type> so_alloc_type;
  
  // The number of iterations to be performed.
! int iterations = 10000;
  
  // TODO - restore Stefan's comment?  i don't understand it.  -- fwy
  int insert_values = 128;


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