Memory swapping method, memory access management method, electronic device, and computer storage medium

By dividing the memory page into sub-memory pages and using a shared compressed dictionary, the problem of poor memory switching efficiency in the prior art is solved, and more efficient memory switching and data compression are achieved.

WO2025163416A1PCT designated stage Publication Date: 2025-08-07CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/IB2025/050504
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-01-31
Filing Date
2025-01-17
Publication Date
2025-08-07

AI Technical Summary

Technical Problem

In existing memory switching solutions, the overhead and compression time and compression ratio are difficult to weigh, resulting in poor memory switching efficiency.

Method used

Divide the memory page into multiple sub-memory pages, and compress the feature data blocks in each sub-memory page through a shared compression dictionary, generate a compressed page, store it in the memory swap out area, and restore the compressed page to a sub-memory page when decompressed.

Benefits of technology

It improves the compression rate and data compression efficiency of memory switching, reduces the storage space and loading time occupied by the compressed dictionary, and improves the overall efficiency of memory switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure IB2025050504_07082025_PF_FP_ABST
    Figure IB2025050504_07082025_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a memory swapping method, a memory access management method, an electronic device, and a computer storage medium. The memory swapping method comprises: dividing a memory page into a plurality of sub-memory pages; on the basis of a compression dictionary, compressing a feature data block in each sub-memory page into a corresponding compressed block to obtain a plurality of compressed pages of the plurality of sub-memory pages, wherein the compression dictionary is shared by the plurality of sub-memory pages, and the compression dictionary indicates a correspondence between a preset feature data block and a compressed block of the preset feature data block; and storing the plurality of compressed pages in a memory swap-out area of the memory page.
Need to check novelty before this filing date? Find Prior Art

Description

Memory swap method, memory access management method, electronic device and computer storage medium Technical field

[0001] The embodiments of the present application relate to the field of computer technology, and more particularly to a memory exchange method, a memory access management method, an electronic device, and a computer storage medium.

[0002] Typically, cloud service backend memory can be categorized based on its access frequency, for example, into hot memory and cold memory. Hot memory refers to frequently accessed and frequently used memory areas, typically containing currently active data and program code. This data and code requires fast access to improve system performance and responsiveness. Cold memory refers to memory areas in a computer system that are rarely accessed or used frequently.

[0003] Elastic Memory technology is a memory management technology designed for the ever-changing workload requirements in dynamic environments such as cloud computing. It aims to provide more flexible and efficient management of application memory requirements.

[0004] Elastic memory technology involves swapping memory pages, such as cold memory, to other storage media as a memory swap-out area. This frees up the memory space occupied by cold memory pages for use by other applications, thereby improving memory usage efficiency. Specifically, factors affecting memory swap efficiency in elastic memory technology include the time overhead of compression and decompression, as well as the compression rate. Current memory swap solutions struggle to balance the time overhead of compression and decompression with the compression rate for memory pages of a specific size, resulting in suboptimal memory swap efficiency.

[0005] In view of this, embodiments of the present application provide a memory swap method, a memory access management method, an electronic device, and a computer storage medium to at least partially solve the above problems.

[0006] According to a first aspect of an embodiment of the present application, a memory swap method is provided, comprising: dividing a memory page into a plurality of sub-memory pages; compressing a characteristic data block in each sub-memory page into a corresponding compressed block based on a compression dictionary to obtain a plurality of compressed pages of the plurality of sub-memory pages, wherein the compression dictionary is shared by the plurality of sub-memory pages and indicates a correspondence between preset characteristic data blocks and compressed blocks of the preset characteristic data blocks; and storing the plurality of compressed pages in a memory swap-out area of the memory page.

[0007] According to a second aspect of an embodiment of the present application, a memory swap method is provided, comprising: decompressing a target compressed page compressed block in each compressed page of a memory swap-out area into a feature data block based on a compression dictionary, obtaining a target sub-memory block; The target sub-memory page is stored in a memory swap-in area; and the target sub-memory page is accessed in the memory swap-in area.

[0008] According to a third aspect of an embodiment of the present application, a memory access management method is provided, comprising: when an access frequency of a memory page is lower than a preset access frequency threshold, dividing the memory page into multiple sub-memory pages; compressing a characteristic data block in each sub-memory page into a corresponding compressed block based on a compression dictionary to obtain multiple compressed pages of the multiple sub-memory pages, wherein the compression dictionary is shared by the multiple sub-memory pages and indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block; storing the multiple compressed pages in a memory swap-out area of the memory page; in response to a memory access request, decompressing a target compressed page compressed block in each compressed page of the memory swap-out area into a characteristic data block based on the compression dictionary to obtain a target sub-memory page, wherein the compression dictionary is shared by the various compressed pages and indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block; storing the target sub-memory page in a memory swap-in area; and accessing the target sub-memory page in the memory swap-in area.

[0009] According to a fourth aspect of an embodiment of the present application, a memory swap device is provided, comprising: a partitioning module, configured to partition a memory page into multiple sub-memory pages; a compression module, configured to compress a characteristic data block in each sub-memory page into a corresponding compressed block based on a compression dictionary, thereby obtaining multiple compressed pages of the multiple sub-memory pages, wherein the compression dictionary is shared by the multiple sub-memory pages and indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block; and a storage module, configured to store the multiple compressed pages in a memory swap-out area of the memory page.

