Add option to force I2S routines into IRAM
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- cpp
- Ambito
- embedded-iot, performance
Direzione di ricerca
Inizia individuando le dichiarazioni di I2SClass e l’uso esistente di IRAM_ATTR nel core ESP8266. Esamina l’MCVE collegato e la configurazione di build corrente per capire come un define opt-in potrebbe controllare questi metodi virtuali. Il lavoro è completato quando l’opzione colloca le routine I2S in IRAM quando è abilitata, preservando il comportamento attuale quando non lo è.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.)
- Lingua principale
- C++
- Stelle
- 16.7k
- Fork
- 13.1k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di esp8266/Arduino
-
Typo in Scan Class DocumentationForse già presa @MukundaKatta l’ha presa 183 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
lwip2 time-wait.patch: TCP_TW_LIMIT can abort the pcb that tcp_process() is still handling -> double free, heap corruptionForse già presa @scardus l’ha presa 16 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
Tutte le issue di esp8266/Arduino
Issue simili
-
agent:WSL bug linux LOW
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Build failure: limoAperta0.kind: build failure
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
prestonbrown/helixscreen#1797 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 72/100
finalburnneo/FBNeo#2803 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno