diff mbox series

selftests/vm: 10x speedup for hmm-tests

Message ID 20201003011721.44238-1-jhubbard@nvidia.com (mailing list archive)
State New, archived
Headers show
Series selftests/vm: 10x speedup for hmm-tests | expand

Commit Message

John Hubbard Oct. 3, 2020, 1:17 a.m. UTC
This patch reduces the running time for hmm-tests from about 10+
seconds, to just under 1.0 second, for an approximately 10x speedup.
That brings it in line with most of the other tests in selftests/vm,
which mostly run in < 1 sec.

This is done with a one-line change that simply reduces the number of
iterations of several tests, from 256, to 10. Thanks to Ralph Campbell
for suggesting changing NTIMES as a way to get the speedup.

Suggested-by: Ralph Campbell <rcampbell@nvidia.com>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---

This is based on mmotm.

 tools/testing/selftests/vm/hmm-tests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

SeongJae Park Oct. 3, 2020, 5:23 a.m. UTC | #1
On Fri, 2 Oct 2020 18:17:21 -0700 John Hubbard <jhubbard@nvidia.com> wrote:

> This patch reduces the running time for hmm-tests from about 10+
> seconds, to just under 1.0 second, for an approximately 10x speedup.
> That brings it in line with most of the other tests in selftests/vm,
> which mostly run in < 1 sec.
> 
> This is done with a one-line change that simply reduces the number of
> iterations of several tests, from 256, to 10.

Could this result in reduced test capacity?  If so, how about making the number
easily tweakable?


Thanks,
SeongJae Park

> Thanks to Ralph Campbell for suggesting changing NTIMES as a way to get the
> speedup.
> 
> Suggested-by: Ralph Campbell <rcampbell@nvidia.com>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> ---
> 
> This is based on mmotm.
> 
>  tools/testing/selftests/vm/hmm-tests.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/hmm-tests.c b/tools/testing/selftests/vm/hmm-tests.c
> index 6b79723d7dc6..5d1ac691b9f4 100644
> --- a/tools/testing/selftests/vm/hmm-tests.c
> +++ b/tools/testing/selftests/vm/hmm-tests.c
> @@ -49,7 +49,7 @@ struct hmm_buffer {
>  #define TWOMEG		(1 << 21)
>  #define HMM_BUFFER_SIZE (1024 << 12)
>  #define HMM_PATH_MAX    64
> -#define NTIMES		256
> +#define NTIMES		10
>  
>  #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1)))
>  
> -- 
> 2.28.0
John Hubbard Oct. 3, 2020, 5:50 a.m. UTC | #2
On 10/2/20 10:23 PM, SeongJae Park wrote:
> On Fri, 2 Oct 2020 18:17:21 -0700 John Hubbard <jhubbard@nvidia.com> wrote:
> 
>> This patch reduces the running time for hmm-tests from about 10+
>> seconds, to just under 1.0 second, for an approximately 10x speedup.
>> That brings it in line with most of the other tests in selftests/vm,
>> which mostly run in < 1 sec.
>>
>> This is done with a one-line change that simply reduces the number of
>> iterations of several tests, from 256, to 10.
> 
> Could this result in reduced test capacity?  If so, how about making the number
> easily tweakable?
> 

The choice of iterations was somewhat arbitrary. Unless and until we
have specific bugs that show up at a given number of iterations, we
should avoid running large iteration counts that blow the testing time
budget. Here, I'm not aware of any bugs that show up between 11 and 256
iterations, which is why I think 10 is an acceptable iteration count.

But, you are right: it's a nice thought to make the iteration count
adjustable via the command line. That would allow hmm-tests to act as a
quick selftest item, and also to provide a little bit more of a stress
test, when manually invoked with a higher iteration count.

That's a separate patch, though. Because TEST_F() and related unit test
macros used in this area, expect to run the same way every time, and
they don't really want to be fed iteration arguments. Or maybe they do,
and I've missed it on my first quick pass through.

And in fact, maybe it's not a good fit, if TEST_F() and kselftest are
pushing for more of a CUnit/gtest style of coding.

There are some design and policy questions there. It reminds me that
some programs here don't use TEST_F() at all, actually. But anyway, I'd
definitely like to sidestep all of that for now, and start with just
"get the test run time down under 1 second".

thanks,
--
John Hubbard
NVIDIA
John Hubbard Oct. 6, 2020, 8:34 p.m. UTC | #3
On 10/2/20 6:17 PM, John Hubbard wrote:
> This patch reduces the running time for hmm-tests from about 10+
> seconds, to just under 1.0 second, for an approximately 10x speedup.
> That brings it in line with most of the other tests in selftests/vm,
> which mostly run in < 1 sec.
> 
> This is done with a one-line change that simply reduces the number of
> iterations of several tests, from 256, to 10. Thanks to Ralph Campbell
> for suggesting changing NTIMES as a way to get the speedup.
> 
> Suggested-by: Ralph Campbell <rcampbell@nvidia.com>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> ---

Andrew, do you think we can get this one merged into mmotm? I think it's
pretty low risk.


thanks,
diff mbox series

Patch

diff --git a/tools/testing/selftests/vm/hmm-tests.c b/tools/testing/selftests/vm/hmm-tests.c
index 6b79723d7dc6..5d1ac691b9f4 100644
--- a/tools/testing/selftests/vm/hmm-tests.c
+++ b/tools/testing/selftests/vm/hmm-tests.c
@@ -49,7 +49,7 @@  struct hmm_buffer {
 #define TWOMEG		(1 << 21)
 #define HMM_BUFFER_SIZE (1024 << 12)
 #define HMM_PATH_MAX    64
-#define NTIMES		256
+#define NTIMES		10
 
 #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1)))