[0010] According to a fifth aspect of an embodiment of the present application, a memory swap device is provided, comprising: a decompression module, configured to decompress a target compressed page compression block in each compressed page of a memory swap-out area into a characteristic data block based on a compression dictionary to obtain a target sub-memory page, wherein the compression dictionary is shared by each compressed page and indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block; a storage module, configured to store the target sub-memory page in a memory swap-in area; and an access module, configured to access the sub-memory page in the memory swap-in area.

[0011] According to a sixth aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, wherein the executable instruction enables the processor to perform an operation corresponding to the method described in the first aspect, the second aspect, or the third aspect.

[0012] According to a seventh aspect of the embodiments of the present application, a computer storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method as described in the first aspect, the second aspect or the third aspect is implemented.

[0013] In the embodiment of the present application, the compression dictionary indicates the relationship between the preset feature data block and the preset feature data block. The corresponding relationship between compression blocks is established. Therefore, based on the compression dictionary, the characteristic data blocks in each sub-memory page are compressed into corresponding compressed blocks, ensuring the compression efficiency of each sub-memory page. Furthermore, the compression dictionary is shared by multiple sub-memory pages divided by the memory page, and multiple compressed pages are stored in the memory swap area of the memory page. Compared with the case where a compression dictionary is generated for each sub-memory page, this reduces the storage space occupied by the compression dictionary and improves the compression ratio of memory swapping. Furthermore, the compression dictionary is shared by multiple sub-memory pages divided by the memory page, saving compression dictionary loading time, improving data compression efficiency, and thus improving the efficiency of memory swapping. Figure Description

[0014] To more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments described in the embodiments of the present application. Those skilled in the art can also obtain other drawings based on these drawings.

[0015] FIG1 is a schematic diagram of a data compression process of memory swapping in some embodiments of the present application.

[0016] FIG2 is a flowchart of the steps of a memory swap method according to some other embodiments of the present application.

[0017] FIG3 is a schematic diagram of a data compression process of memory exchange according to some other embodiments of the present application.

[0018] FIG4 is a flowchart of the steps of a memory swap method according to some other embodiments of the present application.

[0019] FIG5 is a flowchart of the steps of a memory swap method according to some other embodiments of the present application.

[0020] FIG6 is a schematic diagram of a data decompression process of memory exchange according to some other embodiments of the present application.

[0021] FIG7 is a flowchart of the steps of a memory swap method according to some other embodiments of the present application.

[0022] FIG8 is a flowchart of the steps of the memory access management method according to some other embodiments of the present application.

[0023] FIG9 is a schematic block diagram of a memory exchange device according to some other embodiments of the present application.

[0024] FIG10 is a schematic block diagram of a memory exchange device according to some other embodiments of the present application.

[0025] FIG11 is a schematic diagram of the structure of electronic devices according to some other embodiments of the present application.

[0026] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions 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. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by persons of ordinary skill in the art shall fall within the scope of protection of the embodiments of this application.

[0027] The specific implementation of the embodiment of the present application is further explained below in conjunction with the accompanying drawings of the embodiment of the present application.

[0028] As an example of elastic memory technology, the operating system can examine all memory pages in memory and determine which memory pages are cold memory, that is, memory pages that have been least recently accessed or used. The operating system then compresses the cold memory pages, for example, using a compression algorithm based on a compression dictionary to compress the data in the memory pages and simultaneously transfer the memory page's storage space to free up the original memory storage space. Furthermore, during the compression process, the operating system maintains a compression address table for the compressed memory pages, recording the address mapping relationship between each memory page before and after compression.

[0029] When necessary, such as when a memory page access is foreseeable, the operating system decompresses the compressed page and swaps it in. Specifically, when a process needs to access a previously compressed memory page, the operating system locates the corresponding compressed page based on the compression address table. The operating system then reads the compressed page from the swap-out area into the swap-in area for decompression, restoring it to the original memory page. Once decompression is complete, the operating system loads the decompressed page into appropriate storage space, allowing the process to access and use the page normally.

[0030] Specifically, elastic memory technology involves swapping memory pages, such as cold memory, to other storage media as a memory swap-out area. This frees up the memory space occupied by these pages for use by other applications, thereby improving memory usage efficiency. Factors influencing memory swap efficiency in elastic memory technology include the compression and decompression time overhead and the compression ratio. Current memory swap solutions struggle to balance compression and decompression time overhead with compression ratio for memory pages of a specific size, resulting in suboptimal memory swap efficiency.

[0031] In the example shown in Figure 1, the compression and decompression processes of Elastic Memory technology are performed in memory pages. The memory pages in the server can be 4KB or 2MB. Compression and decompression of memory pages in 4KB units takes less time, is more efficient, and has a lower data compression ratio. Compression and decompression of memory pages in 2MB units takes longer time, is less efficient, and has a higher data compression ratio. Both compression and decompression efficiency and data compression ratio affect service performance.

[0032] For example, compression algorithms such as Zstandard and Lempel-Ziv-4 use compression dictionaries to compress repeated feature data blocks. As shown in Figure 1, a compression dictionary (compression dictionary 1-N) is generated for each memory page (memory page 1-N) in the memory page storage space and stored in the memory swap area. The compression dictionary is then used to compress the data in the memory page, and the compressed memory page is associated with the corresponding compression dictionary for storage. In this case, both the generation and loading of the compression dictionary consumes Time, resulting in memory exchange efficiency not being optimal, and the compression dictionary itself needs to occupy memory space, resulting in data compression rate not being optimal.

[0033] The memory swap method according to other embodiments of the present application will be described in detail below with reference to FIG2 . The memory swap method of FIG2 can be executed using an operating system of an electronic device, which may be a terminal device or a server. Specifically, the memory swap method includes S210 to S230.

[0034] S210: Divide the memory page into multiple sub-memory pages.

[0035] It should be understood that the operating system may examine all memory pages in the memory and determine which memory pages are to be compressed. The operating system then divides the memory pages to be compressed into multiple sub-memory pages. For example, the memory pages to be compressed may be memory pages with low access frequency or low usage frequency, such as memory pages in cold memory.

[0036] That is, when the access frequency of a memory page is lower than a preset access frequency threshold, the operating system can divide the memory page into multiple sub-memory pages. If the access frequency is lower than the preset access frequency threshold, the memory is considered to be cold memory, thereby starting the memory swap process.

[0037] S220: Compress the characteristic data blocks in each sub-memory page into corresponding compressed blocks based on a compression dictionary, obtaining multiple compressed pages of the multiple sub-memory pages. The compression dictionary is shared by the multiple sub-memory pages, and the compression dictionary indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block.

[0038] It should be understood that compression algorithms such as Zstandard and Lempel-Ziv-4 compress repeated feature data blocks using a compression dictionary. The compression field stores the correspondence between pre-set feature data blocks and their compressed blocks. Therefore, feature data blocks can be compressed into compressed blocks, and compressed blocks can be decompressed into feature data blocks.

[0039] S230: Storing the plurality of compressed pages in a memory swap-out area of the memory page.

[0040] It should be understood that the memory swap-out area can be adjacent to the previous storage area of the memory page to improve memory swap-out efficiency. During memory swap-in, if the previous storage area of the memory page is idle, the previous storage area of the memory page can be preferentially determined as the memory swap-in area.

[0041] It should also be understood that after the memory is swapped out, memory access management can be achieved by changing the readable and writable state of the memory page in the kernel address table of the operating system. For example, the readable and writable state of the memory page in the kernel address table can be changed to a read-only state. In this case, when accessing the table entry of the memory page in the kernel address table of the operating system, a memory page exception will be triggered.

[0042] In the embodiment of the present application, the compression dictionary indicates the correspondence between the preset feature data block and the compressed block of the preset feature data block. Therefore, based on the compression dictionary, the feature data block in each sub-memory page is compressed into the corresponding compressed block, thereby ensuring the compression efficiency of each sub-memory page. In addition, the compression dictionary is divided into multiple sub-memory pages by the memory page. Sharing: Multiple compression pages and compression dictionaries are associated and stored in the memory swap-out area of the memory page. Compared with generating a compression dictionary for each sub-memory page, this reduces the storage space occupied by the compression dictionary and improves the compression ratio of memory swapping. In addition, the compression dictionary is shared by multiple sub-memory pages divided by the memory page, saving compression dictionary loading time, improving data compression efficiency, and thus improving the efficiency of memory swapping.

[0043] In some examples, as shown in FIG3 , a memory page in a memory page storage space (ie, cold memory) includes sub-memory pages 1-N. The compression dictionary is shared by multiple sub-memory pages divided by the memory page, and is used by each compressed sub-memory page 1-N. (i.e., compressed pages) are stored in the memory swap-out area.

[0044] In other embodiments, before dividing a memory page into multiple sub-memory pages, the memory swap method further includes: traversing each data block in the memory page, determining data blocks whose occurrence frequency exceeds a preset frequency threshold as preset characteristic data blocks, and then establishing a correspondence between the preset characteristic data blocks and compressed blocks of the preset characteristic data blocks to generate a compression dictionary. In other words, determining data blocks whose occurrence frequency exceeds the preset frequency threshold as preset characteristic data blocks further improves the matching degree between the characteristic data blocks and the data blocks in the memory page, thereby ensuring a certain data compression rate by using the preset frequency threshold.

[0045] Furthermore, the data blocks can be divided into training data blocks within a memory page by varying the data block length. When the cumulative frequency of occurrence of each training data block reaches a maximum, each training data block is determined as a data block within the memory page. This processing method traverses each training data block within the memory page for training and generates a compression dictionary, improving the matching degree between the characteristic data blocks in the compression dictionary and the data blocks within the memory page, thereby achieving an optimal data compression rate.

[0046] In other embodiments, the memory swap method further includes: storing a compression dictionary in a memory swap-out area of the memory page before dividing the memory page into multiple sub-memory pages. Accordingly, storing the multiple compressed pages in the memory swap-out area of the memory page includes associating the multiple compressed pages with the compression dictionary and storing them in the memory swap-out area of the memory page. In other words, pre-storing the compression dictionary in the memory swap-out area of the memory page and then associating the multiple compressed pages with the compression dictionary and storing them in the memory swap-out area of the memory page facilitates improving the compression efficiency of the compression process for each sub-memory page.

[0047] Furthermore, storing the plurality of compressed pages in association with the compression dictionary in the memory swap-out area of the memory page includes: generating a physical address of the compressed page based on a base address of the compression dictionary in the memory swap-out area and an offset of each compressed page; and then storing the compressed page in the memory swap-out area based on the physical address of the compressed page. By storing the compression dictionary at the base address and storing each compressed page using an offset based on the base address, the efficiency of compression dictionary access management can be further improved, thereby increasing the granularity of memory swap management.

[0048] Furthermore, the step of associating the plurality of compressed pages with the compression dictionary and storing them in the memory swap-out area of the memory page further includes: The compressed address table between each sub-memory page and its compressed page is stored in the memory swap area. For example, the compressed address table can be associated with the operating system's kernel address table using the physical address of each sub-memory page. This allows access to the compressed address table by accessing the kernel address table, improving the efficiency of access management for compressed pages in memory swapping. In other words, the compressed address table is associated with (e.g., mounted to) the memory page's entry in the operating system's kernel address table, thereby maintaining compatibility with the operating system's address management algorithm.

[0049] In other embodiments, the memory swap method further includes: determining virtual addresses and corresponding physical addresses of multiple memory pages based on a memory page entry in an operating system's kernel address table; and modifying the entry into multiple sub-entries, each of which indicates a correspondence between the virtual addresses and physical addresses of the multiple memory pages. This processing approach allows for memory swapping based on memory pages while also enabling management based on sub-memory pages, thereby improving the granularity of memory page management.

[0050] In other embodiments, the memory swap method further includes: before dividing the memory page into multiple sub-memory pages, changing the memory page mode from read-write to read-only in the table entry. This process prevents uncompressed sub-memory pages from being read, thereby improving the reliability of memory swapping. Furthermore, since the memory page cannot be written to in read-only mode, utilizing the read-only mode can trigger a memory page exception, thereby performing subsequent decompression of the compressed memory page.

[0051] In other embodiments, the memory swap method further includes: after decompressing at least one compressed page from the memory swap-out area to the memory swap-in area, changing the at least one compressed page from read-only mode to read-write mode in the sub-table entry corresponding to the at least one compressed page. This processing method triggers decompression of the compressed memory page, as the memory page cannot be written to in read-only mode. The memory page can then be written to in read-write mode, allowing write access to the memory page. Furthermore, while performing memory swap based on a memory page, decompression can also be performed based on a sub-compressed page, thereby improving the granularity of memory page management.

[0052] Specifically, as an example of dividing a memory page into multiple sub-memory pages, the memory page can be divided into multiple sub-memory pages when the access frequency of the memory page is lower than a preset access frequency threshold. With this processing approach, when the access frequency of a memory page is lower than the preset access frequency threshold, the memory page can be determined to be cold memory. The memory page is then divided into multiple sub-memory pages, and memory swapping is performed on the memory page, freeing up the memory space occupied by the memory page for use by other applications or data, thereby improving memory usage efficiency.

[0053] Specifically, when the access frequency of a memory page is lower than a preset access frequency threshold, a compression dictionary may be stored based on a base address of a memory swap-out area of the memory page, and then the memory page may be divided into a plurality of sub-memory pages.

[0054] FIG4 is a flowchart of the steps of the memory exchange method of another embodiment of the present application. Including S410 to S450.

[0055] S410: When the access frequency of the memory page is lower than a preset access frequency threshold, a compression dictionary is stored based on a base address of a memory swap-out area of the memory page.

[0056] S420: Divide the memory page into multiple sub-memory pages.

[0057] S430: Compress the data blocks matching the preset characteristic data blocks in each memory page into corresponding compressed blocks to obtain a compressed page.

[0058] S440: Generate a physical address of each compressed page based on the base address and the offset of the compressed page.

[0059] S450: Based on the physical address of the compressed page, store the compressed page in the memory swap-out area.

[0060] It should be understood that the description and explanation of the execution process of the memory swap method in FIG. 4 may refer to the various steps of the memory swap method in FIG. 2 , and will not be repeated here.

[0061] The memory exchange method of other embodiments of the present application will be described in detail below with reference to Figure 5. The memory exchange method of Figure 5 includes S510 to S530.

[0062] S510: Decompress target compressed page compressed blocks in each compressed page of the memory swap-out area into characteristic data blocks based on a compression dictionary to obtain a target sub-memory page. The compression dictionary is shared by each compressed page and indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block.

[0063] It should be understood that the memory swap-out area of a memory page can be determined using management information used to manage memory swapping. For example, the management information may include a memory page identifier or a sub-memory page identifier. Furthermore, the management information may include a compression mapping table that records an address mapping between the physical address of the compressed page (an example of a physical address of the memory swap-out area) and the original physical address of the sub-memory page before the memory swap.

[0064] It should be understood that the process of converting a compressed page to a sub-memory page is a process of restoring the data in the sub-memory page. For example, based on the compression dictionary, the feature data matching the compressed block in each compressed page can be restored to obtain the sub-memory page.

[0065] S520: Store the target sub-memory page in the memory swap-in area.

[0066] It should be understood that storing the target sub-memory page in the memory swap-in area is a process of decompressing the compressed page from the memory swap-out area to the memory swap-in area.

[0067] S530: Access the target sub-memory page in the memory swap-in area.

[0068] It should be understood that after the memory is swapped in, the sub-memory page can be changed in the kernel address table of the operating system. Read and write status and sub-item contents to implement memory access management.

[0069] For example, the physical address corresponding to the virtual address in the sub-table entry can be changed to the physical address of the memory swap-in area. That is, if the memory swap-in area is consistent with the previous storage area of the memory page before the memory is swapped out, the changed physical address in the sub-table entry will be consistent with the physical address of the sub-memory page before the memory is swapped out. If the memory swap-in area is inconsistent with the previous storage area of the memory page before the memory is swapped out, the changed physical address in the sub-table entry will be consistent with the physical address of the sub-memory page before the memory is swapped out.

[0070] For another example, the read / write state of the sub-memory page in the kernel address table is changed from read-only to read / write. Then, when accessing the sub-table entry of the sub-memory page in the kernel address table of the operating system, reliable access to the sub-memory page can be achieved.

[0071] In the embodiments of the present application, a compression dictionary indicates the correspondence between preset characteristic data blocks and compressed blocks of the preset characteristic data blocks. Therefore, when a compressed block of a target compressed page is decompressed into characteristic data blocks to obtain a target sub-memory page, decompression efficiency is maintained. Furthermore, the compression dictionary is shared by all compressed pages. When a compressed page is decompressed from the memory swap-out area to the memory swap-in area, compared to configuring a separate compression dictionary for each compressed page, the storage space occupied by the compression dictionary is reduced, and the compression ratio of memory swapping is improved. Furthermore, the compression dictionary is shared by all compressed pages, which reduces compression dictionary loading time, improves data compression efficiency, and thus improves memory swapping efficiency.

[0072] It should be understood that the memory swap method of FIG5 can be performed after the memory swap method of FIG2. In some examples, as shown in FIG6, the compression dictionary is shared by multiple sub-memory pages divided by the memory page, and the compressed sub-memory pages 1-N (i.e., compressed pages) are associated and stored in the memory swap-out area, and each compressed page is decompressed into sub-memory pages 1-N and stored in the memory swap-in area.

[0073] In some examples, after each sub-memory page of a memory page is stored in the memory swap-in area, a target sub-memory page may be accessed in the memory swap-in area in response to a memory access request, where the memory access request includes a virtual address of the target sub-memory page.

[0074] Alternatively, in response to a memory access request, the compressed blocks of the target compressed page in each compressed page of the memory swap-out area can be decompressed into characteristic data blocks based on a compression dictionary to obtain the target sub-memory page. The memory access request includes the virtual address of the target sub-memory page. This processing method determines the decompression timing that matches the memory access request, and decompression is performed in response to the memory access request, thus ensuring compatibility with the memory access process.

[0075] Specifically, in response to a memory access request, the kernel address table of the operating system can be queried based on the virtual address of the target sub-memory page to obtain the original physical address of the target sub-memory page. Then, the physical address of the target sub-memory page in the memory swap-in area is used to replace the original physical address and update the kernel address table.

[0076] Furthermore, in the memory swapping method, a compression address table can be queried based on the original physical address to obtain the physical address of the target compressed page in the memory swap-out area. Then, based on the physical address of the target compressed page in the memory swap-out area, the target compressed page is retrieved. Then, based on the base address of the memory swap-out area, a compression dictionary is retrieved. The compression address table indicates the mapping between the original physical address of each memory page (i.e., the physical address before the sub-memory page is compressed) and the physical address of the compressed page in the memory swap-out area. By using this processing approach, the compression address table improves the decompression efficiency of compressed pages, thereby improving the efficiency of memory swapping.

[0077] Furthermore, as an example of replacing the original physical address with the physical address of the target sub-memory page in the memory swap-in area, when querying the operating system's kernel address table based on the virtual address of the target sub-memory page, if a memory page access exception occurs, the original physical address can be replaced with the physical address of the target sub-memory page in the memory swap-in area. If no memory access exception occurs, the original physical address can be determined as the physical address of the target sub-memory page. This processing approach allows the occurrence of a memory page access exception to trigger decompression, and the physical address of the sub-memory page to be obtained using the operating system's kernel address table, further maintaining compatibility with the operating system's access management process.

[0078] Furthermore, during the memory swap process, the kernel address table can be queried for the sub-entry corresponding to the target sub-memory page. If the sub-entry indicates read-only mode, a memory page access exception is determined. This approach allows the memory page to be accessed in read-only mode, which cannot be written to. This can trigger a memory page exception by leveraging read-only mode, and the compressed and decompressed memory page can be executed accordingly.

[0079] FIG7 is a flowchart of the memory swap method according to some other embodiments of the present application. The memory swap method in FIG7 includes S710 to S740.

[0080] S710: When querying the kernel address table of the operating system based on the virtual address of the target sub-memory page, if a memory page access exception occurs, the physical address of the target sub-memory page in the memory swap-in area is replaced with the original physical address.

[0081] S720: Query the compression address table based on the physical address of the target sub-memory page to obtain the physical address of the compressed page corresponding to the sub-memory page.

[0082] S730: Based on the compression dictionary, decompress the compressed page with the physical address from the memory swap-out area to the memory swap-in area to obtain the target sub-memory page.

[0083] S740: Access the sub-memory page in the memory swap-in area based on the updated physical address of the target sub-memory page.

[0084] It should be understood that the description and explanation of the execution process of the memory swap method in FIG. 7 may refer to the various steps of the memory swap method in FIG. 5 , and will not be repeated here.

[0085] FIG8 is a flowchart of the steps of the memory access management method of another embodiment of the present application. The management method may be executed by the operating system, including S810 to S860.

[0086] S810: When the access frequency of the memory page is lower than a preset access frequency threshold, divide the memory page into a plurality of sub-memory pages.

[0087] S820: Compress the characteristic data blocks in each sub-memory page into corresponding compressed blocks based on a compression dictionary, thereby obtaining multiple compressed pages of the multiple sub-memory pages. The compression dictionary is shared by the multiple sub-memory pages, and the compression dictionary indicates a correspondence between preset characteristic data blocks and compressed blocks of the preset characteristic data blocks.

[0088] S83O: Store multiple compressed pages in the memory swap-out area of the memory page.

[0089] S840: In response to the memory access request, based on a compression dictionary, decompress the target compressed page compressed blocks in each compressed page of the memory swap-out area into characteristic data blocks to obtain a target sub-memory page. The compression dictionary is shared by each compressed page, and the compression dictionary indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block.

[0090] S850: Store the target sub-memory page into the memory swap-in area.

[0091] S860: Access the target sub-memory page in the memory swap-in area.

[0092] It should be understood that the description and explanation of the execution process of the memory swap method in FIG. 8 may refer to the various steps of the memory swap method in FIG. 2 and FIG. 5 , and will not be repeated here.

[0093] The memory exchange apparatus of other embodiments of the present application will be described below in conjunction with FIG9. The memory exchange apparatus of FIG9 corresponds to the memory exchange method of FIG2, and includes a partitioning module 910, a compression module 920, and a storage module 930.

[0094] The division module 910 divides the memory page into multiple sub-memory pages.

[0095] A compression module 920 compresses the characteristic data block in each sub-memory page into a corresponding compressed block based on a compression dictionary, thereby obtaining multiple compressed pages of the multiple sub-memory pages. The compression dictionary is shared by the multiple sub-memory pages, and the compression dictionary indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block.

[0096] The storage module 930 stores the multiple compressed pages in the memory swap-out area of the memory page.

[0097] In the embodiments of the present application, a compression dictionary indicates the correspondence between preset feature data blocks and compressed blocks of the preset feature data blocks. Therefore, based on the compression dictionary, the feature data blocks in each sub-memory page are compressed into corresponding compressed blocks, ensuring compression efficiency for each sub-memory page. Furthermore, the compression dictionary is shared by multiple sub-memory pages divided by a memory page. Multiple compressed pages and the compression dictionary are associated and stored in the memory swap-out area of the memory page. Compared to generating a separate compression dictionary for each sub-memory page, this reduces the storage space occupied by the compression dictionary and improves the compression ratio of memory swapping. Furthermore, the compression dictionary is shared by multiple sub-memory pages divided by a memory page, reducing compression dictionary loading time, improving data compression efficiency, and, consequently, improving memory swapping efficiency.

[0098] In other embodiments, the storage module is further used to: before dividing the memory page into multiple sub-memory pages, traverse each data block in the memory page, and determine the data block whose appearance frequency is greater than a preset frequency threshold as a preset characteristic data block; establish a correspondence between the preset characteristic data block and the compressed block of the preset characteristic data block, and generate the compression dictionary.

[0099] In some other embodiments, the memory exchange device further includes: a training module that divides the memory page into training data blocks by changing the data block length; and determines the training data blocks as data blocks in the memory page when the cumulative value of the occurrence frequency of the training data blocks is maximum.

[0100] In other embodiments, the storage module is specifically configured to: before dividing a memory page into multiple sub-memory pages, store the compression dictionary in a memory swap-out area of the memory page; and associate the multiple compressed pages with the compression dictionary and store them in the memory swap-out area of the memory page.

[0101] In other embodiments, the storage module is specifically used to: generate a physical address of the compressed page based on the base address of the compression dictionary in the memory swap-out area and the offset of each compressed page; and store the compressed page in the memory swap-out area based on the physical address of the compressed page.

[0102] In some other embodiments, the storage module is further configured to: store a compressed address table between each sub-memory page and the compressed page of the sub-memory page in the memory swap-out area.

[0103] In other embodiments, the memory exchange device further includes: an access module, which determines the virtual addresses of the multiple memory pages and the physical addresses corresponding to the virtual addresses based on the table entries of the memory pages in the kernel address table of the operating system; and modifies the table entries into multiple sub-table entries, wherein the multiple sub-table entries respectively indicate the correspondence between the virtual addresses of the multiple memory pages and the physical addresses of the multiple memory pages.

[0104] In some other embodiments, the access module is further configured to: before dividing the memory page into a plurality of sub-memory pages, change the memory page from a read-write mode to a read-only mode in the table entry.

[0105] In other embodiments, the access module is further used to: after decompressing at least one compressed page from the memory swap-out area to the memory swap-in area, change the at least one compressed page from read-only mode to read-write mode in the sub-table entry corresponding to the at least one compressed page.

[0106] In some other embodiments, the partitioning module is specifically configured to: when the access frequency of a memory page is lower than a preset access frequency threshold, partition the memory page into a plurality of sub-memory pages.

[0107] FIG10 is a schematic block diagram of a memory exchange device according to another embodiment of the present application. The memory exchange device of FIG10 corresponds to the memory exchange method of FIG5 , and includes a decompression module 1010 , a storage module 1020 , and an access module 1030 .

[0108] The decompression module 1010 decompresses a target compressed page compressed block in each compressed page of the memory swap-out area into a characteristic data block based on a compression dictionary shared by each compressed page, and obtains a target sub-memory page. The compression dictionary indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block.

[0109] The storage module 1020 stores the target sub-memory page in the memory swap-in area.

[0110] The access module 1030 accesses the sub-memory page in the memory swap-in area.

[0111] In the embodiments of the present application, a compression dictionary indicates the correspondence between preset characteristic data blocks and compressed blocks of the preset characteristic data blocks. Therefore, when a compressed block of a target compressed page is decompressed into characteristic data blocks to obtain a target sub-memory page, decompression efficiency is maintained. Furthermore, the compression dictionary is shared by all compressed pages. When a compressed page is decompressed from the memory swap-out area to the memory swap-in area, compared to configuring a separate compression dictionary for each compressed page, the storage space occupied by the compression dictionary is reduced, and the compression ratio of memory swapping is improved. Furthermore, the compression dictionary is shared by all compressed pages, which reduces compression dictionary loading time, improves data compression efficiency, and thus improves memory swapping efficiency.

[0112] In other embodiments, the access module is further used to: obtain a memory access request, wherein the memory access request includes the virtual address of the target sub-memory page; in response to the memory access request, query the kernel address table of the operating system based on the virtual address of the target sub-memory page to obtain the original physical address of the target sub-memory page; replace the original physical address with the physical address of the target sub-memory page in the memory swap-in area, and update the kernel address table.

[0113] In some other embodiments, the access module is further used to: query a compression address table based on the original physical address to obtain the physical address of the target compressed page in the memory swap-out area; obtain the target compressed page based on the physical address of the target compressed page in the memory swap-out area; and obtain the compression dictionary based on the base address of the memory swap-out area.

[0114] In other embodiments, the access module is specifically used to: when querying the kernel address table of the operating system based on the virtual address of the target sub-memory page, if a memory page access exception occurs, replace the original physical address with the physical address of the target sub-memory page in the memory swap area; if no memory access exception occurs, determine the original physical address as the physical address of the target sub-memory page.

[0115] In other embodiments, the access module is further configured to: query the kernel address table for a sub-table entry corresponding to the target sub-memory page; and determine that a memory page access is abnormal if the sub-table entry indicates a read-only mode.

[0116] The specific implementation of each module in the device can refer to the corresponding description of the corresponding steps in the above method embodiment, and has corresponding beneficial effects, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described device and module can refer to the above-described method embodiment. The process description should be omitted here.

[0117] 11, a schematic structural diagram of an electronic device according to another embodiment of the present application is shown. The specific embodiments of the present application do not limit the specific implementation of the electronic device.

[0118] As shown in FIG11 , the electronic device may include: a processor 1102 for executing a program 1110 , a communication interface 1104 , a memory 1106 , and a communication bus 1108 .

[0119] The processor, communication interface, and memory communicate with each other through a communication bus.

[0120] Communication interface, used to communicate with other electronic devices or servers.

[0121] The processor is used to execute the program, and specifically can execute the relevant steps in the above method embodiment.

[0122] Specifically, the program may include program code, and the program code includes computer operation instructions.

[0123] The processor may be a CPU, an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs, or may be processors of different types, such as one or more CPUs and one or more ASICs.

[0124] Memory, used to store programs. The memory may include high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk storage.

[0125] The program may include multiple computer instructions. Specifically, the program may enable the processor to execute operations corresponding to each method described in any of the aforementioned method embodiments through the multiple computer instructions.

[0126] The specific implementation of each step in the program can be found in the corresponding descriptions of the corresponding steps and units in the above-mentioned method embodiments, and corresponding beneficial effects are achieved, so a detailed description thereof is omitted here. Those skilled in the art will clearly understand that, for the sake of convenience and brevity of description, the specific operating processes of the above-described devices and modules can be found in the corresponding process descriptions in the above-mentioned method embodiments, and a detailed description thereof is omitted here.

[0127] The present application also provides a computer storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described in any one of the aforementioned method embodiments is implemented. The computer storage medium includes, but is not limited to, a compact disc read-only memory (CD-ROM), a random access memory (RAM), and a computer program. (Random Access Memory, RAM), floppy disk, hard disk or magneto-optical disk, etc.

[0128] An embodiment of the present application further provides a computer program product, including computer instructions, which instruct a computing device to execute operations corresponding to each method in the above-mentioned multiple method embodiments.

[0129] In addition, it should be noted that the user-related information involved in the embodiments of this application (including but not limited to User device information, user personal information, etc.) and data (including but not limited to sample data used for model training, data used for analysis, stored data, displayed data, etc.) are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of relevant data must comply with relevant regulations and standards, and corresponding operation portals must be provided for users to choose to authorize or refuse.

[0130] It should be noted that, according to implementation needs, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.

[0131] The methods described above according to the embodiments of the present application can be implemented in hardware or firmware, or as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code originally stored in a remote recording medium or non-transitory machine-readable medium downloaded via a network and then stored in a local recording medium. Thus, the methods described herein can be processed by software stored on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an application-specific integrated circuit (ASIC) or a field-programmable gate array (FPGA)). It will be understood that a computer, processor, microprocessor controller, or programmable hardware includes a storage component (e.g., random access memory (RAM), read-only memory (ROM), flash memory, etc.) that can store or receive software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the methods described herein are implemented. In addition, when a general purpose computer accesses code for implementing the methods shown herein, the execution of the code transforms the general purpose computer into a special purpose computer for executing the methods shown herein.

[0132] Those skilled in the art will appreciate that the various exemplary units and method steps described in conjunction with the embodiments disclosed herein can be implemented using electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented using hardware or software depends on the specific application and design constraints of the technical solution. Professionals may use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of the embodiments of this application.

[0133] The above embodiments are only used to illustrate the embodiments of the present application and are not intended to limit the embodiments of the present application. A person skilled in the art may make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also fall within the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application shall be defined by the claims.

Claims

Claims 1. A memory swap method, comprising: Divide the memory page into multiple sub-memory pages; compressing the characteristic data block in each sub-memory page into a corresponding compressed block based on a compression dictionary to obtain multiple compressed pages of the multiple sub-memory pages, wherein the compression dictionary is shared by the multiple sub-memory pages, and the compression dictionary indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block; The plurality of compressed pages are stored in a memory swap-out area of the memory page.

2. The method according to claim 1, wherein: Before dividing the memory page into a plurality of sub-memory pages, the method further includes: traversing each data block in the memory page, and determining a data block whose occurrence frequency is greater than a preset frequency threshold as a preset characteristic data block; and establishing a correspondence between the preset characteristic data block and a compressed block of the preset characteristic data block to generate the compression dictionary.

3. The method according to claim 2, wherein: The method further includes: dividing the memory page into individual training data blocks by changing the data block length; and determining the individual training data blocks as individual data blocks in the memory page when the cumulative value of the occurrence frequency of the individual training data blocks is maximum.

4. The method according to claim 1, wherein: The method also includes: before dividing the memory page into multiple sub-memory pages, storing the compression dictionary in the memory swap-out area of the memory page; storing the multiple compressed pages in the memory swap-out area of the memory page, including: associating the multiple compressed pages with the compression dictionary and storing them in the memory swap-out area of the memory page.

5. The method according to claim 4, wherein: Storing the plurality of compressed pages in association with the compression dictionary in a memory swap-out area of the memory page includes: generating a physical address of the compressed page based on a base address of the compression dictionary in the memory swap-out area and an offset of each compressed page; and storing the compressed page in the memory swap-out area based on the physical address of the compressed page.

6. The method according to claim 5, wherein: Storing the plurality of compressed pages in association with the compression dictionary in a memory swap-out area of the memory page further includes: storing a compression address table between each sub-memory page and the compressed page of the sub-memory page in the memory swap-out area.

7. The method according to claim 1, wherein: The method also includes: determining the virtual addresses of the multiple memory pages and the physical addresses corresponding to the virtual addresses based on the table entries of the memory pages in the kernel address table of the operating system; modifying the table entries into multiple sub-table entries, and the multiple sub-table entries respectively indicate the correspondence between the virtual addresses of the multiple memory pages and the physical addresses of the multiple memory pages.

8. The method according to claim 7, wherein: The method further includes: before dividing the memory page into a plurality of sub-memory pages, changing the memory page from a read-write mode to a read-only mode in the table entry.

9. The method according to claim 8, wherein: The method further includes: after decompressing at least one compressed page from the memory swap-out area to the memory swap-in area, changing the at least one compressed page from a read-only mode to a read-write mode in a sub-table entry corresponding to the at least one compressed page.

10. The method according to claim 1, wherein: Dividing a memory page into a plurality of sub-memory pages includes: when an access frequency of the memory page is lower than a preset access frequency threshold, dividing the memory page into a plurality of sub-memory pages.

11. A memory swap method, comprising: decompressing target compressed page compressed blocks in each compressed page of the memory swap-out area into characteristic data blocks based on a compression dictionary shared by each compressed page, the compression dictionary indicating a correspondence between preset characteristic data blocks and compressed blocks of the preset characteristic data blocks, to obtain a target sub-memory page; Storing the target sub-memory page in a memory swap-in area; The target sub-memory page is accessed in the memory swap-in area.

12. The method according to claim 11, wherein: The method also includes: obtaining a memory access request, wherein the memory access request includes the virtual address of the target sub-memory page; responding to the memory access request, querying the kernel address table of the operating system based on the virtual address of the target sub-memory page to obtain the original physical address of the target sub-memory page; replacing the original physical address with the physical address of the target sub-memory page in the memory swap-in area, and updating the kernel address table.

13. The method according to claim 12, wherein: The method further includes: querying a compression address table based on the original physical address to obtain a physical address of the target compressed page in the memory swap-out area; obtaining the target compressed page based on the physical address of the target compressed page in the memory swap-out area; and obtaining the compression dictionary based on a base address of the memory swap-out area.

14. The method according to claim 13, wherein: The target sub-memory page is placed in the memory swap area 18 replaces the original physical address with the physical address in the target sub-memory page, comprising: when querying the kernel address table of the operating system based on the virtual address of the target sub-memory page, if a memory page access exception occurs, replacing the original physical address with the physical address of the target sub-memory page in the memory swap-in area; if no memory access exception occurs, determining the original physical address as the physical address of the target sub-memory page.

15. The method according to claim 14, wherein: The method further includes: querying a sub-table entry corresponding to the target sub-memory page in the kernel address table; and determining that a memory page access is abnormal if the sub-table entry indicates a read-only mode.

16. A memory access management method, comprising: When the access frequency of the memory page is lower than a preset access frequency threshold, the memory page is divided into a plurality of sub-memory pages; compressing the characteristic data block in each sub-memory page into a corresponding compressed block based on a compression dictionary to obtain multiple compressed pages of the multiple sub-memory pages, wherein the compression dictionary is shared by the multiple sub-memory pages, and the compression dictionary indicates a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block; Storing the plurality of compressed pages in a memory swap-out area of the memory page; In response to the memory access request, decompressing a target compressed page compressed block in each compressed page of the memory swap-out area into a characteristic data block based on a compression dictionary shared by each compressed page and indicating a correspondence between a preset characteristic data block and a compressed block of the preset characteristic data block to obtain a target sub-memory page; Storing the target sub-memory page in a memory swap-in area; The target sub-memory page is accessed in the memory swap-in area.

17. An electronic device, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, where the executable instruction enables the processor to perform an operation corresponding to the method according to any one of claims 1 to 16.

18. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 16 is implemented.

Citation Information

Patent Citations

  • Apparatus and method for memory management of multi-core system

    KR101155127B1

  • Virtual memory system utilizing data compression implemented through a device

    US20020147893A1

  • Electronic device and data compression method thereof

    US20190004708A1

  • Virtual memory paging system and translation lookaside buffer with pagelets

    WO2023239671A1