Memory processing method and device, storage medium and electronic equipment
By merging and compressing the system memory pages in terminal memory management, the problem of insufficient memory compression times in the prior art is solved, and the effect of improving memory compression efficiency and speed is achieved.
Patent Information
- Application Number
- CN202311401929.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-26
- Publication Date
- 2025-04-29
AI Technical Summary
In the prior art, when terminal memory is tight, the memory compression mechanism does not compress the system memory pages in the number of times, making it difficult to meet the growing memory page compression needs.
By obtaining the target system memory page from the system memory page table, merging and processing to form a system memory page combination, and then compressing the combination to form a system memory compression block.
The system memory pages are merged first and then compressed, which reduces the number of times the memory compression mechanism compresses the system memory pages, improves the memory compression efficiency and compression speed, reduces the compression time, and meets the growing memory page compression needs.
Smart Images

Figure CN119902688A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a memory processing method, device, storage medium and electronic device. Background Art
[0002] The terminal will allocate certain memory pages according to the needs of the application. Even if the application is not running, it will occupy a part of the memory pages. When the terminal memory is tight, the memory compression mechanism will be used to compress the memory pages occupied by the application and write the compressed memory pages to the compression space first, which can free up part of the memory space. When the data is needed again, it will be decompressed and called. Summary of the invention
[0003] The embodiments of this specification provide a memory processing method, device, storage medium and electronic device, and the technical solution is as follows:
[0004] In a first aspect, an embodiment of the present specification provides a memory processing method, the method comprising:
[0005] Get the target system memory page from the system memory page table;
[0006] The target system memory pages are merged to obtain a system memory page combination, and the system memory page combination is compressed to obtain a system memory compression block.
[0007] In a second aspect, an embodiment of the present specification provides a memory processing device, the device comprising:
[0008] An acquisition module, used for acquiring a target system memory page from a system memory page table;
[0009] The processing module is used to merge the target system memory pages to obtain a system memory page combination, and compress the system memory page combination to obtain a system memory compression block.
[0010] In a third aspect, an embodiment of the present specification provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.
[0011] In a fourth aspect, an embodiment of the present specification provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.
[0012] The beneficial effects brought by the technical solutions provided by some embodiments of this specification include at least:
[0013] In an embodiment of the present specification, the terminal obtains a target system memory page from a system memory page table, merges the target system memory page to obtain a system memory page combination, compresses the system memory page combination to obtain a system memory compression block, and adopts a method of merging the system memory pages first and then compressing them, thereby further reducing the number of times the terminal memory compression mechanism compresses the system memory pages, thereby greatly improving the memory compression efficiency and compression speed, reducing the compression time, and meeting the growing demand for memory page compression. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0015] Figure 1 It is a flowchart of a memory processing method provided in an embodiment of this specification;
[0016] Figure 2 This is a schematic diagram of a terminal memory page scenario provided by an embodiment of this specification;
[0017] Figure 3 It is a flowchart of another memory processing method provided by an embodiment of this specification;
[0018] Figure 4 It is a schematic diagram of verifying the effect after executing a memory processing method provided in an embodiment of this specification;
[0019] Figure 5 It is a flowchart of another embodiment of a memory processing method provided in an embodiment of this specification;
[0020] Figure 6 It is a structural schematic diagram of a memory processing device provided in an embodiment of this specification;
[0021] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of this specification;
[0022] Figure 8 It is a schematic diagram of the structure of the operating system and user space provided in the embodiments of this specification;
[0023] Fig. 9 yes Figure 8 The architecture diagram of the Android operating system;
[0024] Fig.10 yes Figure 8 Architecture diagram of the IOS operating system. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0026] In the description of this specification, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of this specification, it should be noted that, unless otherwise clearly specified and limited, "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in this specification can be understood in specific circumstances. In addition, in the description of this specification, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are an "or" relationship.
[0027] In the related art, memory compression mechanism (such as ZRAM) is a technology currently widely used in terminal systems. The Linux kernel divides the available memory of the system into fixed-size (4096 bytes or 4KB) memory pages, and uses memory pages as the smallest unit to provide memory to applications in the system. The memory compression mechanism compresses and stores the data of memory pages that will not be used temporarily in the system but cannot be directly discarded. When it is needed, it is first decompressed and then provided to the system for use; by using the central processing unit to perform compression and decompression, the purpose of saving memory space is achieved, so as to provide more available memory for the system.
[0028] However, in the related art, each time memory is recycled, many memory pages need to be compressed. However, due to the setting of the system's own mechanism, only a single memory page (such as 4KB) can be compressed each time, which results in a waste of compression performance and makes it difficult to meet the growing demand for memory page compression.
[0029] The present specification is described in detail below with reference to specific embodiments.
[0030] In one embodiment, Figure 1 As shown, a memory processing method is proposed, which can be implemented by a computer program and can be run on a memory processing device based on the von Neumann system. The computer program can be integrated in an application or run as an independent tool application. The memory processing device can be a terminal device, including but not limited to: a personal computer, a tablet computer, a handheld device, a vehicle-mounted device, a wearable device, a computing device or other processing device connected to a wireless modem. In different networks, terminal devices can be called different names, such as: user equipment, access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent or user device, cellular phone, cordless phone, 5G network or terminal device in future evolution network, etc.
[0031] Specifically, the memory processing method includes:
[0032] S102: Obtain a target system memory page from a system memory page table;
[0033] The system memory page table may be a least recently used list (LRU list), an inactive anonymous page linked list, or other lists used by the terminal system for system memory management.
[0034] When using the terminal, Figure 2 As shown, Figure 2 It is a schematic diagram of a terminal memory page scenario. Figure 2 In the present invention, the terminal memory can be divided into multiple system memory pages {P1\P2\P3...PageN}, and the terminal memory can be managed in units of system memory pages. A system memory page can be, for example, 512 to 8k bytes. Each system memory page has a physical memory address, which corresponds to a virtual memory address. The terminal processor can indirectly access the corresponding physical memory address through the virtual memory address, thereby accessing the data in the memory page corresponding to the physical memory address. Each system memory page can be associated with one or more threads. When the thread accesses the virtual memory address corresponding to the system memory page, the data in the system memory page can be accessed.
[0035] In actual applications, when the terminal memory is insufficient, some memory pages can be compressed. For example, the memory pages of the system memory pages such as the Least Recently Used list can be compressed to release part of the memory space, and then decompressed when the data in these memory pages is needed.
[0036] In one or more embodiments of this specification, in a scenario where memory compression is required, considering that there are many memory pages that need to be compressed each time memory is recycled, in order to meet the compression requirements, in this specification, the terminal can obtain multiple target system memory pages from the system memory page table, and use a method of merging and then compressing the memory to further reduce the number of compressions, so as to greatly improve the memory compression efficiency and reduce the compression time, and meet the compression requirements;
[0037] The target system memory page can be understood as a plurality of system memory pages to be merged that are screened out by the terminal from the system memory page table.
[0038] In a feasible implementation, a target system memory page may be randomly selected from a system memory page table;
[0039] In a feasible implementation, when the terminal performs memory management and maintains system memory pages, it will sort the system memory pages of the system memory page table in sequence according to the activity of the system memory pages, with the activity decreasing from the head of the system memory page table to the tail of the system memory page table. Based on this, with the reverse order of the memory pages of the system memory page table as a reference, the target system memory page is obtained from the system memory page table, that is, multiple system memory pages to be merged are screened from the tail of the system memory page table.
[0040] S104: merging the target system memory pages to obtain a system memory page combination, and compressing the system memory page combination to obtain a system memory compression block.
[0041] In a feasible implementation, when the terminal is performing memory management, usually the size occupied by each system memory page is the same, such as 4kb. Multiple target system memory pages cannot be directly written into a new system memory page after merging. Based on this, the terminal can temporarily divide or create a temporary system memory page that is different from the regular size. The short life cycle of the temporary system memory page will not significantly affect memory management, and the resources occupied by the temporary system memory page can be immediately released after merging and then compressing. The temporary system page is dissolved. After determining the temporary system memory page, multiple target system memory pages are written into the temporary system memory page. The size occupied by the temporary system memory page is greater than or equal to the total size occupied by multiple target system memory pages. The temporary system memory page can be regarded as a system memory page combination at this time, and then the system memory page combination, that is, the temporary system memory page, is directly compressed using the terminal memory compression mechanism to obtain a memory compression block;
[0042] In a feasible implementation, during the memory management process of the terminal, usually the occupied size of each system memory page is the same, such as 4kb. The merge of multiple target system memory pages cannot be directly written into a new system memory page. Based on this, the terminal can keep the memory management mechanism of the original system memory page unchanged, but build a link relationship (such as a head-to-tail link) between the multiple target system memory pages. After the link relationship of the multiple target system memory pages is built, the multiple target system memory pages are regarded as a system memory page combination, and then the multiple target system memory pages represented by the system memory page combination are compressed by calling the terminal memory compression mechanism to obtain a memory compression block;
[0043] In a feasible implementation, when the terminal is performing memory management, usually the occupied size of each system memory page is the same, such as 4kb. The merge of multiple target system memory pages cannot be directly written into a new system memory page. Based on this, the terminal can keep the memory management mechanism of the original system memory page unchanged, but build a structure tree relationship between multiple target system memory pages. Each target system memory page is a tree node in the structure tree relationship. After the structure tree relationship of multiple target system memory pages is built, these multiple target system memory pages are regarded as a system memory page combination of a structure tree type. Then, the multiple target system memory pages represented by the system memory page combination are compressed by calling the terminal memory compression mechanism to obtain a memory compression block.
[0044] In an embodiment of the present specification, the terminal obtains a target system memory page from a system memory page table, merges the target system memory page to obtain a system memory page combination, compresses the system memory page combination to obtain a system memory compression block, and adopts a method of merging the system memory pages first and then compressing them, thereby further reducing the number of times the terminal memory compression mechanism compresses the system memory pages, thereby greatly improving the memory compression efficiency and compression speed, reducing the compression time, and meeting the growing demand for memory page compression.
[0045] See also Figure 3 , Figure 3 This is a flow chart of another embodiment of a memory processing method proposed in this specification. Specifically:
[0046] S202: taking the reverse order of memory pages in the system memory page table as a reference, dividing at least one memory page interval from the system memory page table, and sampling at least one target system memory page from each of the memory page intervals;
[0047] In a feasible implementation, when the terminal performs memory management and maintains system memory pages, it will sort the system memory pages of the system memory page table in sequence according to the activity of the system memory pages, with the activity decreasing from the head of the system memory page table to the tail of the system memory page table. Based on this, with the reverse order of the memory pages of the system memory page table as a reference, n memory page intervals are divided from the system memory page table, that is, n memory page intervals are divided from the tail of the system memory page table to the front, and i target system memory pages are sampled from each memory page interval in order from the tail to the front, thereby screening out multiple system memory pages to be merged.
[0048] Wherein, n and i are positive integers, and the specific values can be customized based on the actual application situation and are not limited here.
[0049] In this specification, the selection of each target system memory page is discretized by the above method, and the correlation between the target system memories selected by discrete screening is also greatly reduced. This can avoid the need for fast decompression and restoration of system memory pages caused by sudden page faults of multiple related system memory pages when the target system memory pages are subsequently merged and compressed, thereby reducing the urgency of fast decompression and restoration of multiple system memory pages in page fault scenarios.
[0050] S204: Determine a reference application corresponding to a system memory page in the system memory page table, and acquire a target system memory page having an application association relationship from the system memory page based on the reference application;
[0051] Specifically, the kernel of the terminal divides the available memory in the terminal system into system memory pages of specified byte size, and provides the memory to the applications running in the terminal system in units of system memory pages. That is, each system memory page corresponds to an associated reference application. Multiple applications may be running in the terminal system. When an application is placed in the background by the user, since the background will not be used by the user temporarily, the data stored in its system memory page can be compressed and stored, and the data of its system memory page is temporarily released, and the system memory page with temporarily released data can be provided to the foreground process for use.
[0052] In this specification, taking into account that the system memory of the same reference application may also have certain correlations in the future, when a system memory page of a certain application is faulted, multiple system memory pages related to the application may subsequently have the same page fault situation. The method in the sampling related technology requires multiple consecutive decompressions, and this specification introduces a method of merging and then compressing multiple system memories. In the merging process, multiple system memories of the same reference application can be screened out, and multiple system memory pages of the same reference application can be gathered together for merging. When a page fault occurs subsequently, multiple system memory pages of the same reference application can be decompressed at one time, which has the effect of preloading or pre-parsing multiple system memory pages, and to a certain extent reduces the number of page fault interruptions of the same reference application.
[0053] S206: writing the target system memory page into a temporary memory page table, and performing link combination processing on each of the target system memory pages in the temporary memory page table to obtain a system memory page combination;
[0054] In this specification, in order to release system memory, multiple target system memory pages are taken out from the system memory page table. After the target system memory pages are taken out, these target system memory pages do not exist in the system memory page table. In order to avoid related page missing exceptions after the target system memory pages are taken out, a new temporary memory page table is created, and the target system memory pages to be merged are placed in the temporary memory page table. That is, before compressing the target system memory pages, the page missing exception instructions for the target system memory pages can be responded to based on the temporary memory page table, and the relevant data can be provided to the system for processing from the temporary memory page table.
[0055] Specifically, the target system memory page is written into the temporary memory page table, and the target system memory pages in the temporary memory page table are linked and combined to obtain a system memory page combination, for example, the target system memory pages are linked head-to-tail to obtain a system memory page combination.
[0056] In the actual application stage, the target system memory pages may be taken out from the system memory page list in batches. When the separated target system memory pages do not meet the preset threshold (such as a power of 2, such as 2, 4, 8...), they are waited for and not merged and compressed.
[0057] The preset threshold is related to the terminal memory compression mechanism, and the preset threshold can be defined based on the compression mode of the terminal memory compression mechanism.
[0058] In a feasible implementation, if the target number meets a preset threshold, the step of linking and combining the target system memory pages in the temporary memory page table to obtain a system memory page combination is executed; that is, linking and combining the target system memory pages in the temporary memory page table to obtain a system memory page combination, and then transmitting the system memory page combination to the terminal memory compression mechanism for compression to obtain a system memory compression block.
[0059] S208: compressing the system memory page combination to obtain a system memory compression block;
[0060] In a feasible implementation manner, the terminal calls a memory compression service to compress the system memory page combination to obtain a system memory compression block, and generates a memory block structure for the system memory page combination.
[0061] It can be understood that when the system memory page combination is transmitted to the terminal memory compression mechanism for compression, during the compression process, a preset data structure (such as a structure, an array, etc.) is used to store the information of the system memory compression block to obtain a memory block structure for the system memory page combination.
[0062] Optionally, the storage area of the system memory compression block may be a part of the terminal memory space or other storage media.
[0063] Exemplarily, the memory block structure includes at least a page table entry and an offset entry, as follows:
[0064] Each page table entry contains a mapping relationship between the virtual memory address and the physical memory address of a system memory page. Correspondingly, the page table entry corresponding to the system memory page to be compressed also contains the physical memory address and the virtual memory address of the memory page to be compressed. In this specification, the value of the page table entry of each target system memory page in the same system memory page combination can be set to the same target value, that is, no matter which system memory page in the system memory page combination is missing, the memory block structure can be accessed and decompressed, and then these target system memory pages can be restored to the system memory space. Since multiple target system memory pages are decompressed, a pre-reading and pre-loading effect can be achieved.
[0065] Furthermore, since the value of the page table entry of each target system memory page in the same system memory page combination is set to the same target value, an offset item is added based on this to mark each target system memory page, and the offset item represents the page table arrangement order of different target system memory pages in the same system memory page combination.
[0066] Specifically, the terminal executes the generation of the memory block structure for the system memory page combination in the following manner:
[0067] 1. Determine a target page table arrangement order corresponding to each target system memory page in the system memory page combination, and determine a target offset for the target system memory page based on the target page table arrangement order;
[0068] The target page table arrangement order is the page table arrangement order of different target system memory pages in the same system memory page combination. Based on the arrangement order of each target page table, the target offset for the target system memory page can be determined.
[0069] 2. configuring the page table entry of each of the target system memory pages to the same target value, and configuring the offset entry corresponding to the target system memory page based on the target offset;
[0070] 3. Generate a memory block structure including at least the page table entry and the offset entry.
[0071] By adopting the above method, the page table entries of different target system memory pages in the same system memory page combination can be stored as the same value, so that no matter which target system memory page triggers the page fault interrupt, the same system memory compression block will be found, and then another value offset is used to distinguish different target system memory pages in different combinations of the same system memory page, so that no error will occur when they are restored to the memory.
[0072] In an embodiment of the present specification, the terminal obtains the target system memory page from the system memory page table, merges the target system memory page to obtain a system memory page combination, compresses the system memory page combination to obtain a system memory compression block, and adopts a method of merging the system memory pages first and then compressing them, so as to further reduce the number of compression times of the system memory page by the terminal memory compression mechanism, so as to greatly improve the memory compression efficiency and compression speed, reduce the compression time, and meet the growing memory page compression needs; and, set the value of the page table entry of each target system memory page in the same system memory page combination to the same target value, that is, no matter which system memory page in the system memory page combination is missing, the memory block structure can be accessed and decompressed, and then these target system memory pages can be restored to the system memory space. Since multiple target system memory pages are decompressed, a pre-reading and pre-loading effect can be achieved.
[0073] See also Figure 4 , Figure 4 This is a schematic diagram of the effect verification after executing the memory processing method shown in this manual. By splicing pages and compressing them together, the compression speed, decompression speed and compression rate of the same size memory are improved. Specific quantitative data can be obtained here with the help of the memory compression mechanism: benchmark tool. For the data to be compressed, the tool supports setting it to be split into certain occupied memory blocks for compression, such as 4KB, 8KB, etc. The overall test results are as follows Figure 4As shown, when compressing content of the same size, two memory compression mechanisms are shown here: zstd compression and lz4 compression mechanism. The effect verification object is two anonymous page files of 58.com application. Here, the anonymous pages of 58.com application are compressed by zstd as an example. Similar results are also obtained when lz4 is used for compression. When 4 pages (16K) are compressed together, compared with compressing only one page, the speed is increased from 156MB / s to 212MB / s, and the compression speed is improved by 35.9%. The decompression speed is increased from 467MB / s to 666MB / s, and the decompression speed is improved by 42.6%. The compression rate is increased from 26.76% to 23.28%, and the absolute value of the compression rate is increased by 3.48.
[0074] Based on the above effect verification data, the effectiveness of the memory processing method involved in one or more embodiments of this specification is verified, and a good effect is achieved.
[0075] See also Figure 5 , Figure 5 This is a flow chart of another embodiment of a memory processing method proposed in this specification. Specifically:
[0076] S302: In response to a page fault exception instruction for a first system memory page, determining a reference system memory compression block corresponding to the first system memory page from at least one memory block structure;
[0077] The first system memory page can be understood as the system memory page when the current terminal system triggers a system memory page fault exception, and the first system memory page may be compressed. The terminal can respond to the page fault exception instruction for the first system memory page. Since each page table entry contains a mapping relationship between a virtual memory address and a physical memory address of a system memory page, and since the value of the page table entry of each target system memory page in the same system memory page combination is set to the same target value, based on this, the terminal first determines the reference system memory compression block corresponding to the first system memory page from at least one memory block structure by searching the page table entry.
[0078] S304: decompressing the reference system memory compression block to obtain a reference system memory page combination, dividing the reference system memory page combination according to a system memory page specification to obtain at least two second system memory pages, and restoring at least the first system memory page to the system memory based on the reference memory block structure;
[0079] Exemplarily, the terminal decompresses the reference system memory compression block to obtain a reference system memory page combination, divides the reference system memory page combination according to the system memory page specification (such as the system memory page size is 4KB) to obtain at least two second system memory pages, and can quickly locate the first system memory page in the multiple second system memory pages based on the reference memory block structure, and then restore at least the first system memory page to the system memory;
[0080] Optionally, the terminal may restore only the first system memory page to the system memory;
[0081] Optionally, the terminal may restore all second system memory pages to the system memory;
[0082] In a feasible implementation manner, the reference memory block structure generally includes at least a reference page table entry and a reference offset entry, and the terminal performs the restoration of at least the first system memory page to the system memory based on the reference memory block structure in the following manner:
[0083] The terminal may determine the page table arrangement order of each second system memory page based on the reference page table entry and the reference offset entry in the reference memory block structure;
[0084] Then, the terminal determines the first system memory page with the current page fault exception from the second system memory page based on the page table arrangement order, and can restore the first system memory page to the system memory; or, the terminal restores each second system memory page to the system memory according to the page table arrangement order, and each second system memory page includes the first system memory page.
[0085] In an embodiment of the present specification, the terminal obtains the target system memory page from the system memory page table, merges the target system memory page to obtain a system memory page combination, compresses the system memory page combination to obtain a system memory compression block, and adopts a method of merging the system memory pages first and then compressing them, so as to further reduce the number of compression times of the system memory page by the terminal memory compression mechanism, so as to greatly improve the memory compression efficiency and compression speed, reduce the compression time, and meet the growing memory page compression needs; and, set the value of the page table entry of each target system memory page in the same system memory page combination to the same target value, that is, no matter which system memory page in the system memory page combination is missing, the memory block structure can be accessed and decompressed, and then these target system memory pages can be restored to the system memory space. Since multiple target system memory pages are decompressed, a pre-reading and pre-loading effect can be achieved.
[0086] The following will be combined Figure 6 , the memory processing device provided in the embodiment of this specification is introduced in detail. It should be noted that, Figure 6The memory processing device shown is used to execute this instruction Figure 1 to Figure 5 For the convenience of explanation, only the part related to the embodiment of this specification is shown. For the specific technical details not disclosed, please refer to this specification. Figure 1 to Figure 5 The embodiment shown.
[0087] See also Figure 6 , which shows a schematic diagram of the structure of the memory processing device of an embodiment of the present specification. The memory processing device 1 can be implemented as all or part of the user terminal through software, hardware or a combination of both. According to some embodiments, the memory processing device 1 includes an acquisition module 11 and a processing module 12, which are specifically used to:
[0088] An acquisition module 11 is used to acquire a target system memory page from a system memory page table;
[0089] The processing module 12 is used to merge the target system memory pages to obtain a system memory page combination, and compress the system memory page combination to obtain a system memory compression block.
[0090] Optionally, the acquisition module 11 is used to:
[0091] Taking the reverse order of memory pages of the system memory page table as a reference, a target system memory page is obtained from the system memory page table.
[0092] Optionally, the acquisition module 11 is used to:
[0093] Dividing at least one memory page interval from the system memory page table, and sampling at least one target system memory page from each of the memory page intervals; and / or,
[0094] A reference application corresponding to a system memory page in the system memory page table is determined, and a target system memory page having an application association relationship is acquired from the system memory page based on the reference application.
[0095] Optionally, the processing module 12 is used to:
[0096] The target system memory page is written into a temporary memory page table, and link combination processing is performed on each of the target system memory pages in the temporary memory page table to obtain a system memory page combination.
[0097] Optionally, the processing module 12 is used to:
[0098] Monitoring a target number of target system memory pages in the temporary memory page table;
[0099] If the target number meets the preset threshold, the step of linking and combining the target system memory pages in the temporary memory page table to obtain a system memory page combination is executed.
[0100] Optionally, the processing module 12 is used to:
[0101] Invoking a memory compression service to compress the system memory page combination to obtain a system memory compression block;
[0102] And, a memory block structure for the system memory page combination is generated.
[0103] Optionally, the memory block structure includes at least a page table entry and an offset entry, and the processing module 12 is used to:
[0104] Determine a target page table arrangement order corresponding to each target system memory page in the system memory page combination, and determine a target offset for the target system memory page based on the target page table arrangement order;
[0105] Configuring the page table entry of each target system memory page to be the same target value, and configuring the offset item corresponding to the target system memory page based on the target offset;
[0106] A memory block structure is generated which includes at least the page table entry and the offset entry.
[0107] Optionally, the device 1 is further used for:
[0108] In response to a page fault exception instruction for a first system memory page, determining a reference system memory compression block corresponding to the first system memory page from at least one memory block structure;
[0109] The reference system memory compression block is decompressed to obtain at least two second system memory pages, and at least the first system memory page is restored to the system memory based on the reference memory block structure.
[0110] Optionally, the reference memory block structure includes at least a reference page table entry and a reference offset entry, and the device 1 is further used for:
[0111] Determine a page table arrangement order of each second system memory page based on the reference page table entry and the reference offset entry in the reference memory block structure;
[0112] Determine the first system memory page from the second system memory page based on the page table arrangement order, and restore the first system memory page to the system memory; or, restore each second system memory page to the system memory according to the page table arrangement order, wherein each second system memory page includes the first system memory page.
[0113] It should be noted that the memory processing device provided in the above embodiment only uses the division of the above functional modules as an example when executing the memory processing method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the memory processing device provided in the above embodiment and the memory processing method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
[0114] The serial numbers of the embodiments of this specification are for description only and do not represent the advantages or disadvantages of the embodiments.
[0115] In one or more embodiments of the present specification, the terminal obtains the target system memory page from the system memory page table, merges the target system memory page to obtain a system memory page combination, compresses the system memory page combination to obtain a system memory compression block, and adopts a method of merging the system memory pages first and then compressing them to further reduce the number of times the terminal memory compression mechanism compresses the system memory pages, so as to greatly improve the memory compression efficiency and compression speed, reduce the compression time, and meet the growing demand for memory page compression.
[0116] The present specification also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figure 1 to Figure 5 The memory processing method of the embodiment shown in the figure can be specifically executed by referring to Figure 1 to Figure 5 The specific description of the illustrated embodiment will not be repeated here.
[0117] The present specification also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor as described above. Figure 1 to Figure 5 The memory processing method of the embodiment shown in the figure can be specifically executed by referring to Figure 1 to Figure 5 The specific description of the illustrated embodiment will not be repeated here.
[0118] Please refer to Figure 7 , which shows a block diagram of the structure of an electronic device provided by an exemplary embodiment of this specification. The electronic device in this specification may include one or more of the following components: a processor 110, a memory 120, an input device 130, an output device 140, and a bus 150. The processor 110, the memory 120, the input device 130, and the output device 140 may be connected via the bus 150.
[0119] 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, 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 (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 110 can integrate one or a combination of a central processing unit (CPU), a 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 display content; 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.
[0120] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 120 includes a non-transitory computer-readable storage medium. 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 at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The operating system may be an Android system, including a system deeply developed based on the Android system, an IOS system developed by Apple, including a system deeply developed based on the IOS system or other systems. The data storage area may also store data created by the electronic device during use, such as a phone book, audio and video data, chat record data, etc.
[0121] See also Figure 8As shown, the memory 120 can be divided into an operating system space and a user space. The operating system runs in the operating system space, and native and third-party applications run in the user space. In order to ensure that different third-party applications can achieve good operating results, the operating system allocates corresponding system resources to different third-party applications. However, different application scenarios in the same third-party application also have different requirements for system resources. For example, in the local resource loading scenario, the third-party application has higher requirements for disk reading speed; in the animation rendering scenario, the third-party application has higher requirements for GPU performance. The operating system and third-party applications are independent of each other, and the operating system often cannot perceive the current application scenario of the third-party application in a timely manner, resulting in the operating system being unable to perform targeted system resource adaptation according to the specific application scenario of the third-party application.
[0122] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to open up data communication between third-party applications and the operating system so that the operating system can obtain the current scenario information of third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.
[0123] Taking the Android operating system as an example, the programs and data stored in the memory 120 are as follows: Fig. 9As shown, the memory 120 may store a Linux kernel layer 320, a system runtime library layer 340, an application framework layer 360 and an application layer 380, wherein the Linux kernel layer 320, the system runtime library layer 340 and the application framework layer 360 belong to the operating system space, and the application layer 380 belongs to the user space. The Linux kernel layer 320 provides underlying drivers for various hardware of electronic devices, such as display drivers, audio drivers, camera drivers, Bluetooth drivers, Wi-Fi drivers, power management, etc. The system runtime library layer 340 provides the main feature support for the Android system through some C / C++ libraries. For example, the SQLite library provides database support, the OpenGL / ES library provides 3D drawing support, and the Webkit library provides browser kernel support, etc. The Android runtime library (Android runtime) is also provided in the system runtime library layer 340, which mainly provides some core libraries that allow developers to use the Java language to write Android applications. The application framework layer 360 provides various APIs that may be used when building applications. Developers can also use these APIs to build their own applications, such as activity management, window management, view management, notification management, content provider, package management, call management, resource management, and location management. At least one application runs in the application layer 380. These applications can be native applications that come with the operating system, such as contact applications, text messaging applications, clock applications, camera applications, etc.; they can also be third-party applications developed by third-party developers, such as game applications, instant messaging applications, photo beautification applications, etc.
[0124] Taking the operating system as an IOS system as an example, the programs and data stored in the memory 120 are as follows: Fig.10As shown, the IOS system includes: a core operating system layer 420 (Core OS layer), a core service layer 440 (Core Services layer), a media layer 460 (Media layer), and a touchable layer 480 (Cocoa Touch Layer). The core operating system layer 420 includes the operating system kernel, drivers, and underlying program frameworks, which provide functions closer to the hardware for use by the program framework located in the core service layer 440. The core service layer 440 provides system services and / or program frameworks required by the application, such as the foundation framework, account framework, advertising framework, data storage framework, network connection framework, geographic location framework, motion framework, etc. The media layer 460 provides audio-visual interfaces for the application, such as graphics and image related interfaces, audio technology related interfaces, video technology related interfaces, and wireless playback (AirPlay) interfaces for audio and video transmission technologies. The touchable layer 480 provides various commonly used interface-related frameworks for application development, and the touchable layer 480 is responsible for the user's touch interaction operations on the electronic device. For example, local notification service, remote push service, advertising framework, game tool framework, message user interface (UI) framework, user interface UIKit framework, map framework, etc.
[0125] exist Fig.10 Among the frameworks shown, the frameworks related to most applications include but are not limited to: the basic framework in the core service layer 440 and the UIKit framework in the touchable layer 480. The basic framework provides many basic object classes and data types, provides the most basic system services for all applications, and has nothing to do with UI. The classes provided by the UIKit framework are basic UI class libraries for creating touch-based user interfaces. iOS applications can provide UIs based on the UIKit framework, so it provides the basic architecture of applications for building user interfaces, drawing, processing and user interaction events, responding to gestures, etc.
[0126] Among them, the method and principle of implementing data communication between third-party applications and the operating system in the IOS system can be referred to the Android system, and this manual will not go into details here.
[0127] Among them, the input device 130 is used to receive input instructions or data, and the input device 130 includes but is not limited to a keyboard, a mouse, a camera, a microphone or a touch device. The output device 140 is used to output instructions or data, and the output device 140 includes but is not limited to a display device and a speaker. In one example, the input device 130 and the output device 140 can be combined, and the input device 130 and the output device 140 are touch screen displays, which are used to receive touch operations on or near the user using any suitable object such as a finger or a touch pen, and to display the user interface of each application. The touch screen display is usually set on the front panel of the electronic device. The touch screen display can be designed as a full screen, a curved screen or a special-shaped screen. The touch screen display can also be designed as a combination of a full screen and a curved screen, or a combination of a special-shaped screen and a curved screen, which is not limited in the embodiments of this specification.
[0128] In addition, those skilled in the art will appreciate that the structure of the electronic device shown in the above drawings does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown, or combine certain components, or arrange the components differently. For example, the electronic device also includes a radio frequency circuit, an input unit, a sensor, an audio circuit, a wireless fidelity (WiFi) module, a power supply, a Bluetooth module and other components, which will not be described in detail here.
[0129] In the embodiments of this specification, the execution subject of each step may be the electronic device described above. Optionally, the execution subject of each step is the operating system of the electronic device. The operating system may be an Android system, an IOS system, or other operating systems, which is not limited in the embodiments of this specification.
[0130] The electronic device of the embodiment of this specification may also be equipped with a display device, which may be various devices capable of realizing display functions, such as cathode ray tube display (CR), light-emitting diode display (LED), electronic ink screen, liquid crystal display (LCD), plasma display panel (PDP), etc. The user may use the display device on the electronic device 101 to view displayed text, images, videos and other information. The electronic device may be a smart phone, a tablet computer, a gaming device, an AR (Augmented Reality) device, a car, a data storage device, an audio playback device, a video playback device, a notebook, a desktop computing device, a wearable device such as an electronic watch, an electronic glasses, an electronic helmet, an electronic bracelet, an electronic necklace, electronic clothing and other devices.
[0131] exist Figure 7 In the electronic device shown, where the electronic device may be a terminal, the processor 110 may be used to call an application stored in the memory 120 and specifically perform the following operations:
[0132] Get the target system memory page from the system memory page table;
[0133] The target system memory pages are merged to obtain a system memory page combination, and the system memory page combination is compressed to obtain a system memory compression block.
[0134] In one embodiment, the processor 110 performs the following operations when executing the method of obtaining the target system memory page from the system memory page table:
[0135] Taking the reverse order of memory pages of the system memory page table as a reference, a target system memory page is obtained from the system memory page table.
[0136] In one embodiment, the processor 110 performs the following operations when executing the step of obtaining the target system memory page from the system memory page table:
[0137] Dividing at least one memory page interval from the system memory page table, and sampling at least one target system memory page from each of the memory page intervals; and / or,
[0138] A reference application corresponding to a system memory page in the system memory page table is determined, and a target system memory page having an application association relationship is acquired from the system memory page based on the reference application.
[0139] In one embodiment, the processor 110 performs the following operations when performing the merging process on the target system memory pages to obtain a system memory page combination:
[0140] The target system memory page is written into a temporary memory page table, and link combination processing is performed on each of the target system memory pages in the temporary memory page table to obtain a system memory page combination.
[0141] In one embodiment, the processor 110 performs the following operations when performing the link combination processing on each of the target system memory pages in the temporary memory page table to obtain a system memory page combination:
[0142] Monitoring a target number of target system memory pages in the temporary memory page table;
[0143] If the target number meets the preset threshold, the step of linking and combining the target system memory pages in the temporary memory page table to obtain a system memory page combination is executed.
[0144] In one embodiment, the processor 110 performs the following operations when performing the compression process on the system memory page combination to obtain a system memory compression block:
[0145] Invoking a memory compression service to compress the system memory page combination to obtain a system memory compression block;
[0146] And, a memory block structure for the system memory page combination is generated.
[0147] In one embodiment, the memory block structure includes at least a page table entry and an offset entry. When the processor 110 generates a memory block structure for the system memory page combination, the processor 110 performs the following operations:
[0148] Determine a target page table arrangement order corresponding to each target system memory page in the system memory page combination, and determine a target offset for the target system memory page based on the target page table arrangement order;
[0149] Configuring the page table entry of each target system memory page to be the same target value, and configuring the offset item corresponding to the target system memory page based on the target offset;
[0150] A memory block structure is generated which includes at least the page table entry and the offset entry.
[0151] In one embodiment, the processor 110 further performs the following operations when executing the memory processing method:
[0152] In response to a page fault exception instruction for a first system memory page, determining a reference system memory compression block corresponding to the first system memory page from at least one memory block structure;
[0153] The reference system memory compression block is decompressed to obtain at least two second system memory pages, and at least the first system memory page is restored to the system memory based on the reference memory block structure.
[0154] In one embodiment, the reference memory block structure includes at least a reference page table entry and a reference offset entry. When the processor 110 restores at least the first system memory page to the system memory based on the reference memory block structure, the processor 110 performs the following operations:
[0155] Determine a page table arrangement order of each second system memory page based on the reference page table entry and the reference offset entry in the reference memory block structure;
[0156] Determine the first system memory page from the second system memory page based on the page table arrangement order, and restore the first system memory page to the system memory; or, restore each second system memory page to the system memory according to the page table arrangement order, wherein each second system memory page includes the first system memory page.
[0157] In an embodiment of the present specification, the terminal obtains a target system memory page from a system memory page table, merges the target system memory page to obtain a system memory page combination, compresses the system memory page combination to obtain a system memory compression block, and adopts a method of merging the system memory pages first and then compressing them, thereby further reducing the number of times the terminal memory compression mechanism compresses the system memory pages, thereby greatly improving the memory compression efficiency and compression speed, reducing the compression time, and meeting the growing demand for memory page compression.
[0158] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0159] The above disclosure is only the preferred embodiment of this specification, which certainly cannot be used to limit the scope of rights of this specification. Therefore, equivalent changes made according to the claims of this specification are still within the scope covered by this specification.
Claims
1. A memory processing method, characterized in that: The method comprises: Get the target system memory page from the system memory page table; The target system memory pages are merged to obtain a system memory page combination, and the system memory page combination is compressed to obtain a system memory compression block.
2. The method according to claim 1, characterized in that The obtaining of the target system memory page from the system memory page table includes: Taking the reverse order of memory pages of the system memory page table as a reference, a target system memory page is obtained from the system memory page table.
3. The method according to claim 2, characterized in that The obtaining a target system memory page from the system memory page table includes: Dividing at least one memory page interval from the system memory page table, and sampling at least one target system memory page from each of the memory page intervals; and / or, A reference application corresponding to a system memory page in the system memory page table is determined, and a target system memory page having an application association relationship is acquired from the system memory page based on the reference application.
4. The method according to claim 1, characterized in that: The merging of the target system memory pages to obtain a system memory page combination includes: The target system memory page is written into a temporary memory page table, and link combination processing is performed on each of the target system memory pages in the temporary memory page table to obtain a system memory page combination.
5. The method according to claim 4, characterized in that The link combination processing of each target system memory page in the temporary memory page table to obtain a system memory page combination includes: Monitoring a target number of target system memory pages in the temporary memory page table; If the target number meets the preset threshold, the step of linking and combining the target system memory pages in the temporary memory page table to obtain a system memory page combination is executed.
6. The method according to claim 1, characterized in that The compressing the system memory page combination to obtain a system memory compression block includes: Invoking a memory compression service to compress the system memory page combination to obtain a system memory compression block; And, a memory block structure for the system memory page combination is generated.
7. The method according to claim 6, characterized in that The memory block structure at least includes a page table entry and an offset entry. The generating of a memory block structure for the system memory page combination includes: Determine a target page table arrangement order corresponding to each target system memory page in the system memory page combination, and determine a target offset for the target system memory page based on the target page table arrangement order; Configuring the page table entry of each target system memory page to be the same target value, and configuring the offset item corresponding to the target system memory page based on the target offset; A memory block structure is generated which includes at least the page table entry and the offset entry.
8. The method according to claim 1, characterized in that The method further comprises: In response to a page fault exception instruction for a first system memory page, determining a reference system memory compression block corresponding to the first system memory page from at least one memory block structure; Decompress the reference system memory compression block to obtain a reference system memory page combination, divide the reference system memory page combination according to the system memory page specification to obtain at least two second system memory pages, and restore at least the first system memory page to the system memory based on the reference memory block structure.
9. The method according to claim 8, characterized in that The reference memory block structure at least includes a reference page table entry and a reference offset entry. The restoring at least the first system memory page to the system memory based on the reference memory block structure includes: Determine a page table arrangement order of each second system memory page based on the reference page table entry and the reference offset entry in the reference memory block structure; Determine the first system memory page from the second system memory page based on the page table arrangement order, and restore the first system memory page to the system memory; or, restore each second system memory page to the system memory according to the page table arrangement order, wherein each second system memory page includes the first system memory page.
10. A memory processing device, characterized in that: Applied to a terminal, the device comprises: An acquisition module, used for acquiring a target system memory page from a system memory page table; The processing module is used to merge the target system memory pages to obtain a system memory page combination, and compress the system memory page combination to obtain a system memory compression block.
11. A computer storage medium, characterized in that: The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 9.
12. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 9.