mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
test_hashtable_multithread(): Stress it more
Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Hugo Landau <hlandau@devever.net> (Merged from https://github.com/openssl/openssl/pull/25669)
This commit is contained in:
parent
9abd6ca635
commit
837f05fc30
@ -491,10 +491,11 @@ typedef struct test_mt_entry {
|
|||||||
|
|
||||||
static HT *m_ht = NULL;
|
static HT *m_ht = NULL;
|
||||||
#define TEST_MT_POOL_SZ 256
|
#define TEST_MT_POOL_SZ 256
|
||||||
#define TEST_THREAD_ITERATIONS 10000
|
#define TEST_THREAD_ITERATIONS 1000000
|
||||||
|
#define NUM_WORKERS 16
|
||||||
|
|
||||||
static struct test_mt_entry test_mt_entries[TEST_MT_POOL_SZ];
|
static struct test_mt_entry test_mt_entries[TEST_MT_POOL_SZ];
|
||||||
static char *worker_exits[4];
|
static char *worker_exits[NUM_WORKERS];
|
||||||
|
|
||||||
HT_START_KEY_DEFN(mtkey)
|
HT_START_KEY_DEFN(mtkey)
|
||||||
HT_DEF_KEY_FIELD(index, uint32_t)
|
HT_DEF_KEY_FIELD(index, uint32_t)
|
||||||
@ -643,15 +644,15 @@ static int test_hashtable_multithread(void)
|
|||||||
1, /* Check collisions */
|
1, /* Check collisions */
|
||||||
};
|
};
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
thread_t workers[4];
|
thread_t workers[NUM_WORKERS];
|
||||||
int i;
|
int i;
|
||||||
#ifdef MEASURE_HASH_PERFORMANCE
|
#ifdef MEASURE_HASH_PERFORMANCE
|
||||||
struct timeval start, end, delta;
|
struct timeval start, end, delta;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memset(worker_exits, 0, sizeof(char *) * 4);
|
memset(worker_exits, 0, sizeof(char *) * NUM_WORKERS);
|
||||||
memset(test_mt_entries, 0, sizeof(TEST_MT_ENTRY) * TEST_MT_POOL_SZ);
|
memset(test_mt_entries, 0, sizeof(TEST_MT_ENTRY) * TEST_MT_POOL_SZ);
|
||||||
memset(workers, 0, sizeof(thread_t) * 4);
|
memset(workers, 0, sizeof(thread_t) * NUM_WORKERS);
|
||||||
|
|
||||||
m_ht = ossl_ht_new(&hash_conf);
|
m_ht = ossl_ht_new(&hash_conf);
|
||||||
|
|
||||||
@ -666,7 +667,7 @@ static int test_hashtable_multithread(void)
|
|||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < NUM_WORKERS; i++) {
|
||||||
if (!run_thread(&workers[i], do_mt_hash_work))
|
if (!run_thread(&workers[i], do_mt_hash_work))
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
@ -682,7 +683,7 @@ shutdown:
|
|||||||
* conditions
|
* conditions
|
||||||
*/
|
*/
|
||||||
ret = 1;
|
ret = 1;
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < NUM_WORKERS; i++) {
|
||||||
if (worker_exits[i] != NULL) {
|
if (worker_exits[i] != NULL) {
|
||||||
TEST_info("Worker %d failed: %s\n", i, worker_exits[i]);
|
TEST_info("Worker %d failed: %s\n", i, worker_exits[i]);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user