Skip to content

Cache module search paths and add hotplug invalidation API - #335

Merged
JohnAmadis merged 4 commits into
developfrom
feat/module-search-path-cache
Oct 19, 2026
Merged

JohnAmadis merged 4 commits into
developfrom
feat/module-search-path-cache

Conversation

@JaxCalder

@JaxCalder JaxCalder commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Module searches expand /mnt/*/bin while parsing search paths and reuse one global linked-list tail on subsequent lookups. Dmod_InvalidateModuleSearchPaths() clears that tail after mount/unmount or a search configuration change; the next lookup rebuilds the list.

The existing helpers remain in dmod_hlp.c. Wildcard expansion scans the parent directory and adds a search node for each child directory, preserving the literal suffix. The suffix need not exist yet, so uploading bin and new .dmf/.dmfc files does not require invalidation. A single complete * component in an absolute path is supported; literal path precedence is unchanged.

A SAL mutex protects the cache. The tail counts references from the cache and readers so invalidation cannot free a list still used by a lookup or iterator. Initialization/deinitialization manages the mutex; searches without mutex support remain uncached. There is one system-wide cache, so configuration changes require explicit invalidation. Mount managers must call it after releasing filesystem/mount locks.

Validation:

  • 30 tests passed across search-cache, helper, completion and module-enumeration suites.
  • All 10 search-cache tests passed under AddressSanitizer and UndefinedBehaviorSanitizer, including concurrent readers and invalidation.
  • Full Debug firmware for STM32F746G-DISCO builds and links successfully. No firmware was flashed.

Companion PRs: choco-technologies/dmblock#5 and choco-technologies/dmod-boot#143.

@JohnAmadis JohnAmadis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

popraw na razie to, a potem dopiero to jeszcze raz przejrzę

Comment thread src/system/private/dmod_search.c Outdated
#if DMOD_USE_PTHREAD
#include <pthread.h>
static pthread_mutex_t g_searchLock = PTHREAD_MUTEX_INITIALIZER;
#define LOCK() pthread_mutex_lock(&g_searchLock)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jaki kurwa pthread?! masz SAL od tego debilu

Comment thread src/system/private/dmod_search.c Outdated
#include "dmod.h"
#include "private/dmod_hlp.h"
#include <string.h>
#if DMOD_USE_PTHREAD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nie kurwa. Ty masz używać SAL API a nie pthread

Comment thread src/system/private/dmod_search.c Outdated
#define UNLOCK() pthread_mutex_unlock(&g_searchLock)
#else
/* Only metadata is accessed here: never allocate or perform I/O in this lock. */
#define LOCK() Dmod_EnterCritical()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no niby po chuj definiujesz te pieprzone makra LOCK i UNLOCK?!

Comment thread src/system/private/dmod_search.c Outdated

void Dmod_InvalidateModuleSearchPaths(void)
{
SearchSnapshot* old[SEARCH_CACHE_SLOTS];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ta, no pewnie - masz przeciez liste linkowana stworzona specjalnie dla węzłów, ale co tam - lepiej stworzyć tablice globalna na max 8 slotów. POPRAW TO!

Comment thread src/system/private/dmod_search.c Outdated
for (size_t i = 0; i < SEARCH_CACHE_SLOTS; ++i) ReleaseSnapshot(old[i]);
}

Dmod_SearchNode_t* Dmod_Hlp_AddSearchNode(Dmod_SearchNode_t* tail, const char* path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nie masz przenosić tych helperów! Mają być dokładnie tam, gdzie były. Jesteś beznadziejnym programistą i ja muszę widzieć, co dokładnie zmieniłeś baranie

@JohnAmadis JohnAmadis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

popraw to

Comment thread src/system/private/dmod_hlp.c Outdated
@JohnAmadis
JohnAmadis merged commit bc1d635 into develop Oct 19, 2026
6 checks 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