FreeBSD 11.x thread creation time is 9000+ microseconds on Intel Xeon Gold series CPU
Steevan Rodrigues
steevanxperia at gmail.com
Tue Nov 6 09:01:23 UTC 2018
Ok. Sorry about that. Again I have attached that test program as a tar
file. I am not sure whether even this gets stripped by mailing list
software.
Anyway here is the program given below.
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/time.h>
#include <sys/param.h>
#include <sys/cpuset.h>
#define CPU_NUM 5
#define CPUBIND
void *myThreadFun(void *vargp)
{
sleep(1);
printf("Printing from demo for thread creation time \n");
return NULL;
}
void main(void)
{
pthread_t thread_id;
unsigned long int usec, usec2, sec, sec2;
struct timeval tv, tv2;
struct timezone tz;
pthread_attr_t attr;
#ifdef CPUBIND
cpuset_t cset;
const pid_t pid = getpid();
CPU_ZERO(&cset);
CPU_SET(CPU_NUM,&cset);
cpusetid_t setid;
cpuset(&setid);
//sched_setaffinity(pid, sizeof(cpu_set_t), &cset);
//cpuset_setaffinity(CPU_LEVEL_CPUSET, CPU_WHICH_CPUSET, setid,
sizeof(cpuset_t), &cset);
cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid,
sizeof(cpuset_t), &cset);
#endif
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
gettimeofday(&tv, &tz); // take time before creating thread
pthread_create(&thread_id, &attr, myThreadFun, NULL);
gettimeofday(&tv2, &tz); // take time after creation of thread
pthread_join(thread_id, NULL);
usec = tv.tv_usec;
sec = tv.tv_sec;
usec2 = tv2.tv_usec;
sec2 = tv2.tv_sec;
printf("Thread creation time details are: \n");
printf("Before: Sec %lu usec %lu After: Sec %lu usec %lu : SecDiff %lu
UsecDiff %lu \n", sec, usec, sec2, usec2, sec2 - sec , usec2 - usec);
}
---------------------------------------------
Thanks
Steevan
On Tue, Nov 6, 2018 at 12:34 PM Václav Haisman <vhaisman at gmail.com> wrote:
> On 06. 11. 18 5:01, Steevan Rodrigues wrote:
> > Hi ,
> > I am seeing a FreeBSD 11.x OS poor performance issue .
> > CPU is Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz ( dual socket CPU with 10
> > cores per socket )
> >
> > I have attached a simple program which creates thread and computes time
>
> There is no attachment. The mailing list software probably stripped that.
>
> > taken to create this thread. On this CPU with FreeBSD 11.x OS it takes
> 9000
> > to 15000 micro seconds ( us) to create
> > just one thread.
> >
> > On other platforms this thread creation time is usually 20 to 30 us only.
> > Any idea why it takes so much more time with FreeBSD 11.x ?
> > Is there any processor specific tuning that needs to be done ?
> >
> > Thanks,
> > Steevan
> > _______________________________________________
> > freebsd-hackers at freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > To unsubscribe, send any mail to "
> freebsd-hackers-unsubscribe at freebsd.org"
> >
>
>
> --
> VH
>
>
More information about the freebsd-hackers
mailing list