Threads configuration based on no. of CPU-cores

前端 未结 8 1252
孤城傲影
孤城傲影 2020-11-27 13:10

Scenario : I have a sample application and I have 3 different system configuration -

- 2 core processor, 2 GB RAM, 60 GB HHD,
- 4 core processor, 4 GB RAM, 8         


        
8条回答
  •  青春惊慌失措
    2020-11-27 13:35

    I agree with the other answers here that recommend a best-guess approach, and providing configuration for overriding the defaults.

    In addition, if your application is particularly CPU-intensive, you may want to look into "pinning" your application to particular processors.

    You don't say what your primary operating system is, or whether you're supporting multiple operating systems, but most have some way of doing this. Linux, for instance, has taskset.

    A common approach is to avoid CPU 0 (always used by the OS), and to set your application's cpu affinity to a group of CPUs that are in the same socket.

    Keeping the app's threads away from cpu 0 (and, if possible, away from other applications) often improves performance by reducing the amount of task switching.

    Keeping the application on one socket can further increase performance by reducing cache invalidation as your app's threads switch among cpus.

    As with everything else, this is highly dependent on the architecture of the machine that you are running on, as well as what other applications are runnning.

提交回复
热议问题