Core Affinity: Best Practices

DrMickeyLauer
Posts: 168
Joined: Sun May 22, 2022 2:42 pm

Core Affinity: Best Practices

Postby DrMickeyLauer » Thu Apr 04, 2024 2:31 pm

In my ongoing struggle to get the best performance out of the ESP32 family... is there any benefit in pinning tasks that communicate (via any FreeRTOS mechanisms) to the same CPU core or does it not matter? I'm asking because of potential cache locality benefits and similar things I (vaguely) remember from other CPU architectures.

How do you pin your tasks to cores?

MicroController
Posts: 1706
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Core Affinity: Best Practices

Postby MicroController » Thu Apr 04, 2024 5:41 pm

I don't think there is any benefit in terms of synchronization "efficiency", as in, there's no performance gain or penalty for FreeRTOS to schedule a woken-up task to one core or the other. Deep, deep down in the bowels of the FreeRTOS scheduler there will be some inter-core communication happening to cause a context switch on the, from the scheduler's perspective, other core, but that's probably insignificant relative to the ~10us any context switch will take anyway.

Accesses to internal RAM happen directly from either core; there's no CPU cache, so no cache synchronization/locality effects between cores.
How do you pin your tasks to cores?
I don't if I don't have to. Pinning tasks to cores restricts concurrency, which is rarely what I want.

Who is online

Users browsing this forum: No registered users and 77 guests