Data compression method and device, electronic equipment and storage medium

By distinguishing file pages and anonymous pages in electronic devices and selecting suitable algorithms from multiple compression algorithms for data compression, the problem of poor compression effect caused by fixed compression algorithms in the prior art is solved, and data compression is improved Flexibility and effect.

CN118944673APending Publication Date: 2024-11-12GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310533289.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-11
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

Existing electronic devices use fixed compression algorithms in data compression, resulting in poor compression effect and lack of flexibility and intelligent mechanisms.

Method used

By distinguishing file pages and anonymous pages, selecting the adaptive compression algorithm from at least two compression algorithms to be selected, compressing the compressed data, and using different types of pages to improve system memory utilization and performance .

Benefits of technology

It achieves better data compression effect, improves the system performance and memory utilization of electronic devices, adapts to different types of data pages, and reduces memory read and write operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118944673A_ABST
    Figure CN118944673A_ABST
Patent Text Reader

Abstract

The invention discloses a data compression method and device, electronic equipment and a storage medium, and relates to the technical field of data compression. The method comprises the steps that to-be-compressed data is determined, a page type corresponding to the to-be-compressed data is obtained, the page type comprises a file page type and an anonymous page type, the page type corresponding to the to-be-compressed data is at least one of the file page type and the anonymous page type, and the to-be-compressed data is compressed from at least two to-be-selected compression algorithms. A to-be-selected compression algorithm corresponding to the page type is determined as a target compression algorithm, compression parameters corresponding to the at least two to-be-selected compression algorithms are different, the compression parameters comprise a compression rate and a compression speed which are in negative correlation, and compression processing is performed on the to-be-compressed data based on the target compression algorithm. According to the embodiment of the invention, the file page and the anonymous page are distinguished, the adaptive compression algorithm is selected from the at least two to-be-selected compression algorithms, and the to-be-compressed data is compressed, so that a better data compression effect can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data compression, and more specifically, to a data compression method, device, electronic device and storage medium. Background Art

[0002] With the development of science and technology, electronic devices are used more and more widely and have more and more functions, becoming one of the necessities in people's daily life. Among them, electronic devices can compress data according to needs, but current electronic devices are generally configured with a compression algorithm, that is, the compression processing of data adopts this compression algorithm, resulting in a fixed compression algorithm used, resulting in poor data compression effect. Summary of the invention

[0003] In view of the above problems, the present application proposes a data compression method, device, electronic device and storage medium to solve the above problems.

[0004] In a first aspect, an embodiment of the present application provides a data compression method, the method comprising: determining data to be compressed; obtaining a page type corresponding to the data to be compressed, wherein the page type comprises a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type; determining a compression algorithm to be selected corresponding to the page type from at least two compression algorithms to be selected as a target compression algorithm, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters comprise a compression rate and a compression speed that are negatively correlated; and compressing the data to be compressed based on the target compression algorithm.

[0005] In a second aspect, an embodiment of the present application provides a data compression device, the device comprising: a data determination module, used to determine the data to be compressed; a page type acquisition module, used to obtain the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type; a compression algorithm determination module, used to determine the compression algorithm to be selected corresponding to the page type from at least two compression algorithms to be selected as a target compression algorithm, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression rate and a compression speed that are negatively correlated; a data compression module, used to compress the data to be compressed based on the target compression algorithm.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the above method.

[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.

[0008] The data compression method, device, electronic device and storage medium provided in the embodiments of the present application determine the data to be compressed, obtain the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type. From at least two compression algorithms to be selected, the compression algorithm to be selected corresponding to the page type is determined as the target compression algorithm, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression rate and a compression speed that are negatively correlated. The data to be compressed is compressed based on the target compression algorithm, so that by distinguishing between file pages and anonymous pages, an adapted compression algorithm is selected from at least two compression algorithms to be selected, and the data to be compressed is compressed, thereby achieving a better data compression effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0010] Figure 1 A schematic diagram of a data compression method according to an embodiment of the present application is shown;

[0011] Figure 2 A schematic diagram of a data compression method according to an embodiment of the present application is shown;

[0012] Figure 3 A schematic diagram of a data compression method according to an embodiment of the present application is shown;

[0013] Figure 4 This application shows Figure 3 The flowchart of step S330 of the data compression method shown is as follows;

[0014] Figure 5 This application shows Figure 3 The flowchart of step S360 of the data compression method shown is as follows;

[0015] Figure 6 A schematic diagram of a data compression method according to an embodiment of the present application is shown;

[0016] Figure 7 A schematic diagram of a data compression method according to an embodiment of the present application is shown;

[0017] Figure 8 A module block diagram of a data compression device provided by an embodiment of the present application is shown;

[0018] Fig. 9 A block diagram of an electronic device according to an embodiment of the present application for executing a data compression method according to an embodiment of the present application is shown;

[0019] Fig.10 A storage unit for storing or carrying program codes for implementing a data compression method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0021] At present, for data compression schemes, a fixed compression algorithm is generally used for data compression. For example, for the data compression scheme of the virtual memory of the operating system of an electronic device, a fixed compression algorithm is generally used to compress the data in the memory, and different compression algorithms are not used according to different data in the memory. This method lacks an intelligent mechanism and cannot flexibly select a compression algorithm according to the actual situation of the data, which will result in a fixed compression algorithm used, resulting in poor data compression effect.

[0022] In view of the above problems, the inventors have discovered after long-term research and proposed the data compression method, device, electronic device and storage medium provided in the embodiments of the present application, which can achieve better data compression effect by distinguishing file pages and anonymous pages, selecting an adaptive compression algorithm from at least two compression algorithms to be selected, and compressing the data to be compressed. The specific data compression method will be described in detail in the subsequent embodiments.

