Compression method and device of memory resources, electronic equipment and medium

By collecting the temporal characteristics of memory resources and dynamically adjusting the compression strategy using a resource compression prediction model, the problem of poor memory resource compression effect caused by a fixed single compression strategy is solved, thereby improving the operating system's response speed and memory utilization efficiency.

CN121233331APending Publication Date: 2025-12-30NEW H3C BIG DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511429983.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-30
Publication Date
2025-12-30

AI Technical Summary

Technical Problem

In existing technologies, memory resource compression strategies are fixed and singular, resulting in poor compression performance and consequently affecting the operating system's response speed.

Method used

By collecting the temporal characteristics of multiple compression metrics, and using a pre-trained resource compression prediction model, the compression strategy is dynamically determined to adapt to multiple compression metrics of the target memory resources, and flexible compression processing is performed based on the compression prediction results.

Benefits of technology

It improves the compression effect of memory resources, enhances the overall response speed of the operating system, and prevents abnormal process termination due to insufficient physical memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121233331A_ABST
    Figure CN121233331A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of memory compression, and discloses a memory resource compression method and device, electronic equipment and a medium. The method comprises the following steps: collecting a plurality of compression indexes corresponding to a target memory resource to be compressed; extracting time domain features of the plurality of compression indexes, and inputting the time domain features into a pre-trained resource compression prediction model to obtain a compression prediction result corresponding to the target memory resource; and if the compression prediction result represents that the target memory resource needs to be compressed, performing compression processing on the target memory resource based on a compression strategy corresponding to the compression prediction result to obtain a compressed resource. By implementing the compression method provided by the invention, the compression strategy is flexibly and dynamically determined instead of compressing the target memory resource by adopting a single and fixed compression strategy, so that the performance and efficiency of compressing the target memory resource are improved, and the memory exchange rate is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of memory compression technology, specifically to a method, apparatus, electronic device, and medium for compressing memory resources. Background Technology

[0002] Zswap is a memory compression caching technology that acts as a front-end caching layer for the swap space mechanism. It prioritizes compressing target memory resources in physical memory, such as inactive memory pages, and stores the compressed target memory resources in a compressed memory pool (a portion of physical memory). Inactive data is only written to disk when compression fails or the compressed memory pool is full, thus preventing the current process from exiting abnormally due to insufficient physical memory.

[0003] The current management strategy for compressing target memory resources and storing them in a compressed memory pool is a fixed, single compression strategy that cannot be dynamically adjusted. This results in poor compression of target memory resources, leading to a slower overall operating system response speed. Summary of the Invention

[0004] In view of this, this application provides a method, apparatus, electronic device and medium for compressing memory resources to solve the problem of poor compression effect caused by fixed and single compression strategies.

[0005] In a first aspect, this application provides a method for compressing memory resources. The method includes: collecting multiple compression indicators corresponding to the target memory resource to be compressed; extracting the temporal features of the multiple compression indicators and inputting the temporal features into a pre-trained resource compression prediction model to obtain a compression prediction result corresponding to the target memory resource; if the compression prediction result indicates that the target memory resource needs to be compressed, then compressing the target memory resource based on the compression strategy corresponding to the compression prediction result to obtain compressed resources.

[0006] The memory resource compression method provided in this embodiment inputs the temporal features corresponding to multiple compression indicators into a pre-trained resource compression prediction model. The model's predictive capabilities are then used to obtain compression prediction results for the target memory resource, ensuring that these predictions are well-suited to the various compression indicators. If the compression prediction results indicate that the target memory resource needs compression, then compression is performed based on the corresponding compression strategy. This approach allows for flexible and dynamic determination of the compression strategy, ensuring that the chosen strategy effectively adapts to the current compression indicators, rather than using a single, fixed strategy. Therefore, it improves the compression effect on the target memory resource and further enhances the overall operating system response speed.

[0007] In one alternative implementation, if the compression prediction result indicates that the target memory resource does not need to be compressed, the target memory resource is swapped from physical memory to disk.

[0008] When the compression prediction results indicate that the target memory resource does not need to be compressed, the uncompressed target memory resource can be swapped from physical memory to disk, thereby preventing the current process from exiting abnormally due to insufficient physical memory. Furthermore, compared to related technologies that only swap the uncompressed target memory resource from physical memory to disk when compression fails or the compression memory pool is full, this solution allows for more flexible determination of the processing method for the target memory resource and better adapts to the compression metrics corresponding to the target memory resource.

[0009] In one optional implementation, extracting the temporal features of multiple compression metrics includes: normalizing the metric feature values ​​corresponding to each compression metric to obtain normalized feature values ​​corresponding to each compression metric; and standardizing the normalized feature values ​​corresponding to multiple compression metrics to obtain the temporal features of multiple compression metrics.

[0010] By normalizing the characteristic values ​​corresponding to each compression index, the model prediction error caused by the different dimensions of the characteristic values ​​can be eliminated. Moreover, feature extraction of the normalized characteristic values ​​corresponding to multiple compression indices can better capture the changing trend of the normalized characteristic values ​​of multiple compression indices over a period of time. The subsequent resource compression prediction model can make predictions more accurately based on time-domain features, reducing the impact of the normalized characteristic value of the compression index at a single time point on the model prediction accuracy.

[0011] In an optional implementation, the method further includes: obtaining a compressed memory pool corresponding to the target memory resource, wherein the compressed memory pool is a portion of the physical memory space; determining a capacity adjustment strategy for the compressed memory pool based on the compression index each time a compression index is collected; and adjusting the capacity of the compressed memory pool based on the capacity adjustment strategy to obtain an adjusted compressed memory pool.

[0012] Based on the compression metrics corresponding to the target memory resources to be compressed, the capacity adjustment strategy for the compressed memory pool can be dynamically determined. This allows for more reasonable adjustment of the compressed memory pool capacity, preventing resource waste caused by setting the compressed memory pool too large and the inability to properly store compressed resources due to setting it too small.

[0013] In one optional implementation, determining the capacity adjustment strategy for the compressed memory pool based on compression metrics includes: weighting and fusing CPU utilization and memory utilization in the compression metrics to obtain a decision factor; weighting and fusing the decision factor and a historical threshold to obtain a dynamic threshold, wherein the historical threshold is obtained based on the dynamic threshold within a first time sliding window; if the decision factor is greater than the sum of the dynamic threshold and the buffer factor, then the capacity adjustment strategy is determined to be to expand the compressed memory pool; if the decision factor is less than the difference between the dynamic threshold and the buffer factor, then the capacity adjustment strategy is determined to be to shrink the compressed memory pool.

[0014] The capacity adjustment strategy is determined by comparing the sum of the decision factor, dynamic threshold, and buffer factor. This makes the determined capacity adjustment strategy more accurate. In addition, the introduction of a buffer factor in the process of determining the capacity adjustment strategy can prevent frequent oscillations in adjusting the capacity of the compressed memory pool.

[0015] In one optional implementation, the capacity of the compressed memory pool is adjusted based on a capacity adjustment strategy to obtain an adjusted compressed memory pool, including: determining a target capacity adjustment strategy based on the fusion result of the capacity adjustment strategy and historical capacity adjustment strategies within a second time sliding window; and adjusting the capacity of the compressed memory pool based on the target capacity adjustment strategy to obtain the adjusted compressed memory pool.

[0016] By combining the capacity adjustment strategy with the historical capacity adjustment strategy within the second time sliding window, the target capacity adjustment strategy can be determined more accurately. Furthermore, it can avoid the situation where the capacity of the compressed memory pool is constantly adjusted due to the high sampling frequency when sampling the compression index corresponding to the target memory resource to be compressed, which would lead to a jump in the capacity of the compressed memory pool.

[0017] In one optional implementation, multiple compression metrics corresponding to the target memory resource to be compressed are collected, including: collecting multiple raw compression metrics from kernel mode; mapping the multiple raw compression metrics to user mode to obtain multiple compression metrics in user mode; and reading the multiple compression metrics from user mode.

[0018] Collecting multiple raw compression metrics directly from kernel space avoids metric distortion caused by user-space programs' permission restrictions or insufficient hardware access capabilities. Mapping these raw compression metrics to user space via memory mapping, and then reading them from user space, further improves the efficiency of compression metric collection.

[0019] In one optional implementation, multiple raw compression metrics are mapped to user space to obtain multiple compression metrics in user space, including: writing multiple raw compression metrics to a first circular queue in kernel space; mapping the first circular queue based on a memory mapping strategy to obtain a second circular queue in user space; and reading cached data from the second circular queue to obtain multiple compression metrics in user space.

[0020] By mapping the first circular queue in kernel mode directly to the second circular queue in user mode through memory mapping, the overhead of cross-mode data copying is eliminated, thus enabling the raw compression metrics of kernel mode to be obtained in user mode with extremely low latency.

[0021] In an optional implementation, the method further includes: writing the compression prediction result into an initial configuration file to generate a target configuration file; and storing the target configuration file in kernel mode.

[0022] After the target configuration file is stored in kernel mode, the kernel can hot-load the target configuration file and execute the compression prediction results in the target configuration file.

[0023] Secondly, this application provides a memory resource compression device, which includes: an acquisition module for acquiring multiple compression indicators corresponding to the target memory resource to be compressed; an extraction module for extracting the temporal features of the multiple compression indicators and inputting the temporal features into a pre-trained resource compression prediction model to obtain a compression prediction result corresponding to the target memory resource; and a compression module for compressing the target memory resource based on the compression strategy corresponding to the compression prediction result if the compression prediction result indicates that the target memory resource needs to be compressed to obtain compressed resources.

[0024] Thirdly, this application provides an electronic device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the memory resource compression method of the first aspect or any corresponding embodiment described above.

[0025] Fourthly, this application provides a computer-readable storage medium storing computer instructions for causing a computer to execute the memory resource compression method of the first aspect or any corresponding embodiment described above.

[0026] Fifthly, this application provides a computer program product, including computer instructions for causing a computer to execute the memory resource compression method of the first aspect or any corresponding embodiment described above. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0028] Figure 1 This is a flowchart illustrating a method for compressing memory resources according to an embodiment of this application; Figure 2 This is a flowchart illustrating another method for compressing memory resources according to an embodiment of this application; Figure 3 This is a flowchart illustrating another method for compressing memory resources according to an embodiment of this application; Figure 4 This is a flowchart illustrating a specific memory resource compression method according to an embodiment of this application; Figure 5 This is a schematic diagram of a memory resource compression device according to an embodiment of this application; Figure 6 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0030] Zswap is a memory compression caching technology that acts as a front-end caching layer for the swap space mechanism. It prioritizes compressing target memory resources in physical memory, such as inactive memory pages, and stores the compressed target memory resources in a compressed memory pool (a portion of physical memory). Inactive data is only written to disk when compression fails or the compressed memory pool is full, thus preventing the current process from exiting abnormally due to insufficient physical memory.

[0031] The current management strategy for compressing target memory resources and storing them in a compressed memory pool is a fixed, single compression strategy that cannot be dynamically adjusted. This results in poor compression of target memory resources, leading to a slower overall operating system response speed.

[0032] This application provides a method for compressing memory resources. Relying on a pre-trained resource compression prediction model, it uses the temporal features corresponding to multiple compression metrics to predict the compression result for the target memory resource. This allows the compression prediction result to better adapt to the multiple compression metrics corresponding to the target memory resource. Based on the compression strategy corresponding to the compression prediction result, the target memory resource is compressed. This achieves flexible and dynamic determination of the compression strategy, and the determined compression strategy can better adapt to the current compression metrics, rather than using a single and fixed compression strategy to compress the target memory resource. Therefore, it can improve the compression effect of the target memory resource and further improve the overall response speed of the operating system.

