Skip to content

Commit

Permalink
ipvs: improve performance of local addr selection by replacing glibc …
Browse files Browse the repository at this point in the history
…random with rte_rand

Signed-off-by: ywc689 <[email protected]>
  • Loading branch information
ywc689 committed Apr 30, 2024
1 parent efc101b commit e19269d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ipvs/ip_vs_laddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static inline int __laddr_step(struct dp_vs_service *svc)
* */
if (strncmp(svc->scheduler->name, "rr", 2) == 0 ||
strncmp(svc->scheduler->name, "wrr", 3) == 0)
return (random() % 100) < 5 ? 2 : 1;
return rte_rand_max(100) < 5 ? 2 : 1;

return 1;
}
Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ int main(int argc, char *argv[])

gettimeofday(&tv, NULL);
srandom(tv.tv_sec ^ tv.tv_usec ^ getpid());
rte_srand((uint64_t)(tv.tv_sec ^ tv.tv_usec ^ getpid()));
sys_start_time();

if (get_numa_nodes() > DPVS_MAX_SOCKET) {
Expand Down

0 comments on commit e19269d

Please sign in to comment.