[0023] See also Figure 1 , Figure 1 The flowchart of the data compression method provided by an embodiment of the present application is shown. The method is used to distinguish between file pages and anonymous pages, select an adaptive compression algorithm from at least two compression algorithms to be selected, and compress the data to be compressed, so as to achieve a better data compression effect. In a specific embodiment, the data compression method is applied to Figure 8 The data compression device 200 and the electronic device 100 equipped with the data compression device 200 are shown in FIG. Fig. 9). The following will take an electronic device as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment may include a smart phone, a tablet computer, a wearable electronic device, etc., which is not limited here. Figure 1 The process shown is described in detail, and the data compression method may specifically include the following steps:

[0024] Step S110: Determine the data to be compressed.

[0025] Optionally, the data to be compressed may include data in the memory of the electronic device, data in the hard disk of the electronic device, data in a database, data involved in a cloud computing environment, data involved in processing a large-scale data set, data involved in the electronic device, data involved in a large data center, etc., which are not limited here. When the data to be compressed is memory data of the electronic device, the data to be compressed may be data in the virtual memory of the operating system of the electronic device.

[0026] In some embodiments, data to be compressed may be determined. Among them, data to be compressed may be determined, and the data to be compressed may be determined as data to be compressed. Optionally, when the data to be compressed is data in a memory of an electronic device, all data in the memory of the electronic device may be determined as data to be compressed, or part of the data in the memory of the electronic device may be determined as data to be compressed, which is not limited here.

[0027] Step S120: Obtain the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type.

[0028] Optionally, the page type may include a file page type and an anonymous page type. Among them, a file page refers to a page mapped from a disk file to the process memory, representing a page with a file background. It is a cache generated in the memory after the program reads the file, and is generally also called a file cache. Anonymous page refers to a page dynamically allocated by the program, representing a page without a file background, such as a heap, stack, data segment, etc. It does not exist in the form of a file and cannot be exchanged with a disk file.

[0029] When the number of the data to be compressed is one, the page type corresponding to the one data to be compressed may be a file page type, or the page type corresponding to the one data to be compressed may be an anonymous page type. When the number of the data to be compressed is multiple, the page types corresponding to the multiple data to be compressed may all be file page types, may all be anonymous page types, or may include both file page types and anonymous page types, etc., which is not limited here.

[0030] In this embodiment, when the data to be compressed is determined, the page type corresponding to the data to be compressed can be determined, that is, whether the page type corresponding to the data to be compressed is a file page type, an anonymous page type, or includes a file page type and an anonymous page type. As a way, the operating system of the electronic device can identify different programs and divide the memory pages of these programs into two categories: file pages and anonymous pages. Therefore, the page type corresponding to the data to be compressed can be determined by the operating system of the electronic device, so that the page type corresponding to the data to be compressed can be obtained.

[0031] Step S130: Determine a compression algorithm to be selected corresponding to the page type as a target compression algorithm from at least two compression algorithms to be selected, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression ratio and a compression speed that are negatively correlated.

[0032] Optionally, at least two selected compression algorithms may be pre-set and stored in the electronic device, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression rate and a compression speed that are negatively correlated. For example, the at least two compression algorithms to be selected may include a first compression algorithm to be selected and a second compression algorithm to be selected, the first compression algorithm to be selected corresponds to a first compression parameter, and the second compression algorithm to be selected corresponds to a second compression parameter, if the compression rate included in the first compression parameter is higher than the compression rate included in the second compression parameter, then the compression speed included in the first compression parameter is slower than the compression speed included in the second compression parameter; if the compression rate included in the first compression parameter is lower than the compression rate included in the second compression parameter, then the compression speed included in the first compression parameter is faster than the compression speed included in the second compression parameter.

[0033] It is understandable that the faster the electronic device compresses data, the less the consumption of the central processor of the electronic device, and the slower the electronic device compresses data, the more the consumption of the central processor of the electronic device. Among them, the consumption of the central processor of the electronic device may include the occupancy time of the central processor of the electronic device and / or the power consumption of the central processor of the electronic device. The higher the compression rate of the electronic device for data, the more the memory occupancy of the electronic device is reduced, and the lower the compression rate of the electronic device for data, the less the memory occupancy of the electronic device is reduced.

[0034] In this embodiment, when determining the page type corresponding to the data to be compressed, the compression algorithm to be selected corresponding to the page type can be determined from at least two compression algorithms to be selected, and the compression algorithm to be selected corresponding to the page type can be determined as the target compression algorithm.

[0035] In some implementations, a mapping relationship may be pre-set and stored, and the mapping relationship may include a correspondence relationship between at least two compression algorithms to be selected and at least two page types, wherein the correspondence relationship may include: one compression algorithm to be selected corresponds to one page type, one compression algorithm to be selected corresponds to multiple page types, etc., which are not limited here. Based on this, when the page type corresponding to the data to be compressed is obtained, the compression algorithm to be selected that has a correspondence relationship with the page type corresponding to the data to be compressed may be determined as the target compression algorithm based on the mapping relationship.

[0036] For example, assuming that at least two compression algorithms to be selected include a first compression algorithm to be selected and a second compression algorithm to be selected, and at least two page types include a first page type and a second page type, and there is a corresponding relationship between the first compression algorithm to be selected and the first page type, and there is a corresponding relationship between the second compression algorithm to be selected and the second page type. Then, if it is determined that the page type corresponding to the data to be compressed is the first page type, the first compression algorithm to be selected can be determined as the target compression algorithm based on the mapping relationship; if it is determined that the page type corresponding to the data to be compressed is the second page type, the second compression algorithm to be selected can be determined as the target compression algorithm based on the mapping relationship.

[0037] It can be understood that by setting at least two compression algorithms to be selected and selecting a target compression algorithm corresponding to the page type of the data to be compressed, the purpose of improving the utilization rate of the system memory of the electronic device and improving the system performance of the electronic device can be achieved. Specifically, by using different compression algorithms for different types of pages, it can be better compressed according to their characteristics, thereby improving the utilization rate of the system memory of the electronic device; by using different compression algorithms, it can better adapt to different types of pages and reduce the number of memory read and write operations, thereby improving the system performance of the electronic device.

[0038] Step S140: compressing the data to be compressed based on the target compression algorithm.

[0039] In this embodiment, when a target compression algorithm is determined, the data to be compressed may be compressed based on the target compression algorithm.

[0040] Optionally, the data compression method of this embodiment can be applied to cloud computing and virtualization environments. By selecting different compression algorithms for file pages and anonymous pages of the virtual machine, the memory utilization and performance of the virtual machine can be optimized.

[0041] Optionally, the data compression method of this embodiment can be applied to electronic devices. By selecting different compression algorithms for file pages and anonymous pages of different applications, the memory utilization and performance of the electronic device can be optimized.

[0042] Optionally, the data compression method of this embodiment can be applied to a database system. By selecting different compression algorithms for different types of data pages (such as file pages, anonymous pages, index pages), the performance and storage efficiency of the database system can be optimized.

[0043] Optionally, the data compression method of this embodiment can be applied to a large-scale computer cluster. By selecting different compression algorithms for file pages and anonymous pages of different nodes, the memory utilization and performance of the cluster can be optimized.

[0044] A data compression method provided by an embodiment of the present application determines the data to be compressed, obtains the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type. From at least two compression algorithms to be selected, the compression algorithm to be selected corresponding to the page type is determined as a target compression algorithm, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression ratio and a compression speed that are negatively correlated. The data to be compressed is compressed based on the target compression algorithm, thereby distinguishing between file pages and anonymous pages, selecting an adapted compression algorithm from at least two compression algorithms to be selected, and compressing the data to be compressed, thereby achieving a better data compression effect.

[0045] See also Figure 2 , Figure 2 The following is a flow chart of a data compression method provided by an embodiment of the present application. Figure 2 The process shown is described in detail, and the data compression method may specifically include the following steps:

[0046] Step S210: Determine the data to be compressed.

[0047] Step S220: Obtain a page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type.

[0048] For the detailed description of step S210 to step S220, please refer to step S110 to step S120, which will not be repeated here.

[0049] Step S230: If the page type is the file page type, then determine the compression algorithm to be selected corresponding to the file page type from the at least two compression algorithms to be selected as the first target compression algorithm.

[0050] Optionally, the page type may include a file page type and a type page type, and the target compression algorithm may include a first target compression algorithm and a second target compression algorithm, wherein the file page type corresponds to the first target compression algorithm, and the anonymous page corresponds to the second target compression algorithm. It can be understood that file pages are more difficult to compress than anonymous pages, that is, if the compressed data corresponding to the file page type is compressed using a compression algorithm, the compression rate of the compressed data obtained is lower than that of the compressed data corresponding to the anonymous page type is compressed using the same compression algorithm. That is, using a compression algorithm with a lower compression rate to compress the anonymous page type's data to be compressed can achieve the same compression effect as using a compression algorithm with a higher compression rate to compress the file page type's data to be compressed.

[0051] Based on this, this embodiment can set the first target compression algorithm corresponding to the file page to have a better compression rate than the second target compression algorithm corresponding to the anonymous page, so as to improve the compression rate of the data to be compressed of the file page type, thereby achieving a balance in the compression rates of the data to be compressed of the file page type and the anonymous page type. Accordingly, the compression speed of the first target compression algorithm corresponding to the file page is slower than that of the second target compression algorithm corresponding to the anonymous page.

[0052] In this embodiment, if the page type of the data to be compressed is a file page type, then the compression algorithm to be selected corresponding to the file page type can be determined from at least two compression algorithms to be selected, and the compression algorithm to be selected corresponding to the file page type can be determined as the first target compression algorithm. It can be understood that since the compression rate corresponding to the first target compression algorithm is higher, the compression rate of the data to be compressed of the file page type can be improved, that is, the memory usage can be reduced and the disk I / O performance can be improved. Optionally, the first target compression algorithm can include: ZSTD compression algorithm, Snappy algorithm, etc., which are not limited here.

[0053] In some embodiments, if the page type of the data to be compressed is a file page type, the compression algorithm to be selected corresponding to the file page type can be determined as the first target compression algorithm based on a mapping relationship pre-set and stored in the electronic device, including the correspondence between at least two compression algorithms to be selected and at least two page types.

[0054] Step S240: If the page type is the anonymous page type, determine the compression algorithm to be selected corresponding to the anonymous page type from the at least two compression algorithms to be selected as the second target compression algorithm, wherein the compression rate corresponding to the first target compression algorithm is higher than the compression rate corresponding to the second target compression algorithm, and the compression speed corresponding to the first target compression algorithm is slower than the compression speed corresponding to the second target compression algorithm.

[0055] In this embodiment, if the page type of the data to be compressed is an anonymous page type, then the compression algorithm to be selected corresponding to the anonymous page type can be determined from at least two compression algorithms to be selected, and the compression algorithm to be selected corresponding to the anonymous page type can be determined as the second target compression algorithm. It can be understood that since the compression speed corresponding to the second target compression algorithm is faster, the compression speed of the data to be compressed of the anonymous page type can be improved, the memory usage can be reduced, and the performance of anonymous page exchange can be improved. Optionally, the second target compression algorithm can include: Gzip compression algorithm, LZ4 compression algorithm, etc., which are not limited here.

[0056] In some embodiments, if the page type of the data to be compressed is an anonymous page type, the compression algorithm to be selected corresponding to the anonymous page type can be determined as the second target compression algorithm based on a mapping relationship pre-set and stored by the electronic device, including the correspondence between at least two compression algorithms to be selected and at least two page types.

[0057] Step S250: compressing the data to be compressed based on the target compression algorithm.

[0058] For the detailed description of step S250, please refer to step S140, which will not be repeated here.

[0059] A data compression method provided by an embodiment of the present application determines the data to be compressed, obtains the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type. If the page type is a file page type, then the compression algorithm to be selected corresponding to the file page type is determined from at least two compression algorithms to be selected as the first target compression algorithm, or, if the page type is an anonymous page type, then the compression algorithm to be selected corresponding to the anonymous page type is determined from at least two compression algorithms to be selected as the second target compression algorithm, wherein the compression rate corresponding to the first target compression algorithm is higher than the compression rate corresponding to the second target compression algorithm, and the compression speed corresponding to the first target compression algorithm is slower than the compression speed corresponding to the second target compression algorithm, and the data to be compressed is compressed based on the target compression algorithm. Compared to Figure 1As for the data compression method shown, this embodiment also adopts a compression method with a higher compression ratio and a slower compression speed for the data to be compressed of the file page type, and adopts a compression method with a lower compression ratio and a faster compression speed for the data to be compressed of the anonymous page type, thereby improving the compression effect of the file page and anonymous page data.

[0060] See also Figure 3 , Figure 3 The following is a flow chart of a data compression method provided by an embodiment of the present application. Figure 3 The process shown is described in detail. In this embodiment, the data to be compressed is data in the memory of the electronic device. The data compression method may specifically include the following steps:

[0061] Step S310: Determine the memory pressure level of the electronic device.

[0062] Optionally, the data to be compressed may be data in a memory of the electronic device. For example, the data to be compressed may be data in a virtual memory of an operating system of the electronic device.

[0063] In this embodiment, the memory pressure level of the electronic device can be determined. The greater the memory pressure of the electronic device, the more memory needs to be released to reduce memory usage, and the smaller the memory pressure of the electronic device, the less memory needs to be released and the memory usage can be maintained.

[0064] As an implementable manner, the remaining memory space of the electronic device can be determined, and the memory pressure level of the electronic device can be determined based on the remaining memory space of the electronic device. The larger the remaining memory space of the electronic device, the lower the memory pressure level of the electronic device can be determined, and the smaller the remaining memory space of the electronic device, the higher the memory pressure level of the electronic device can be determined.

[0065] As another implementable method, the number of memory compressions of an electronic device within a preset time length can be determined, and the memory pressure level of the electronic device can be determined based on the number of memory compressions. Among them, the fewer the number of memory compressions of the electronic device, the lower the memory pressure level of the electronic device can be determined, and the more the number of memory compressions of the electronic device, the higher the memory pressure level of the electronic device can be determined. In some embodiments, the electronic device can be pre-set and stored with a preset time length, wherein the preset time length can be automatically set by the electronic device, or can be manually set by the user in the electronic device, which is not limited here. Optionally, the preset time length can be 30 seconds, 1 minute, 5 minutes, etc., which is not limited here.

[0066] As another practicable method, the duration of memory compression of the electronic device can be determined, and the memory pressure level of the electronic device can be determined based on the duration. The shorter the duration of memory compression of the electronic device, the lower the memory pressure level of the electronic device can be determined, and the longer the duration of memory compression of the electronic device, the higher the memory pressure level of the electronic device can be determined.

[0067] Step S320: Determine memory compression capacity based on the memory pressure level.

[0068] In this embodiment, when the memory pressure level of the electronic device is determined, the memory compression capacity can be determined based on the memory pressure level. The higher the memory pressure level of the electronic device, the more the electronic device needs to release memory, and the larger the memory compression capacity determined based on the memory pressure level; the lower the memory pressure level of the electronic device, the less the electronic device needs to release memory, and the smaller the memory compression capacity determined based on the memory pressure level.

[0069] In some implementations, a mapping relationship may be pre-set and stored, and the mapping relationship may include a correspondence relationship between multiple memory pressure levels and multiple memory compression capacities, wherein the correspondence relationship may include: one memory pressure level corresponds to one memory compression capacity, multiple memory pressure levels correspond to one memory compression capacity, etc., which are not limited here. Based on this, when the memory pressure level of the electronic device is obtained, the memory compression capacity that has a corresponding relationship with the memory pressure level of the electronic device may be determined based on the mapping relationship.

[0070] In some embodiments, the electronic device may pre-set and store a stress level threshold, wherein the stress level threshold is used as a basis for determining the memory stress level of the electronic device. Therefore, in this embodiment, when the memory stress level of the electronic device is obtained, the memory stress level may be compared with the stress level threshold to determine whether the memory stress level has reached the stress level threshold. Optionally, if it is determined that the memory stress level has reached the stress level threshold, it may be determined that the electronic device needs to be memory compressed, and the compressed memory capacity may be determined based on the memory stress level; if it is determined that the memory stress level has not reached the stress level threshold, it may be determined that the electronic device does not need to be memory compressed, and the determination and compression of the data to be compressed may not be performed.

[0071] Step S330: Based on the memory compression capacity, determine the data to be compressed from the memory data of the electronic device.

[0072] In this embodiment, when the memory compression capacity is determined, the data to be compressed can be determined from the memory data of the electronic device based on the memory compression capacity. The capacity corresponding to the determined data to be compressed is adapted to the memory compression capacity, for example, the capacity corresponding to the determined data to be compressed is consistent with the memory compression capacity, the capacity corresponding to the determined data to be compressed is slightly larger than the memory compression capacity, or the capacity corresponding to the determined data to be compressed is slightly smaller than the memory compression capacity, etc., which is not limited here.

