| 351 | } |
| 352 | |
| 353 | static int |
| 354 | test_hash_readwrite_perf(struct perf *perf_results, int use_htm, |
| 355 | int reader_faster) |
| 356 | { |
| 357 | unsigned int n; |
| 358 | int ret; |
| 359 | int start_coreid; |
| 360 | uint64_t i, read_cnt; |
| 361 | |
| 362 | const void *next_key; |
| 363 | void *next_data; |
| 364 | uint32_t iter; |
| 365 | int use_jhash = 0; |
| 366 | |
| 367 | uint32_t duplicated_keys = 0; |
| 368 | uint32_t lost_keys = 0; |
| 369 | |
| 370 | uint64_t start = 0, end = 0; |
| 371 | |
| 372 | __atomic_store_n(&gwrites, 0, __ATOMIC_RELAXED); |
| 373 | __atomic_store_n(&greads, 0, __ATOMIC_RELAXED); |
| 374 | |
| 375 | __atomic_store_n(&gread_cycles, 0, __ATOMIC_RELAXED); |
| 376 | __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED); |
| 377 | |
| 378 | if (init_params(0, use_htm, 0, use_jhash) != 0) |
| 379 | goto err; |
| 380 | |
| 381 | /* |
| 382 | * Do a readers finish faster or writers finish faster test. |
| 383 | * When readers finish faster, we timing the readers, and when writers |
| 384 | * finish faster, we timing the writers. |
| 385 | * Divided by 10 or 2 is just experimental values to vary the workload |
| 386 | * of readers. |
| 387 | */ |
| 388 | if (reader_faster) { |
| 389 | printf("++++++Start perf test: reader++++++++\n"); |
| 390 | read_cnt = TOTAL_INSERT / 10; |
| 391 | } else { |
| 392 | printf("++++++Start perf test: writer++++++++\n"); |
| 393 | read_cnt = TOTAL_INSERT / 2; |
| 394 | } |
| 395 | |
| 396 | /* We first test single thread performance */ |
| 397 | start = rte_rdtsc_precise(); |
| 398 | /* Insert half of the keys */ |
| 399 | for (i = 0; i < TOTAL_INSERT / 2; i++) { |
| 400 | ret = rte_hash_add_key_data(tbl_rw_test_param.h, |
| 401 | tbl_rw_test_param.keys + i, |
| 402 | (void *)((uintptr_t)i)); |
| 403 | if (ret < 0) { |
| 404 | printf("Failed to insert half of keys\n"); |
| 405 | goto err_free; |
| 406 | } |
| 407 | } |
| 408 | end = rte_rdtsc_precise() - start; |
| 409 | perf_results->single_write = end / i; |
| 410 |
no test coverage detected