System, method, apparatus, device, and medium for providing data
By integrating a data caching module within the WebAssembly Micro Runtime (WAMR), the system addresses the challenges of resource constrained devices by reducing latency and optimizing resource utilization through efficient data caching and retrieval.
Patent Information
- Application Number
- PCT/CN2023/130792
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-11-09
- Publication Date
- 2025-05-15
AI Technical Summary
Resource constrained devices face challenges in executing complex applications due to limited computing power, storage capacity, and energy resources, and accessing external hardware devices introduces latency and overhead.
A system and method that integrates a data caching module within the WebAssembly Micro Runtime (WAMR) to store and retrieve frequently accessed data, reducing latency and optimizing resource utilization.
The caching mechanism effectively reduces latency and optimizes resource utilization in resource-constrained devices by storing frequently accessed data locally, ensuring efficient data access and consistency.
Smart Images

Figure CN2023130792_15052025_PF_FP_ABST
Abstract
Description
System, method, apparatus, device, and medium for providing dataFIELD
[0001] The present invention relates to the technical field of data processing technology, in particular to a system, method, apparatus, device, and medium for providing data.BACKGROUND
[0002] WebAssembly (WASM) is an intermediate compiled bytecode that can run non-JavaScript languages on browsers. WASM is a virtual instruction set architecture (ISA) that includes core ISA definitions, binary encoding, program semantics definition and execution, as well as application programming interfaces (WASM APIs) for different embedded environments such as Web. Its initial goal is to compile programs written for languages such as C / C++ to ensure security and run better on web platform at speeds close to native applications. WebAssembly Micro Runtime (WAMR) is an independent WASM runtime primarily used for small capacity devices. WAMR typically includes: WASM Virtual Machine (VM) core; APIs for WASM applications; mechanism for dynamically managing WASM applications.
[0003] In the context of WAMR integration, it is necessary to improve the performance and resource utilization of embedded systems and resource constrained devices (such as edge devices) . Resource constrained devices typically have limited computing power, storage capacity, and energy resources. Due to these resource limitations, executing complex applications on such devices may be challenging. In addition, accessing external hardware devices (such as sensors or actuators) may introduce latency and overhead.SUMMARY
[0004] Embodiments of the present invention propose a system, method, apparatus, device, and medium for providing data.
[0005] In a first aspect, a system for providing data is provided. The system comprising:
[0006] a data acquiring module deployed in a WAMR of a device, configured to obtain data from a data source;
[0007] a data caching module deployed in the WAMR, configured to cache the data; and
[0008] a data providing module deployed in the WAMR, configured to receive a data provision request from a data access object, read the data from the data caching module based on the data provision request, and provide the data to the data access object.
[0009] Therefore, by integrating caching mechanisms in WAMR, it is effective in storing and retrieving frequently accessed data, reducing latency and optimizing resource utilization, especially suitable for resource constrained devices.
[0010] Preferably, wherein the data acquiring module is configured to obtain updated data from the data source when a predetermined update cycle expires; the data caching module is configured to update cached data based on the updated data.
[0011] Therefore, data in the cache can be regularly updated to ensure data consistency between cache and data source (such as external hardware devices) , ensuring that subsequent read operations can retrieve the latest data from the cache, avoiding outdated information.
[0012] Preferably, wherein the data acquiring module is configured to obtain updated data from the data source in response to receiving data update instruction; the data caching module is configured to update cached data based on the updated data.
[0013] Therefore, it may proactively update data in the cache at any time based on update instruction to ensure data consistency between the cache and data source (such as external hardware devices) , ensuring that subsequent read operations can retrieve the latest data from the cache and avoid outdated information.
[0014] Preferably, wherein the data providing module is configured to validate the data before providing it to the data access object.
[0015] Therefore, accuracy of the data can be improved by validating the data.
[0016] Preferably, wherein the data providing module is configured to perform at least one of the following:
[0017] compare the data with a predetermined numerical range, and determine that the data does not pass validation when the comparison results indicate that the data does not belong to the numerical range;
[0018] compare the data with a predetermined numerical range, and determine that the data passes validation when the comparison results indicate that the data belongs to the numerical range;
[0019] compare a timestamp of the data with a predetermined active time range, and determine that the data does not pass validation when the comparison results indicate that the timestamp does not belong to the active time range;
[0020] compare a timestamp of the data with a predetermined active time range, and determine that the data passes validation when the comparison results indicate that the timestamp belongs to the active time range.
[0021] Therefore, data validation can be performed in multiple ways.
[0022] Preferably, wherein the data source comprises at least one of the following:
[0023] a sensor connected to the device;
[0024] a WASM module deployed in the WAMR;
[0025] a WASM module deployed in a WAMR of a device other than the device.
[0026] Preferably, wherein the data access object comprises at least one of the following:
[0027] a WASM module deployed in the WAMR;
[0028] a WASM module deployed in a WAMR of a device other than device;
[0029] a device connected to the device.
[0030] Therefore, both data source and data access object have multiple instances, enabling multiple data provision scenarios.
[0031] Preferably, the device comprises a resource constrained device.
[0032] Preferably, wherein the resource constrained device comprises at least one of the following:
[0033] a specialized equipment with industrial edge functionality;
[0034] a supporting equipment with industrial edge functionality.
[0035] Therefore, embodiments of the present invention improve the performance and resource utilization of resource constrained devices, and can be applicable to various types of edge devices.
[0036] In a second aspect, a method for providing data is provided. The method comprising:
[0037] deploying WAMR;
[0038] loading a data acquiring module and a data caching module in the WAMR, wherein the data acquiring module is adapted to obtain data from a data source, and the data caching module is adapted to cache the data; and
[0039] loading a data providing module in the WAMR, wherein the data providing module is adapted to receive a data provision request from a data access object, read the data from the data caching module based on the data provision request, and provide the data to the data access object.
[0040] Therefore, by integrating caching mechanisms in WAMR, it is effective in storing and retrieving frequently accessed data, reducing latency and optimizing resource utilization, especially suitable for resource constrained devices.
[0041] Preferably, the method comprising: cleaning up the data acquiring module and data providing module in the WAMR; retaining the data caching module in the WAMR.
[0042] Therefore, embodiments of the present invention clean up data acquiring module and data providing module, thereby saving system resources, and ensure that the cached data can be continuously accessed by retaining the cache.
[0043] Preferably, the method comprising: validating the data before providing it to the data access object.
[0044] Therefore, accuracy of the data can be improved by validating the data.
[0045] Preferably, the method comprising at least one of the following:
[0046] comparing the data with a predetermined numerical range, and determining that the data does not pass validation when the comparison results indicate that the data does not belong to the numerical range;
[0047] comparing the data with a predetermined numerical range, and determining that the data passes validation when the comparison results indicate that the data belongs to the numerical range;
[0048] comparing a timestamp of the data with a predetermined active time range, and determining that the data does not pass validation when the comparison results indicate that the timestamp does not belong to the active time range;
[0049] comparing a timestamp of the data with a predetermined active time range, and determining that the data passes validation when the comparison results indicate that the timestamp belongs to the active time range.
[0050] Therefore, data validation can be performed in multiple ways.
[0051] In a third aspect, an apparatus for providing data is provided. The apparatus comprising:
[0052] a deploying module, configured to deploy WAMR;
[0053] a first loading module, configured to load a data acquiring module and a data caching module in the WAMR, wherein the data acquiring module is adapted to obtain data from a data source, and the data caching module is adapted to cache the data; and
[0054] a second loading module, configured to load a data providing module in the WAMR, wherein the data providing module is adapted to receive a data provision request from a data access object, read the data from the data caching module based on the data provision request, and provide the data to the data access object.
[0055] In a fourth aspect, an electronic device is provided. The electronic device comprising a processor and a memory, wherein an application program executable by the processor is stored in the memory for causing the processor to execute a method for providing data as described in any of the above.
[0056] In a fifth aspect, a computer-readable medium comprising computer-readable instructions stored thereon is provided, wherein the computer-readable instructions, when executed by a processor, implement a method for providing data as described in any of the above.
[0057] In a sixth aspect, a computer program product comprising a computer program, when the computer program is executed by a processor for executing a method for providing data as described in any of the above.BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to make technical solutions of examples of the present disclosure clearer, accompanying drawings to be used in description of the examples will be simply introduced hereinafter. Obviously, the accompanying drawings to be described hereinafter are only some examples of the present disclosure. Those skilled in the art may obtain other drawings according to these accompanying drawings without creative labor.
[0059] FIG. 1 is an exemplary structural diagram of a system for providing data according to an embodiment of the present invention.
[0060] FIG. 2 is an exemplary flowchart of a method for providing data according to an embodiment of the present invention.
[0061] FIG. 3 is an exemplary schematic diagram of data caching process according to an embodiment of the present invention.
[0062] FIG. 4 is an exemplary flowchart of a data caching method according to an embodiment of the present invention.
[0063] FIG. 5 is a schematic diagram of an exemplary interaction process between WASM module and cache according to an embodiment of the present invention.
[0064] FIG. 6 is a flowchart of an exemplary interaction process between WASM module and cache according to an embodiment of the present invention.
[0065] FIG. 7 is a structural diagram of apparatus for providing data according an embodiment of the present invention.
[0066] FIG. 8 is an exemplary structural diagram of an electronic device according to an embodiment of the present invention.
[0067] List of reference numbers: DETAILED DESCRIPTION
[0068] In order to make the purpose, technical scheme, and advantages of the invention clearer, the following examples are given to further explain the invention in detail.
[0069] In order to be concise and intuitive in description, the scheme of the invention is described below by describing several representative embodiments. Many details in the embodiments are only used to help understand the scheme of the invention. However, it is obvious that the technical scheme of the invention can be realized without being limited to these details. In order to avoid unnecessarily blurring the scheme of the invention, some embodiments are not described in detail, but only the framework is given. Hereinafter, "including" refers to "including but not limited to" , "according to... " refers to "at least according to..., but not limited to... " . When the number of an element is not specifically indicated below, it means that the element can be one or more, or can be understood as at least one.
[0070] WAMR is primarily designed to provide a lightweight WebAssembly runtime environment for embedded systems and resource-constrained devices. In WAMR applications, it is necessary to improve the performance and resource utilization of embedded systems and resource constrained devices. Resource constrained devices typically have limited computing power, storage capacity, and energy resources. Due to these resource limitations, executing complex applications on such devices may be challenging. In addition, accessing external hardware devices, such as sensors or actuators, may introduce latency and overhead. At present, the WAMR mechanism does not explicitly include built-in data caching processing. In fact, these challenges can be addressed by providing a data caching mechanism within the WAMR mechanism. In data caching mechanism, frequently accessed data is stored in fast local storage (cache) to reduce duplicate access to slower external resources such as hardware devices or databases. By caching frequently accessed data and reducing the time and resources required for data retrieval, the overall performance and efficiency of the system can be improved. Cache module in WAMR integration enables developers to leverage data caching techniques in the execution of WebAssembly modules on embedded systems and resource-constrained devices. By implementing a cache module alongside WAMR, the system can store and retrieve frequently accessed data more efficiently, reducing latency and optimizing resource utilization. Therefore, the technical problem addressed by the invention of the Cache Module is the need to enhance the performance and resource efficiency of embedded systems and resource-constrained devices when executing WebAssembly code by incorporating data caching optimization techniques.
[0071] The integration of WAMR with data caching optimization addresses the challenges of performance and resource utilization in embedded systems and resource-constrained devices through several key technical features:
[0072] Customizable caching mechanism: The integration incorporates a customizable caching mechanism that allows developers to tailor caching strategies to the specific requirements and access patterns of their applications. Developers can select appropriate data structure, caching strategy (e.g., LRU, LFU) , and cache invalidation strategy based on the characteristics of their embedded systems and application scenarios.
[0073] Efficient data access: The cache module within the integration optimizes data access by storing frequently accessed data in a fast, local memory (cache) . This minimizes the need for repeated access to slower external resources such as hardware devices or databases, reducing latency and improving overall performance.
[0074] Cache consistency management: The cache module ensures data consistency between the cache and external hardware devices by appropriately updating cache data when hardware device data is modified. This guarantees that subsequent read operations retrieve the latest data from the cache, avoiding stale or outdated information.
[0075] Resource utilization optimization: By caching frequently accessed data, the integration optimizes resource utilization in resource-constrained devices. It reduces the need for frequent access to external resources, conserves computational power, memory, and energy resources, and improves overall efficiency.
[0076] Seamless Integration with WAMR: The integration seamlessly incorporates the cache module into the WAMR runtime environment, enabling developers to easily integrate caching functionality into their applications without extensively modifying WAMR's source code. This facilitates a streamlined integration process and ensures compatibility with other features and capabilities provided by WAMR.
[0077] These technical features collectively solve the problem of improving performance and resource utilization in resource-constrained devices by providing an efficient, customizable, and seamless caching mechanism within the WAMR runtime environment.
[0078] FIG. 1 is an exemplary structural diagram of a system for providing data according to an embodiment of the present invention.
[0079] As shown in FIG. 1, the system comprises: a data acquiring module 12 deployed in a WAMR 11 of a device 10, configured to obtain data from a data source 15; a data caching module 13 deployed in the WAMR 11, configured to cache the data; and a data providing module 14 deployed in the WAMR 11, configured to receive a data provision request from a data access object 16, read the data from the data caching module 13 based on the data provision request, and provide the data to the data access object 16.
[0080] WASM is a bytecode standard proposed to improve the performance of performance sensitive modules in web pages. WASM can be used not only in browsers, but also in other environments. In these environments, it is necessary to support the runtime of the WebAssembly System Interface (WASI) to execute compiled and running WASM modules. Preferably, device 10 may also include WASI 17 and operating system 18.
[0081] In one embodiment, device 10 includes resource constrained devices. For example, resource constrained devices can be implemented as edge devices. Preferably, edge devices include: specialized devices with industrial edge functionality; Supporting equipment with industrial edge functionality.
[0082] Specialized devices with industrial edge functionality are designed specifically for industrial edges and can be connected to the IEM system platform to achieve centralized management of edge devices. For example, specialized devices with industrial edge functionality can include IPC 227E, IPC 127E / 427E / 647E, and IOT gateway products. Supporting devices with industrial edge functionality do not primarily focus on industrial edge functionality, and cannot achieve centralized management of edge devices. However, they have the ability to deploy edge APPs. For example, supporting devices with industrial edge functionality can include: Open Controller; Unified Comfort Panel; S7-1500 with TM MFP; SCALANCE / RUGGEDCOM, etc.
[0083] The above exemplary description provides typical examples of edge devices, and those skilled in the art may realize that this description is only exemplary and is not intended to limit the scope of protection of the present invention's embodiments.
[0084] The data acquiring module 12, data caching module 13, and data providing module 14 are all WASM modules that can run in WAMR 11. The data acquiring module 12, data caching module 13, and data providing module 14 are essentially software modules.
[0085] In one embodiment, the data source 15 includes:
[0086] (1) Sensors connected to device 10 (such as temperature sensors, humidity sensors, etc. ) . The sensing data detected by the sensors (such as temperature or humidity values, etc. ) is provided to the data acquiring module 12.
[0087] (2) WASM modules (for example, WASM modules other than data acquiring module 12, data caching module 13, and data providing module 14) deployed in WAMR11. The data (such as various intermediate variables) generated by these WASM modules in WAMR11 is provided to the data acquiring module 12.
[0088] (3) WASM module deployed in WAMR of other devices other than device 10. The data (such as various intermediate variables) generated by these WASM modules in devices different from device 10 is provided to the data acquiring module 12.
[0089] The data acquiring module 12 can obtain data from data source 15 based on multiple strategies. For example, data acquiring module 12 can periodically obtain data from data source 15 or obtain data from data source 15 based on instructions.
[0090] The data caching module 13 can cache data based on multiple strategies. For example, data caching module 13 can store cached data in its own memory through local caching. The data caching module 13 can store the cached data in a distributed caching manner in the memory of any specified WASM module in WAMR11. The data caching module 13 can store cached data in both local and distributed caches.
[0091] Moreover, the data caching module 13 can delete cached data based on various cache elimination strategies. Cache elimination strategy refers to deleting some cached data according to certain rules when the amount of cached data reaches a certain threshold, in order to maintain a balance between cache capacity and performance. For example, cache elimination strategies can include:
[0092] (1) Least Recently Used (LRU) : Delete the cache entries that have been least recently used.
[0093] (2) First In First Out (FIFO) strategy: Delete the cache entry that was first added to the cache.
[0094] (3) Least Frequently Used (LFU) strategy: Delete the cache item with the lowest frequency of use.
[0095] (4) Random Replacement (RR) strategy: Select cache items to be deleted based on a random algorithm.
[0096] (5) Size based Eviction: When the memory occupied by the cache exceeds the preset capacity, a portion of the cache items are eliminated according to a certain strategy.
[0097] (6) Time to Live (TTL) based on the lifecycle of cache items: When the survival time of cache items exceeds the preset time threshold, they are automatically eliminated.
[0098] The above exemplary description provides typical examples of cache strategies and cache elimination strategies. Those skilled in the art may realize that this description is only exemplary and is not intended to limit the scope of protection of the embodiments of the present invention.
[0099] Therefore, by integrating caching implemented as a WASM module in WAMR (i.e., data caching module 13) , it is possible to utilize caching when executing other WASM modules on embedded systems and resource constrained devices, which can more effectively store and retrieve frequently accessed data, reduce latency, and optimize resource utilization.
[0100] In one embodiment, the data access object 16 includes at least one of the following:
[0101] (1) WASM modules deployed in WAMR11 (for example, WASM modules in WAMR11 other than data acquiring module 12, data caching module 13, and data providing module 14) ;
[0102] (2) WASM module deployed in the WAMR of devices other than device 10;
[0103] (3) devices connected to device 11.
[0104] In one embodiment, the data in the cache can be updated to ensure data consistency between the cache and the data source 15 (such as external hardware devices) , ensuring that subsequent read operations can retrieve the latest data from the cache, avoiding outdated information.
[0105] In one embodiment, the data acquiring module 12 is configured to obtain updated data from the data source 15 when a predetermined update cycle expires; the data caching module 13 is configured to update cached data based on the updated data.
[0106] Therefore, the data acquiring module 12 obtains updated data from data source 15 when predetermined update cycle expires, and updates the data cached in the data caching module 13 based on the updated data, thereby achieving data updates based on time dimension.
[0107] In one embodiment, the data acquiring module 12 is configured to obtain updated data from the data source 15 when a predetermined update cycle expires; the data caching module 13 is configured to update cached data based on the updated data.
[0108] Therefore, when receiving a data update instruction, data acquiring module 12 obtains updated data from data source 15 and updates the data cached in data cache module 13 based on the updated data, thereby enabling data updates based on the instruction. Compared to the method of updating data based on update cycles, the method of updating data based on instructions has greater flexibility.
[0109] In one embodiment, the data providing module14 is configured to validate the data before providing it to the data access object 16. In one embodiment, the data providing module 14 is configured to perform at least one of the following: (1) compare the data with a predetermined numerical range, and determine that the data does not pass validation when the comparison results indicate that the data does not belong to the numerical range; (2) compare the data with a predetermined numerical range, and determine that the data passes validation when the comparison results indicate that the data belongs to the numerical range; (3) compare a timestamp of the data with a predetermined active time range, and determine that the data does not pass validation when the comparison results indicate that the timestamp does not belong to the active time range; (4) compare a timestamp of the data with a predetermined active time range, and determine that the data passes validation when the comparison results indicate that the timestamp belongs to the active time range.
[0110] Embodiments of the present invention also proposes a data provision method. FIG. 2 is an exemplary flowchart of a method for providing data according to an embodiment of the present invention. As shown in FIG. 2, the method comprises:
[0111] Step 201: deploying WAMR. For example, deploying downloaded WAMR on an edge device.
[0112] Step 202: loading a data acquiring module and a data caching module in the WAMR, wherein the data acquiring module is adapted to obtain data from a data source, and the data caching module is adapted to cache the data; and
[0113] Step 203: loading a data providing module in the WAMR, wherein the data providing module is adapted to receive a data provision request from a data access object, read the data from the data caching module based on the data provision request, and provide the data to the data access object.
[0114] In one embodiment, the method comprising: cleaning up the data acquiring module and the data providing module in the WAMR; retaining the data caching module in the WAMR.
[0115] Therefore, by cleaning up the data acquiring module and the data providing module, WAMR resources can be saved. Moreover, by retaining the data cache module, it ensures that the cached data can still be used.
[0116] In one embodiment, the method comprising: validating the data before providing it to the data access object. In one embodiment, the method comprising at least one of the following: comparing the data with a predetermined numerical range, and determining that the data does not pass validation when the comparison results indicate that the data does not belong to the numerical range; comparing the data with a predetermined numerical range, and determining that the data passes validation when the comparison results indicate that the data belongs to the numerical range; comparing a timestamp of the data with a predetermined active time range, and determining that the data does not pass validation when the comparison results indicate that the timestamp does not belong to the active time range; comparing a timestamp of the data with a predetermined active time range, and determining that the data passes validation when the comparison results indicate that the timestamp belongs to the active time range.
[0117] FIG. 3 is an exemplary schematic diagram of data caching process according to an embodiment of the present invention. As shown in FIG. 3, the data caching process comprises:
[0118] Step 20: Start.
[0119] Step 21: Initialize data caching module in WAMR.
[0120] Step 22: Read data from data caching module.
[0121] Step 23: Check whether to find data from data caching module or not. If so (corresponding to the "Y" branch) , execute step 29 and its subsequent steps; Otherwise (corresponding to the "N" branch) , proceed to step 24 and its subsequent steps.
[0122] Step 24: Access sensors connected to the device to obtain data.
[0123] Step 25: Initiate storage operation to store data in the data caching module.
[0124] Step 26: Check whether the data cache module is full or not. If so (corresponding to the "Y" branch) , proceed to step 27; Otherwise (corresponding to the "N" branch) , proceed to step 28.
[0125] Step 27: Delete the least recently used cache entries in the data caching module and end this process.
[0126] Step 28: Store the data in the data caching module and end this process.
[0127] Step 29: Read data from the data caching module.
[0128] Step 30: Check whether the data has passed validation or not. If so (corresponding to the "Y" branch) , execute step 31; Otherwise (corresponding to the "N" branch) , proceed to step 32.
[0129] Step 31: Provide the data to a data access object to end this process.
[0130] Step 32: Initiate the storage operation to store data in the data caching module.
[0131] FIG. 4 is an exemplary flowchart of a data caching method according to an embodiment of the present invention. The data caching method in Figure 4 includes a sequentially executed cache initialization process 50, cache update process 51, cache read process 52, and the removal process 53 of unverified data. Perform steps 401 to 419 based on chronological order.
[0132] Main function 40: The main participant or component initiating the sequence; data caching module 41: The cache participant responsible for storing and managing cached data; InitCache 42: The participant representing the initialization of the cache; ReadFromCache 43: The participant representing the process of reading data from the cache; UpdateCache 44: The participant representing the process of updating the cache; InvalidateCacheEntry 45: The participant representing the process of invalidating a cache entry.
[0133] The cache initialization process 50 includes:
[0134] Step 401: The main function 40 sends an initialization command to InitCache 42, which initializes the data caching module 41 based on the initialization command.
[0135] Step 402: The main function 40 initiates a read cache command to ReadFromCache 43.
[0136] Step 403: ReadFromCache 43 initiates a data read operation to data caching module 41.
[0137] Step 404: The data caching module 41 returns data to ReadFromCache 43.
[0138] Step 405: ReadFromCache 43 returns data to main function 40.
[0139] After completing the cache initialization process 50, execute the cache update process 51. The cache update process 51 includes:
[0140] Step 406: The main function 40 sends an update cache command to UpdateCache 44.
[0141] Step 407: UpdateCache 44 initiates a data read operation to data caching module 41.
[0142] Step 408: The data caching module 41 returns data to UpdateCache 44.
[0143] Step 409: UpdateCache 44 updates the data and sends the updated data to data caching module 41 to update data cached in data caching module 41.
[0144] Step 410: UpdateCache 44 returns an update completion notification message to main function 40.
[0145] After completing the cache update process 51, execute the cache read process 52. The cache read process 52 includes:
[0146] Step 411: The main function 40 initiates a read cache command to ReadFromCache 43 when a data access request is received from a WASM module.
[0147] Step 412: ReadFromCache 43 initiates a data read operation to data caching module 41.
[0148] Step 413: The data caching module 41 returns data to ReadFromCache 43.
[0149] Step 414: ReadFromCache 43 returns data to main function 40, the main function 40 sends data to the WASM module.
[0150] After completing the cache read process 52, perform the removal process 53 of the unverified data. The removal process of unverified data 53 includes:
[0151] Step 415: After determining that the data returned by ReadFromCache 43 does not pass validation, the main function 40 initiates a data removal command to InvalidateCacheEntry 45.
[0152] Step 416: InvalidateCacheEntry 45 initiates a data query operation to data cache module 41.
[0153] Step 417: The data cache module 41 returns storage location of the data to InvalidateCacheEntry 45.
[0154] Step 418: InvalidateCacheEntry 45 deletes data from data caching module 41 based on its storage location.
[0155] Step 419: InvalidateCacheEntry 45 returns a data deletion notification to main function 40.
[0156] FIG. 5 is a schematic diagram of an exemplary interaction process between WASM module and cache according to an embodiment of the present invention. As shown in FIG. 5, the process includes:
[0157] Step 60: Start.
[0158] Step 61: Initialize WAMR.
[0159] Step 62: Determine whether the initialization of WAMR is successful or not. If it is successful (corresponding to the "Y" branch) , execute step 62 and its subsequent steps. Otherwise, execute step 74 and its subsequent steps.
[0160] Step 63: Load the data caching module in WAMR.
[0161] Step 64: Determine whether the loading of the data caching module is successful or not. If it is successful (corresponding to the "Y" branch) , execute step 65 and its subsequent steps. Otherwise, execute step 72 and its subsequent steps.
[0162] Step 65: Initialize the data caching module.
[0163] Step 66: Load a WASM module in WAMR that requires access to the data.
[0164] Step 67: Determine whether the loading of the WASM module is successful. If it is successful (corresponding to the "Y" branch) , execute step 68 and its subsequent steps. Otherwise, execute step 71 and its subsequent steps.
[0165] Step 68: The WASM module interacts with the data caching module to obtain cached data from the data caching module.
[0166] Step 69: Apply the data in the WASM module.
[0167] Step 70: Clean up the WASM module in WAMR and perform step 75.
[0168] Step 71: Process the WASM module loading failure process and execute step 75.
[0169] Step 72: Process data caching module loading failure process.
[0170] Step 73: Destroy the WAMR and follow step 75.
[0171] Step 74: Process runtime initialization failure process and execute step 75.
[0172] Step 75: End.
[0173] FIG. 6 is a flowchart of an exemplary interaction process between a WASM module and a cache according to an embodiment of the present invention. The interaction process between WASM module and cache includes:
[0174] Step 801: The main function 80 sends WAMR initialization command to WAMR manager 81, which initializes WAMR based on the WAMR initialization command.
[0175] Step 802: WAMR manager 81 returns initialization-success notification to main function 80.
[0176] Step 803: The main function 80 sends a data caching module loading command to WAMR manager 81, which loads the data caching module based on the data caching module loading command.
[0177] Step 804: WAMR manager 81 returns a loading-success notification of the data cache module to main function 80.
[0178] Step 805: The main function 80 sends an initialization command to data caching module 82, which performs initialization.
[0179] Step 806: The main function 80 sends WASM module loading command to WAMR manager 81, which loads an WASM module based on the WASM module loading command.
[0180] Step 807: WAMR manager 81 returns a loading-success notification of the WASM module to main function 80.
[0181] Step 808: The data caching module 82 interacts with the WASM module 83, so that the WASM module 83 reads data from the data caching module 82.
[0182] Step 809: WAMR manager 81 executes WASM module 83 based on the date read from the data caching module 82.
[0183] Step 810: WAMR manager 81 cleans up WASM module 83 and retains data caching module 82 for subsequent data access.
[0184] Step 811: WAMR manager 81 returns a task completion notification to main function 80.
[0185] FIG. 7 is a structural diagram of apparatus for providing data according an embodiment of the present invention. As shown in FIG. 7, the apparatus 500 comprises:
[0186] a deploying module 501, configured to deploy WAMR; a first loading module 502, configured to load a data acquiring module and a data caching module in the WAMR, wherein the data acquiring module is adapted to obtain data from a data source, and the data caching module is adapted to cache the data; and a second loading module 503, configured to load a data providing module in the WAMR, wherein the data providing module is adapted to receive a data provision request from a data access object, read the data from the data caching module based on the data provision request, and provide the data to the data access object.
[0187] In summary, the cache solution provided in the above embodiments is intended to illustrate the integration of cache optimization techniques within the WAMR runtime. It may not be as feature-rich or robust as known cache solutions or products specifically designed for performance optimization. However, there are still some notable differences and advantages to consider:
[0188] (1) Lightweight and portable: The cache solution in the examples is designed to be lightweight and portable, suitable for embedded devices and IoT applications. It can be integrated directly within the WAMR runtime without relying on external dependencies or complex cache management frameworks. This lightweight approach reduces the resource overhead and allows for easy deployment on resource-constrained devices.
[0189] (2) Customizable for WebAssembly workloads: The cache solution can be customized and tailored specifically for WebAssembly workloads. By analyzing the characteristics of the workload, such as access patterns, data sizes, and value, you can adapt the cache replacement strategy or hot-probe method to suit the specific requirements of your WebAssembly applications. This level of customization can potentially lead to better cache hit ratios and improved performance compared to general-purpose cache solutions.
[0190] (3) Seamless integration with WAMR: The provided cache solution integrates directly with the WAMR runtime, allowing for seamless interaction between the cache and WebAssembly applications. This integration simplifies the development process, as you don't need to manage the cache separately from the runtime. The cache functions become part of the WAMR API, making it easier to incorporate cache optimization in your WebAssembly code.
[0191] (4) Lower overhead and latency: As the cache solution is designed to run directly within the WAMR runtime, it minimizes overhead and latency associated with cache access. The cache operations are tightly integrated with the runtime, reducing the time required for data retrieval and cache management compared to external cache solutions. This advantage is especially valuable in real-time or latency-sensitive applications.
[0192] The embodiment of the present invention also proposes an electronic device with a processor memory architecture. Figure 6 is an exemplary structural diagram of an electronic device with a processor memory architecture according to an embodiment of the present invention. As shown in Figure 6, electronic device 600 includes a processor 601, a memory 602, and a computer program stored on memory 602 that can run on processor 601. When the computer program is executed by processor 601, the method for providing data as described in either of the above methods is implemented. Among them, memory 602 can be implemented as various storage media such as electrically erasable programmable read-only memory (EEPROM) , flash memory, programmable program read-only memory (PROM) , etc. Processor 601 can be implemented to include one or more central processors or one or more field programmable gate arrays, wherein the field programmable gate array integrates one or more central processor cores. Specifically, the central processing unit or core can be implemented as a CPU, MCU, DSP, and so on.
[0193] It should be noted that not all steps and modules in the above processes and structural diagrams are necessary, and some steps or modules can be ignored according to actual needs. The execution sequence of each step is not fixed and can be adjusted as needed. The division of each module is only for the convenience of describing the functional division used. In actual implementation, a module can be divided into multiple modules, and the functions of multiple modules can also be implemented by the same module. These modules can be in the same device or different devices. The hardware modules in each implementation can be implemented mechanically or electronically. For example, a hardware module can include specially designed permanent circuits or logic devices (such as dedicated processors, such as FPGA or ASIC) to complete specific operations. Hardware modules can also include programmable logic devices or circuits temporarily configured by software (such as general-purpose processors or other programmable processors) for performing specific operations. As for the specific use of mechanical methods, either dedicated permanent circuits or temporarily configured circuits (such as software configuration) to implement hardware modules, it can be determined based on cost and time considerations.
[0194] The above is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this invention shall be included within the scope of protection of this invention.
Claims
1.A system for providing data, comprising:a data acquiring module (12) deployed in a WAMR (11) of a device (10) , configured to obtain data from a data source (15) ;a data caching module (13) deployed in the WAMR (11) , configured to cache the data; anda data providing module (14) deployed in the WAMR (11) , configured to receive a data provision request from a data access object (16) , read the data from the data caching module (13) based on the data provision request, and provide the data to the data access object (16) .2.The system of claim 1, wherein the data acquiring module (12) is configured to obtain updated data from the data source (15) when a predetermined update cycle expires; the data caching module (13) is configured to update cached data based on the updated data.3.The system of claim 1, wherein the data acquiring module (12) is configured to obtain updated data from the data source (15) in response to receiving data update instruction; the data caching module (13) is configured to update cached data based on the updated data.4.The system of claim 1, wherein the data providing module (14) is configured to validate the data before providing it to the data access object (16) .5.The system of claim 4, wherein the data providing module (14) is configured to perform at least one of the following:compare the data with a predetermined numerical range, and determine that the data does not pass validation when the comparison results indicate that the data does not belong to the numerical range;compare the data with a predetermined numerical range, and determine that the data passes validation when the comparison results indicate that the data belongs to the numerical range;compare a timestamp of the data with a predetermined active time range, and determine that the data does not pass validation when the comparison results indicate that the timestamp does not belong to the active time range;compare a timestamp of the data with a predetermined active time range, and determine that the data passes validation when the comparison results indicate that the timestamp belongs to the active time range.6.The system of claim 1, wherein the data source (15) comprises at least one of the following:a sensor connected to the device (10) ;a WASM module deployed in the WAMR (11) ;a WASM module deployed in a WAMR of a device other than device (10) .7.The system of claim 1, wherein the data access object (16) comprises at least one of the following:a WASM module deployed in the WAMR (11) ;a WASM module deployed in a WAMR of a device other than device (10) ;a device connected to the device (10) .8.The system of any one of claims 1-7, wherein the device (10) comprises a resource constrained device.9.The system of claim 8, wherein the resource constrained device comprises at least one of the following:a specialized equipment with industrial edge functionality;a supporting equipment with industrial edge functionality.10.A method for providing data, comprising:deploying (201) WAMR;loading (202) a data acquiring module and a data caching module in the WAMR, wherein the data acquiring module is adapted to obtain data from a data source, and the data caching module is adapted to cache the data; andloading (203) a data providing module in the WAMR, wherein the data providing module is adapted to receive a data provision request from a data access object, read the data from the data caching module based on the data provision request, and provide the data to the data access object.11.The method of claim 10, comprising:cleaning up the data acquiring module and the data providing module in the WAMR;retaining the data caching module in the WAMR.12.The method of claim 10, comprising:validating the data before providing it to the data access object.13.The method of claim 12, comprising at least one of the following:comparing the data with a predetermined numerical range, and determining that the data does not pass validation when the comparison results indicate that the data does not belong to the numerical range;comparing the data with a predetermined numerical range, and determining that the data passes validation when the comparison results indicate that the data belongs to the numerical range;comparing a timestamp of the data with a predetermined active time range, and determining that the data does not pass validation when the comparison results indicate that the timestamp does not belong to the active time range;comparing a timestamp of the data with a predetermined active time range, and determining that the data passes validation when the comparison results indicate that the timestamp belongs to the active time range.14.An apparatus for providing data, comprising:a deploying module (501) , configured to deploy WAMR;a first loading module (502) , configured to load a data acquiring module and a data caching module in the WAMR, wherein the data acquiring module is adapted to obtain data from a data source, and the data caching module is adapted to cache the data; anda second loading module (503) , configured to load a data providing module in the WAMR, wherein the data providing module is adapted to receive a data provision request from a data access object, read the data from the data caching module based on the data provision request, and provide the data to the data access object.15.An electronic device, comprising a processor (601) and a memory (602) , wherein an application program executable by the processor (601) is stored in the memory (602) for causing the processor (601) to execute a method for providing data according to any one of claims 10-13.16.A computer-readable medium comprising computer-readable instructions stored thereon, wherein the computer-readable instructions for executing a method for providing data according to any one of claims 10-13.17.A computer program product comprising a computer program, upon the computer program is executed by a processor for executing a method for providing data according to any one of claims 10-13.
Citation Information
Patent Citations
System and method for storing cache location information for cache entry transfer
CN109478164A
Data cache processing method and device, caching grid platform and storage medium
CN113973135A
Managing shared applications at edge of content delivery network
CN114981792A
Provision of cached data
WO2012010214A1