[0033] According to an embodiment of this application, a method for compressing memory resources is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0034] This embodiment provides a method for compressing memory resources, which can be used in electronic devices. Figure 1 This is a flowchart of a memory resource compression method according to an embodiment of this application, such as... Figure 1 As shown, the process includes the following steps: Step S101: Collect multiple compression metrics corresponding to the target memory resources to be compressed.

[0035] The target memory resource can be memory data in physical memory whose physical memory usage can be reduced through compression. For example, the target memory resource can be a memory page in physical memory with an access frequency below a first predetermined value. This memory page can be an online webpage or a page corresponding to an application.

[0036] Compression metrics can be used to determine the compression strategy corresponding to a target memory resource. For example, compression metrics can be the content entropy, central processing unit (CPU) utilization, memory utilization, and input / output (I / O) utilization of the target memory resource. Of course, compression metrics are not limited to the content entropy, CPU utilization, memory utilization, and I / O utilization mentioned above; other compression metrics corresponding to target memory resources can also be used, which are not limited here. Among these, content entropy is used to determine the "degree of disorder" or "information density" of the target memory resource.

[0037] Here, multiple compression metrics corresponding to the target memory resource to be compressed are collected by calling the operating system interface, such as the Linux system interface. Alternatively, multiple compression metrics corresponding to the target memory resource to be compressed can be collected by a memory monitoring tool.

[0038] Step S102: Extract the temporal features of multiple compression indicators and input the temporal features into the pre-trained resource compression prediction model to obtain the compression prediction result corresponding to the target memory resource.

[0039] The sampling time points corresponding to multiple compression metrics can be different. Therefore, by extracting features from multiple compression metrics, we can obtain the time-domain features corresponding to multiple compression metrics over a certain period of time. For example, by setting the sampling time of multiple compression metrics to 1ms, 2ms, 3ms, 4ms, and 5ms, and extracting features from multiple compression metrics, we can obtain the time-domain features corresponding to multiple compression metrics within 1 to 5ms.

[0040] The resource compression prediction model is used to predict the compression strategy corresponding to the target memory resource based on the received temporal features. This data generation model can be trained based on a large language model architecture, a machine learning model architecture, or a combination of multiple model architectures. No specific limitations are imposed here, as long as it can achieve the function of predicting the compression strategy corresponding to the target memory resource based on the received temporal features.

[0041] Step S103: If the compression prediction result indicates that the target memory resource needs to be compressed, then the target memory resource is compressed based on the compression strategy corresponding to the compression prediction result to obtain compressed resources.

[0042] The compression prediction result is used to characterize whether the target memory resource needs to be compressed. If compression is required, the target memory resource is compressed based on the compression strategy corresponding to the compression prediction result to obtain compressed resources, which are then written to a compressed memory pool. The compressed memory pool can be a portion of physical memory.

[0043] Compression strategies can be strategies for compressing target memory resources. For example, a specific compression strategy can be a compression algorithm. Therefore, when the compression prediction result indicates that the target memory resource needs to be compressed, the target memory resource can be compressed based on the compression algorithm corresponding to the compression prediction result to obtain compressed resources. This achieves flexible determination of the appropriate compression algorithm to compress the target memory resource, instead of using a single compression algorithm to compress the target memory resource.

[0044] As a specific example, compression algorithms can be LZO (Lempel-Ziv-Oberhumer), LZ4 (Lempel-Ziv4), and ZSTD (Zstandard). Regarding compression ratio, LZ4 has a lower compression ratio than LZO, and LZO has a lower compression ratio than ZSTD. Regarding compression speed, LZO's compression speed is lower than LZ4's, while ZSTD's compression speed can be flexibly set. Regarding decompression speed, LZO's decompression speed is higher than LZ4's, and LZ4's decompression speed is higher than ZSTD's. Regarding memory usage, LZO's memory usage is lower than LZ4's, and LZ4's memory usage is lower than ZSTD's. Regarding CPU usage, during decompression, LZO's CPU usage is lower than LZ4's, while during compression, LZ4's CPU usage is lower than LZO's.

[0045] The memory resource compression method provided in this embodiment inputs the temporal features corresponding to multiple compression indicators into a pre-trained resource compression prediction model. The model's predictive capabilities are then used to obtain compression prediction results for the target memory resource, ensuring that these predictions are well-suited to the various compression indicators. If the compression prediction results indicate that the target memory resource needs compression, then compression is performed based on the corresponding compression strategy. This approach allows for flexible and dynamic determination of the compression strategy, ensuring that the chosen strategy effectively adapts to the current compression indicators, rather than using a single, fixed strategy. Therefore, it improves the compression effect on the target memory resource and further enhances the overall operating system response speed.

[0046] This embodiment provides a method for compressing memory resources, which can be used in electronic devices. Figure 2 This is a flowchart of a memory resource compression method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps: Step S201: Collect multiple compression metrics corresponding to the target memory resource to be compressed. For details, please refer to [link to relevant documentation]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.

[0047] Step S202: Extract the temporal features of multiple compression indices and input the temporal features into the pre-trained resource compression prediction model to obtain the compression prediction results corresponding to the target memory resources.

[0048] Specifically, step S202 includes: Step S2021: Normalize the characteristic value of each compression index to obtain the normalized characteristic value of each compression index.

[0049] For any given compression index, the dimensions of its corresponding feature values ​​may differ, potentially leading to significant variations in the original numerical ranges of these feature values. This, in turn, can affect the prediction accuracy of the resource compression prediction model. Normalizing the feature values ​​of each compression index can map their ranges to the [0, 1] interval, eliminating the prediction accuracy issues caused by dimensional differences and balancing the contribution of different feature values ​​to the temporal features.

