A snapshot processing method and an embedded snapshot system

By identifying page popularity using a global bitmap and a two-bit aging method, and calculating the pressure index in conjunction with system resource indicators, the snapshot strategy is dynamically adjusted. This solves the problems of high overhead in hot page identification and static strategy configuration in embedded environments, achieving low-overhead and highly stable snapshot processing.

CN122432431APending Publication Date: 2026-07-21NAT HIGH SPEED TRAIN QINGDAO TECH INNOVATION CENT
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NAT HIGH SPEED TRAIN QINGDAO TECH INNOVATION CENT
Filing Date
2026-04-28
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing snapshot technologies in embedded environments incur excessive overhead in hot page identification, and the snapshot strategy cannot be dynamically adjusted, leading to resource contention and business process jitter, failing to meet the requirements of low overhead and high stability.

Method used

A global bitmap data structure and a two-bit aging method are used to identify page popularity status. The system pressure index is calculated by combining system resource indicators, and the snapshot strategy is dynamically adjusted to optimize resource usage.

Benefits of technology

It significantly reduces the CPU and memory overhead of hot page identification, achieves highly stable and adaptable snapshot processing in resource-constrained environments, and avoids resource contention and business delays.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122432431A_ABST
    Figure CN122432431A_ABST
Patent Text Reader

Abstract

The application discloses a snapshot processing method and an embedded snapshot system, and relates to the technical field of snapshots. A current page access bit is acquired under a global bitmap, CPU and memory overheads of hot spot identification are reduced by using a simple structure, and business jitter is avoided. A double-bit aging method is used to update the access bit to determine page heat, and load pressure of a resource-limited device is relieved. System pressure indexes are calculated by collecting system real-time resource indexes, and the defect that a traditional snapshot cannot perceive instantaneous load is solved. Snapshot strategies are adaptively adjusted based on the pressure indexes and threshold values, overheads are reduced and businesses are avoided when resources are tight, efficiency is improved when resources are relaxed, and the snapshot processing of the embedded environment is low in overhead, high in stability and high in adaptation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of snapshot technology, and in particular to a snapshot processing method and an embedded snapshot system. Background Technology

[0002] Current snapshot technologies used in embedded environments either follow traditional solutions from server scenarios, which are too demanding in terms of bandwidth and computing power and difficult to adapt to, or while optimized for specific scenarios, they still rely on complex mechanisms such as sliding windows and high-frequency scanning in the hot page identification process, significantly increasing the identification overhead. This can easily consume the limited central processing unit (CPU) and memory resources of embedded devices and cause business process jitter. At the same time, snapshot strategies mostly adopt a static configuration mode, which lacks the ability to dynamically perceive the instantaneous load of the device. They cannot adaptively adjust the execution strategy based on real-time resource status such as CPU usage, remaining power, and input / output (I / O) queue depth. When system resources are scarce, they still force the standard snapshot process to be executed, which leads to severe resource contention among business processes, a significant increase in response latency, and even process starvation. This makes it difficult to meet the low-overhead and high-stability snapshot requirements of embedded environments.

[0003] Therefore, how to improve snapshot stability under the requirement of low overhead is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] The purpose of this application is to provide a snapshot processing method and an embedded snapshot system to solve the problems of high memory overhead for hot page identification and poor resource adaptive adjustment caused by the use of static configuration mode in snapshot strategies.

[0005] To address the aforementioned technical problems, this application provides a snapshot processing method, comprising:

[0006] Obtain the current access bit of the current page under the global bitmap data structure, and update the current access bit according to the two-bit aging method to determine the page popularity status of the current page;

[0007] Determine the current system stress index based on current server resource metrics;

[0008] The snapshot strategy for the current page is adjusted based on the relationship between the current system pressure index and the threshold in order to perform snapshot processing.

[0009] On the one hand, the process of obtaining the current access bit includes:

[0010] The global bitmap system is initialized to allocate a global bitmap with a physical memory page size of 2 / 8 bytes, and each 2 bits under each bitmap corresponds to the heat status of a physical page;

[0011] Attach the scan hook to the page table scanner under the operating system;

[0012] Pre-configure background scan thread parameters to start a preset kernel thread to traverse page table entries;

[0013] The CPU hardware automatically maintains the access bits of the page table entries for acquisition during page reads and writes.

[0014] On the other hand, the current access position is updated according to the two-position aging method to determine the current page popularity status, including:

[0015] Perform bitwise operations to update the current page to obtain the current page's state value;

[0016] The current page is categorized based on its current status value to obtain the corresponding page popularity status.

[0017] On the other hand, the current system stress index is determined based on the current server resource indicators, including:

[0018] Get the current CPU load, I / O wait time, and remaining memory.

[0019] Assign a first weighting coefficient, a second weighting coefficient, and a third weighting coefficient to the current CPU load value, IO wait time, and remaining memory, respectively; wherein the sum of the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient is 1;

[0020] The current system stress index is determined based on the current CPU load value, the first weighting coefficient, the I / O wait time, the second weighting coefficient, the remaining memory, and the third weighting coefficient.

[0021] On the other hand, adjusting the snapshot strategy of the current page based on the relationship between the current system pressure index and the threshold includes:

[0022] Obtain a first pressure threshold and a second pressure threshold; wherein the first pressure threshold is greater than the second pressure threshold;

[0023] If the current system pressure index is greater than the first pressure threshold, it is determined that the system resources corresponding to the current system pressure index are under pressure. The first pressure threshold is increased by a step size so that the number of hot page states corresponding to the current system pressure index meets the first preset number. Then, the first preset number of hot page states are subjected to a shutdown snapshot.

[0024] If the current system pressure index is less than the second pressure threshold, it is determined that the system resources corresponding to the current system pressure index are sufficient. The first pressure threshold is then processed by decreasing the step size so that the number of hot page states and warm page states corresponding to the current system pressure index meets the second preset number. Background transmission processing is then started for the second preset number of hot page states and warm page states.

[0025] On the other hand, a shutdown snapshot process is performed on the first preset number of pages in the hot page state, including:

[0026] Copy the pages marked as hot pages in the bitmap to the pre-allocated snapshot buffer;

[0027] Suspend all user-space processes to freeze file system metadata;

[0028] Batch set the write protection bits of the page table entries for the remaining pages that have not been copied to the snapshot buffer to restore the CPU and device state for runtime processing.

[0029] On the other hand, the write protection bits of the remaining pages not copied to the snapshot buffer are set in batches to restore the CPU and device state for runtime processing, including:

[0030] If the first target page is abnormal when performing copy-on-write processing on the remaining pages, the abnormal first target page will be copied to the snapshot storage area and the write protection bit will be removed.

[0031] Start the first thread to scan the remaining pages for the second target page that is inactive;

[0032] The token bucket mechanism is used to throttle the IO traffic transmitted by the first thread.

[0033] On the other hand, when performing snapshot processing on pages in a hot page state, the method further includes:

[0034] Pages in hot state are stored in a memory circular buffer;

[0035] If a page in the hot page state is modified within a preset time, the logical write in the memory circular buffer is updated until the preset number of logical writes is reached, at which point write merging is performed.

[0036] On the other hand, when performing snapshot processing on the current page, the method further includes:

[0037] When the content of the current page is all zeros, the metadata tag corresponding to the current page is recorded;

[0038] When the current page and the previous page are consecutive snapshots, and the page content of the current page and the previous page differs by a preset number of pages, the page content of the current page corresponding to the preset number of pages is recorded.

[0039] To address the aforementioned technical problems, this application also provides an embedded snapshot system, comprising:

[0040] Memory, used to store computer programs;

[0041] A processor for implementing the snapshot processing method as described above when executing the computer program.

[0042] This application provides a snapshot processing method. First, it obtains the currently accessed bit of the current page under a global bitmap data structure. Compared to conventional solutions that rely on sliding windows, high-frequency scanning, complex linked lists, or counter arrays for hot page identification, resulting in huge CPU and memory overhead and easily causing business process jitter, this application records the page access status using a simplified global bitmap data structure. This eliminates the need to maintain complex historical windows and perform high-frequency full scans, significantly reducing CPU usage and memory overhead in the hotspot identification process. Second, it updates the currently accessed bit using a two-bit aging method to determine the current page's popularity status, fundamentally alleviating the load pressure on resource-constrained devices caused by hotspot tracking, avoiding business process jitter, and improving system stability. Third, it determines the current system pressure index based on current server resource indicators. Compared to conventional snapshot strategies that generally use static configuration, which cannot perceive the instantaneous load status of the device and cannot adapt to real-time resource conditions such as CPU usage, I / O queue depth, and remaining battery power, this method addresses the issue of static configuration in conventional snapshot strategies. This application achieves quantitative perception of the system's current operating load by collecting real-time system resource indicators and calculating the system pressure index. This endows the snapshot mechanism with resource awareness, accurately reflecting the system's busy and resource-constrained levels, thus overcoming the technical deficiency of traditional snapshot solutions that cannot perceive instantaneous system load. Finally, the snapshot strategy for the current page is adjusted based on the relationship between the current system pressure index and a threshold for snapshot processing. Compared to conventional solutions that still force a fixed snapshot process when resources are scarce, causing severe resource contention, increased business latency, and even process "starvation," this application adaptively adjusts the snapshot strategy based on the system pressure index. It can dynamically select the appropriate execution method according to the system load, automatically reducing snapshot overhead and avoiding business processes when resources are scarce, and improving snapshot efficiency when resources are plentiful. This avoids resource contention and business blockage, ensures business priority operation, and significantly improves the stability and availability of snapshots in embedded environments. It can achieve low-overhead, highly stable, and highly adaptable snapshot processing in resource-constrained embedded environments.

[0043] In addition, this application also provides an embedded snapshot system that has the same beneficial effects as the snapshot processing method described above. Attached Figure Description

[0044] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 A flowchart illustrating a snapshot processing method provided in this application embodiment;

[0046] Figure 2 A schematic diagram illustrating the state transition of a lightweight dual-position aging hotspot identification algorithm provided in this application embodiment;

[0047] Figure 3 A logic diagram illustrating the dynamic adjustment of heat threshold and I / O rate based on system pressure index provided in this application embodiment;

[0048] Figure 4 A flowchart illustrating another snapshot processing method provided in this application embodiment;

[0049] Figure 5 A structural diagram of a snapshot processing apparatus provided in an embodiment of this application;

[0050] Figure 6 This is a structural diagram of an embedded snapshot system provided in an embodiment of this application. Detailed Implementation

[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0052] The core of this application is to provide a snapshot processing method and an embedded snapshot system to solve the problems of high memory overhead for hot page identification and poor resource adaptive adjustment caused by the use of static configuration mode in snapshot strategies.

[0053] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0054] With the proliferation of the Internet of Things (IoT), edge computing, and spaceborne / vehicle-mounted computing systems, an increasing number of mission-critical tasks are running on resource-constrained computing platforms. These platforms typically have the following characteristics: limited CPU computing power (usually low-power Advanced RISC Machine (ARM) or RISC-V fifth-generation architecture), small memory capacity (MB to GB level), and storage media (such as flash memory, Secure Digital (SD) cards, and embedded Multi Media Cards (eMMC)) that are sensitive to write life and have low bandwidth. To ensure rapid system recovery in the event of a failure, or to support online migration and upgrades, it is necessary to take snapshots of the running operating system.

[0055] Existing snapshot technologies are mainly divided into two categories: one is traditional technologies for server environments (such as Stop-and-Copy and Pre-copy), which often assume that the system has sufficient bandwidth and computing power and are not suitable for embedded environments; the other is optimized technologies for specific scenarios. Specific scenarios are resource-constrained embedded edge computing environments, such as satellite payloads (which need to complete state backup within a limited orbital time), vehicle autonomous driving controllers (which need to meet hard real-time constraints), and industrial IoT gateways (which typically use low-power, narrow-bandwidth embedded chips).

[0056] The existing methods suffer from the following shortcomings: High overhead for hotspot identification: Existing hotspot identification algorithms typically require maintaining complex sliding windows or performing high-frequency sampling scans, which places a heavy burden on the CPU and memory of resource-constrained devices, easily causing business process jitter. Lack of resource awareness: Existing snapshot strategies are usually statically configured and cannot perceive the instantaneous load of the current device (such as CPU busy / idle status, remaining battery power, and I / O queue depth). Forcibly implementing standard snapshot strategies when resources are extremely scarce can lead to business processes being "starved" or a sharp increase in system response latency. The snapshot processing method provided in this application can solve the above technical problems.

[0057] Figure 1 A flowchart of a snapshot processing method provided in an embodiment of this application is shown below. Figure 1 As shown, the method includes:

[0058] S11: Obtain the current access bit of the current page under the global bitmap data structure, and update the current access bit according to the two-bit aging method to determine the page popularity status of the current page.

[0059] S12: Determine the current system stress index based on the current server resource indicators;

[0060] S13: Adjust the snapshot strategy of the current page based on the relationship between the current system pressure index and the threshold to perform snapshot processing.

[0061] Specifically, during the system initialization phase, a global bitmap data structure is allocated to record the page heat status. The size of the global bitmap is determined based on the number of physical memory pages of the embedded device. The specific calculation formula is: global bitmap size = number of physical memory pages × 2bit ÷ 8bit / byte, which is 2 / 8 bytes of the number of physical memory pages. Compared with the complex linked lists and counter arrays used in traditional technologies, this greatly reduces memory usage.

[0062] In this embodiment, the embedded device has 2GB of physical memory and a page size of 4KB. Therefore, the number of physical memory pages = 2GB ÷ 4KB = 524288 pages, and the corresponding global bitmap size = 524288 × 2 ÷ 8 = 131072 bytes (i.e. 128KB). This memory usage is negligible for resource-constrained embedded devices, effectively solving the problem of high memory overhead in traditional hotspot identification structures.

[0063] In the global bitmap, each 2-bit corresponds to the hotness state of a physical page. The initial state is set to 00 (binary), indicating that the page is in a dormant state, meaning it has not been accessed for a long time. At the same time, the system attaches the scan hook to the memory management unit (MMU) of the embedded Linux system. Relying on the access bit in the page table entry (PTE) automatically maintained by the CPU hardware, the system achieves zero software overhead capture of page access. When any physical page is read or written by the business process, the CPU hardware will automatically set the access bit of the corresponding page table entry to 1. There is no need for high-frequency scanning or real-time monitoring by software, which completely eliminates the complex mechanism of traditional sliding window and high-frequency sampling.

[0064] In addition, the system starts a low-priority kernel scan thread to periodically read the Access Bit and perform two-bit aging updates. The default scan cycle of this thread is set to 200ms, and the scan cycle can be adaptively scaled according to the subsequently calculated System Pressure Index (SPI) to avoid the scan thread consuming too much CPU resources and further reduce system overhead.

[0065] The kernel scanning thread iterates through all currently active page table entries in the system at a preset 200ms cycle, reading the Access Bit (i.e., the current access bit) of each physical page entry. This Access Bit is maintained in real time by the CPU hardware, and the reading process requires no software intervention, only simple hardware register read operations, resulting in extremely low overhead and solving the problem of excessive CPU usage caused by traditional high-frequency scanning. In this embodiment, an Access Bit of 1 indicates that the page has been accessed within the current scan cycle, and 0 indicates that it has not been accessed within the current scan cycle. After reading, the value of the current access bit is temporarily stored for subsequent hot status updates.

[0066] For each physical page, the system updates it using a preset bitwise operation formula, based on the read current access bit (Hardware Access Bit) and the page's historical hotness state (Old_State) recorded in the global bitmap. After the update, the system immediately clears the Access Bit of the page table entry (sets it to 0) to capture page access information in the next scan cycle, ensuring the accuracy of subsequent hotness identification. The dual-bit aging method uses 2-bit status bits to record the access status of memory pages in the two most recent consecutive scan cycles. It achieves automatic decay and update of hotness through simple bitwise operations, completing page hotness classification with almost no computational overhead, thus solving the problem of excessive overhead in traditional hotspot identification algorithms.

[0067] The system uses the / proc and / sys file systems of the embedded Linux system to collect multi-dimensional indicators reflecting the current system resource status in real time. The collection period is consistent with the kernel scan thread period in step one (default 200ms) to ensure the synchronization of resource indicators with page heat status, such as CPU load, I / O wait time, remaining memory, and battery level. Specifically, CPU load (LoadAvg) collects the average CPU load over the past minute, reflecting the CPU's activity level; I / O wait time (IOWAIT) collects the percentage of time the CPU spends waiting for I / O operations to complete, reflecting the activity level of I / O devices; remaining memory (FreeMem) collects the amount of available physical memory in the system, reflecting the scarcity of memory resources; and for battery-powered embedded devices (such as IoT terminals), it collects the current percentage of remaining battery power, reflecting the device's power resource status. Because the collected resource metrics have different dimensions (e.g., CPU load is dimensionless, I / O wait time is a percentage, and remaining memory is in bytes), direct weighted calculation is not possible. Therefore, it is necessary to normalize each metric, mapping all metrics to the [0, 1] range to ensure the reasonableness of the calculation results. A weighted summation method is used to calculate the current system stress index (SPI) based on the normalized resource metrics. The SPI value ranges from [0, 1]. A larger SPI value indicates more strained system resources and a higher business load; a smaller SPI value indicates more abundant system resources and a lower business load.

[0068] The system presets two SPI thresholds to classify system stress levels and determine the corresponding snapshot strategy. The threshold settings are combined with the resource characteristics of the embedded device and business requirements, and can be adaptively adjusted according to the actual application scenario. For example, the high-voltage threshold is 0.8. When SPI > 0.8, the system is in high-voltage mode, resources are extremely scarce, and the business load is extremely high. The low-voltage threshold is 0.3. When SPI < 0.3, the system is in low-voltage mode, resources are abundant, and the business load is relatively small. The standard mode is when 0.3 ≤ SPI ≤ 0.8. The system is in standard mode, resources are moderate, and the business load is normal.

[0069] The current SPI value is compared with a preset threshold to determine the current system stress level, and the snapshot strategy is adjusted accordingly. Key adjustments focus on the hot page filtering ratio, snapshot execution speed, and I / O overhead to ensure snapshot processing matches system resource status and business load. In low-pressure mode, priority is given to improving snapshot efficiency to ensure rapid snapshot completion, the hot page filtering threshold is lowered, and full-speed background transmission is initiated without pausing background scanning. In high-pressure mode, priority is given to ensuring the normal operation of business processes and avoiding resource contention. The hot page filtering threshold is significantly increased, background active scanning is paused, and full reliance on copy-on-write and disabling full-speed background transmission are implemented.

[0070] Based on the adjusted snapshot policy, the system performs specific snapshot processing. Taking the low-voltage mode in this embodiment as an example, the specific execution process is as follows:

[0071] 1. The system receives a snapshot trigger request (which can be triggered manually by the user or by a timer).

[0072] 2. Suspend all user-space business processes and freeze file system metadata to prevent data from being modified during the snapshot process and ensure the consistency of snapshot data. This process should take less than 10ms to reduce business interruption time.

[0073] 3. Based on the determined page popularity status, all extremely popular and moderately popular pages are directly filtered out through the global bitmap index, without having to traverse the entire physical memory, thus improving snapshot speed;

[0074] 4. Copy the selected hot page content to the pre-allocated snapshot buffer (the snapshot buffer size is 200MB in this embodiment) to complete the snapshot backup of the core data;

[0075] 5. Batch set write protection bits for page table entries of unsaved, dormant pages, and then immediately restore all user-mode business processes and file system operation to ensure rapid recovery of business processes and reduce the impact of interruption;

[0076] 6. Start the background kflush thread to scan and save the remaining dormant pages at full speed. No I / O throttling is required. Quickly complete the snapshot persistence of all pages and finally complete the entire snapshot process.

[0077] This application provides a snapshot processing method. First, it obtains the current access bit of the current page under a global bitmap data structure. Compared to conventional solutions that rely on sliding windows, high-frequency scanning, complex linked lists, or counter arrays for hot page identification, resulting in huge CPU and memory overhead and easily causing business process jitter, this application records the page access status using a very simple global bitmap data structure. It eliminates the need to maintain complex historical windows and high-frequency full scans, significantly reducing CPU usage and memory overhead in the hotspot identification process. Second, it updates the current access bit using a two-bit aging method to determine the current page's popularity status, fundamentally alleviating the load pressure on resource-constrained devices caused by hotspot tracking, avoiding business process jitter, and improving system stability. Third, it determines the current system pressure index based on current server resource indicators. Compared to conventional snapshot strategies that generally use static configuration, which cannot perceive the instantaneous load status of the device and cannot adapt to real-time resource conditions such as CPU usage, I / O queue depth, and remaining battery power, this method addresses the issue of static configuration in conventional solutions. This application achieves quantitative perception of the system's current operating load by collecting real-time system resource indicators and calculating the system pressure index. This endows the snapshot mechanism with resource awareness, accurately reflecting the system's busy and resource-constrained levels, thus overcoming the technical deficiency of traditional snapshot solutions that cannot perceive instantaneous system load. Finally, the snapshot strategy for the current page is adjusted based on the relationship between the current system pressure index and a threshold for snapshot processing. Compared to conventional solutions that still force a fixed snapshot process when resources are scarce, causing severe resource contention, increased business latency, and even process "starvation," this application adaptively adjusts the snapshot strategy based on the system pressure index. It can dynamically select the appropriate execution method according to the system load, automatically reducing snapshot overhead and avoiding business processes when resources are scarce, and improving snapshot efficiency when resources are plentiful. This avoids resource contention and business blockage, ensures business priority operation, and significantly improves the stability and availability of snapshots in embedded environments. It can achieve low-overhead, highly stable, and highly adaptable snapshot processing in resource-constrained embedded environments.

[0078] In some embodiments, the process of obtaining the current access bit includes:

[0079] The global bitmap system is initialized to allocate a global bitmap with a physical memory page size of 2 / 8 bytes, and each 2 bits under each bitmap corresponds to the heat status of a physical page;

[0080] Attach the scan hook to the page table scanner under the operating system;

[0081] Pre-configure background scan thread parameters to start a preset kernel thread to traverse page table entries;

[0082] The CPU hardware automatically maintains the access bits of the page table entries for acquisition during page reads and writes.

[0083] Specifically, the global bitmap system is initialized. The system allocates a global bitmap of size equal to the number of physical memory pages × 2 ÷ 8 bytes, based on the total number of physical memory pages in the embedded device. Each consecutive 2 bits in the global bitmap represents the "hotness" status of a physical page, initially set to 00 to indicate that the page is in a "cold" state. This bitmap structure occupies very little memory and requires no complex data structures such as linked lists, arrays, or sliding windows.

[0084] The scan hook is attached to the page table scanner in the operating system kernel, enabling the system to intervene in the page table traversal process and obtain hardware information related to page table entries. Background scan thread parameters are pre-configured, and a low-priority preset kernel thread is started. This thread traverses all valid page table entries in the system at fixed intervals to periodically obtain page access status. During normal system operation, the CPU hardware automatically maintains the Access Bit in the page table entries (PTEs). When any physical page is read or written by a business process, the hardware automatically sets the Access Bit of the corresponding page table entry to 1. The software does not need to actively intervene, poll, or perform additional calculations; it can directly obtain the access bit status in subsequent cycles, thus achieving access tag capture with zero software overhead.

[0085] The access bit acquisition process provided in this embodiment significantly reduces the memory overhead required for hot page state storage through a simplified global bitmap, avoiding the memory pressure caused by traditional counters, linked lists, hash tables, and other structures. This makes it particularly suitable for resource-constrained embedded environments. By attaching a scan hook to the page table scanner and utilizing CPU hardware to automatically maintain the Access Bit, fully hardware-level access marking is achieved. This eliminates the need for high-frequency software scanning, sampling, or tracing, thus removing the additional CPU overhead associated with hot page identification and preventing business process jitter or increased system latency. Periodic traversal of the page table by a low-priority background kernel thread ensures real-time access state acquisition while avoiding preemption of normal business computing resources, making the hot page identification process virtually non-intrusive to system operation. The overall access bit acquisition process is simple and efficient, requiring no complex algorithms or extensive computation. It is stably compatible with various embedded processor architectures such as ARM and RISC-V, solving the problem that traditional server-level snapshot technologies cannot run in embedded environments.

[0086] In some embodiments, updating the currently accessed bit according to a two-bit aging method to determine the current page popularity status includes:

[0087] Perform bitwise operations to update the current page to obtain the current page's state value;

[0088] The current page is categorized based on its current status value to obtain the corresponding page popularity status.

[0089] Specifically, the background scanning thread (with a default scan cycle of 200ms) traverses the active page table entries, obtains the current access bit (the page table entry access bit maintained by the CPU hardware), and then performs a preset bitwise operation update logic on the current page. The specific process is as follows:

[0090] First, read the historical popularity status (denoted as Old_State) recorded in the global bitmap of the current page. Old_State is 2-bit binary data, which corresponds to the popularity status after the previous scan cycle. The value range is 00 (binary, corresponding to decimal 0), 01 (decimal 1), 10 (decimal 2), and 11 (decimal 3).

[0091] Secondly, determine the value of the current access bit (denoted as Hardware_Access_Bit): if the page is read or written by the business process during the current scan cycle, the CPU hardware has set the Access Bit to 1, so Hardware_Access_Bit=1; if it is not accessed, the Access Bit remains 0, so Hardware_Access_Bit=0.

[0092] Subsequently, a preset bitwise operation formula is executed to update the current page state value (denoted as New_State). The bitwise operation formula is as follows:

[0093] New_State=((Old_State&0x1)<<1)|Hardware_Access_Bit;

[0094] Where 0x1 is a hexadecimal mask used to extract the low-order bits of Old_State (i.e., the access records of the previous scan cycle); <<1 indicates that the extracted low-order bits are shifted left by 1 bit and used as the high-order bits of New_State, realizing the natural aging of historical access states, that is, the access records of the previous cycle become earlier historical records; |Hardware_Access_Bit indicates that the current access bit is placed into the low-order bits of New_State, completing the real-time update of the access state of the current cycle.

[0095] After the update is complete, the system immediately clears the Access Bit of the page table entry (sets it to 0) to ensure that the access status of the page can be accurately captured in the next scan cycle, avoiding the deviation in popularity judgment caused by the accumulation of access records.

[0096] This embodiment provides three typical bitwise operation update examples based on specific scenarios, clearly demonstrating the operation logic:

[0097] Example 1: Old_State=00 (not accessed in the previous cycle), current access bit=1 (accessed in this cycle), calculation process: ((00&01)<<1)|01=(00<<1)|01=00|01=01 (New_State=01);

[0098] Example 2: Old_State=01 (accessed in the previous cycle), current access bit=1 (accessed in the current cycle), calculation process: ((01&01)<<1)|01=(01<<1)|01=10|01=11 (New_State=11);

[0099] Example 3: Old_State=11 (accessed in the previous cycle and the cycle before that), current access bit=0 (not accessed in this cycle), calculation process: ((11&01)<<1)|00=(01<<1)|00=10|00=10 (New_State=10).

[0100] Figure 2 A schematic diagram illustrating the state transition of a lightweight two-position aging hotspot identification algorithm provided in this application embodiment is shown below. Figure 2 As shown, the popularity is represented by a 2-bit status bit on each page. In each scan cycle, the status bit is adjusted according to the formula New_State = ((Old_State & 0x1) << 1) | Hardware_Access_Bit Update to achieve natural aging and real-time updates of popularity; when a page is in the extremely hot (11) state, it will remain in the 11 state if it is still accessed in the current period, and will change to the warm (10) state if it is not accessed; a page in the warm (10) state will change to the extremely hot (11) state if it is accessed in the current period, and will change to the cold (00) state if it is not accessed; a page in the cold (00) state will change to the warm (01) state if it is accessed in the current period, and will remain in the 00 state if it is not accessed; a page in the warm (01) state will change to the extremely hot (11) state if it is accessed in the current period, and will change to the cold (00) state if it is not accessed. Through this state transition, the system can automatically divide the page into four popularity states of extremely hot, warm, warm and cold based on the access situation of the last two periods without complex calculations, providing a low-overhead and highly accurate basis for the adaptive adjustment of the subsequent snapshot strategy.

[0101] The dual-bit aging method of simple bit operation update and state classification provided in this application completely abandons the complex mechanism of traditional hot page identification, and realizes low-overhead and high-precision page popularity identification. It not only solves the problem of excessive CPU and memory consumption of traditional technology, but also avoids business process jitter, while ensuring the accuracy of popularity classification. This lays the foundation for the subsequent execution of adaptive snapshot strategy, further improves the stability and efficiency of snapshot processing in embedded environment, and meets the low-overhead and high-stability snapshot requirements of embedded environment.

[0102] In some embodiments, determining the current system stress index based on current server resource metrics includes:

[0103] Get the current CPU load, I / O wait time, and remaining memory.

[0104] Assign a first weighting coefficient, a second weighting coefficient, and a third weighting coefficient to the current CPU load value, I / O wait time, and remaining memory, respectively; wherein the sum of the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient is 1;

[0105] The current system stress index is determined based on the current CPU load, the first weighting factor, the I / O wait time, the second weighting factor, the remaining memory, and the third weighting factor.

[0106] Specifically, multi-dimensional resource metrics are collected. The system quickly reads the current CPU load (LoadAvg), I / O wait time (IOWAIT), and remaining memory (FreeMem) from the / proc or / sys file system. For battery-powered devices, the current battery percentage is also read. The formula for calculating the current system stress index is as follows:

[0107] SPI=α*CPU_Norm+β*IO_Norm+γ*(1-Mem_Norm);

[0108] Wherein, CPU_Norm is the current CPU load value, α is the first weight coefficient, IO_Norm is the IO wait time, β is the second weight coefficient, 1-Mem_Norm is the remaining memory, and γ is the third weight coefficient. All indicators are normalized to the range [0, 1], and the sum of the first weight coefficient, the second weight coefficient, and the third weight coefficient is 1.

[0109] This embodiment achieves accurate, quantitative, and real-time perception of the instantaneous load of embedded systems by comprehensively collecting core resource indicators, rationally allocating weight coefficients, and rigorously calculating system stress indexes. It completely solves the defects of existing snapshot strategies, which are statically configured and lack resource awareness capabilities. At the same time, the entire process has extremely low overhead, rigorous logic, and can be adapted to different embedded scenarios, laying a solid foundation for the execution of subsequent adaptive snapshot strategies. It further meets the low-overhead and high-stability snapshot requirements in embedded environments, ensuring that snapshot processing is highly matched with system resource status and business load, and prioritizing the normal operation of business processes.

[0110] In some embodiments, adjusting the snapshot strategy of the current page based on the relationship between the current system pressure index and a threshold includes:

[0111] Obtain a first pressure threshold and a second pressure threshold; wherein the first pressure threshold is greater than the second pressure threshold;

[0112] If the current system pressure index is greater than the first pressure threshold, it is determined that the system resources corresponding to the current system pressure index are under pressure. The first pressure threshold is increased by a step size so that the number of hot page states corresponding to the current system pressure index meets the first preset number. Then, the first preset number of hot page states are taken down for snapshot processing.

[0113] If the current system pressure index is less than the second pressure threshold, it is determined that the system resources corresponding to the current system pressure index are sufficient. The first pressure threshold is then reduced by a step size to ensure that the number of hot and warm page states corresponding to the current system pressure index meets the second preset number. Background transmission processing is then initiated for the second preset number of hot and warm page states.

[0114] Specifically, a first pressure threshold and a second pressure threshold are preset and obtained to classify the system pressure level. The first pressure threshold is greater than the second pressure threshold. The values ​​of the two thresholds are set based on the resource characteristics and business requirements of the embedded device, and can be adaptively adjusted according to specific application scenarios to ensure accurate differentiation between the two states of system resource scarcity and resource abundance. In this embodiment, combined with the business requirements of the embedded IoT terminal (prioritizing the stability of business processes while taking into account snapshot integrity), the preset thresholds are as follows:

[0115] First pressure threshold (denoted as SPI_H): with a value of 0.8, used to determine whether the system is in a state of extreme resource shortage. When SPI > SPI_H, the system resources cannot support a large number of snapshot operations, and business processes must be prioritized.

[0116] The second pressure threshold (denoted as SPI_L) has a value of 0.3 and is used to determine whether the system is in a resource-sufficient state. When SPI < SPI_L, the system has sufficient resources to perform snapshot operations, which can improve snapshot efficiency and ensure snapshot integrity.

[0117] Meanwhile, the thresholds can be adjusted according to the scenario. For example, in industrial control scenarios, where business stability requirements are higher, the first pressure threshold can be adjusted to 0.7 and the second pressure threshold can be adjusted to 0.2. After adjustment, the relationship between the two thresholds is still satisfied, adapting to the snapshot requirements of different scenarios.

[0118] When the real-time calculated SPI exceeds the first pressure threshold (SPI_H=0.8), the system is determined to be in a state of extreme resource stress. If a conventional snapshot strategy is executed at this time, it will consume a large amount of CPU, I / O, and memory resources, leading to resource contention among business processes, a sharp increase in response latency, and even process starvation. Therefore, it is necessary to increase the step size of the first pressure threshold. By increasing the hot page filtering threshold, the number of hot pages is controlled to meet the first preset number. Then, a shutdown snapshot is performed on these hot pages. The specific implementation process is as follows:

[0119] Step size setting and first pressure threshold adjustment: The preset step size is 0.05 (the step size can be adjusted according to the system sensitivity, ranging from 0.02 to 0.1). The first pressure threshold is adjusted by increasing the step size. The adjusted first pressure threshold = original first pressure threshold + increased step size = 0.8 + 0.05 = 0.85. After adjustment, the screening criteria for hot page status (only "extremely hot" pages) are simultaneously improved, retaining only the core extremely hot pages with the highest access frequency, ensuring that the number of hot pages meets the first preset number.

[0120] First preset quantity setting: Based on the memory resources (2GB) and service characteristics of the embedded device in this embodiment, the first preset quantity is set to 5% of the total number of physical memory pages (i.e., 524288 pages × 5% ≈ 26214 pages). This quantity can ensure the integrity of the core data of the snapshot, and minimize the snapshot overhead and avoid occupying too many resources.

[0121] Shutdown snapshot processing execution: The system only performs shutdown snapshot processing on hot pages (extremely hot pages) that meet the first preset number. The specific process is as follows: a signal is sent to suspend all user-mode business processes, freeze file system metadata (the time taken is controlled within 10ms), quickly locate and copy the extremely hot pages to the snapshot buffer through the global bitmap index, and immediately resume business process operation after copying is completed; at the same time, the background scanning thread is suspended, and the unsaved pages are handled entirely by the copy-on-write (COW) mechanism to further reduce system load and prioritize the normal operation of business processes.

[0122] When the real-time calculated SPI is less than the second pressure threshold (SPI_L=0.3), the system is determined to be in a resource-sufficient state. At this time, the system has sufficient CPU, I / O, and memory resources, which can reduce the hot page filtering threshold, improve snapshot efficiency, and ensure snapshot data integrity. Therefore, the first pressure threshold needs to be decremented by a step size to ensure that the total number of pages in the hot page state and the warm page state meets the second preset number. Then, background transmission processing is started for this part of the pages. The specific implementation process is as follows:

[0123] Step size setting and first pressure threshold adjustment: The preset decreasing step size is 0.05 (consistent with the increasing step size, and can be adjusted synchronously). The first pressure threshold is processed by decreasing the step size. The adjusted first pressure threshold = original first pressure threshold - decreasing step size = 0.8 - 0.05 = 0.75. After adjustment, the hot page filtering threshold is reduced, and both "extremely hot" pages and "warm" pages are included in the snapshot range to ensure that the total number of the two types of pages meets the second preset number.

[0124] The second preset quantity setting: In combination with the embedded device resources in this embodiment, the second preset quantity is set to 20% of the total number of physical memory pages (i.e., 524288 pages × 20% ≈ 104858 pages). This quantity can ensure the integrity of snapshot data and make full use of idle system resources without affecting the operation of business processes.

[0125] Background transfer processing execution: The system initiates background transfer processing for hot pages (extremely hot + warm hot) that meet the second preset number. The specific process is as follows: without pausing the business process for a long time, after freezing the file system metadata (time < 10ms), extremely hot and warm hot pages are selected through global bitmap index and copied to the snapshot buffer. Then, the business process is immediately resumed. The background kflush thread is started to persist the pages in the snapshot buffer to the storage device in full-speed mode without I / O throttling. At the same time, the background scanning thread is kept running normally to continuously update the page heat status and ensure the real-time performance and integrity of the snapshot data.

[0126] Figure 3 A logic diagram illustrating the dynamic adjustment of heat threshold and I / O rate based on system pressure index provided in this application embodiment is shown below. Figure 3As shown, the complete logic of dynamically adjusting the snapshot strategy based on the relationship between the System Stress Index (SPI) and a preset threshold is presented intuitively, illustrating the entire process from collecting system resource indicators and calculating the stress index to threshold judgment and adaptive adjustment of the snapshot strategy. The diagram clearly marks the criteria for the division between the first stress threshold (0.8) and the second stress threshold (0.3), as well as the details of strategy adjustments under different stress scenarios. The diagram illustrates how, when the SPI is greater than the first stress threshold (resource strain), the first stress threshold is increased by increasing the step size, and a first preset number (5% of total physical memory pages) of extremely hot pages are selected to execute a shutdown fast-track. The logic also presents the process of reducing the first pressure threshold by decreasing the step size and selecting a second preset number (20% of the total physical memory pages) of extremely hot and warm pages to start background transmission when the SPI is less than the second pressure threshold (resources are sufficient). At the same time, it is related to the calculation process of the system pressure index (including the collection and weighted calculation of CPU load, IO wait time, and remaining memory). It clearly reflects the relationship between each link and intuitively presents the core solution of reducing overhead and ensuring business when resources are tight, and improving efficiency and ensuring integrity when resources are sufficient. This makes it easy for those skilled in the art to understand the execution logic of the entire adaptive snapshot strategy.

[0127] This embodiment provides a method to dynamically adjust the first pressure threshold and snapshot strategy by presetting a reasonable pressure threshold and combining it with the real-time quantitative results of the system pressure index. This achieves adaptive matching between the snapshot strategy and the system resource status, reducing overhead and ensuring business operations when resources are scarce, and improving efficiency and ensuring integrity when resources are abundant. The entire adjustment process is logically rigorous, the parameters are reproducible, and the overhead is extremely low, requiring no complex calculations or additional resource investment, perfectly adapting to the resource-constrained characteristics of embedded devices. Combined with the system pressure index determination method in the above embodiment, this further improves the technical solution of the lightweight embedded snapshot system, completely solving the defects of static and rigid snapshot strategies and lack of resource awareness in existing technologies. It provides strong support for low-overhead and highly stable execution of subsequent snapshot processing, achieving a technical effect of accurate, quantitative, and real-time perception of the instantaneous load of the embedded system. Together, they meet the low-overhead and highly stable snapshot requirements in the embedded environment, ensuring that snapshot processing is highly matched with the system resource status and business load, and prioritizing the normal operation of business processes.

[0128] In some embodiments, performing a shutdown snapshot process on a first preset number of pages in a hot page state includes:

[0129] Copy the pages marked as hot pages in the bitmap to the pre-allocated snapshot buffer;

[0130] Suspend all user-space processes to freeze file system metadata;

[0131] Batch set the write protection bits of the page table entries for the remaining pages that have not been copied to the snapshot buffer to restore the CPU and device state for runtime processing.

[0132] Specifically, during the system initialization phase, a snapshot buffer of fixed size is pre-allocated. In this embodiment, the buffer size is set to the space corresponding to 5% of the total number of physical memory pages (i.e., 2GB × 5% = 100MB), which matches the first preset number (only the top 5% of extremely hot pages are saved), avoiding the overhead of dynamic memory allocation, while ensuring that all hot page data that needs to be saved during shutdown can be accommodated at once.

[0133] When a stop snapshot is triggered, the system directly traverses the global bitmap and copies only the pages marked as "extremely hot" (2-bit value of 11) to the pre-allocated snapshot buffer in batches according to their page numbers. In this embodiment, this process only needs to traverse the index of the global bitmap, without traversing the entire physical memory, and the time taken can be controlled within 5ms. Moreover, it only occupies a fixed space in the snapshot buffer and does not consume additional system memory resources.

[0134] Before (or during) copying a hot page, the system sends a SIGSTOP signal to suspend all user-space business processes and calls the file system interface to freeze metadata (such as the ext4 freeze command) to prevent business processes from modifying file metadata during the snapshot process, which could lead to inconsistent snapshot data. In this embodiment, the time taken for this step is strictly controlled within 10ms to minimize business interruption time.

[0135] After hot page replication is complete, the system immediately sets the write protection bit (PROT_WRITE) of the page table entries for the remaining pages not copied to the snapshot buffer (i.e., warm pages and cold pages). This batch setting is completed in a single system call, avoiding the overhead of page-by-page operations. Subsequently, all user-space processes are immediately restored, file system metadata is unfrozen, CPU and device states are unfrozen, and system business processes resume normal operation. At this time, unsaved pages are subsequently processed asynchronously through the copy-on-write (COW) mechanism. During the downtime phase, only core hot pages are saved, minimizing business interruption time.

[0136] This embodiment addresses the shortcomings of embedded snapshot technology, which, when executed in resource-constrained conditions, suffers from long service interruptions, severe resource contention, and process starvation. By pre-allocating a snapshot buffer matching a predetermined number, it avoids the additional overhead and uncertainty of dynamic memory allocation. By briefly pausing user processes and freezing file system metadata, it ensures data consistency during the downtime snapshot phase, preventing snapshot corruption caused by concurrent modifications. Simultaneously, by strictly controlling the pause time to a minimum, it minimizes service interruption time and solves the problem of excessively long downtime in traditional snapshots. After write protection settings are completed, system operation resumes immediately, fundamentally preventing the snapshot process from occupying CPU and I / O resources for extended periods during resource-constrained conditions, thus avoiding the "starvation" of service processes and a surge in response latency. This achieves service-priority, low-downtime snapshot processing.

[0137] In some embodiments, batch setting of write-protect bits for page table entries not copied to the snapshot buffer to restore CPU and device state for runtime processing includes:

[0138] If the first target page is abnormal when performing copy-on-write processing on the remaining pages, the abnormal first target page will be copied to the snapshot storage area and the write protection bit will be removed.

[0139] Start the first thread to scan the remaining pages for the second target page that is inactive;

[0140] The token bucket mechanism is used to throttle the IO traffic transmitted by the first thread.

[0141] Specifically, after hot page replication is completed during the shutdown snapshot phase, the system sets the write protection bit (VM_READONLY) of page table entries for all unreplicated pages (the remaining pages) in batches through the kernel interface. Then, it immediately restores all user-space processes, unfreezes file system metadata, and the system services resume normal operation. At this time, write operations by service processes on these protected pages will trigger page fault exceptions, which are caught and handled by the kernel.

[0142] When a business process performs a write operation on a write-protected page, the system captures the page error exception and determines the page as the first target page. First, the current data of the page (i.e., the original data before the write operation) is copied to the snapshot storage area. After the copy is completed, the write protection bit of the page is immediately removed, allowing the business process to continue writing. This process is transparent to the business process and will not cause additional blocking. Snapshot saving is only triggered when the business process actually modifies the page, realizing on-demand saving and avoiding the CPU and I / O overhead caused by active scanning.

[0143] After the system resumes operation, a low-priority background kernel thread (denoted as kflush_snap, i.e., the first thread) is started. This thread only runs during CPU idle time to avoid preempting business process resources. The thread's task is to scan the remaining pages for the second target page marked as "cold" and asynchronously write its data to the snapshot storage area.

[0144] To prevent background thread cold page scanning from consuming excessive storage bandwidth and impacting the I / O performance of business processes, the system introduces a token bucket mechanism for flow control: Initializing the token bucket: Setting the token generation rate, which is related to the system stress index as follows: Token generation rate = base rate × (1 − SPI), where the base rate is set to 10MB / s; Flow control rules: For every 1MB of data transferred by a background thread, 1 token is consumed; If the token bucket is empty, the thread actively sleeps until a token is generated; Dynamic adaptation: When SPI increases (system load increases), the value of (1 − SPI) decreases, and the token generation rate slows down accordingly, automatically reducing the speed of background transmission; When SPI decreases (system load decreases), the token generation rate increases, automatically increasing the speed of background transmission.

[0145] In this embodiment, when SPI=0.9 (high voltage), the token generation rate is only 1MB / s, the background transmission is almost suspended, and business I / O is completely avoided; when SPI=0.2 (low voltage), the token generation rate recovers to 8MB / s, and the background transmission is at full speed.

[0146] This embodiment achieves snapshot saving only when a page is modified by capturing page fault exceptions on write-protected pages, eliminating the need for active scanning and traversal, thus significantly reducing CPU and I / O overhead during the snapshot phase. It also initiates a low-priority background thread to asynchronously process inactive pages, delaying the snapshot saving of non-core data until system idle periods. This ensures the integrity of snapshot data while avoiding the performance impact of active scanning during system busy times. Furthermore, it implements a business-priority resource scheduling strategy, preventing business processes from "starving" or experiencing response delays due to I / O preemption. The token bucket mechanism completely resolves the bandwidth contention between background snapshot transmission and business process I / O, ensuring the responsiveness of business processes and significantly improving the stability and reliability of snapshot processing in embedded environments.

[0147] In conventional solutions, embedded devices mostly use Flash storage. Although incremental snapshot technology is available, frequent and indiscriminate writing of small data blocks can lead to severe write amplification, shortening device lifespan and reducing I / O efficiency.

[0148] In some embodiments, when performing snapshot processing on a page in a hot page state, the method further includes:

[0149] Pages in hot state are stored in a memory circular buffer;

[0150] If a page in the hot page state is modified within a preset time, the logical write in the memory circular buffer is updated until the preset number of logical writes is reached, at which point write merging is performed.

[0151] Specifically, during the initialization phase, the system pre-allocates a fixed-size circular memory buffer for the snapshot processing module. This size can be adjusted based on the available memory resources of the embedded device and the business scenario. The buffer adopts a circular queue structure, with each unit corresponding to a snapshot of a hot page. It also maintains read pointers, write pointers, and data status flags, supporting multi-round write overwrite updates, avoiding frequent memory allocation and release operations, and reducing overhead.

[0152] After copying the hot page data to the snapshot buffer during the shutdown snapshot phase, the system simultaneously writes the current snapshot data of the hot page into the memory circular buffer, establishing a mapping relationship between page addresses and buffer units. When the business process modifies the hot page again within a preset time window (the default window in this embodiment is 500ms, which is configurable), the copy-on-write (COW) mechanism is triggered. The system catches the write exception and only updates the modified page data to the corresponding unit in the circular buffer, without immediately performing the physical write operation to the storage device.

[0153] The system maintains a logical write counter for each hot page. Each modification triggers a buffer update, and the counter increments by 1. When the counter reaches a preset number of times (3 times in this embodiment, adjustable based on business modification frequency), or when a preset time window ends, the system performs a write merging process: the latest data for that hot page in the circular buffer is written to the snapshot storage area in one go, the logical write counter for that page is reset, and the buffer unit is released for use by other hot pages. If the counter does not reach the preset number of times within the time window, a write merging process is automatically triggered at the end of the window to prevent data from remaining in the buffer for an extended period.

[0154] To prevent the circular buffer from overflowing, the system has a buffer full trigger mechanism: when the buffer utilization reaches a preset threshold (such as 90%), write merging is performed on all hot pages in the buffer in advance to release space; at the same time, for hot pages that have not been modified for a long time, a timeout cleanup mechanism is set to automatically merge and write after a preset time to ensure efficient use of buffer resources.

[0155] The method provided in this embodiment, which uses a memory circular buffer for temporary storage, logical write updates, and write merging, effectively solves the problem of excessive I / O overhead caused by frequent modifications of hot pages in embedded snapshots. It achieves low-overhead and efficient snapshot data persistence. Combined with the adaptive snapshot strategy based on system pressure index, COW exception handling, and token bucket I / O throttling mechanism in the above embodiments, it further optimizes the overall performance of the embedded snapshot system, ensuring low-overhead and highly stable snapshot processing in resource-constrained environments, and meeting the core requirement of business priority.

[0156] In some embodiments, when performing snapshot processing on the current page, the method further includes:

[0157] When the content of the current page is all zeros, the corresponding metadata tag for the current page is recorded;

[0158] If the current page and the previous page are consecutive snapshots, and the page content of the current page and the previous page differs by a preset number of bytes, then the page content of the current page corresponding to the preset number of bytes is recorded.

[0159] Specifically, when performing snapshot processing on the current page (including hot page processing for downtime snapshots and cold / warm page processing for background asynchronous snapshots), the system first checks if the content of the current page is all zeros. The system uses a kernel-level memory scanning interface to perform byte-by-byte verification of the content of the current page (4KB). The verification method adopts an efficient batch comparison mechanism (comparing in groups of 128 bytes to reduce CPU overhead) to determine whether all bytes in the page are 0x00 (all hexadecimal zeros). In this embodiment, the batch comparison time is controlled within 0.1ms, which will not affect the operation of the business process. If the verification determines that the content of the current page is all zeros, the system does not write the all-zero content of the page to the snapshot storage area. Instead, it records the metadata tag corresponding to the current page in the snapshot metadata area (preset size 16KB, used to store page tags, address mappings and other metadata). The tag format is page physical address + all-zero flag bit (1 bit, set to 1 indicates all-zero page). At the same time, it is associated with the snapshot timestamp of the page to ensure that the all-zero page can be accurately identified when the snapshot is restored.

[0160] If the current page is a zero-based page, but is subsequently modified by a business process (triggering a COW exception), the system immediately clears the zero-based metadata marker for that page and writes the modified page content to the snapshot storage area according to the normal page processing procedure, ensuring the consistency of the snapshot data.

[0161] When taking a snapshot of the current page, the system simultaneously determines whether the current page and the previous snapshot page are consecutive snapshots (i.e., the physical addresses of the two pages are consecutive, and the physical address of the previous page + 4KB = the physical address of the current page). If they are consecutive snapshots, the system further determines whether the difference in the content of the two pages is a preset byte page. If so, only the content of the preset byte page with the difference is recorded.

[0162] The system determines whether the physical addresses of the current page and the previous page are consecutive by reading them. In this embodiment, the page size is 4KB. Therefore, when the physical address of the previous page is 0x80001000, the physical address of the current page is 0x80002000 (0x80001000+4096=0x80002000), which is considered a consecutive snapshot. If the physical addresses are not consecutive, the complete page content is recorded according to the normal process. Considering the limited storage resources of embedded devices, the preset byte page size in this embodiment is set to 512 bytes (which can be adaptively adjusted according to the page size and storage bandwidth, ranging from 256 bytes to 1KB). This determines whether the content difference between two consecutive pages is concentrated within a single 512-byte unit.

[0163] The system compares the content of the current page with the previous page byte by byte, counting the number of difference units. If only one 512-byte unit differs (i.e., the difference is a preset byte page), the difference condition is met. If the number of difference units exceeds one, or the size of the difference unit is not 512 bytes, the complete content of the current page is recorded according to the normal process. When consecutive snapshots are met and the difference is a preset byte page, the system does not record the complete content of the current page. Instead, it records the physical address of the previous page, the offset of the difference unit, and the content of the preset byte page in the snapshot storage area. At the same time, it marks the page as a difference page in the metadata area and associates it with the address of the previous page, ensuring that the current page can be restored using the content of the previous page plus the difference content during subsequent snapshot restoration.

[0164] This embodiment provides dual optimizations through all-zero page metadata tagging and continuous snapshot page difference content recording, further reducing the storage and I / O overhead of snapshot processing and improving snapshot efficiency. Simultaneously, the entire processing flow has extremely low overhead and rigorous logic, requiring no complex calculations or additional resource investment. It perfectly adapts to the resource-constrained characteristics of embedded devices, effectively solving the shortcomings of existing embedded snapshot technologies such as high storage overhead and high I / O pressure. This further improves the technical solution of lightweight embedded snapshot systems, ensuring low-overhead, highly stable, and highly efficient snapshot processing in resource-constrained environments, meeting the core requirements of snapshot processing in embedded environments, and extending the lifespan of storage devices.

[0165] Figure 4A flowchart of another snapshot processing method provided in the embodiments of this application is shown below. Figure 4 As shown, it includes:

[0166] S21: Snapshot initialization;

[0167] S22: Monitoring resources and hotspot tracking;

[0168] S23: Determine whether a snapshot has been triggered. If yes, proceed to step S24; otherwise, return to step S22.

[0169] S24: Calculate the system pressure index;

[0170] S25: Determine the snapshot execution mode based on the system stress index;

[0171] S26: Only the extremely hot page is saved in high-pressure mode;

[0172] S27: Save hot pages and warm pages in low-pressure mode;

[0173] S28: Perform default processing in standard mode;

[0174] S29: Shutdown snapshot;

[0175] S30: Resume operation and write protection;

[0176] S31: Background transmission;

[0177] S32: Perform copy-on-write processing on warm pages;

[0178] S33: Perform background thread scanning for cold pages;

[0179] S34: Determine whether an IO throttle valve is needed. If yes, proceed to step S35; otherwise, proceed to step S36.

[0180] S35: Low-speed transmission;

[0181] S36: High-speed transmission;

[0182] S37: Optimized storage writes;

[0183] S38: Snapshot complete.

[0184] The above describes in detail the various embodiments corresponding to the snapshot processing method. Based on this, this application also discloses a snapshot processing apparatus corresponding to the above method. Figure 5 This is a structural diagram of a snapshot processing apparatus provided in an embodiment of this application. Figure 5 As shown, the snapshot processing apparatus includes:

[0185] The acquisition module 11 is used to acquire the current access bit of the current page under the global bitmap data structure, and update the current access bit according to the two-bit aging method to determine the page popularity status of the current page.

[0186] Module 12 is used to determine the current system stress index based on the current server resource indicators;

[0187] Processing module 13 is used to adjust the snapshot strategy of the current page based on the relationship between the current system pressure index and the threshold, so as to perform snapshot processing.

[0188] Since the embodiments of the device part correspond to the embodiments described above, please refer to the embodiments described in the method part for the embodiments of the device part, and will not be repeated here.

[0189] For a description of the snapshot processing apparatus provided in this application, please refer to the above method embodiments. This application will not repeat the description here, as it has the same beneficial effects as the above snapshot processing method.

[0190] Figure 6 A structural diagram of an embedded snapshot system provided in an embodiment of this application is shown below. Figure 6 As shown, the system includes:

[0191] Memory 21 is used to store computer programs;

[0192] Processor 22 is used to implement the snapshot processing method when executing a computer program.

[0193] The processor 22 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 22 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 22 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 22 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 22 may also include an Artificial Intelligence (AI) processor, which handles computational operations related to machine learning.

[0194] The memory 21 may include one or more computer-readable storage media, which may be non-transitory. The memory 21 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 21 is used to store at least the following computer program 211, which, after being loaded and executed by the processor 22, is capable of implementing the relevant steps of the snapshot processing method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 21 may also include an operating system 212 and data 213, etc., and the storage method may be temporary storage or permanent storage. The operating system 212 may include Windows, Unix, Linux, etc. The data 213 may include, but is not limited to, the data involved in the snapshot processing method, etc.

[0195] In some embodiments, the embedded snapshot system may further include a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27.

[0196] Those skilled in the field can understand, Figure 6 The structure shown does not constitute a limitation on the embedded snapshot system and may include more or fewer components than illustrated.

[0197] The processor 22 implements the snapshot processing method provided in any of the above embodiments by calling instructions stored in the memory 21.

[0198] For an introduction to the embedded snapshot system provided in this application, please refer to the above method embodiments. This application will not repeat the details here, as it has the same beneficial effects as the above snapshot processing method.

[0199] Furthermore, this application also provides a computer-readable storage medium storing a computer program, which, when executed by processor 22, implements the steps of the snapshot processing method described above.

[0200] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0201] For a description of the computer-readable storage medium provided in this application, please refer to the above method embodiments. This application will not repeat the description here, but it has the same beneficial effects as the above snapshot processing method.

[0202] The snapshot processing method and embedded snapshot system provided in this application have been described in detail above. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of this application.

[0203] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

Claims

1. A snapshot processing method, characterized in that, include: Obtain the current access bit of the current page under the global bitmap data structure, and update the current access bit according to the two-bit aging method to determine the page popularity status of the current page; Determine the current system stress index based on current server resource metrics; The snapshot strategy for the current page is adjusted based on the relationship between the current system pressure index and the threshold in order to perform snapshot processing.

2. The snapshot processing method according to claim 1, characterized in that, The process of obtaining the currently accessed bit includes: The global bitmap system is initialized to allocate a global bitmap with a physical memory page size of 2 / 8 bytes, and each 2 bits under each bitmap corresponds to the heat status of a physical page; Attach the scan hook to the page table scanner under the operating system; Pre-configure background scan thread parameters to start a preset kernel thread to traverse page table entries; The CPU hardware automatically maintains the access bits of the page table entries for acquisition during page reads and writes.

3. The snapshot processing method according to claim 2, characterized in that, The current access position is updated according to the two-position aging method to determine the current page popularity status, including: Perform bitwise operations to update the current page to obtain the current page's state value; The current page is categorized based on its current status value to obtain the corresponding page popularity status.

4. The snapshot processing method according to claim 1, characterized in that, The current system stress index is determined based on current server resource metrics, including: Get the current CPU load, I / O wait time, and remaining memory. Assign a first weighting coefficient, a second weighting coefficient, and a third weighting coefficient to the current CPU load value, IO wait time, and remaining memory, respectively; wherein the sum of the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient is 1; The current system stress index is determined based on the current CPU load value, the first weighting coefficient, the I / O wait time, the second weighting coefficient, the remaining memory, and the third weighting coefficient.

5. The snapshot processing method according to claim 4, characterized in that, Adjusting the snapshot strategy of the current page based on the relationship between the current system stress index and the threshold includes: Obtain a first pressure threshold and a second pressure threshold; wherein the first pressure threshold is greater than the second pressure threshold; If the current system pressure index is greater than the first pressure threshold, it is determined that the system resources corresponding to the current system pressure index are under pressure. The first pressure threshold is increased by a step size so that the number of hot page states corresponding to the current system pressure index meets the first preset number. Then, the first preset number of hot page states are subjected to a shutdown snapshot. If the current system pressure index is less than the second pressure threshold, it is determined that the system resources corresponding to the current system pressure index are sufficient. The first pressure threshold is then processed by decreasing the step size so that the number of hot page states and warm page states corresponding to the current system pressure index meets the second preset number. Background transmission processing is then started for the second preset number of hot page states and warm page states.

6. The snapshot processing method according to claim 5, characterized in that, Perform a shutdown snapshot process on the first preset number of pages in the hot page state, including: Copy the pages marked as hot pages in the bitmap to the pre-allocated snapshot buffer; Suspend all user-space processes to freeze file system metadata; Batch set the write protection bits of the page table entries for the remaining pages that have not been copied to the snapshot buffer to restore the CPU and device state for runtime processing.

7. The snapshot processing method according to claim 6, characterized in that, Batch set the write protection bits of page table entries for the remaining pages not copied to the snapshot buffer to restore CPU and device state for runtime processing, including: If the first target page is abnormal when performing copy-on-write processing on the remaining pages, the abnormal first target page will be copied to the snapshot storage area and the write protection bit will be removed. Start the first thread to scan the remaining pages for the second target page that is inactive; The token bucket mechanism is used to throttle the IO traffic transmitted by the first thread.

8. The snapshot processing method according to claim 1, characterized in that, When performing snapshot processing on a page in a hot page state, the method further includes: Pages in hot state are stored in a memory circular buffer; If a page in the hot page state is modified within a preset time, the logical write in the memory circular buffer is updated until the preset number of logical writes is reached, at which point write merging is performed.

9. The snapshot processing method according to claim 1, characterized in that, When performing snapshot processing on the current page, the method further includes: When the content of the current page is all zeros, the metadata tag corresponding to the current page is recorded; When the current page and the previous page are consecutive snapshots, and the page content of the current page and the previous page differs by a preset number of pages, the page content of the current page corresponding to the preset number of pages is recorded.

10. An embedded snapshot system, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the snapshot processing method as described in any one of claims 1 to 9.