How much overhead is there when creating a thread?

后端 未结 11 1378
故里飘歌
故里飘歌 2020-12-02 20:14

I just reviewed some really terrible code - code that sends messages on a serial port by creating a new thread to package and assemble the message in a new thread for every

11条回答
  •  鱼传尺愫
    2020-12-02 20:46

    Interesting.

    I tested with my FreeBSD PCs and got the following results:

    FreeBSD 12-STABLE, Core i3-8100T, 8GB RAM: 9.523sec
    FreeBSD 12.1-RELEASE, Core i5-6600K, 16GB: 8.045sec

    You need to do

    sysctl kern.threads.max_threads_per_proc=500100
    

    though.

    Core i3-8100T is pretty slow but the results are not very different. Rather the CPU clocks seem to be more relevant: i3-8100T 3.1GHz vs i5-6600k 3.50GHz.

提交回复
热议问题