[0050] Following the previous example, a compression metric is defined, corresponding to content entropy, CPU utilization, memory utilization, and I / O utilization. The content entropy can range from 0 to 8 bits per byte, while the CPU utilization, memory utilization, and I / O utilization can range from 0 to 100 (percentage). Normalizing the content entropy, CPU utilization, memory utilization, and I / O utilization of the target memory resource corresponding to the compression metric yields metric characteristic values ​​within the range [0, 1].

[0051] Step S2022: Standardize the normalized feature values ​​corresponding to multiple compression indices to obtain the time-domain features of multiple compression indices.

[0052] The standard processing here can be the process of performing statistical calculations, feature transformations, or frequency domain transformations on the normalized eigenvalues ​​corresponding to multiple compression indices.

[0053] As a concrete example, let's define multiple compression metrics corresponding to four time points. Each compression metric corresponds to content entropy, CPU utilization, memory utilization, and I / O utilization, and is represented as a one-dimensional array. The four compression metrics can then be represented as shown below. 4 two-dimensional array

[0054] As shown in the previous text, 4 The four-dimensional array contains four time points: the first column represents the content entropy, the second column represents the CPU utilization, the third column represents the memory utilization, and the fourth column represents the I / O utilization. By standardizing the normalized eigenvalues ​​corresponding to these four compression metrics, we can obtain the content entropy volatility by taking the standard deviation of the content entropy in the first column, the average CPU utilization by taking the average of the CPU utilization in the second column, the average memory utilization by taking the average of the memory utilization in the third column, and the average I / O utilization by taking the average of the I / O utilization in the fourth column.

[0055] Furthermore, standardization processing can be performed on the normalized eigenvalues ​​corresponding to multiple compression indices. When a certain number of compression indices, such as 4 or 5, are obtained in a single sampling, standardization processing can be performed on a certain number of compression indices. Of course, a time sliding window approach can also be used to continuously standardize the normalized eigenvalues ​​corresponding to multiple compression indices within the time sliding window. This application does not impose specific limitations on this approach, and adjustments can be made flexibly according to the actual situation.

[0056] Step S2023: Input the temporal features into the pre-trained resource compression prediction model to obtain the compression prediction result corresponding to the target memory resource. Please refer to the previous text.

[0057] By normalizing the characteristic values ​​corresponding to each compression index, the model prediction error caused by the different dimensions of the characteristic values ​​can be eliminated. Moreover, feature extraction of the normalized characteristic values ​​corresponding to multiple compression indices can better capture the changing trend of the normalized characteristic values ​​of multiple compression indices over a period of time. The subsequent resource compression prediction model can make predictions more accurately based on time-domain features, reducing the impact of the normalized characteristic value of the compression index at a single time point on the model prediction accuracy.

[0058] Step S203: If the compression prediction result indicates that the target memory resource needs to be compressed, then based on the compression strategy corresponding to the compression prediction result, the target memory resource is compressed to obtain the compressed resource. For details, please refer to [link to details]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.

[0059] Step S204: If the compression prediction result indicates that the target memory resource does not need to be compressed, then the target memory resource is swapped from physical memory to disk.

[0060] Physical memory, also known as RAM or memory modules, is a computer's temporary high-speed storage device. It's a high-speed storage area that can directly interact with the CPU. A hard disk, on the other hand, is a device for long-term data storage, used to store files and programs that need to be retained for an extended period; data is not lost even when power is off.

[0061] When the compression prediction results indicate that the target memory resource does not need to be compressed, the uncompressed target memory resource can be swapped from physical memory to disk, thereby preventing the current process from exiting abnormally due to insufficient physical memory. Furthermore, compared to related technologies that only swap the uncompressed target memory resource from physical memory to disk when compression fails or the compression memory pool is full, this solution allows for more flexible determination of the processing method for the target memory resource and better adapts to the compression metrics corresponding to the target memory resource.

[0062] As mentioned earlier, after compressing the target memory resources using the compression strategy corresponding to the compression prediction results, the compressed resources can be written to the compressed memory pool. However, if the compressed memory pool capacity is set too large, it will occupy excessive physical memory for an extended period, resulting in insufficient space in physical memory outside the pool to store memory resources with access frequency exceeding a predetermined value, thus impacting memory utilization and operating system performance. Conversely, if the compressed memory pool capacity is set too small, it cannot accommodate a large number of compressed resources, requiring CPU resources to swap the uncompressed memory resources corresponding to uncached compressed resources to disk. Therefore, flexible and dynamic management of the compressed memory pool capacity is necessary.

[0063] Step S205: Obtain the compressed memory pool corresponding to the target memory resource. The compressed memory pool is a portion of the physical memory space.

[0064] A compressed memory pool can be used to store compressed resources corresponding to a target memory resource. As a concrete example, a memory pool can be first searched in physical memory, and the found memory pool can then be used as the compressed memory pool corresponding to the target memory resource. Alternatively, when the operating system detects the existence of a target memory resource to be compressed, a portion of storage space in physical memory can be selected as the compressed memory pool corresponding to the target memory resource. It should be understood that the above are merely examples and are not intended to impose specific limitations.

[0065] Step S206: When a compression index is collected, determine the capacity adjustment strategy of the compression memory pool based on the compression index.

[0066] Here, the capacity adjustment strategy for the compressed memory pool can be determined based on one or more of the following: CPU utilization, memory utilization, content entropy, and I / O utilization.

[0067] If the CPU is under high load, such as above 80%, expanding the compression memory pool and adding compression tasks will lead to CPU resource contention, thus slowing down the operating system's response speed, resulting in application lag. Conversely, when the CPU is idle, even if the memory pool is expanded, the additional compression overhead will not affect the user experience. Furthermore, if memory utilization is high, such as above 90%, the operating system is prone to triggering the space swap mechanism. In this case, expanding the compression memory pool and compressing more target resources can reduce the number of space swaps. Conversely, if memory utilization is low, such as below 50%, the operating system itself has sufficient free memory, and expanding the compression memory pool will waste physical memory. Therefore, CPU utilization and memory utilization can be used to determine the appropriate capacity adjustment strategy for the compression memory pool.

