Add option to force I2S routines into IRAM
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- cpp
- Área
- embedded-iot, performance
Línea de trabajo
Comienza localizando las declaraciones de I2SClass y el uso existente de IRAM_ATTR en el core de ESP8266. Revisa el MCVE enlazado y la configuración de build actual para entender cómo un define opt-in podría controlar estos métodos virtuales. Se considera terminado cuando la opción coloca las rutinas de I2S en IRAM al habilitarse, mientras conserva el comportamiento actual cuando no está habilitada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git). (The relevant code is identical between master and latest release)
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it. (There is none.)
- I have filled out all fields below.
Platform
- Hardware: ESP8266EX (Wemos/Lolin D1 mini)
- Core Version: 3.1.2
- Development Env: Arduino IDE
- Operating System: Windows
Settings in IDE
- Module: Wemos D1 mini r2
- Flash Mode: dio
- Flash Size: 4MB, no FS
- MMU: 16KB/48KB with shared second heap
- lwip Variant: v2 Lower Memory
- Flash Frequency: 80Mhz
- CPU Frequency: 160MHz
- Upload Using: SERIAL
- Upload Speed: 921600
Problem Description
In situations where a very high CPU load is present, and the I2S engine is constantly running to play audio, it is important that I2S can run as fast as possible to not slow down other parts of the system. If memory load is additionally significantly restrained, xtensa-gcc can sometimes decide to move code in and out of IRAM for no apparent reason. For me, this happened when several unrelated functions increased in size significantly - suddenly the I2S routines weren't in IRAM anymore, or something else was going on with un-inlining, I am not quite certain. (Some bloaty information that may provide further clues is here.) This slowed down the high-load procedure significantly, and
The fix for this problem was simply to force all virtual functions of I2SClass into IRAM, like so:
// from Stream
virtual int IRAM_ATTR available();
virtual int IRAM_ATTR read(); // Blocking, will wait for incoming data
virtual int IRAM_ATTR peek(); // Blocking, will wait for incoming data
virtual void IRAM_ATTR flush();
// from Print (see notes on write() methods below)
virtual size_t IRAM_ATTR write(uint8_t);
virtual size_t IRAM_ATTR write(const uint8_t *buffer, size_t size);
virtual int IRAM_ATTR availableForWrite();
Despite my initial expectations, this made xtensa-gcc happy again and the code returned to previous performance.
To avoid having to edit base libraries for this to work, I'd prefer if there was the option to enable these attributes via a define, for those who need it. This would mean no functional changes to everyone who doesn't need it, providing any user full control over IRAM code.
Note: I would like to not receive recommendations for "better" hardware specific to my project. Not only is there no direct replacement for the D1 mini given my peripherals, but I am operating far away enough from the ESP8266's performance and memory limit that it's manageable without weird tricks (not that it's comfortable either, but if you want comfortable programming you become a web developer). I am asking for an option that allows me to optimize my code, and I consider carefully moving functions in and out of IRAM to be a proper optimization technique on architectures like the ESP8266. The inner demoscene kid in me is also having some fun here.
MCVE
This exact commit; note that it requires specific hardware which is laid out in the repository. It doesn't really get more minimal than this, since the issue only presents itself when the CPU load is extremely high.
Debug Messages
(None. I can't even enable the serial console here.)
- Lenguaje dominante
- C++
- Estrellas
- 16.7k
- Forks
- 13.1k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de esp8266/Arduino
-
Typo in Scan Class DocumentationPosiblemente ocupada @MukundaKatta la tomó hace 182 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
lwip2 time-wait.patch: TCP_TW_LIMIT can abort the pcb that tcp_process() is still handling -> double free, heap corruptionPosiblemente ocupada @scardus la tomó hace 15 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
Todos los issues de esp8266/Arduino
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Medio día Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
KhronosGroup/glslang#4469 ·
Los mantenedores suelen responder en 1 día
-
chore: update release scheduleAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Sagiroth/TortoiseBots#917 ·
Los mantenedores suelen responder en 1 día