#10795 added calls to port_yield() much more frequently, on every background_callback_run_all(). On most ports, port_yield() does nothing, but on Espressif, port_yield() delays for 4 msecs. This causes a 1400x (!) slowdown in a simple timing loop. Pico W boards will probably also have a big slowdown.
Thanks @daniel-alsen for catching this.
Test:
import time
while True:
start = time.monotonic()
count = 0
while count < 10000:
count += 1
print(time.monotonic() - start)
Without the call to port_yield() , on a Metro ESP32-S3, this prints times of about 0.03 seconds. With the port_yield() call, the times are about 40 seconds each.
The vTaskDelay(4) was added in #6742 several years ago to fix a problem with missing output in web workflow. I tried substituting portYIELD() instead of vTaskDelay(4). That still slows down Espressif by a factor of 2, and I don't know if it would fix the problem that #6742 fixes.
I will make a PR to back out the port_yield() change, because it's only for zephyr, and make a 10.1.1 release.
#10795 added calls to
port_yield()much more frequently, on everybackground_callback_run_all(). On most ports,port_yield()does nothing, but on Espressif,port_yield()delays for 4 msecs. This causes a 1400x (!) slowdown in a simple timing loop. Pico W boards will probably also have a big slowdown.Thanks @daniel-alsen for catching this.
Test:
Without the call to
port_yield(), on a Metro ESP32-S3, this prints times of about0.03seconds. With theport_yield()call, the times are about 40 seconds each.The
vTaskDelay(4)was added in #6742 several years ago to fix a problem with missing output in web workflow. I tried substitutingportYIELD()instead ofvTaskDelay(4). That still slows down Espressif by a factor of 2, and I don't know if it would fix the problem that #6742 fixes.I will make a PR to back out the port_yield() change, because it's only for zephyr, and make a 10.1.1 release.