[0068] Specifically, step S206 includes: Step S2061: Weighted fusion of CPU utilization and memory utilization in the compression index to obtain the decision factor.

[0069] As a concrete example, one could use To determine the decision factors. Used to represent decision factors, Weights used to represent CPU utilization and Weights used to represent memory utilization, and and The sum is 1, for example, The value can be 0.6 and... The value can be 0.4; this is just an example and is not a specific limitation.

[0070] It should be understood that, in the process of determining decision factors, CPU utilization and memory utilization can be normalized eigenvalues ​​after normalization.

[0071] Step S2062: The decision factor and historical threshold are weighted and fused to obtain the dynamic threshold. The historical threshold is obtained based on the dynamic threshold within the first time sliding window.

[0072] As a concrete example, one could use ,in, Used to represent dynamic thresholds Used to represent historical thresholds Used to represent a smoothing factor. For example, C can take the value 0.8; this is just an example and not a specific limitation.

[0073] The historical threshold can be obtained by taking the average of the dynamic thresholds corresponding to the first time sliding window. For example, if the current time point is the 6th millisecond, when calculating the dynamic threshold corresponding to the 6th millisecond, the decision factor corresponding to the 6th millisecond and the historical thresholds within the time sliding window from the 1st to the 5th millisecond can be used to determine it. Another example, if the current time point is the 7th millisecond, when calculating the dynamic threshold corresponding to the 7th millisecond, the decision factor corresponding to the 7th millisecond and the historical thresholds within the time sliding window from the 2nd to the 6th millisecond can be used to determine it.

[0074] Step S2063, if the decision factor is greater than the sum of the dynamic threshold and the buffer factor, determine that the capacity adjustment strategy is to expand the compressed memory pool.

[0075] For example, when Swap_Score > Threshold + D, it indicates that the space in the compressed memory pool is tense at this time, so the compressed memory pool needs to be expanded. Here, D is used to represent the buffer interval to prevent frequent oscillation adjustments. As a specific example, D can take 0.1.

[0076] The specific value for expanding the compressed memory pool here can be an empirical value, or it can be flexibly determined based on the decision factor and / or the sum of the dynamic threshold and the buffer factor. For example, when the decision factor is less than the first expansion factor, it can be determined to expand the compressed memory pool by a second predetermined value; when the decision factor is greater than or equal to the first expansion factor and less than or equal to the second expansion factor, it can be determined to expand the compressed memory pool by a third predetermined value; when the decision factor is greater than the second expansion factor, it can be determined to expand the compressed memory pool by a fourth predetermined value, where the fourth predetermined value is greater than the third predetermined value, and the third predetermined value is greater than the second predetermined value.

[0077] It should be understood that the first expansion factor, the second expansion factor, the second predetermined value, the third predetermined value, and the fourth predetermined value can be flexibly adjusted, and the present application does not make specific limitations on this.

[0078] Step S2064, if the decision factor is less than the difference between the dynamic threshold and the buffer factor, determine that the capacity adjustment strategy is to shrink the compressed memory pool.

[0079] For example, when Swap_Score < Threshold - D, it indicates that the space other than the compressed memory pool in the physical memory is tense, and the compressed memory pool needs to be shrunk to reserve a certain storage space for the target memory resources whose access heat is greater than the first predetermined value.

[0080] The specific value for shrinking the compressed memory pool here can be an empirical value, or it can be flexibly determined based on the sum of the decision factor and / or the dynamic threshold and the buffer factor. For example, when the decision factor is less than the first shrinkage factor, a fifth predetermined value for shrinking the compressed memory pool can be determined; when the decision factor is greater than or equal to the first shrinkage factor and less than or equal to the second shrinkage factor, a sixth predetermined value for shrinking the compressed memory pool can be determined; when the decision factor is greater than the second shrinkage factor, a seventh predetermined value for shrinking the compressed memory pool can be determined, wherein the seventh predetermined value is less than the sixth predetermined value, and the sixth predetermined value is less than the fifth predetermined value.

[0081] It should be understood that the first shrinkage factor, the second shrinkage factor, the fifth predetermined value, the sixth predetermined value, and the seventh predetermined value can be flexibly adjusted, and this application does not impose specific limitations on them.

[0082] The capacity adjustment strategy is determined by comparing the sum of the decision factor, dynamic threshold, and buffer factor. This makes the determined capacity adjustment strategy more accurate. In addition, the introduction of a buffer factor in the process of determining the capacity adjustment strategy can prevent frequent oscillations in adjusting the capacity of the compressed memory pool.

[0083] Step S207: Based on the capacity adjustment strategy, adjust the capacity of the compressed memory pool to obtain the adjusted compressed memory pool.

[0084] For example, if the capacity adjustment strategy is to expand the compressed memory pool, then the compressed memory pool is expanded based on the capacity adjustment strategy; if the capacity adjustment strategy is to shrink the compressed memory pool, then the compressed memory pool is shrunk based on the capacity adjustment strategy.

[0085] Specifically, step S207 includes: Step S2071: Determine the target capacity adjustment strategy based on the fusion result of the capacity adjustment strategy and the historical capacity adjustment strategy within the second time sliding window.

[0086] Here, we can analyze the adjustment trends of historical capacity adjustment strategies in the second time sliding window and integrate these strategies to determine the target capacity adjustment strategy. For example, if the adjustment trend corresponding to the second time sliding window is an expansion trend, and the current capacity adjustment strategy represents expanding the memory compaction pool, then the target capacity adjustment strategy can be to expand the memory compaction pool, and the specific value of the expansion can be greater than the maximum value of the specific expansion value within the second time sliding window.

[0087] If the adjustment trend corresponding to the second time sliding window is an expansion trend, and the current capacity adjustment strategy represents shrinking the memory compression pool, then the target capacity adjustment strategy can be to expand the memory compression pool, and the specific value of expanding the memory compression pool this time can be less than the minimum value of the specific expansion value within the second time sliding window.

