Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Nov 2018 14:31:09 +0530
From:      Steevan Rodrigues <steevanxperia@gmail.com>
To:        vhaisman@gmail.com
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: FreeBSD 11.x thread creation time is 9000+ microseconds on Intel Xeon Gold series CPU
Message-ID:  <CAKsGTHTLAaPW6P94J_uv%2ByPpOv9FuZZQQjBDYV-vTJUDYZSa%2Bg@mail.gmail.com>
In-Reply-To: <7bb8463e-aa5d-bade-7ae7-6c612bae65f9@gmail.com>
References:  <CAKsGTHQnaEsqmf_g%2BhH=agmfJ5Z4sZY8qkw1iJWyOF=1e6qm-g@mail.gmail.com> <7bb8463e-aa5d-bade-7ae7-6c612bae65f9@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 =3D 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 =3D tv.tv_usec;
    sec =3D tv.tv_sec;
    usec2 =3D tv2.tv_usec;
    sec2 =3D 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=C3=A1clav Haisman <vhaisman@gmail.com> wr=
ote:

> 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 onl=
y.
> > 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@freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > To unsubscribe, send any mail to "
> freebsd-hackers-unsubscribe@freebsd.org"
> >
>
>
> --
> VH
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAKsGTHTLAaPW6P94J_uv%2ByPpOv9FuZZQQjBDYV-vTJUDYZSa%2Bg>