watcher started only when needed#4369
Open
dtrawins wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines OVMS model monitoring so the watcher thread starts only when required (config file monitoring and/or filesystem version polling), and gates version polling work behind a dynamically re-evaluated versionPollingNeeded flag.
Changes:
- Introduces
versionPollingNeededandevaluatePollingState()to decide whether filesystem version polling is required and whether to start the watcher. - Updates the watcher loop to run
updateConfigurationWithoutConfigFile()only when version polling is needed, and re-evaluates polling state after config reloads. - Updates a test JSON config to explicitly set
target_deviceto CPU.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/test/configs/config_string.json | Adds target_device: CPU to the string passthrough test config. |
| src/modelmanager.hpp | Adds versionPollingNeeded state and declares evaluatePollingState(). |
| src/modelmanager.cpp | Implements polling-state evaluation and gates watcher/version polling behavior accordingly. |
Comment on lines
+132
to
+136
| /** | ||
| * @brief Evaluates whether filesystem version polling is needed | ||
| * and starts the watcher thread if at least one model uses version directories | ||
| */ | ||
| void evaluatePollingState(); |
Comment on lines
+242
to
+244
| } else { | ||
| SPDLOG_LOGGER_DEBUG(modelmanager_logger, "Filesystem version polling disabled - no model uses version directories"); | ||
| } |
Comment on lines
1086
to
1090
| configFileReloadNeeded(isNeeded); | ||
| if (isNeeded) { | ||
| loadConfig(); | ||
| evaluatePollingState(); | ||
| } |
Comment on lines
+215
to
+219
| void ModelManager::evaluatePollingState() { | ||
| static const std::set<std::string> singleFileExtensions = { | ||
| ".xml", ".onnx", ".pdmodel", ".pdiparams", ".pb", ".tflite"}; | ||
|
|
||
| versionPollingNeeded = false; |
Comment on lines
+216
to
+217
| static const std::set<std::string> singleFileExtensions = { | ||
| ".xml", ".onnx", ".pdmodel", ".pdiparams", ".pb", ".tflite"}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 Summary
Now the design is:
versionPollingNeeded — member variable re-evaluated by evaluatePollingState() after every config load
Watcher starts if either config file monitoring is needed OR version polling is needed
updateConfigurationWithoutConfigFile() only runs when versionPollingNeeded is true
After each loadConfig(), evaluatePollingState() is called again — so if the new config adds a versioned model, version polling activates dynamically
🧪 Checklist
``