[0088] Of course, if the current capacity adjustment strategy represents shrinking the memory compression pool, then the target capacity adjustment strategy can be to shrink the memory compression pool, and the specific value of shrinking the memory compression pool this time can be less than the minimum value of the specific value of expansion within the second time sliding window.

[0089] It should be understood that the above are merely specific examples and are subject to specific limitations. Moreover, when the adjustment trend corresponding to the second time sliding window is a shrinking trend, the content of the target capacity adjustment strategy for determining the expansion trend shown above is the opposite, and will not be elaborated here.

[0090] Step S2072: Based on the target capacity adjustment strategy, adjust the capacity of the compressed memory pool to obtain the adjusted compressed memory pool.

[0091] In this application, the compression prediction result is obtained by using a resource compression prediction model based on time-domain features, and the compression strategy corresponding to the compression prediction result is executed. The capacity of the compression memory pool is adjusted by the target capacity adjustment strategy. These actions can be performed in parallel or asynchronously.

[0092] By combining the capacity adjustment strategy with the historical capacity adjustment strategy within the second time sliding window, the target capacity adjustment strategy can be determined more accurately. Furthermore, it can avoid the situation where the capacity of the compressed memory pool is constantly adjusted due to the high sampling frequency when sampling the compression index corresponding to the target memory resource to be compressed, which would lead to a jump in the capacity of the compressed memory pool.

[0093] The memory resource compression method provided in this embodiment dynamically determines the capacity adjustment strategy of the compressed memory pool based on the compression index corresponding to the target memory resource to be compressed. This can more reasonably adjust the capacity of the compressed memory pool, preventing resource waste caused by setting the compressed memory pool too large and the inability to store compressed resources well due to setting the compressed memory pool too small.

[0094] This embodiment provides a method for compressing memory resources, which can be used in electronic devices such as mobile phones and tablets. Figure 3 This is a flowchart of a memory resource compression method according to an embodiment of this application, such as... Figure 3 As shown, the process includes the following steps: Step S301: Collect multiple compression metrics corresponding to the target memory resources to be compressed.

[0095] Specifically, step S301 includes: Step S3011: Collect multiple raw compression metrics from the kernel state.

[0096] Kernel mode is one of the two core states in which a computer operating system operates. The operating system kernel program has the highest level of control over computer hardware (such as CPU, memory, and disk).

[0097] As a concrete example, the extended Berkeley Packet Filter (eBPF) can also be used to collect multiple raw compression metrics from kernel space. For instance, CPU utilization can be collected via `metrics.cpu_usage=bpf_get_cpu_usage()`; content entropy of the target memory resource to be compressed can be collected via `metrics.mem_entropy=calc_mem_entropy()`; memory utilization can be collected via `metrics.mem_usage=bpf_get_mem_usage()`; and I / O utilization can be collected via `metrics.cpu_io_wait=get_cpu_io_wait()`.

[0098] Step S3012: Map multiple raw compression metrics to user space to obtain multiple compression metrics in user space, and read multiple compression metrics from user space.

[0099] Here, multiple raw compression metrics can be mapped to user space using a request-response mapping method; alternatively, raw compression metrics in kernel space can be presented as "virtual files," and user space can map multiple raw compression metrics to user space by reading and writing virtual files; alternatively, multiple raw compression metrics can be mapped to user space by sharing a physical memory region between kernel space and user space.

[0100] In some optional implementations, step S3012 above includes: Step b1: Write multiple raw compression metrics to the first circular queue in kernel mode.

[0101] Step b2: Map the first circular queue based on the memory mapping strategy to obtain the second circular queue in user space.

[0102] Step b3: Read the cached data in the second circular queue to obtain multiple compression metrics in user space.

[0103] When raw CPU utilization, raw memory utilization, raw content entropy, and raw I / O utilization are collected from kernel space, these metrics can be encapsulated into a data block and written to the tail of the first circular queue in kernel space. At this point, a data block represents one raw compression metric as described earlier. Furthermore, starting from the head of the second circular queue, data blocks (i.e., cached data) can be read one by one to obtain multiple compression metrics in user space.

[0104] In the process of reading cached data from the second circular queue to obtain multiple compression metrics in user space, a producer thread can copy the cached data in the second circular queue (which maps the multiple original compression metrics from the first circular queue to the mapping area in user space) and write the copied compression metrics to the write buffer of the double-buffered queue. Simultaneously, according to preset trigger conditions, the write buffer is updated to a read buffer, and the read buffer is updated to a write buffer. This allows the consumer thread to consume the compression metrics from the read buffer of the double-buffered queue to obtain multiple compression metrics in user space. Furthermore, by using both a producer thread and a consumer thread, instead of just one thread reading the cached data from the second circular queue, the efficiency of reading and writing compression metrics can be improved. The preset trigger conditions can be that the write buffer is full, all compression metrics from the read buffer have been read, or a preset time window has been reached, etc. There are no restrictions on the preset trigger conditions here; they can be flexibly adjusted according to actual needs.

[0105] By mapping the first circular queue in kernel mode directly to the second circular queue in user mode through memory mapping, the overhead of cross-mode data copying is eliminated, thus enabling the raw compression metrics of kernel mode to be obtained in user mode with extremely low latency.

[0106] Step S302: Extract the temporal features of multiple compression metrics and input these features into a pre-trained resource compression prediction model to obtain the compression prediction result corresponding to the target memory resource. For details, please refer to [link to details]. Figure 1 Step S102 of the illustrated embodiment will not be described again here.

[0107] Step S303: If the compression prediction result indicates that the target memory resource needs to be compressed, then the target memory resource is compressed based on the compression strategy corresponding to the compression prediction result to obtain compressed resources.

[0108] Step S304: Write the compressed prediction results into the initial configuration file to generate the target configuration file.

