Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perftest: replace rand() with getrandom() during MR buffer initializa…
…tion rand() has very poor performance in some OS. ib_send_bw will spend a lot of time during MR initialization when testing large packects in above scenario. test has been done: """ \#define HUGE_MR_SIZE 2147483647 int main(int argc, char *argv[]) { char *a = malloc(HUGE_MR_SIZE * sizeof(char)); unsigned int i; char *tmp = a; int ret; srand(time(NULL)); if (a == NULL) exit(1); if (argc <= 1) goto fall_back; for (i = HUGE_MR_SIZE; i > 0;) { ret = getrandom(tmp, i, 0); if (ret < 0) goto fall_back; tmp += ret; i -= ret; } goto out; fall_back: for(i = 0; i < HUGE_MR_SIZE; i++) a[i] = (char)rand(); out: free(a); return 0; } time ./a.out real 5m35.033s user 5m33.546s sys 0m0.918s time ./a.out 1 real 0m6.454s user 0m0.000s sys 0m6.449s """ As shown in the test above, getrandom() has a much better performance, so replace rand() with it. Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
- Loading branch information