diff mbox series

libstdc++: testsuite: reduce max_size_type.cc exec time [PR113175]

Message ID 20240102174826.1868173-1-ppalka@redhat.com
State New
Headers show
Series libstdc++: testsuite: reduce max_size_type.cc exec time [PR113175] | expand

Commit Message

Patrick Palka Jan. 2, 2024, 5:48 p.m. UTC
Tested on x86_64-pc-linux-gnu, does this look OK for trunk and release
branches (r14-205 was backported everywhere)?

-- >8 --

The adjustment to max_size_type.cc in r14-205-g83470a5cd4c3d2
inadvertently increased the execution time of the test by over 5x due to
enabling the two main loops to actually run in the signed_p case instead
of being dead code.  This suggests that the current range of the loop is
far too big and the test too time consuming, especially when run on
simulators.

So this patch cuts the loop range by 10x as proposed in the PR.  This
shouldn't significantly weaken the test since the same important edge
cases are still checked in the new range.  On my x86_64 machine this
reduces the test execution time by 10x, and 1.6x less time than before
r14-205.

	PR testsuite/113175

libstdc++-v3/ChangeLog:

	* testsuite/std/ranges/iota/max_size_type.cc (test02): Reduce
	'limit' to 100 from 1000 and adjust 'log2_limit' accordingly.
	(test03): Likewise.
---
 libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jonathan Wakely Jan. 2, 2024, 9:53 p.m. UTC | #1
On Tue, 2 Jan 2024, 17:49 Patrick Palka, <ppalka@redhat.com> wrote:

> Tested on x86_64-pc-linux-gnu, does this look OK for trunk and release
> branches (r14-205 was backported everywhere)?
>

Yes, thanks.



> -- >8 --
>
> The adjustment to max_size_type.cc in r14-205-g83470a5cd4c3d2
> inadvertently increased the execution time of the test by over 5x due to
> enabling the two main loops to actually run in the signed_p case instead
> of being dead code.  This suggests that the current range of the loop is
> far too big and the test too time consuming, especially when run on
> simulators.
>
> So this patch cuts the loop range by 10x as proposed in the PR.  This
> shouldn't significantly weaken the test since the same important edge
> cases are still checked in the new range.  On my x86_64 machine this
> reduces the test execution time by 10x, and 1.6x less time than before
> r14-205.
>
>         PR testsuite/113175
>
> libstdc++-v3/ChangeLog:
>
>         * testsuite/std/ranges/iota/max_size_type.cc (test02): Reduce
>         'limit' to 100 from 1000 and adjust 'log2_limit' accordingly.
>         (test03): Likewise.
> ---
>  libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
> b/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
> index a1fbc3241dc..27f25c758fe 100644
> --- a/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
> @@ -199,8 +199,8 @@ test02()
>    using max_type = std::conditional_t<signed_p, max_diff_t, max_size_t>;
>    using shorten_type = std::conditional_t<shorten_p, hw_type, max_type>;
>    const int hw_type_bit_size = sizeof(hw_type) * __CHAR_BIT__;
> -  const int limit = 1000;
> -  const int log2_limit = 10;
> +  const unsigned limit = 100;
> +  const int log2_limit = 7;
>    static_assert((1 << log2_limit) >= limit);
>    const int min = (signed_p ? -limit : 0);
>    const int max = limit;
> @@ -257,8 +257,8 @@ test03()
>    using max_type = std::conditional_t<signed_p, max_diff_t, max_size_t>;
>    using base_type = std::conditional_t<toggle_base_p, hw_type, max_type>;
>    constexpr int hw_type_bit_size = sizeof(hw_type) * __CHAR_BIT__;
> -  constexpr int limit = 1000;
> -  constexpr int log2_limit = 10;
> +  constexpr unsigned limit = 100;
> +  constexpr int log2_limit = 7;
>    static_assert((1 << log2_limit) >= limit);
>    const int min = (signed_p ? -limit : 0);
>    const int max = limit;
> --
> 2.43.0.232.ge79552d197
>
>
Hans-Peter Nilsson Jan. 4, 2024, 2:02 a.m. UTC | #2
> From: Patrick Palka <ppalka@redhat.com>
> Date: Tue,  2 Jan 2024 12:48:26 -0500

> Tested on x86_64-pc-linux-gnu, does this look OK for trunk and release
> branches (r14-205 was backported everywhere)?
> 
> -- >8 --
> 
> The adjustment to max_size_type.cc in r14-205-g83470a5cd4c3d2
> inadvertently increased the execution time of the test by over 5x due to
> enabling the two main loops to actually run in the signed_p case instead
> of being dead code.  This suggests that the current range of the loop is
> far too big and the test too time consuming, especially when run on
> simulators.
> 
> So this patch cuts the loop range by 10x as proposed in the PR.  This
> shouldn't significantly weaken the test since the same important edge
> cases are still checked in the new range.  On my x86_64 machine this
> reduces the test execution time by 10x, and 1.6x less time than before
> r14-205.
> 
> 	PR testsuite/113175
> 
> libstdc++-v3/ChangeLog:
> 
> 	* testsuite/std/ranges/iota/max_size_type.cc (test02): Reduce
> 	'limit' to 100 from 1000 and adjust 'log2_limit' accordingly.
> 	(test03): Likewise.


Oh the irony...  This now fails for cris-elf.  For CRIS,
it's not a timeout but an actual failure.

See PR113226; suddenly 1*-100 == 4294967196.  You changed
the type of "limit" to unsigned, but that doesn't appear to
matter.  So why would *narrowing* the tested range yield an
error?

I can't tell if this is target-specific: not enough
32-bitters results for r14-6888-ga138b99646a555 and later on
gcc-testresults@ for libstdc++ yet.  (No, I don't count the
32-bit multilibs of x86_64 and s390x.)

brgds, H-P
diff mbox series

Patch

diff --git a/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc b/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
index a1fbc3241dc..27f25c758fe 100644
--- a/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
+++ b/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
@@ -199,8 +199,8 @@  test02()
   using max_type = std::conditional_t<signed_p, max_diff_t, max_size_t>;
   using shorten_type = std::conditional_t<shorten_p, hw_type, max_type>;
   const int hw_type_bit_size = sizeof(hw_type) * __CHAR_BIT__;
-  const int limit = 1000;
-  const int log2_limit = 10;
+  const unsigned limit = 100;
+  const int log2_limit = 7;
   static_assert((1 << log2_limit) >= limit);
   const int min = (signed_p ? -limit : 0);
   const int max = limit;
@@ -257,8 +257,8 @@  test03()
   using max_type = std::conditional_t<signed_p, max_diff_t, max_size_t>;
   using base_type = std::conditional_t<toggle_base_p, hw_type, max_type>;
   constexpr int hw_type_bit_size = sizeof(hw_type) * __CHAR_BIT__;
-  constexpr int limit = 1000;
-  constexpr int log2_limit = 10;
+  constexpr unsigned limit = 100;
+  constexpr int log2_limit = 7;
   static_assert((1 << log2_limit) >= limit);
   const int min = (signed_p ? -limit : 0);
   const int max = limit;