[0109] The initial configuration file can be a configuration file for Zswap's basic runtime parameters. This initial configuration file can include default configuration items for memory compression functionality, such as compression algorithm selection, maximum compression memory pool size, and threshold for triggering compression, etc.

[0110] Step S305: Store the target configuration file in kernel mode.

[0111] The process of storing the target configuration file from user space to kernel space can be achieved through the "configuration injection interface" provided by the kernel, which passes the target configuration file from user space to the kernel and makes it effective.

[0112] After the target configuration file is stored in kernel mode, the kernel can hot-load the target configuration file and execute the compression prediction results in the target configuration file.

[0113] The memory resource compression method provided in this embodiment directly collects multiple raw compression metrics from the kernel space, avoiding metric distortion caused by user-space programs' permission restrictions or insufficient hardware access capabilities. By mapping multiple raw compression metrics to user space through memory mapping, and then reading them from user space to obtain the compression metrics, the efficiency of compression metric collection is further improved.

[0114] As a specific application embodiment of this application, such as Figure 4 The figure shows a method for compressing memory resources according to this application, which includes steps S401 to S409.

[0115] Step S401: Collect raw compression metrics from kernel mode.

[0116] Step S402: Normalize the original CPU utilization and original memory utilization in the original compression metrics to obtain normalized CPU utilization and memory utilization.

[0117] Step S403: The CPU utilization rate and memory utilization rate in the compression index are weighted and fused to obtain the decision factor; the decision factor and historical threshold are weighted and fused to obtain the dynamic threshold; if the decision factor is greater than the sum of the dynamic threshold and the buffer factor, the capacity adjustment strategy is determined to be to expand the compressed memory pool; if the decision factor is less than the difference between the dynamic threshold and the buffer factor, the capacity adjustment strategy is determined to be to shrink the compressed memory pool.

[0118] Step S404: Based on the capacity adjustment strategy, adjust the compressed memory pool to obtain the adjusted compressed memory pool.

[0119] Step S405: Map the original compression metrics from kernel mode to user mode to obtain the compression metrics in user mode.

[0120] Step S406: Extract the temporal features of multiple compression metrics in user space.

[0121] Step S407: Input the time-domain features into the resource compression prediction model to obtain the compression prediction result.

[0122] Step S408: If the compression prediction result indicates that the target memory resource needs to be compressed, then based on the compression strategy corresponding to the compression prediction result, the target memory resource is compressed to obtain compressed resources and written into the compressed memory pool.

[0123] Step S409: If the compression prediction result indicates that the target memory resource does not need to be compressed, then the target memory resource is swapped from physical memory to disk.

[0124] This embodiment also provides a memory resource compression device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.

[0125] This embodiment provides a memory resource compression device, such as... Figure 5 As shown, it includes: The acquisition module 501 is used to acquire multiple compression metrics corresponding to the target memory resources to be compressed.

[0126] The extraction module 502 is used to extract the temporal features of multiple compression indicators and input the temporal features into a pre-trained resource compression prediction model to obtain the compression prediction result corresponding to the target memory resource.

[0127] The compression module 503 is used to compress the target memory resources based on the compression strategy corresponding to the compression prediction result if the compression prediction result indicates that the target memory resources need to be compressed.

[0128] In some alternative implementations, the apparatus further includes a switching module for switching the target memory resource from physical memory to disk if the compression prediction result indicates that the target memory resource does not need to be compressed.

[0129] In some optional implementations, the extraction module 502 is further configured to normalize the feature values ​​corresponding to each compression index to obtain the normalized feature value corresponding to each compression index; and to perform standard processing on the normalized feature values ​​corresponding to multiple compression indices to obtain the time-domain features of multiple compression indices.

[0130] In some alternative embodiments, the device further includes: The acquisition module is used to acquire the compressed memory pool corresponding to the target memory resource. The compressed memory pool is a portion of the physical memory space.

[0131] The determination module is used to determine the capacity adjustment strategy of the compressed memory pool based on the compression index when a compression index is collected.

[0132] The adjustment module is used to adjust the capacity of the compressed memory pool based on the capacity adjustment strategy, so as to obtain the adjusted compressed memory pool.

[0133] In some optional implementations, the determining module is further configured to perform weighted fusion of CPU utilization and memory utilization in the compression metrics to obtain a decision factor; perform weighted fusion of the decision factor and historical threshold to obtain a dynamic threshold, wherein the historical threshold is obtained based on the dynamic threshold within the first time sliding window; if the decision factor is greater than the sum of the dynamic threshold and the buffer factor, the capacity adjustment strategy is determined to be to expand the compressed memory pool; if the decision factor is less than the difference between the dynamic threshold and the buffer factor, the capacity adjustment strategy is determined to be to shrink the compressed memory pool.

[0134] In some optional implementations, the adjustment module is further configured to determine a target capacity adjustment strategy based on the fusion result of the capacity adjustment strategy and the historical capacity adjustment strategy within the second time sliding window; and to adjust the capacity of the compressed memory pool based on the target capacity adjustment strategy to obtain the adjusted compressed memory pool.

[0135] In some optional implementations, the acquisition module 501 is also used to acquire multiple raw compression metrics from the kernel space; map the multiple raw compression metrics to the user space to obtain multiple compression metrics in the user space; and read the multiple compression metrics from the user space.

[0136] In some optional implementations, the acquisition module 501 is further configured to write multiple raw compression metrics to a first circular queue in kernel mode; map the first circular queue based on a memory mapping strategy to obtain a second circular queue in user mode; and read the cached data in the second circular queue to obtain multiple compression metrics in user mode.

[0137] In some alternative embodiments, the device further includes: The generation module is used to write the compressed prediction results into the initial configuration file to generate the target configuration file.

[0138] The storage module is used to store the target configuration file in kernel mode.

[0139] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0140] In this embodiment, the memory resource compression device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0141] This application also provides an electronic device having the above-described features. Figure 5 The memory resource compression device shown. Please refer to [link / reference]. Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided in an optional embodiment of this application, such as... Figure 6 As shown, the electronic device includes one or more processors 610, a memory 620, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise as required. The processors can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple electronic devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 6 Take the 610 processor as an example.

[0142] The processor 610 may be a central processing unit, a network processor, or a combination thereof. The processor 610 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.

[0143] The memory 620 stores instructions executable by at least one processor 610 to cause the at least one processor 610 to perform the method shown in the above embodiments.

[0144] The memory 620 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 620 may include high-speed random access memory and non-transient memory, such as at least one disk storage device, flash memory device, or other non-transient solid-state storage device. In some alternative embodiments, the memory 620 may optionally include memory remotely located relative to the processor 610, which can be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof. The memory 620 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid-state drive; the memory 620 may also include combinations of the above types of memory.

[0145] The electronic device also includes an input device 630 and an output device 640. The processor 610, memory 620, input device 630, and output device 640 can be connected via a bus or other means. Figure 6 Taking the example of a connection between China and Israel via a bus.

[0146] Input device 630 can receive input numerical or character information, and generate key signal inputs related to user settings and function control of the electronic device, such as a touchscreen, keypad, mouse, trackpad, touchpad, joystick, one or more mouse buttons, trackball, joystick, etc. Output device 640 may include display devices, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors). The aforementioned display devices include, but are not limited to, liquid crystal displays, light-emitting diodes, displays, and plasma displays. In some alternative embodiments, the display device may be a touchscreen.

[0147] This application also provides a computer-readable storage medium. The methods described in this application can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the methods shown in the above embodiments are implemented.

[0148] A portion of this application can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to this application through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.

[0149] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A compression method of memory resources, characterized in that, The method comprises: Collecting a plurality of compression indicators corresponding to a target memory resource to be compressed; Extracting time domain features of the plurality of compression indicators and inputting the time domain features into a pre-trained resource compression prediction model to obtain a compression prediction result corresponding to the target memory resource; If the compression prediction result indicates that the target memory resource needs to be compressed, performing compression processing on the target memory resource based on a compression strategy corresponding to the compression prediction result to obtain a compressed resource.

2. The method of claim 1, wherein, Further comprising: If the compression prediction result indicates that the target memory resource does not need to be compressed, exchanging the target memory resource from a physical memory to a disk.

3. The method of claim 1, wherein, The extraction of the time domain features of the plurality of compression indicators comprises: Normalizing each index feature value corresponding to each compression indicator to obtain a normalized feature value corresponding to each compression indicator; Performing standard processing on the normalized feature values corresponding to the plurality of compression indicators to obtain the time domain features of the plurality of compression indicators.

4. The method of claim 1, wherein, Further comprising: Obtaining a compressed memory pool corresponding to the target memory resource, the compressed memory pool being a part of space of a physical memory; Based on the compression indicator, determining a capacity adjustment strategy of the compressed memory pool every time one compression indicator is collected; Based on the capacity adjustment strategy, adjusting the capacity of the compressed memory pool to obtain an adjusted compressed memory pool.

5. The method of claim 4, wherein, The determination of the capacity adjustment strategy of the compressed memory pool based on the compression indicator comprises: Weighted fusion of CPU occupancy and memory utilization in the compression indicator to obtain a decision factor; Weighted fusion of the decision factor and a historical threshold value to obtain a dynamic threshold value, the historical threshold value being obtained based on a dynamic threshold value in a first time sliding window; If the decision factor is greater than the sum of the dynamic threshold value and a buffer factor, it is determined that the capacity adjustment strategy is to expand the capacity of the compressed memory pool; If the decision factor is less than the difference between the dynamic threshold value and the buffer factor, it is determined that the capacity adjustment strategy is to shrink the capacity of the compressed memory pool.

6. The method of claim 4, wherein, The adjustment of the capacity of the compressed memory pool based on the capacity adjustment strategy to obtain the adjusted compressed memory pool comprises: Based on the fusion result of the capacity adjustment strategy and a historical capacity adjustment strategy in a second time sliding window, a target capacity adjustment strategy is determined; Based on the target capacity adjustment strategy, the capacity of the compressed memory pool is adjusted to obtain the adjusted compressed memory pool.

7. The method according to any one of claims 1 to 6, characterized in that, The collection of a plurality of compression indicators corresponding to a target memory resource to be compressed comprises: Collecting a plurality of original compression indicators from a kernel state; Mapping the plurality of original compression indicators to a user state to obtain the plurality of compression indicators in the user state, and reading the plurality of compression indicators from the user state.

8. The method of claim 7, wherein, The mapping of the plurality of original compression indicators to the user state to obtain the plurality of compression indicators in the user state comprises: Writing the plurality of original compression indicators to a first ring queue in the kernel state; Based on a memory mapping strategy, mapping the first ring queue to obtain a second ring queue in the user state; reading the cached data in the second circular queue to obtain the plurality of compression indicators in the user mode.

9. The method according to any one of claims 1 to 6, characterized in that, Further comprising: writing the compression prediction result into an initial configuration file to generate a target configuration file; storing the target configuration file to a kernel mode.

10. A memory resource compression apparatus, comprising: The device comprises: a collection module, configured to collect a plurality of compression indicators corresponding to a target memory resource to be compressed; an extraction module, configured to extract time domain features of the plurality of compression indicators, and input the time domain features into a pre-trained resource compression prediction model to obtain a compression prediction result corresponding to the target memory resource; a compression module, configured to, if the compression prediction result represents that the target memory resource needs to be compressed, perform compression processing on the target memory resource based on a compression strategy corresponding to the compression prediction result to obtain a compressed resource.

11. An electronic device, comprising: comprise: a memory and a processor, which are in communication connection with each other, and the memory stores computer instructions, and the processor executes the computer instructions to perform the memory resource compression method in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to make the computer execute the memory resource compression method in any one of claims 1 to 9.