WebServer.handleClient() longer time execution on ESP32-C3 compares to ESP8266 (930 us vs 10us) #7708
Description
Board
ESP32-C3
Device Description
ESP32-C3 DevKitM-1
Hardware Configuration
GPIO 19 as a test for Logic Analyzer software
Version
latest master (checkout manually)
IDE Name
PlatformIO
Operating System
Windows 10 x64
Flash frequency
mode:DOUT, clock div:1
PSRAM enabled
yes
Upload speed
ota
Description
Im using WebServer.handleClient() to manage GET commands with parameters in URL. This function on ESP32 takes 90 times longer compares to ESP8266.
My method of testing:
with Logic analyzer.
platform = espressif32
board = esp32-c3-devkitm-1
test with few handlers (webServer.on("/setParams"......):
933us
test without any handlers, just webServer.init():
933us
platform = espressif8266
board = esp07
test with few handlers:
11.88us
test without any handlers, just init:
11.88us
ESP32-C3 needs 933us compares to 11us on ESP8266 which is 90x timer slower than older chips. In my solution time is critical and I had to slow down other peripherals (to prevent overflow buffers), which affects essential on performance.
Sketch
void esp_get_hardware_info(void);
WebServer server(80);
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_MODE_STA);
IPAddress ip(192,168,1,116);
IPAddress gw(192,168,1,1);
IPAddress subnet(255,255,255,0);
WiFi.config(ip, gw, subnet);
WiFi.begin("ssid", "pw");
while(WiFi.status() != WL_CONNECTED)
{
delay(500);
}
localIP = WiFi.localIP();
WiFi.setAutoReconnect(true);
WiFi.setTxPower(WIFI_POWER_19_5dBm);
server.on(PSTR("/info"), esp_get_hardware_info);
server.begin();
pinMode(19, OUTPUT);
digitalWrite(19,LOW);
}
void loop()
{
digitalWrite(19, HIGH);
server.handleClient();
digitalWrite(19, LOW);
}
void esp_get_hardware_info(void)
{
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
Serial.println("Hardware info");
Serial.printf("%d cores Wifi %s%s\n", chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
Serial.printf("Silicon revision: %d\n", chip_info.revision);
Serial.printf("%dMB %s flash\n", spi_flash_get_chip_size()/(1024*1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embeded" : "external");
//get chip id
String chipId = String((uint32_t)ESP.getEfuseMac(), HEX);
chipId.toUpperCase();
Serial.printf("Chip id: %s\n", chipId.c_str());
}
platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32-c3-devkitm-1
board_build.flash_mode = dout
board_build.f_cpu = 160000000L
board_build.filesystem = littlefs
board_build.mcu = esp32c3
board_build.variant = esp32c3
framework = arduino
Debug Message
-
Other Steps to Reproduce
This long time execution doesnt matter if WiFi is connected or not, also doesnt matter if we called before webServer.init() or not.
Both chips are clocked 160MHz.
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Assignees
Type
Projects
Status
Todo