WIP/MEDIUM: thread: order CPUs before picking the first ones

WIP: still not true because the number of threads is not necessarily
equal to the number of CPUs we're bound to. For now the node id
remains the sole criterion used on this test. Also, we should only
bind CPUs that are either:
  - not excluded at boot when !cpu_map_configured()
  - mapped when cpu_map_configured()
and not offline of course.

Now when starting a default number of threads, instead of limiting
ourselves to the first 32 or 64 CPUs that appear in the list, we'll
take the same number after having sorted them by capacity and vicinity.
This means that setups which have a single declared NUMA node and CPUs
spread between sockets before threads will at least have a chance to
bind only to threads of related cores and to avoid using the second
package by default.

The goal will now be to improve on this selection.
This commit is contained in:
Willy Tarreau 2023-07-21 17:10:52 +02:00
parent d7e21999c8
commit e1f1ba13c2
1 changed files with 3 additions and 0 deletions

View File

@ -1416,6 +1416,9 @@ void thread_detect_count(void)
ha_cpuset_zero(&node_cpu_set);
/* sort CPUs by capacity and vicinity */
cpu_optimize_topology(ha_cpu_topo, maxcpus);
for (cpu = 0; cpu < maxcpus; cpu++) {
if (ha_cpu_topo[cpu].no_id >= 0) {
first_node_id = ha_cpu_topo[cpu].no_id;