[0073] In some embodiments, when determining the memory compression capacity, the data to be compressed can be determined from the memory data of the electronic device in order from large to small; when determining the memory compression capacity, the data to be compressed can be determined from the memory data of the electronic device in order from small to large; when determining the memory compression capacity, the data to be compressed can be determined from the memory data of the electronic device according to the priority relationship of the data type of each memory data; when determining the memory compression capacity, the data to be compressed can be determined from the memory data of the electronic device according to the priority relationship of the application to which each memory data belongs, etc., and no limitation is made here.

[0074] See also Figure 4 , Figure 4 This application shows Figure 3 The following is a flow chart of step S330 of the data compression method. Figure 4 The process shown is described in detail, and the method may specifically include the following steps:

[0075] Step S331: determining a memory compression parameter based on the memory pressure level, wherein the memory compression parameter represents a compression ratio of anonymous pages and file pages.

[0076] In some implementations, when the memory pressure level of the electronic device is determined, a memory compression parameter may be determined based on the memory pressure level, wherein the memory compression parameter represents the compression ratio of anonymous pages and file pages.

[0077] Among them, since file pages are more difficult to compress than anonymous pages, a compression algorithm with a higher compression rate and a slower compression speed is generally used for file page type data, and a compression algorithm with a lower compression rate and a faster compression speed is generally used for anonymous page type data. Therefore, if the memory pressure level of the electronic device is high, it indicates that the electronic device needs to release memory as soon as possible, that is, you can try to improve the overall compression speed of the data by processing more anonymous page type data and less file page type data, so as to improve the memory release speed of the electronic device; if the memory pressure level of the electronic device is low, it indicates that the electronic device does not need to release memory as soon as possible, that is, you can try to improve the overall compression rate of the data by processing less anonymous page type data and more file page type data, so as to improve the memory release space of the electronic device.

[0078] It can be understood that, since the memory compression parameter represents the compression ratio of anonymous pages and file pages, and the compression speed of anonymous pages is faster than that of file pages. Therefore, if the compression ratio of anonymous pages and file pages in the memory compression parameter increases, the ratio of anonymous pages increases and the ratio of file pages decreases, and accordingly, the processing speed for file pages and anonymous pages is accelerated; if the compression ratio of anonymous pages and file pages in the memory compression parameter decreases, the ratio of file pages increases and the ratio of anonymous pages decreases, and accordingly, the processing speed for file pages and anonymous pages slows down. Therefore, in this embodiment, the memory compression parameter can be determined based on the memory pressure level. When the memory pressure level is high, it represents that the electronic device needs to quickly release the memory of the electronic device, then the ratio of anonymous pages in the determined memory compression parameter can be increased and the ratio of file pages can be reduced, so as to achieve the purpose of improving the memory release speed; when the memory pressure level is low, it represents that the electronic device does not need to quickly release the memory of the electronic device, then the ratio of anonymous pages in the determined memory compression parameter can be reduced and the ratio of file pages can be increased, so as to achieve the purpose of improving the memory release space.

[0079] In some implementations, the electronic device may pre-set and store a mapping relationship, which may include a correspondence between multiple memory pressure levels and multiple memory compression parameters, wherein the correspondence may include one memory pressure level corresponding to one memory compression parameter, multiple memory pressure levels corresponding to one memory compression parameter, etc., which are not limited here. Based on this, when the memory pressure level of the electronic device is obtained, the memory compression parameter that has a corresponding relationship with the memory pressure level of the electronic device can be determined based on the mapping relationship.

[0080] Step S332: Based on the memory compression capacity and the memory compression parameters, determine the data to be compressed from the memory data of the electronic device.

[0081] In some embodiments, when the memory compression capacity and the memory compression parameters are determined, the data to be compressed can be determined from the memory data of the electronic device based on the memory compression capacity and the memory compression parameters. The capacity corresponding to the determined data to be compressed is adapted to the memory compression capacity, and the parameters corresponding to the determined data to be compressed are adapted to the memory compression parameters. The adaptation of the parameters corresponding to the determined data to be compressed to the memory compression parameters indicates that the ratio of anonymous pages and file pages included in the data to be compressed is consistent or close to the memory compression parameters.

[0082] Step S340: Obtain the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type.

[0083] In some implementations, the electronic device may pre-set and store a pressure level threshold, wherein the pressure level threshold is used as a basis for determining the memory pressure level of the electronic device. Therefore, in this embodiment, when the memory pressure level of the electronic device is obtained, the memory pressure level may be compared with the pressure level threshold to determine whether the memory pressure level reaches the pressure level threshold.

[0084] Among them, if it is determined that the memory pressure level reaches the pressure level threshold, it can be determined that the memory of the electronic device needs to be compressed quickly and effectively to quickly release the memory of the electronic device, and the page type corresponding to the data to be compressed can be obtained, so as to select an adaptive compression algorithm from at least two compression algorithms to be selected for compression processing, thereby improving the data compression effect and alleviating the memory pressure of the electronic device.

[0085] Among them, if it is determined that the memory pressure does not reach the pressure level threshold, it can be determined that the memory of the electronic device can be appropriately compressed to normally release the memory of the electronic device, and the data to be compressed can be compressed by the default compression algorithm to reduce the complexity of the electronic device's data processing and reduce the power consumption of the electronic device.

[0086] Step S350: Determine a compression algorithm to be selected corresponding to the page type as a target compression algorithm from at least two compression algorithms to be selected, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression ratio and a compression speed that are negatively correlated.

[0087] Step S360: compressing the data to be compressed based on the target compression algorithm.

[0088] For the detailed description of step S350 to step S360, please refer to step S130 to step S140, which will not be repeated here.

[0089] See also Figure 5 , Figure 5 This application shows Figure 3 The following is a flow chart of step S360 of the data compression method. Figure 5 The process shown is described in detail, and the method may specifically include the following steps:

[0090] Step S361: If the page type includes the file page type and the anonymous page type, the compression order of the to-be-compressed data of the file page type and the to-be-compressed data of the anonymous page type is determined based on the memory pressure level.

[0091] Optionally, there may be multiple data to be compressed, and the page types corresponding to the multiple data to be compressed may include a file page type and an anonymous page type.

[0092] In some embodiments, if the page type includes a file page type and an anonymous page type, the compression order of the data to be compressed of the file page type and the data to be compressed of the anonymous page type can be determined based on the memory pressure level. The compression order of the data to be compressed of the file page type and the data to be compressed of the anonymous page type can include: first compressing the data to be compressed of the file page type, and then compressing the data to be compressed of the anonymous page type; first compressing the data to be compressed of the anonymous page type, and then compressing the data to be compressed of the file page type; and processing the data to be compressed of the file page type and the data to be compressed of the anonymous page type at the same time.

[0093] It is understandable that the compression rate of the compression algorithm for the data to be compressed of the file page type is higher than the compression rate of the compression algorithm for the data to be compressed of the anonymous page type, and the compression speed of the compression algorithm for the data to be compressed of the file page type is slower than the compression speed of the compression algorithm for the data to be compressed of the anonymous page type. Based on this, when determining the compression order of the data to be compressed of the file page type and the data to be compressed of the anonymous page type based on the memory pressure level, if the memory pressure level is large (such as the memory pressure level is greater than the pressure level threshold), it can be considered that the electronic device urgently needs to release memory space, and a faster memory release method can be selected, that is, the data to be compressed of the anonymous page type can be compressed first, and then the data to be compressed of the file page type can be compressed; if the memory pressure level is small (such as the memory pressure level is less than the pressure level threshold), it can be considered that the electronic device does not need to release memory space immediately, and a memory release method with a higher compression rate can be selected, that is, the data to be compressed of the file page type can be compressed first, and then the data to be compressed of the anonymous page type can be compressed.

[0094] Step S362: Based on the target compression algorithm, compress the to-be-compressed data of the file page type and the to-be-compressed data of the anonymous page type in sequence according to the compression order.

[0095] In some implementations, when the compression order is determined, the to-be-compressed data of the file page type and the to-be-compressed data of the anonymous page type may be compressed in sequence according to the compression order based on the target compression algorithm to adapt to the degree of memory pressure.

[0096] Optionally, it is assumed that the target compression algorithm corresponding to the file page type is the first target compression algorithm, and the target compression algorithm corresponding to the anonymous page type is the second target compression algorithm. If the compression order is to first compress the data to be compressed of the anonymous page type, and then compress the data to be compressed of the file page type, then the data to be compressed of the anonymous page type can be compressed by the second target compression algorithm first, and then the data to be compressed of the file page type can be compressed by the first target compression algorithm; if the compression order is to first compress the data to be compressed of the file page type, and then compress the data to be compressed of the anonymous page type, then the data to be compressed of the file page type can be compressed by the first target compression algorithm first, and then the data to be compressed of the anonymous page type can be compressed by the second target compression algorithm.

[0097] A data compression method provided by an embodiment of the present application determines the memory pressure level of an electronic device, determines the memory compression capacity based on the memory pressure level, determines the data to be compressed from the memory data of the electronic device based on the memory compression capacity, obtains the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type, and determines the compression algorithm to be selected corresponding to the page type as the target compression algorithm from at least two compression algorithms to be selected, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression rate and a compression speed that are negatively correlated, and the data to be compressed is compressed based on the target compression algorithm. Compared to Figure 1 The data compression method shown in this embodiment also determines the data to be compressed according to the memory pressure level of the electronic device, so that the operating state of the electronic device can be adapted to balance the performance of the electronic device and the data compression effect.

[0098] See also Figure 6 , Figure 6 The following is a flow chart of a data compression method provided by an embodiment of the present application. Figure 6 The process shown is described in detail, and the data compression method may specifically include the following steps:

[0099] Step S410: Determine the data to be compressed.

[0100] Step S420: Obtain the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type.

[0101] For the detailed description of step S410 to step S420, please refer to step S110 to step S120, which will not be repeated here.

[0102] Step S430: Determine the application to which the data to be compressed belongs.

[0103] Among them, the memory access mode and data structure of different applications are different, therefore, for different applications, using different compression algorithms can obtain better compression rate and performance. In this embodiment, when the data to be compressed is determined, the application to which the data to be compressed belongs can be determined.

[0104] In some implementations, the operating system of the electronic device can identify different applications and identify the memory pages of the application, file pages or anonymous pages. Therefore, the application to which the data to be compressed belongs can be identified by the operating system of the electronic device to determine the application to which the data to be compressed belongs.

[0105] Step S440: Determine, from the at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the application and the page type as the target compression algorithm, wherein the at least two compression algorithms to be selected each have different corresponding compression parameters, and the compression parameters include a compression ratio and a compression speed that are negatively correlated.

[0106] In this embodiment, when the page type of the data to be compressed and the application to which the data to be compressed belongs are determined, the compression algorithm to be selected corresponding to the page type and the application can be determined from at least two compression algorithms to be selected, and the compression algorithm to be selected corresponding to the page type and the application can be determined as the target compression algorithm.

[0107] In some embodiments, a mapping relationship can be pre-set and stored, and the mapping relationship can include a correspondence between at least two compression algorithms to be selected, at least two page types, and at least two applications, wherein the correspondence may include: one compression algorithm to be selected corresponds to one page type and one application, one compression algorithm to be selected corresponds to one page type and multiple applications, one compression algorithm to be selected corresponds to multiple page types and one application, one compression algorithm to be selected corresponds to multiple page types and multiple applications, etc., which are not limited here.

[0108] Step S450: compressing the data to be compressed based on the target compression algorithm.

