@@ -24,14 +24,49 @@ class SIMPLNX_EXPORT Preferences
2424 friend class AbstractPlugin ;
2525
2626public:
27- static inline constexpr StringLiteral k_LargeDataSize_Key = " large_data_size" ; // bytes
28- static inline constexpr StringLiteral k_PreferredLargeDataFormat_Key = " large_data_format" ; // string
29- static inline constexpr StringLiteral k_InMemoryFormat = " Simplnx-Default-In-Memory" ; // explicit in-core; empty string means "not configured"
30- static inline constexpr StringLiteral k_LargeDataStructureSize_Key = " large_datastructure_size" ; // bytes
31- static inline constexpr StringLiteral k_ForceOocData_Key = " force_ooc_data" ; // boolean
32- static inline constexpr nx::core::StringLiteral k_OoCTempDirectory_ID = " ooc_temp_directory" ; // Out-of-Core temp directory
33- static inline constexpr StringLiteral k_OocRangeScanTimeoutSeconds_Key = " ooc_range_scan_timeout_seconds" ; // uint32, seconds
34- static inline constexpr StringLiteral k_OocMemoryBudgetBytes_Key = " ooc_memory_budget_bytes" ; // uint64, bytes
27+ // / @name Preference Keys
28+ // / JSON keys used to store and retrieve preference values. These keys appear
29+ // / in the serialized preferences.json file and are used internally by the
30+ // / getter/setter methods below.
31+ // / @{
32+
33+ // / Byte-size threshold above which a single DataArray is considered "large"
34+ // / and may be written to an OOC-capable format instead of in-memory storage.
35+ static inline constexpr StringLiteral k_LargeDataSize_Key = " large_data_size" ;
36+
37+ // / Name of the preferred storage format for large DataArrays (e.g., "HDF5-OOC").
38+ // / An empty string means "not yet configured by the user or plugin".
39+ static inline constexpr StringLiteral k_PreferredLargeDataFormat_Key = " large_data_format" ;
40+
41+ // / Sentinel value for k_PreferredLargeDataFormat_Key that explicitly requests
42+ // / in-memory storage. This is distinct from an empty string, which means
43+ // / "not configured" and falls back to plugin-supplied defaults.
44+ static inline constexpr StringLiteral k_InMemoryFormat = " Simplnx-Default-In-Memory" ;
45+
46+ // / Byte-size threshold for the entire DataStructure. When total memory usage
47+ // / approaches this value, the application may switch to OOC storage for new arrays.
48+ // / The default is computed dynamically by updateMemoryDefaults() based on system RAM.
49+ static inline constexpr StringLiteral k_LargeDataStructureSize_Key = " large_datastructure_size" ;
50+
51+ // / Boolean flag that, when true, forces all new DataArrays to use OOC storage
52+ // / regardless of their size. Only takes effect when an OOC format is active.
53+ static inline constexpr StringLiteral k_ForceOocData_Key = " force_ooc_data" ;
54+
55+ // / Filesystem path to the directory where OOC temporary files (chunk stores,
56+ // / backing HDF5 files) are created during filter execution.
57+ static inline constexpr nx::core::StringLiteral k_OoCTempDirectory_ID = " ooc_temp_directory" ;
58+
59+ // / Timeout in seconds for the background thread that scans OOC DataArrays to
60+ // / compute their value ranges (min/max). If the scan does not complete within
61+ // / this window, the range is reported as unknown. Default: 30 seconds.
62+ static inline constexpr StringLiteral k_OocRangeScanTimeoutSeconds_Key = " ooc_range_scan_timeout_seconds" ;
63+
64+ // / Total memory budget in bytes shared across all OOC caching subsystems
65+ // / (chunk cache, stride cache, partition cache). The OOC memory budget manager
66+ // / distributes this budget via global LRU eviction. Default: 8 GB.
67+ static inline constexpr StringLiteral k_OocMemoryBudgetBytes_Key = " ooc_memory_budget_bytes" ;
68+
69+ // / @}
3570
3671 /* *
3772 * @brief Returns the default file path for storing preferences based on the application name.
@@ -230,7 +265,15 @@ class SIMPLNX_EXPORT Preferences
230265 void setForceOocData (bool forceOoc);
231266
232267 /* *
233- * @brief Updates memory-related default values based on system capabilities.
268+ * @brief Recomputes the default value for k_LargeDataStructureSize_Key based
269+ * on the current system's total physical RAM.
270+ *
271+ * The target value is (totalRAM - 2 * k_LargeDataSize), which reserves
272+ * headroom for the OS and the application itself. If the reservation would
273+ * exceed total RAM (e.g., on a low-memory system), the fallback is totalRAM / 2.
274+ *
275+ * Called automatically during construction, after loadFromFile(), and after
276+ * clear(). Can also be called explicitly after changing k_LargeDataSize_Key.
234277 */
235278 void updateMemoryDefaults ();
236279
@@ -253,32 +296,54 @@ class SIMPLNX_EXPORT Preferences
253296 void setOocTempDirectory (const std::string& path);
254297
255298 /* *
256- * @brief Gets the timeout (in seconds) for the background OOC range scan.
299+ * @brief Gets the timeout for the background OOC range scan.
300+ *
301+ * The range scan runs on a background thread after an OOC DataArray is loaded,
302+ * computing min/max values by reading through all chunks sequentially. If the
303+ * scan does not complete within this timeout, the range is reported as unknown
304+ * and the UI shows "N/A" for the array's value range.
305+ *
257306 * @return Timeout in seconds (default 30)
258307 */
259308 uint32 oocRangeScanTimeoutSeconds () const ;
260309
261310 /* *
262- * @brief Sets the timeout (in seconds) for the background OOC range scan.
263- * @param seconds Timeout value in seconds
311+ * @brief Sets the timeout for the background OOC range scan.
312+ * @param seconds Timeout value in seconds. A value of 0 effectively disables
313+ * the range scan by expiring it immediately.
264314 */
265315 void setOocRangeScanTimeoutSeconds (uint32 seconds);
266316
267317 /* *
268- * @brief Gets the total memory budget for all OOC caching (chunk cache, stride cache, partition cache).
318+ * @brief Gets the total memory budget for all OOC caching subsystems.
319+ *
320+ * The OOC memory budget manager distributes this budget across the chunk
321+ * cache, stride cache, and partition cache using global LRU eviction. When
322+ * the combined memory usage of all caches exceeds this budget, the least
323+ * recently used entries are evicted to make room for new data.
269324 *
270- * The budget manager distributes this across subsystems via global LRU eviction.
271- * The default (8 GB) is a safe fallback; the SimplnxOoc plugin overrides this on
272- * startup with OocMemoryBudgetManager::defaultBudgetBytes() (50% of system RAM)
273- * if the user has not saved an explicit preference.
325+ * The default value (8 GB) is a conservative fallback used when no plugin
326+ * has configured a more appropriate value. On startup, the SimplnxOoc plugin
327+ * calls OocMemoryBudgetManager::defaultBudgetBytes() (50% of system RAM) and
328+ * sets that as the budget, unless the user has already saved an explicit
329+ * preference via the UI.
274330 *
275- * @return Budget in bytes (default 8 GB)
331+ * @note This reads from m_Values (user-set) directly, NOT from m_DefaultValues,
332+ * because the default is hard-coded as a compile-time constant.
333+ *
334+ * @return Budget in bytes (default 8 GB if not explicitly set)
276335 */
277336 uint64 oocMemoryBudgetBytes () const ;
278337
279338 /* *
280- * @brief Sets the total memory budget for all OOC caching.
281- * @param bytes Budget in bytes
339+ * @brief Sets the total memory budget for all OOC caching subsystems.
340+ *
341+ * The new budget takes effect immediately for subsequent cache eviction
342+ * decisions. Existing cached data that exceeds the new budget will be
343+ * evicted lazily as new cache entries are requested.
344+ *
345+ * @param bytes Budget in bytes. Must be > 0; passing 0 would effectively
346+ * disable caching.
282347 */
283348 void setOocMemoryBudgetBytes (uint64 bytes);
284349
@@ -297,7 +362,13 @@ class SIMPLNX_EXPORT Preferences
297362 void addDefaultValues (std::string pluginName, std::string valueName, const nlohmann::json& value);
298363
299364 /* *
300- * @brief Checks and updates whether out-of-core mode should be used based on current settings.
365+ * @brief Recomputes the cached m_UseOoc flag based on the current value of
366+ * k_PreferredLargeDataFormat_Key.
367+ *
368+ * OOC mode is considered active when the resolved format string is non-empty
369+ * and is not the sentinel value k_InMemoryFormat. This method is called after
370+ * any operation that could change the format: construction, loadFromFile(),
371+ * setLargeDataFormat(), and setDefaultLargeDataFormat().
301372 */
302373 void checkUseOoc ();
303374
0 commit comments