Skip to content

Resolve a handle's driver functions once, at open - #71

Merged
JohnAmadis merged 1 commit into
mainfrom
perf/cache-driver-functions
Oct 11, 2026
Merged

JohnAmadis merged 1 commit into
mainfrom
perf/cache-driver-functions

Conversation

@JaxCalder

Copy link
Copy Markdown
Contributor

Summary

fread, fwrite, ioctl, flush and sync looked up the driver's DIF function with Dmod_GetDifFunction() on every call, which compares signature strings. An audio stream writes hundreds of times a second through two nodes (the codec, then its SAI), and a profile on the STM32F746G-DISCO showed the signature comparisons as a visible share of the audio service's CPU.

The functions are now resolved once, when the file is opened, and kept in the handle. The handle keeps its driver node for its lifetime. It is zeroed at allocation, so /dev/null handles hold NULLs.

The file-system layer above already caches its own DIF functions (dmvfs#61); this is the same for the driver layer below.

Test plan

  • ctest with -DDMDEVFS_BUILD_TESTS=ON: everything passes except test_dmdevmon, which fails on main as well (test_order also fails there now and then)
  • STM32F746G-DISCO: the whole system boots and plays audio

🤖 Generated with Claude Code

read, write, ioctl and flush looked up the driver's DIF function
(Dmod_GetDifFunction(), comparing signatures) on every call; an audio
stream writes hundreds of times a second through two nodes. They are
resolved when the file is opened and kept in its handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 5c2579d into main Oct 11, 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