[0109] For the detailed description of step S450, please refer to step S140, which will not be repeated here.

[0110] A data compression method provided by an embodiment of the present application determines the data to be compressed, obtains the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type, determines the application to which the data to be compressed belongs, and determines the compression algorithm to be selected corresponding to the application and the page type from at least two compression algorithms to be selected as the target compression algorithm, wherein at least two compression algorithms to be selected each have different corresponding compression parameters, and the compression parameters include a compression ratio and a compression speed that are negatively correlated, and compresses the data to be compressed based on the target compression algorithm. Compared to Figure 1 The data compression method shown in this embodiment also determines a compression algorithm based on the application to which the data to be compressed belongs, which can improve the accuracy of the determined compression algorithm.

[0111] See also Figure 7 , Figure 7 The following is a flow chart of a data compression method provided by an embodiment of the present application. Figure 7The process shown is described in detail, and the data compression method may specifically include the following steps:

[0112] Step S510: Determine the current time.

[0113] The data that needs to be used at different times is different. If the data that needs to be used has not been compressed, the data can be used directly, which takes less time; if the data that needs to be used has been compressed, the data needs to be decompressed before use, which takes longer time. Therefore, different data can be compressed at different times. For example, at a certain time, the data that does not need to be used at that time can be compressed, while the data that needs to be used can be not compressed, so as to improve the response speed of data use.

[0114] In this embodiment, the current time can be determined. Optionally, the electronic device can have a built-in clock, and the current time can be determined by the clock.

[0115] Step S520: Determine the data to be compressed based on the current time.

[0116] In this embodiment, when the current time is determined, the data to be compressed can be determined based on the current time. Optionally, the data to be compressed can be data that is not needed at the current time.

[0117] In some implementations, when the current time is determined, the time period to which the current time belongs may be determined, and the data to be compressed may be determined based on the time period. Optionally, the data to be compressed may be data that is not needed in the time period.

[0118] In some implementations, when the current time is determined, the time period to which the current time belongs can be determined, and the historical time period corresponding to the time period can be determined, and the data used and the data not used by the electronic device in the historical time period can be determined, and the data to be compressed can be determined based on the data used and the data not used by the electronic device in the historical time period. For example, the data corresponding to the data not used by the electronic device in the historical time period can be determined as the data to be compressed.

[0119] Step S530: Obtain the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type.

[0120] Step S540: Determine the compression algorithm to be selected corresponding to the page type from the at least two compression algorithms to be selected as the target compression algorithm, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression ratio and a compression speed that are negatively correlated.

[0121] Step S550: compressing the data to be compressed based on the target compression algorithm.

[0122] For the detailed description of step S530 to step S550, please refer to step S120 to step S140, which will not be repeated here.

[0123] The data compression method provided by an embodiment of the present application determines the current time, determines the data to be compressed based on the current time, obtains the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type. From at least two compression algorithms to be selected, the compression algorithm to be selected corresponding to the page type is determined as the target compression algorithm, wherein at least two compression algorithms to be selected have different corresponding compression parameters, and the compression parameters include a compression rate and a compression speed that are negatively correlated, and the data to be compressed is compressed based on the target compression algorithm. Compared to Figure 1 The data compression method shown in this embodiment also determines the data to be compressed based on the current time, which can improve the accuracy of the determined data to be compressed.

[0124] See also Figure 8 , Figure 8 The module block diagram of the data compression device provided by an embodiment of the present application is shown below. Figure 8 The block diagram shown in the figure is used to illustrate that the data compression device 200 includes: a data determination module 210, a page type acquisition module 220, a compression algorithm determination module 230 and a data compression module 240, wherein:

[0125] The data determination module 210 is used to determine the data to be compressed.

[0126] Furthermore, the data to be compressed is data in the memory of the electronic device, and the data determination module 210 includes: a memory pressure level determination submodule, a memory compression capacity determination submodule and a first data determination submodule, wherein:

[0127] The memory pressure level determination submodule is used to determine the memory pressure level of the electronic device.

[0128] The memory compression capacity determination submodule is used to determine the memory compression capacity based on the memory pressure level.

[0129] The first data determination submodule is used to determine the data to be compressed from the memory data of the electronic device based on the memory compression capacity.

[0130] Furthermore, the first data determination submodule includes: a memory compression parameter determination unit and a data determination unit, wherein:

[0131] A memory compression parameter determination unit is used to determine a memory compression parameter based on the memory pressure level, wherein the memory compression parameter represents a compression ratio of anonymous pages and file pages.

[0132] A data determination unit is used to determine the data to be compressed from the memory data of the electronic device based on the memory compression capacity and the memory compression parameter.

[0133] Furthermore, the data determination module 210 includes: a current time determination submodule and a second data determination submodule, wherein:

[0134] The current time determination submodule is used to determine the current time.

[0135] The second data determination submodule is used to determine the data to be compressed based on the current time.

[0136] The page type acquisition module 220 is used to acquire the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type.

[0137] Furthermore, the page type acquisition module 220 includes: a page type acquisition submodule, wherein:

[0138] The page type acquisition submodule is used to acquire the page type corresponding to the data to be compressed if the memory pressure level reaches a pressure level threshold.

[0139] Furthermore, the page type acquisition module 220 further includes: a compression processing submodule, wherein:

[0140] The compression processing submodule is used to compress the data to be compressed by using a default compression algorithm if the memory pressure level does not reach the pressure level threshold.

[0141] The compression algorithm determination module 230 is used to determine the compression algorithm to be selected corresponding to the page type as the target compression algorithm from at least two compression algorithms to be selected, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression ratio and a compression speed that are negatively correlated.

[0142] Furthermore, the compression algorithm determination module 230 includes: a first compression algorithm determination submodule and a second compression algorithm determination submodule, wherein:

[0143] The first compression algorithm determination submodule is used to determine, if the page type is the file page type, from the at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the file page type as a first target compression algorithm.

[0144] A second compression algorithm determination submodule is used to determine, if the page type is the anonymous page type, from the at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the anonymous page type as the second target compression algorithm, wherein the compression ratio corresponding to the first target compression algorithm is higher than the compression ratio corresponding to the second target compression algorithm, and the compression speed corresponding to the first target compression algorithm is slower than the compression speed corresponding to the second target compression algorithm.

[0145] Further, the compression algorithm determination module 230 includes: an application determination submodule and a third compression algorithm determination submodule, wherein:

[0146] The application determination submodule is used to determine the application to which the data to be compressed belongs.

[0147] The third compression algorithm determination submodule is used to determine, from the at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the application and the page type as the target compression algorithm.

[0148] The data compression module 240 is used to compress the data to be compressed based on the target compression algorithm.

[0149] Furthermore, the data compression module 240 includes: a compression order determination submodule and a data compression submodule, wherein:

[0150] A compression order determination submodule is used to determine the compression order of the to-be-compressed data for the file page type and the to-be-compressed data for the anonymous page type based on the memory pressure level if the page type includes the file page type and the anonymous page type.

[0151] The data compression submodule is used to compress the to-be-compressed data of the file page type and the to-be-compressed data of the anonymous page type in sequence according to the compression order based on the target compression algorithm.

[0152] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0153] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0154] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0155] See also Fig. 9 , which shows a structural block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0156] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0157] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing functions (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0158] See also Fig.10 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 300 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0159] The computer readable storage medium 300 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer readable storage medium 300 has storage space for program code 310 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 310 can be compressed, for example, in an appropriate form.

[0160] In summary, the data compression method, device, electronic device and storage medium provided in the embodiments of the present application determine the data to be compressed, obtain the page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type. From at least two compression algorithms to be selected, the compression algorithm to be selected corresponding to the page type is determined as the target compression algorithm, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression rate and a compression speed that are negatively correlated. The data to be compressed is compressed based on the target compression algorithm, so that by distinguishing between file pages and anonymous pages, an adapted compression algorithm is selected from at least two compression algorithms to be selected, and the data to be compressed is compressed, thereby achieving a better data compression effect.

[0161] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data compression method, characterized in that: The method comprises: Determine the data to be compressed; Acquire a page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type; Determine, from at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the page type as a target compression algorithm, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression ratio and a compression speed that are negatively correlated; The data to be compressed is compressed based on the target compression algorithm.

2. The method according to claim 1, characterized in that The step of determining, from at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the page type as a target compression algorithm includes: If the page type is the file page type, determining, from the at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the file page type as the first target compression algorithm; or If the page type is the anonymous page type, then the compression algorithm to be selected corresponding to the anonymous page type is determined from the at least two compression algorithms to be selected as the second target compression algorithm, wherein the compression rate corresponding to the first target compression algorithm is higher than the compression rate corresponding to the second target compression algorithm, and the compression speed corresponding to the first target compression algorithm is slower than the compression speed corresponding to the second target compression algorithm.

3. The method according to claim 1, characterized in that The data to be compressed is data in a memory of the electronic device, and the step of determining the data to be compressed includes: determining a level of memory pressure of the electronic device; determining a memory compression capacity based on the memory pressure level; Based on the memory compression capacity, the data to be compressed is determined from the memory data of the electronic device.

4. The method according to claim 3, characterized in that The step of determining the data to be compressed from the memory data of the electronic device based on the memory compression capacity includes: Determining a memory compression parameter based on the memory pressure level, wherein the memory compression parameter represents a compression ratio of anonymous pages and file pages; The data to be compressed is determined from the memory data of the electronic device based on the memory compression capacity and the memory compression parameter.

5. The method according to claim 3, characterized in that: The compressing the data to be compressed based on the target compression algorithm includes: If the page type includes the file page type and the anonymous page type, determining a compression order of the to-be-compressed data of the file page type and the to-be-compressed data of the anonymous page type based on the memory pressure level; Based on the target compression algorithm, the to-be-compressed data of the file page type and the to-be-compressed data of the anonymous page type are compressed in sequence according to the compression order.

6. The method according to any one of claims 3 to 5, characterized in that: The obtaining the page type corresponding to the data to be compressed includes: If the memory pressure level reaches a pressure level threshold, the page type corresponding to the data to be compressed is obtained.

7. The method according to claim 6, characterized in that The method further comprises: If the memory pressure level does not reach the pressure level threshold, the data to be compressed is compressed using a default compression algorithm.

8. The method according to any one of claims 1 to 3, characterized in that: The step of determining, from at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the page type as a target compression algorithm includes: Determine the application to which the data to be compressed belongs; From the at least two compression algorithms to be selected, a compression algorithm to be selected corresponding to the application and the page type is determined as the target compression algorithm.

9. The method according to any one of claims 1 to 3, characterized in that: The step of determining the data to be compressed includes: Determine the current time; Based on the current time, the data to be compressed is determined.

10. A data compression device, characterized in that: The device comprises: A data determination module, used for determining data to be compressed; A page type acquisition module, used to acquire a page type corresponding to the data to be compressed, wherein the page type includes a file page type and an anonymous page type, and the page type corresponding to the data to be compressed is at least one of the file page type and the anonymous page type; A compression algorithm determination module, used to determine a compression algorithm to be selected corresponding to the page type from at least two compression algorithms to be selected as a target compression algorithm, wherein the compression parameters corresponding to the at least two compression algorithms to be selected are different, and the compression parameters include a compression ratio and a compression speed that are negatively correlated; A data compression module is used to compress the data to be compressed based on the target compression algorithm.

11. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 9.