From 6edb0a56e6aa12c3ee96cf27ee601fb464869235 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 8 Mar 2023 06:12:52 +0000 Subject: Process up to four test vector files concurrently. This avoids having a slow down when processing test vector files that only have a single group. Note that the processing of test vector files is in turn going to be rate limited by the number of concurrent test groups, which means we do not need variable limits for vectors. Reduces a Wycheproof regress run down to ~8 seconds on an Apple M1. --- src/regress/lib/libcrypto/wycheproof/wycheproof.go | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index accd9ab9cb..f98d4b13e8 100644 --- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go +++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go @@ -1,4 +1,4 @@ -/* $OpenBSD: wycheproof.go,v 1.137 2023/03/08 05:41:08 jsing Exp $ */ +/* $OpenBSD: wycheproof.go,v 1.138 2023/03/08 06:12:52 jsing Exp $ */ /* * Copyright (c) 2018 Joel Sing * Copyright (c) 2018,2019,2022 Theo Buehler @@ -90,6 +90,7 @@ import ( "regexp" "runtime" "strings" + "sync" "unsafe" ) @@ -2973,6 +2974,14 @@ func main() { success := true + var wg sync.WaitGroup + + vectorsRateLimitCh := make(chan bool, 4) + for i := 0; i < cap(vectorsRateLimitCh); i++ { + vectorsRateLimitCh <- true + } + resultCh := make(chan bool, 1024) + testc = newTestCoordinator() skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sha3|sha512_(224|256))_`) @@ -2990,9 +2999,26 @@ func main() { fmt.Printf("INFO: Skipping tests from \"%s\"\n", strings.TrimPrefix(tv, testVectorPath+"/")) continue } - if !runTestVectors(tv, test.variant) { - success = false - } + wg.Add(1) + <-vectorsRateLimitCh + go func(tv string, variant testVariant) { + select { + case resultCh <- runTestVectors(tv, variant): + default: + log.Fatal("result channel is full") + } + vectorsRateLimitCh <- true + wg.Done() + }(tv, test.variant) + } + } + + wg.Wait() + close(resultCh) + + for result := range resultCh { + if !result { + success = false } } -- cgit v1.2.3-55-g6feb