-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize ELG with the number of affinitized cores
The MultiThreadedEventLoopGroup that runs the HTTPServer is initialized with all the available cores. On Linux, it could be instead initialised to the number of affinitized cores. If the number of affinitized cores is lesser than the `System.coreCount`, initializing the MultiThreadedEventLoopGroup with the later comes with a performance penalty.
- Loading branch information
Pushkar N Kulkarni
committed
Dec 17, 2018
1 parent
0722291
commit 6439ae1
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifdef __linux__ | ||
|
||
#define _GNU_SOURCE | ||
#include <sched.h> | ||
#include <stdbool.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
int linux_sched_getaffinity() { | ||
cpu_set_t mask; | ||
long nproc, i, count = 0; | ||
|
||
if (sched_getaffinity(0, sizeof(cpu_set_t), &mask) == -1) { | ||
return -1; | ||
} else { | ||
nproc = sysconf(_SC_NPROCESSORS_ONLN); | ||
for (i = 0; i < nproc; i++) { | ||
if(CPU_ISSET(i, &mask)) | ||
count += 1; | ||
} | ||
return count; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#if __linux__ | ||
int linux_sched_getaffinity(); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters