Skip to content

port_yield additions in #10795 cause huge performance degradation on Espressif #10822

@dhalbert

Description

@dhalbert

#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.

Metadata

Metadata

Assignees

Labels

espressifapplies to multiple Espressif chips

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions