The esp-idf FreeRTOS port has a default tick rate of 100Hz and that's dumb

What the menuconfig window looks like when setting the FreeRTOS tick rate

What the menuconfig window looks like when setting the FreeRTOS tick rate

No matter how many esp-idf projects I create, I almost always wast time solving a bug that I eventually realize is simply from the low initial tick rate.

The FreeRTOS tick rate is the rate at which the RTOS performs one incremental tick, or “clock cycle”, of its scheduler. This affects things like how fast it can context switch between tasks, or how long a tick-based delay will actually delay in processor/real-time.

Unless one is attempting to save power by running the CPU slower or in a very resource-constrained environment (definitely not the case for the Espressif chips), the typical tick rate used for a FreeRTOS-based firmware is 1000Hz, or once every millisecond. esp-idf, however, defaults its menuconfig option to 100Hz, or ten milliseconds per tick.

If you’re using the proper abstraction macros and functions to handle variable tick rates, this issue is masked at first. For example, instead of calling vTaskDelay(100) when trying to delay for 100ms with a (expected) tick rate of 1000Hz, the better way would be to call vTaskDelay(pdMS_TO_TICKS(100)). That macro will convert the desired millisecond delay to ticks using the settings defined in FreeRTOSConfig.h.

I usually end up catching it when I start to add a few tasks that are blocking and waiting for signals from each other. The main symptom of the mistake is drastically reduced throughput in the system. If the firmware is meant to receive packets over UART or some other hardware peripheral and then take action upon that data in another task, it might appear as though the RTOS is struggling to keep up, with overflowing queues or message buffers. In reality, the firmware is limited to context switching and processing its internal API functions every 10ms, which is a huge bottleneck for all but the slowest protocols or actions.

The fix is dead simple: simply bump the tick rate in the Menuconfig > Component Config > FreeRTOS > Kernel > configTICK_RATE_HZ option and voila, speedy system.