printk becomes slow when CONFIG_LOG=y and trying to recieve serial communication over uart

I'm using a nRF52840 with the nRF Connect SDK version 2.4.1. I've been using Zephyr's logging module however now I want to also receive data over UART. I followed the Serial Communication (UART) example in nRF Connect SDK Fundamentals course however I've noticed it's very unresponsive (takes ~3 seconds to indicate that data was recieved). I found that this was due to enabling logging (removing CONFIG_LOG makes it responsive).

As an example, take the Lesson 5 Exercise 1 Solution repo from the course NRF Connect Fundamentals and add

case UART_RX_RDY:
        printk("Recieved!");

Then upload normally, when you type into the terminal it instantly prints backed Recieved!

However, if in prj.conf you add

CONFIG_LOG=y

You can see that it takes ~2 seconds before Received! is printed to the console

I thought this may be an issue with both the trying to receive logs and communication over uart0 so I tried switching the logging backend to RTT

CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_BACKEND_RTT=y

However, it still takes ~2 seconds for Received! to be printed

Related