Skip to content

dmmp3: the decoder's state in fast memory, when the system has it - #3

Merged
JohnAmadis merged 2 commits into
mainfrom
perf/decoder-heap
Oct 18, 2026
Merged

JohnAmadis merged 2 commits into
mainfrom
perf/decoder-heap

Conversation

@JaxCalder

@JaxCalder JaxCalder commented Oct 17, 2026 •

Copy link
Copy Markdown

What

minimp3's state and its scratch - 23 kB worked on for every frame - are now a block of their own, allocated as "fast" memory: Dmod_MallocTagged("fast", sizeof(state_t)) - a heap the system tags fast (dmheap: a heap's name is the list of its tags), when it has one with room, else the default memory. The rest of a decoder (16 kB of the file, a frame of samples) stays where it was.

A closed decoder's state is kept for the next one (one block): a player goes from file to file, and the block freed and allocated again could lose its fast memory - on the board something small took a part of the place meanwhile, and the next state was 28 bytes short.

Why

On the STM32F746G Discovery the default memory is the SDRAM behind a 4 kB data cache. Playing a 44.1 kHz stereo MP3 in carhmi-demo, sampled with a debugger:

decoder state CPU of the player thread
SDRAM (the default heap) 70 %
DTCM 15 %

With the decoding at 70 % the views (below the player's priority) got a few frames a second.

Depends on

CI builds against dmod's develop: it passes once dmod#332 is merged.

Tests

5/5 on the host (against dmod#332's dmod_loader).

🤖 Generated with Claude Code

JohnAmadis and others added 2 commits October 18, 2026 08:29
minimp3's state and its scratch - 23 kB worked on for every frame - are a
block of their own, allocated as "fast" memory (Dmod_MallocTagged): a heap
the system tags so, else the default memory. On an STM32F746 with its SDRAM
behind a 4 kB data cache decoding took 70 % of the CPU there, 15 % in the
DTCM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A player goes from file to file: the state freed and allocated again could
lose its fast memory - something small taking a part of the place
meanwhile, the next one not fitting (seen on the board: the DTCM's block
was 28 bytes short after a track changed). The block of a closed decoder
is kept for the next one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 96e468e into main Oct 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants