Method for managing compressed memory of a terminal device

By acquiring page lifecycle characteristics and classifying them using the Q-table strategy table, differentiated compression or write-back strategies are selected, solving the problem of invalid compression operations in terminal devices, achieving more efficient memory management, and improving device operating efficiency and application response performance.

CN123047859APending Publication Date: 2026-11-06XIAMEN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611136003.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-29
Publication Date
2026-11-06

AI Technical Summary

Technical Problem

Existing compression memory management mechanisms cannot effectively distinguish page lifecycle behaviors in terminal devices, resulting in invalid compression operations, wasting processor resources and occupying limited compression memory space. It is difficult to achieve a balance between compression overhead, compression memory space occupation, page swapping latency and application response performance.

Method used

By acquiring page lifecycle characteristics, standardized state items are generated and classified using the Q-table strategy table. Differentiated compression or write-back strategies are selected, and the management strategy is dynamically adjusted based on application performance and system overhead feedback to reduce ineffective compression overhead and minimize wasted compressed memory space.

Benefits of technology

It improves the overall operating efficiency of terminal devices under memory pressure scenarios, reduces ineffective compression overhead, reduces waste of compressed memory space, and improves application response performance and system energy consumption balance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123047859A_ABST
    Figure CN123047859A_ABST
Patent Text Reader

Abstract

The application provides a terminal device-oriented compressed memory management method, which comprises the following steps: collecting the life cycle characteristics of a page to be swapped out; classifying the page according to the life cycle characteristics and a Q-table strategy table, and dividing the page into a page possibly read back, a page less likely to be read back, and a page less likely to be read back and difficult to compress; and selecting a differential processing strategy according to the classification result, wherein a light compression strategy is adopted for the page possibly read back, a high compression ratio compression strategy is adopted for the page less likely to be read back, and the page less likely to be read back and difficult to compress is directly written back to a back-end storage device by bypassing a normal compression path; and the page classification strategy and the processing strategy in the Q-table strategy table are dynamically adjusted according to the application running performance and system overhead feedback; thus, invalid compression overhead can be reduced, compressed memory space waste can be reduced, and a more optimal balance between memory recycling efficiency, application response performance and system energy consumption can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer storage management technology, and in particular to a compressed memory management method for terminal devices, a computer-readable storage medium, and a computer device. Background Technology

[0002] As the application scenarios of terminal devices such as smartphones, tablets, and wearable devices continue to expand, the number and complexity of applications running on these devices are constantly increasing. However, due to factors such as device size, power consumption, heat dissipation, and cost, the configurable physical memory capacity and processor resources of terminal devices are relatively limited. In scenarios such as multi-application concurrency, frequent switching between foreground and background processes, and the launch of large applications, the system is prone to memory pressure, placing higher demands on memory management efficiency. To maintain system availability under limited physical memory conditions, existing mobile operating systems typically employ compressed memory swapping mechanisms. When memory pressure is high, some anonymous pages are swapped out, compressed, and then stored in compressed memory. For example, in the Android system, the ZRAM compressed swapping device can compress pages to be swapped out and store them in a compressed area of ​​memory, thereby reducing the occupation of physical memory to a certain extent.

[0003] However, while compression swapping can alleviate the problem of insufficient memory capacity, it also introduces additional overhead. On the one hand, pages need to be compressed when swapped out and decompressed when swapped in, which consumes processor resources and increases page swapping latency. On the other hand, compressed pages are stored in the compressed area of ​​memory, which still occupies memory space. When a large number of pages are written to compressed memory, it may lead to shortage of compressed memory space, further affecting the efficiency of system memory reclamation and application response performance.

[0004] Existing compressed memory management mechanisms typically focus on selecting compression algorithms, adjusting compression ratios, optimizing swapping in and out paths, or improving compression execution efficiency. However, they often lack effective differentiation of a page's subsequent lifecycle behavior before it enters compressed memory. In actual operation, different pages exhibit significant differences in behavior after being swapped out: some pages may be re-accessed and read back by the application within a short period, some pages are not read back after being written to compressed memory until the end of their lifecycle, and some pages are inherently difficult to compress and have a low probability of being read back later. If a uniform compression strategy is applied to these different types of pages, it may result in low-return or even unreturnable compression operations, wasting processor resources and occupying limited compressed memory space.

[0005] Furthermore, the page lifecycle behavior on terminal devices is influenced by various factors, including the application to which the page belongs, the application's runtime stage, the source of page recycling, historical compression length, access behavior, and current system load. The probability of page readback and compressibility may also vary under different applications and operating scenarios. Existing solutions typically struggle to dynamically adjust page processing strategies based on application performance and system operating status, thus failing to achieve an optimal balance between compression overhead, compression memory usage, page swapping latency, and application response performance. Summary of the Invention

[0006] This invention aims to at least partially solve one of the technical problems in the aforementioned technologies. To this end, one objective of this invention is to propose a compressed memory management method for terminal devices. This method can predict the likelihood of a page being read back later based on its lifecycle characteristics before it is swapped out to compressed memory. Furthermore, it selects differentiated compression or write-back strategies for different types of pages based on page compressibility. Simultaneously, it dynamically adjusts the management strategy based on application performance and system overhead feedback to reduce ineffective compression overhead, minimize wasted compressed memory space, and improve the overall operating efficiency of terminal devices under memory pressure scenarios.

[0007] A second objective of this invention is to provide a computer-readable storage medium.

[0008] The third objective of this invention is to provide a computer device.

[0009] To achieve the above objectives, a first aspect of the present invention proposes a compressed memory management method for terminal devices. The method includes the following steps: obtaining page lifecycle characteristics corresponding to a page to be swapped out, and generating standardized state items based on the page lifecycle characteristics; querying a preset or dynamically updated Q-table strategy table based on the standardized state items to obtain corresponding processing actions, wherein the processing actions include preset classification results, compression algorithms, compression granularity, compression execution paths, or write-back paths; classifying the page to be swapped out based on the processing actions to obtain corresponding lifecycle classification results, wherein the lifecycle classification results include pages that may be read back, pages that are unlikely to be read back, and pages that are unlikely to be read back and difficult to compress; executing corresponding memory management strategies on the page to be swapped out based on the lifecycle classification results and processing actions, and recording path identifiers, algorithm identifiers, and swapping out mapping information in corresponding metadata; obtaining application performance feedback and system overhead feedback, and dynamically updating the Q-table strategy table based on the application performance feedback and system overhead feedback.

[0010] In addition, the compressed memory management method for terminal devices proposed in the above embodiments of the present invention may also have the following additional technical features: Optionally, the page lifecycle characteristics include one or more of the following: the application to which the page belongs, the source of page recycling, the application's running stage, page access behavior, historical compression length, and system performance status.

[0011] Optionally, the page recycling source includes one or more of background kernel recycling, direct memory recycling, memory control group recycling, and cache application optimization recycling; the system performance status includes one or more of memory pressure status, processor load status, compression time status, and hardware compression engine load status.

[0012] Optionally, generating standardized state items based on the page lifecycle characteristics includes: encoding the application identifier of the page in the page lifecycle characteristics into the high bits of the page reference count field; and generating standardized state items suitable for querying the Q-table strategy table after discretizing or bucketing the state items.

[0013] Optionally, the page to be swapped out is classified according to the processing action to obtain a corresponding lifecycle classification result, including: determining whether the probability of the page to be swapped out being accessed or swapped in later is higher than a preset readback threshold; if yes, the page to be swapped out is marked as a page that may be read back; if no, determining whether the compression benefit of the page to be swapped out is lower than a preset compression benefit threshold; if yes, the page to be swapped out is marked as a page that is unlikely to be read back and difficult to compress; if no, the page to be swapped out is marked as a page that is unlikely to be read back.

[0014] Optionally, based on the lifecycle classification result and processing action, a corresponding memory management strategy is executed for the page to be swapped out, including: if the lifecycle classification result indicates that the page may be read back, then the memory management strategy corresponding to the page to be swapped out is determined to be to perform low-latency lightweight compression using a CPU software compression path, and to preferentially retain the compressed page data in compressed memory; if the lifecycle classification result indicates that the page is unlikely to be read back and is difficult to compress, then the memory management strategy corresponding to the page to be swapped out is determined to bypass the normal compression path, so as to directly write the page to be swapped out back to the backend storage device or a low-cost write-back path; if the lifecycle classification result indicates that the page is unlikely to be read back, then the memory management strategy corresponding to the page to be swapped out is determined to be to compress using high compression ratio compression or cross-page granular compression, and to asynchronously submit multiple pages to be compressed to the hardware compression engine after being organized in batches, so that the hardware compression engine can read the page data to be compressed and write back the compression result via DMA.

[0015] Optionally, the application performance feedback includes one or more of the following collected by the application monitoring module: application startup time, application restart time, foreground / background switching time, response time, and lag status; the system overhead feedback includes one or more of the following collected by the processor performance monitoring unit: processor cycle count, compression time, decompression time, cache miss count, processor load, and hardware compression engine load.

[0016] Optionally, the Q-table strategy table is dynamically updated based on the application performance feedback and system overhead feedback, including: determining whether the current page classification strategy and compression or write-back processing strategy affect application performance based on the application performance feedback, and generating performance-driven rewards; generating system overhead status based on the system overhead feedback to characterize the current processor overhead, compression overhead, and hardware compression engine usage status; determining the effect of the current lifecycle classification result and corresponding processing action based on the performance-driven rewards and system overhead status, wherein when the page classification and processing strategy reduces processor overhead, reduces compression memory usage, and does not reduce application performance, a positive reward is given to the corresponding status item and processing action in the Q-table strategy; when the page classification and processing strategy causes the page to be read back within a preset time after being swapped out, increases swap-in latency, or reduces application performance, a negative reward is given to the corresponding status item and processing action in the Q-table strategy, and the Q-table strategy table is updated based on the positive or negative reward.

[0017] To achieve the above objectives, a second aspect of the present invention provides a computer-readable storage medium storing a compressed memory management program for a terminal device, which, when executed by a processor, implements the compressed memory management method for a terminal device as described above.

[0018] To achieve the above objectives, a third aspect of the present invention provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the compressed memory management method for terminal devices as described above.

[0019] The above-mentioned compressed memory management method for terminal devices has the following advantages: it can predict the likelihood of a page being read back later based on the page's lifecycle characteristics before the page is swapped out to compressed memory, and select differentiated compression or write-back strategies for different types of pages based on page compressibility. At the same time, it can dynamically adjust the management strategy based on application performance and system overhead feedback to reduce ineffective compression overhead, reduce wasted compressed memory space, and improve the overall operating efficiency of terminal devices under memory pressure scenarios. Attached Figure Description

[0020] Figure 1 This is a flowchart illustrating a compressed memory management method for terminal devices according to an embodiment of the present invention. Figure 2 This is a schematic diagram of the overall architecture according to an embodiment of the present invention; Figure 3 This is an example of the intent to represent the Q-table strategy according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the page lifecycle feature collection process according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the field structure carrying some page lifecycle features according to an embodiment of the present invention; Figure 6 This is a schematic diagram of the page lifecycle classification process based on Q-table according to an embodiment of the present invention; Figure 7 This is a schematic diagram of the differential compression and write-back path execution flow according to an embodiment of the present invention; Figure 8 This is a schematic diagram of the dynamic update process of Q-table according to an embodiment of the present invention. Detailed Implementation

[0021] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0022] To better understand the above technical solutions, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the invention to those skilled in the art.

[0023] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.

[0024] It should be noted that the overall architecture of the compressed memory management method for terminal devices in this application is as follows: Figure 2As shown, this applies to smartphones, tablets, wearable devices, or other mobile terminals with compressed memory swapping mechanisms. Compressed memory can be a memory-based compressed swapping device, such as the ZRAM compressed swapping device in the Android system. The backend storage device can be flash memory, block devices, or swap partitions. Applications in the terminal device consume physical memory during operation. When the system experiences memory pressure and triggers memory reclamation, some pages are identified as pages to be swapped out. Before these pages enter compressed memory, the system collects the page lifecycle characteristics and classifies them based on these characteristics and a Q-table strategy table. An example of the Q-table strategy table can be found here. Figure 3 The system selects differentiated compression or write-back processing strategies for different categories of pages based on the classification results: For pages that may be read back, low-latency, lightweight compression is performed using the CPU software compression path, and the pages are preferentially retained in compressed memory; for pages that are unlikely to be read back, a high compression ratio compression strategy is adopted, and multiple pages to be compressed can be organized in batches and submitted asynchronously to the hardware compression engine, which reads the page data to be compressed via DMA and writes back the compression results; for pages that are unlikely to be read back and are difficult to compress, the normal compression path is bypassed and the pages are directly written back to the backend storage device. After executing the corresponding page management strategy, the page classification and processing strategies in the Q-table are dynamically adjusted based on application performance and system overhead feedback.

[0025] refer to Figure 1 As shown, the compressed memory management method for terminal devices according to an embodiment of the present invention includes the following steps: S101, obtain the page lifecycle characteristics corresponding to the page to be swapped out, and generate standardized state items based on the page lifecycle characteristics.

[0026] As an example, page lifecycle characteristics include one or more of the following: the application to which the page belongs, the source of page recycling, the application's running stage, page access behavior, historical compression length, and system performance status.

[0027] It should be noted that by combining information from application dimensions, recycling source dimensions, access behavior dimensions, compression history dimensions, and system status dimensions, we can more accurately characterize the readback probability and compression benefits of the page to be swapped out in the subsequent lifecycle, making the lifecycle classification results more adaptable to the operating scenarios of multiple applications running concurrently, frequent switching between foreground and background, and changes in memory pressure on terminal devices.

[0028] As an example, page reclamation sources include one or more of background kernel reclamation, direct memory reclamation, memory control group reclamation, and cache application optimization reclamation; system performance status includes one or more of memory pressure status, processor load status, compression time status, and hardware compression engine load status.

[0029] As an example, generating standardized status items based on page lifecycle characteristics includes: encoding the application identifier of the page in the page lifecycle characteristics into the high bits of the page reference count field; and generating standardized status items suitable for querying the Q-table strategy table after discretizing or binning the status items.

[0030] Specifically, such as Figure 4 As shown, the steps for collecting page lifecycle features include: (1) During the execution of applications in the terminal device, anonymous pages, heap pages, stack pages, or other memory pages that can be swapped out are generated. When the system memory pressure increases, the memory reclamation mechanism determines the pages to be swapped out. (2)

[0031] (2) Before the page to be swapped out is written to compressed memory, the page state acquisition module collects the page lifecycle characteristics of the page to be swapped out. Page lifecycle characteristics include one or more of the following: the application to which the page belongs, the source of page recycling, the application's runtime stage, page access behavior, historical compression length, and system performance status. Without affecting the original page reference counting semantics, the application identifier to which the page belongs is encoded into the high-order bits of the page reference count field for carrying the page lifecycle characteristics, thereby avoiding the addition of a separate metadata structure and reducing storage and access overhead. (Refer to...) Figure 5 Transition process (3).

[0032] (3) The page state acquisition module combines the above page lifecycle features into state items, and discretizes or buckets them to form state items suitable for querying the Q-table strategy table. For example, the historical compression length can be divided into states such as high compression benefit, medium compression benefit and low compression benefit, and the page access behavior can be divided into states such as recent frequent access, recent few accesses and long-term no access, and the different states can be combined as the query input of Q-table.

[0033] S102, query the preset or dynamically updated Q-table strategy table based on the standardized status items to obtain the corresponding processing action, wherein the processing action includes the preset classification result, compression algorithm, compression granularity, compression execution path or write-back path.

[0034] It should be noted that by using Q-table to record and query the correspondence between page states and processing actions, the complexity of online decision-making can be reduced, and the classification and processing strategies can be dynamically adjusted based on runtime feedback.

[0035] S103, classify the page to be swapped out according to the processing action to obtain the corresponding lifecycle classification result, wherein the lifecycle classification result includes pages that may be read back, pages that are unlikely to be read back, and pages that are unlikely to be read back and are difficult to compress.

[0036] As one embodiment, the page to be swapped out is classified according to the processing action to obtain the corresponding lifecycle classification result, including: determining whether the probability of the page to be swapped out being accessed or swapped in later is higher than a preset readback threshold; if so, the page to be swapped out is marked as a page that may be read back; if not, determining whether the compression benefit of the page to be swapped out is lower than a preset compression benefit threshold; if so, the page to be swapped out is marked as a page that is unlikely to be read back and difficult to compress; if not, the page to be swapped out is marked as a page that is unlikely to be read back.

[0037] It should be noted that, as Figure 3 As shown, in the Q-table strategy table, each state item corresponds to multiple candidate actions, and each action has a Q-value. The probability of the page being subsequently accessed or swapped in is implicit in the Q-table strategy table. The optimal action selected by the Q-table strategy table for the current state item represents the system's comprehensive evaluation of the probability of reading back the page and the compression benefits. The threshold comparison essentially checks which type of action the optimal action belongs to (lightweight compression / high compression ratio / direct write-back), thereby mapping it to the corresponding page category tag.

[0038] S104. Based on the lifecycle classification results and processing actions, execute the corresponding memory management strategy for the page to be swapped out, and record the path identifier, algorithm identifier, and swapping out mapping information into the corresponding metadata.

[0039] As an example, based on the lifecycle classification result and processing action, the corresponding memory management strategy is executed for the page to be swapped out, including: if the lifecycle classification result is that the page may be read back, then the memory management strategy corresponding to the page to be swapped out is determined to be to perform low-latency lightweight compression using the CPU software compression path, and to preferentially retain the compressed page data in compressed memory; if the lifecycle classification result is that the page is unlikely to be read back and is difficult to compress, then the memory management strategy corresponding to the page to be swapped out is determined to bypass the normal compression path, so as to directly write the page to be swapped out back to the backend storage device or a low-cost write-back path; if the lifecycle classification result is that the page is unlikely to be read back, then the memory management strategy corresponding to the page to be swapped out is determined to be to use high compression ratio compression or cross-page granular compression, and to organize multiple pages to be compressed in batches and submit them asynchronously to the hardware compression engine, which reads the page data to be compressed through DMA and writes back the compression result.

[0040] Specifically, such as Figure 6 As shown, the page lifecycle classification includes the following steps: (1) The page lifecycle classification module receives the status items output by the page status acquisition module and queries the preset or dynamically updated Q-table strategy table based on the status items. The Q-table strategy table records the correspondence between status items and processing actions. The processing actions include one or more of the following: preset classification results, compression algorithm, compression granularity, compression execution path, or write-back path. (2)

[0041] (2) The page lifecycle classification module determines whether the probability of the page to be swapped out being accessed or swapped in later is higher than the preset readback threshold based on the query results of the Q-table strategy table. If the probability of the page to be swapped out being accessed or swapped in later is higher than the preset readback threshold, then proceed to process (3); if the probability of the page to be swapped out being accessed or swapped in later is not higher than the preset readback threshold, then proceed to process (4).

[0042] (3) The page lifecycle classification module marks the page to be swapped out as a page that may be read back, and determines its corresponding processing action as performing low-latency lightweight compression using the CPU software compression path and prioritizing its retention in compressed memory. (7)

[0043] (4) The page lifecycle classification module further determines whether the compression benefit of the page to be replaced is lower than the preset compression benefit threshold based on the query results of the Q-table strategy table, the historical compression length, or the current compression result. If the compression benefit of the page to be replaced is not lower than the preset compression benefit threshold, then proceed to process (5); if the compression benefit of the page to be replaced is lower than the preset compression benefit threshold, then proceed to process (6).

[0044] (5) The page lifecycle classification module marks the page to be swapped out as unlikely to be read back, and determines that its corresponding processing action is to adopt a high compression ratio compression strategy. It can also organize multiple pages to be compressed in batches and submit them asynchronously to the hardware compression engine. The hardware compression engine reads the data of the pages to be compressed through DMA and writes back the compression result. (7)

[0045] (6) The page lifecycle classification module marks the page to be swapped out as unlikely to be read back and difficult to compress, and determines its corresponding processing action as bypassing the normal compression path and directly writing back to the backend storage device or a low-cost write-back path. (7)

[0046] (7) The page lifecycle classification module passes the page identifier, page status item, lifecycle classification result and corresponding processing action to the compression and storage path selection module, so that the compression and storage path selection module can perform the corresponding compression or write-back path according to the page category.

[0047] Specifically, such as Figure 7 As shown, the differential compression and write-back path execution includes the following steps: (1) The compression and storage path selection module receives the page identifier, page status item, life cycle classification result and corresponding processing action output by the page life cycle classification module, and selects the corresponding compression or write-back path according to the life cycle classification result. If the life cycle classification result is that the page may be read back, then proceed to process (2); if the life cycle classification result is that the page is unlikely to be read back, then proceed to process (3); if the life cycle classification result is that the page is unlikely to be read back and difficult to compress, then proceed to process (9).

[0048] (2) For pages to be swapped out that are classified as potentially read back, the compression and storage path selection module selects the CPU software compression path to perform low-latency lightweight compression and determines the corresponding compression path information and compression algorithm information. (8)

[0049] (3) For pages to be swapped out that are classified as unlikely to be read back, the compression and storage path selection module selects a high compression ratio compression strategy. The system organizes multiple pages to be compressed into batches and uses a high compression ratio compression algorithm or cross-page granular compression method. (4)

[0050] (4) The system determines whether to submit the batch to be compressed to the hardware compression engine based on the current processor load, the number of pages to be compressed, the compression task overhead, and the hardware compression engine load status. If the hardware compression engine is available and the number of pages to be compressed meets the batch processing conditions, proceed to process (5); otherwise, proceed to process (7).

[0051] (5) The system constructs hardware compression task description information and asynchronously submits the hardware compression task to the hardware compression engine. The hardware compression task description information includes one or more of the following: the address of the page data to be compressed, the number of pages, the compression algorithm type, the output buffer address, and the result write-back location. (6)

[0052] (6) The hardware compression engine reads the page data to be compressed via DMA, performs high compression ratio compression or cross-page granular compression, and determines the corresponding compression path information and compression algorithm information. (8)

[0053] (7) When the hardware compression engine is unavailable, the hardware compression task queue is congested, or the number of pages to be compressed is insufficient to generate batch processing benefits, the system performs high compression ratio compression on pages that are unlikely to be read back through the CPU software compression path, and determines the corresponding compression path information and compression algorithm information. (8)

[0054] (8) After compression, the system allocates storage space for the compression result through the compressed memory allocator, writes the compressed page data into the storage space, records the compressed storage information, path identifier, and algorithm identifier of the page in the metadata of the slot corresponding to the compressed memory, and records the page being swapped out to the compressed memory in the swap-out entry of the page table. Among them, the path identifier is used to indicate whether the page is written by the CPU software compression path or the hardware compression engine path, and the algorithm identifier is used to indicate the compression algorithm used for the page. Transition process (10).

[0055] (9) For pages classified as unlikely to be read back and difficult to compress, the compression and storage path selection module bypasses the normal compression path and writes the page directly back to the back-end storage device or a low-cost write-back path. The system records the page being swapped out to the back-end storage device in the page table entry and records the corresponding write-back location, block address, or swap mapping information. (10)

[0056] (10) The system updates the corresponding swap-out mapping information according to the location of the page. For pages located in compressed memory, the system marks the corresponding compressed memory slot as readable; for pages located in back-end storage devices, the system saves the corresponding write-back location or block address. When a page is subsequently swapped in, if the page is located in compressed memory, the system selects the corresponding decompression path and decompression algorithm according to the path identifier and algorithm identifier recorded in the compressed memory slot metadata; if the page is located in back-end storage devices, the system reads the page data and restores it to memory according to the swap mapping relationship or back-end storage device mapping information. (11)

[0057] (11) In a preferred embodiment, to ensure the consistency of compressed memory slots, the slot is not marked as readable before the hardware compression result is written to the corresponding compressed memory slot; or when the slot is swapped in before the hardware compression task is completed, the system waits for the corresponding hardware compression task to be completed before returning the page data. It should be noted that direct write-back does not mean discarding page data, but rather saving the page data to the backend storage device or the corresponding write-back path on the premise of satisfying the correctness of page swapping out and subsequent swapping in.

[0058] It should be noted that for pages that may be read back, low-latency lightweight compression is performed using the CPU software compression path, and the compressed page data is preferentially retained in compressed memory. Since these pages are more likely to be re-accessed by the application and swapped in later, the low-latency compression strategy reduces subsequent decompression and swapping latency, improving response performance during application startup, restart, and foreground / background switching. For pages that are unlikely to be read back, high compression ratio algorithms or cross-page granular compression are used. Multiple pages to be compressed can be batched and asynchronously submitted to the hardware compression engine, which reads the page data via DMA and writes back the compression result. Since these pages have a low probability of being read back later, the focus can be on improving the compression ratio, reducing compression memory usage, and lowering processor software compression overhead. For pages that are unlikely to be read back and difficult to compress, their compressibility is determined based on historical compression length or current compression results. If the page compression benefit is below a preset threshold, the normal compression path is bypassed, and the page is directly written back to the backend storage device or a low-cost write-back path. It can reduce the invalid compression overhead caused by difficult-to-compress pages while ensuring the correctness of the swap, and reduce its occupation of limited compressed memory space.

[0059] S105: Obtain application performance feedback and system overhead feedback, and dynamically update the Q-table strategy table based on the application performance feedback and system overhead feedback.

[0060] As an example, application performance feedback includes one or more of the following collected by the application monitoring module: application startup time, application restart time, foreground / background switching time, response time, and lag status; system overhead feedback includes one or more of the following collected by the processor performance monitoring unit: processor cycle count, compression time, decompression time, cache miss count, processor load, and hardware compression engine load.

[0061] As one embodiment, the Q-table policy table is dynamically updated based on application performance feedback and system overhead feedback. This includes: determining whether the current page classification strategy and compression or write-back processing strategy affect application performance based on application performance feedback, and generating performance-driven rewards; generating system overhead status based on system overhead feedback to characterize the current processor overhead, compression overhead, and hardware compression engine usage status; and determining the effect of the current lifecycle classification result and corresponding processing action based on performance-driven rewards and system overhead status. Specifically, when page classification and processing strategies reduce processor overhead, reduce compression memory usage, and do not reduce application performance, positive rewards are given to the corresponding status items and processing actions in the Q-table policy. When page classification and processing strategies cause pages to be read back within a preset time after being swapped out, increase swap-in latency, or reduce application performance, negative rewards are given to the corresponding status items and processing actions in the Q-table policy, and the Q-table policy table is updated based on the positive or negative rewards.

[0062] Specifically, such as Figure 8 As shown, dynamic updates to Q-table include the following steps: (1) During the page swapping out, compression, write-back, and subsequent swap-in process, the system records the page status item, lifecycle classification result, compression or write-back path, compressed memory slot metadata, swapping out mapping information, and whether the page is subsequently swapped in. (2)

[0063] (2) The application monitoring module collects application performance feedback. Application performance feedback includes one or more of the following: application startup time, application restart time, foreground / background switching time, response time, and lag status. The system determines whether the current page categorization strategy and compression or write-back processing strategy affect application performance based on the application performance feedback, and generates performance-driven rewards. (3)

[0064] (3) The processor performance monitoring unit collects system overhead feedback. System overhead feedback includes one or more of the following: processor cycle count, compression time, decompression time, cache miss count, processor load, and hardware compression engine load. The system generates a system overhead status based on the system overhead feedback, which is used to characterize the current processor overhead, compression overhead, and hardware compression engine usage status. (4)

[0065] (4) The dynamic strategy update module determines the effect of the current lifecycle classification result and the corresponding processing action based on the performance-driven reward and system overhead status. If the current processing action reduces processor overhead, reduces compressed memory usage, and does not reduce application performance, then proceed to process (5); if the current processing action causes the page to be swapped in within a preset time after being swapped out, increases the swapping in delay, or reduces application performance, then proceed to process (6).

[0066] (5) The dynamic strategy update module provides positive rewards to the processing actions corresponding to the page state items in the Q-table, increasing the probability of selecting the processing action for the same or similar state items in the future. Transition process (7).

[0067] (6) The dynamic strategy update module provides a negative reward for the processing action corresponding to the state item of the page in the Q-table, reducing the probability of selecting the processing action for the same or similar state items in the future. (7)

[0068] (7) The dynamic strategy update module updates the Q-table strategy table based on positive or negative rewards. The update includes adjusting one or more of the following: lifecycle classification results, compression algorithm, compression granularity, compression execution path, or write-back path, so that subsequent pages with the same or similar lifecycle characteristics can choose a more suitable compression or write-back processing strategy. (8)

[0069] (8) In one embodiment, the Q-table strategy table can be initialized in advance based on offline statistical results and updated online during the operation of the terminal device according to application performance feedback and system overhead feedback; in another embodiment, the Q-table strategy table can also be gradually built and updated during the operation of the terminal device. The updated Q-table strategy table is used for the lifecycle classification and processing action selection of subsequent pages to be swapped out.

[0070] It's important to note that the Q-table is dynamically adjusted based on application performance feedback and system overhead feedback. When page classification and processing strategies reduce processor overhead and compressed memory usage without compromising application performance, positive rewards are given to the corresponding status items and processing actions. Conversely, when the strategy causes pages to be read back within a preset time after being swapped out, increases swapping-in latency, or degrades application performance, negative rewards are given. This allows the compressed memory management strategy to adaptively adjust according to different applications, different operational stages, and different system loads.

[0071] In summary, the compressed memory management method for terminal devices according to embodiments of the present invention, by collecting page lifecycle characteristics and classifying pages based on a Q-table strategy table, and adopting differentiated compression or write-back strategies for different categories of pages, can reduce ineffective compression overhead, reduce wasted compressed memory space, improve memory reclamation efficiency, and achieve a better balance between application response performance and system power consumption.

[0072] In addition, the present invention also proposes a computer-readable storage medium storing a compressed memory management program for a terminal device, which, when executed by a processor, implements the compressed memory management method for a terminal device as described above.

[0073] In addition, this invention also proposes a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the compressed memory management method for terminal devices as described above.

[0074] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0075] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0076] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1The function specified in one or more boxes.

[0077] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0078] It should be noted that any reference signs placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.

[0079] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.

[0080] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

[0081] In the description of this invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0082] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0083] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.

[0084] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms should not be construed as necessarily referring to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0085] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A compression memory management method for a terminal device, characterized by, Includes the following steps: Obtain the page lifecycle characteristics corresponding to the page to be swapped out, and generate standardized status items based on the page lifecycle characteristics; The corresponding processing action is obtained by querying the preset or dynamically updated Q-table strategy table based on the standardized state item. The processing action includes the preset classification result, compression algorithm, compression granularity, compression execution path or write-back path. The page to be swapped out is classified according to the processing action to obtain the corresponding lifecycle classification result, wherein the lifecycle classification result includes pages that may be read back, pages that are unlikely to be read back, and pages that are unlikely to be read back and are difficult to compress. Based on the lifecycle classification results and processing actions, the corresponding memory management strategy is executed on the page to be swapped out, and the path identifier, algorithm identifier, and swapping out mapping information are recorded in the corresponding metadata; Obtain application performance feedback and system overhead feedback, and dynamically update the Q-table strategy table based on the application performance feedback and system overhead feedback.

2. The terminal device-oriented compressed memory management method of claim 1, wherein, The page lifecycle characteristics include one or more of the following: the application to which the page belongs, the source of page recycling, the application's running stage, page access behavior, historical compression length, and system performance status.

3. The compressed memory management method for terminal devices as described in claim 2, characterized in that, The page recycling sources include one or more of the following: background kernel recycling, direct memory recycling, memory control group recycling, and cache application optimization recycling; the system performance status includes one or more of the following: memory pressure status, processor load status, compression time status, and hardware compression engine load status.

4. The compressed memory management method for terminal devices as described in claim 3, characterized in that, Standardized state items are generated based on the page lifecycle characteristics, including: The application identifier of the page in the page lifecycle characteristics is encoded into the high bits of the page reference count field; after discretization or bucketing of the status items, standardized status items suitable for querying the Q-table strategy table are generated.

5. The compressed memory management method for terminal devices as described in claim 1, characterized in that, The page to be swapped out is categorized according to the processing action to obtain the corresponding lifecycle classification result, including: Based on the processing action, determine whether the probability of the page to be swapped out being accessed or swapped in later is higher than a preset readback threshold; If yes, mark the page to be swapped out as a page that may be read back; if no, determine whether the compression benefit of the page to be swapped out is lower than a preset compression benefit threshold. If yes, mark the page to be swapped out as unlikely to be read back and difficult to compress; if no, mark the page to be swapped out as unlikely to be read back.

6. The compressed memory management method for terminal devices as described in claim 5, characterized in that, Based on the lifecycle classification results and processing actions, the corresponding memory management strategy is executed on the page to be swapped out, including: If the lifecycle classification result is that the page may be read back, then the memory management strategy corresponding to the page to be swapped out is determined to be to perform low-latency lightweight compression using the CPU software compression path, and to retain the compressed page data in the compressed memory first. If the lifecycle classification result is that the page is unlikely to be read back and is difficult to compress, then the memory management strategy corresponding to the page to be swapped out is determined to be to bypass the normal compression path, so as to write the page to be swapped out directly back to the backend storage device or a low-cost write-back path. If the lifecycle classification result indicates that the page is unlikely to be read back, then the memory management strategy corresponding to the page to be swapped out is determined to be high compression ratio compression or cross-page granular compression. Multiple pages to be compressed are then organized in batches and asynchronously submitted to the hardware compression engine. The hardware compression engine reads the page data to be compressed via DMA and writes back the compression result.

7. The compressed memory management method for terminal devices as described in claim 1, characterized in that, The application performance feedback includes one or more of the following collected by the application monitoring module: application startup time, application restart time, foreground / background switching time, response time, and lag status; the system overhead feedback includes one or more of the following collected by the processor performance monitoring unit: processor cycle count, compression time, decompression time, cache miss count, processor load, and hardware compression engine load.

8. The compressed memory management method for terminal devices as described in claim 7, characterized in that, The Q-table strategy table is dynamically updated based on the application performance feedback and system overhead feedback, including: Based on the application's runtime performance feedback, determine whether the current page categorization strategy and compression or write-back processing strategy affect the application's runtime performance, and generate performance-driven rewards. The system overhead status is generated based on the system overhead feedback to characterize the current processor overhead, compression overhead, and hardware compression engine usage status; Based on the performance-driven rewards and system overhead status, the effects of the current lifecycle classification results and corresponding processing actions are determined. Specifically, when the page classification and processing strategy reduces processor overhead, reduces compressed memory usage, and does not reduce application performance, a positive reward is given to the corresponding status item and processing action in the Q-table strategy. When the page classification and processing strategy causes the page to be read back within a preset time after being swapped out, increases swapping in latency, or reduces application performance, a negative reward is given to the corresponding status item and processing action in the Q-table strategy, and the Q-table strategy table is updated according to the positive or negative reward.

9. A computer-readable storage medium, characterized in that, It stores a compressed memory management program for terminal devices, which, when executed by the processor, implements the compressed memory management method for terminal devices as described in any one of claims 1-8.

10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the compressed memory management method for terminal devices as described in any one of claims 1-8.