Data persistence method and device and electronic equipment
By creating a child process in the memory database to copy the memory metadata and address mapping table of the parent process, and asynchronously completing the address mapping table replication, the problem of user request delay during data persistence is solved, and efficient data persistence and system performance improvement are achieved.
Patent Information
- Application Number
- CN202510856494.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-10-10
AI Technical Summary
In the process of in-memory database persistence, existing technologies cause user request delays and system performance degradation. Especially in high-throughput services, the problem of parent process data processing delay caused by data persistence has not been effectively solved.
By creating a child process corresponding to the parent process, copying the parent process's memory metadata and address mapping table, using a query table to record table entry changes caused by data operations, asynchronously completing the multi-level address mapping table copy operation, and persisting it after the child process is completed, data integrity is ensured.
This reduces the data processing delay of the parent process for data persistence, improves system performance, and ensures the integrity and consistency of persistent data.
Smart Images

Figure CN120762784A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more particularly, to a data persistence method, device, and electronic device. Background Art
[0002] In computer systems, some databases store all data in memory, such as the IMKVS (In-Memory Key-Value Store) Redis database. Compared to disk, memory has relatively fast read and write speeds, resulting in higher query performance for these databases. However, memory lacks persistent storage capabilities; it relies on an electric current to maintain data, and data disappears upon power loss. Therefore, to balance the high speed of memory with data security, these databases need to regularly back up memory data to disk, a process known as persistence. Persistence isn't simply writing memory data to disk; more critical is ensuring the accuracy of the backed-up data. Therefore, when implementing persistence, these databases need to select an appropriate time point to ensure that the memory data is in a complete and consistent state. This "snapshot" is then saved to disk. A "snapshot" essentially takes a picture of the data, freezing it at a moment in time for persistence, recording the state of memory at that moment.
[0003] It can take tens of seconds or even minutes to fully write database data to disk. If the system pauses service during data persistence to wait for data to be fully written to disk before continuing to process data operation requests, user requests will be forced to wait during the data persistence period, resulting in a poor user experience. For high-throughput services, the resulting lag is unacceptable. Therefore, reducing user request latency during in-memory database data persistence is crucial. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a data persistence method, device and electronic device, so that the child process completes the copy operation of the address mapping table at all levels, and records the table entry changes caused by the data operations processed by the parent process through the query table, thereby ensuring the integrity of the persistent data, reducing the parent process data processing delay caused by data persistence, and improving system performance.
[0005] In a first aspect, an embodiment of the present invention provides a data persistence method, the method comprising:
[0006] In response to the persistence instruction, a child process corresponding to the parent process is created;
[0007] Copy the memory metadata corresponding to the parent process to the child process;
[0008] Running the child process to copy the address mapping table corresponding to the parent process at the data persistence time based on the memory metadata and the corresponding query table, wherein the query table is used to record original entry information of entries in the address mapping table of the parent process that have changed since the data persistence time;
[0009] In response to completion of the copying of the sub-process, the memory data pointed to by the multi-level address mapping table in the sub-process is persisted.
[0010] In a second aspect, an embodiment of the present invention provides a data persistence device, the device comprising:
[0011] A creation unit, configured to create a child process corresponding to the parent process in response to the persistence instruction;
[0012] A first copying unit is configured to copy the memory metadata corresponding to the parent process to the child process;
[0013] a second copying unit configured to run the child process to copy the address mapping table corresponding to the parent process at the data persistence time based on the memory metadata and the corresponding query table, wherein the query table is used to record original entry information of entries in the address mapping table of the parent process that have been changed since the data persistence time;
[0014] The third copying unit is configured to persist the memory data pointed to by the multi-level address mapping table in the sub-process in response to completion of the copying of the sub-process.
[0015] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method as described above.
[0016] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0017] In a fifth aspect, an embodiment of the present invention provides a computer program product, which, when executed on a computer, enables the computer to execute the method described above.
[0018] In response to a persistence instruction, the embodiment of the present application creates a child process corresponding to a parent process, copies memory metadata of the parent process to the child process, runs the child process to copy an address mapping table of the parent process at a data persistence time based on the memory metadata and a corresponding query table, and in response to completion of copying by the child process, obtains memory data pointed to by a multi-level address mapping table in the child process for persistence, wherein the query table is used to record original table item information of a table item in the parent process address mapping table that has changed since the data persistence time. Thus, the embodiment of the present application enables the child process to complete copying of the address mapping tables, and records table item changes caused by data operations processed by the parent process through the query table, thereby ensuring data persistence integrity, reducing parent process data processing delay caused by data persistence, and improving system performance. BRIEF DESCRIPTION OF DRAWINGS
[0019] The above and other objects, features and advantages of the present application will become more apparent from the following description when taken in conjunction with the accompanying drawings, in which:
[0020] Figure 1 is a flowchart of a data persistence method of the embodiment of the present application;
[0021] Figure 2 is a flowchart of a query table updating method of the embodiment of the present application;
[0022] Figure 3 is an operating address diagram of the embodiment of the present application;
[0023] Figure 4 is a flowchart of another query table updating method of the embodiment of the present application;
[0024] Figure 5 is a diagram of a table item operation mode change process in an address mapping table of the embodiment of the present application;
[0025] Figure 6 is a diagram of a query table of the embodiment of the present application;
[0026] Figure 7 is a flowchart of a table copying method of a child process of the embodiment of the present application;
[0027] Figure 8 is a table copying process diagram of a child process of the embodiment of the present application;
[0028] Figure 9 is a flowchart of another table copying method of a child process of the embodiment of the present application;
[0029] Figure 10-11 is a diagram of a data persistence process of the embodiment of the present application;
[0030] Figure 12 is a schematic diagram of a data persistence device according to an embodiment of the present invention;
[0031] Figure 13 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The present application is described below based on the following embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, certain specific details are described in detail. Those skilled in the art can fully understand the present application without the description of these details. To avoid obscuring the essence of the present application, well-known methods, processes, procedures, components, and circuits are not described in detail.
[0033] Furthermore, persons of ordinary skill in the art will appreciate that the figures provided herein are for illustration purposes only and are not necessarily drawn to scale.
[0034] Unless the context clearly requires otherwise, words like “include”, “comprising” and the like throughout this application should be interpreted as including rather than exclusive or exhaustive; that is, as meaning “including but not limited to”.
[0035] In the description of this application, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.
[0036] Where the solutions described in this specification and in the examples involve the processing of personal information, such processing will be conducted with a legitimate basis (e.g., with the consent of the personal information subject or as necessary for the performance of a contract) and only within the prescribed or agreed scope. A user's refusal to process personal information other than that required for basic functions will not affect the user's use of these basic functions.
[0037] In the description of the following embodiments, the Redis database is mainly used as an example. It should be understood that the data persistence method of this embodiment can be applied to the persistence of any data stored in the memory, and is not limited to the Redis database. Examples will not be given one by one here.
[0038] To mitigate user request latency during data persistence, the Redis database utilizes the fork system call in Linux. The fork system creates a child process that is nearly identical to the calling process (the parent process). When the parent process (the program responsible for handling user requests) needs to persist (back up) data, it invokes the fork system to spawn a child process. This child process is a "copy" of the parent process (also called the main process), possessing identical memory data, but operating independently to perform backup tasks. With this approach, whenever the database needs to persist data, it invokes the fork system to create a child process to perform the persistence operation, while the parent process continues to process user requests. The two copies do not interfere with each other. Regardless of how the parent process modifies memory data, the modifications remain in its own copy and do not affect the child process's data. The child process's data is always a snapshot of the data at the moment of creation, allowing it to be backed up to disk over time without interruption. This approach eliminates the need to suspend the main process for persistence while maintaining the memory snapshot feature.
[0039] However, in practice, calling the fork system requires creating a data copy for the child process, which is equivalent to copying the parent process's data in memory. This memory copy process is also time-consuming, potentially taking more than ten seconds. During this data copy period, the parent process is still unable to process user requests. Although this pause is much shorter than the original waiting time for persistence (tens of seconds), it still has a significant impact on system performance.
[0040] Therefore, in a related comparative example, the Linux kernel was further optimized to omit the memory copy process. That is, when the fork system is called to create a child process, all the memory data of the parent process is not immediately copied out. Instead, the child process and the parent process share the same memory data. This further eliminates the need for data copying, allowing the fork process to complete in a few hundred milliseconds, further reducing the pause time of the Redis master process.
[0041] However, this optimization step also brings a problem. The parent and child processes share the same data. If the main process wants to modify the memory, the data seen by the child process will be constantly updated instead of seeing an unchanging snapshot. If this is the case, the data eventually persisted to the disk will also be a mess.
[0042] To address this issue, the Linux kernel introduced the concept of "copy-on-write." Its core idea is that when a child process and a parent process share the same memory data, the operating system marks that memory data as "read-only," prohibiting either process from modifying it. In actual operation, the main process must continuously handle requests, and memory data will inevitably change. With "copy-on-write," when a parent process attempts to modify a block of memory, the operating system detects that it is modifying "read-only" memory and creates a copy of the affected small block of memory. The parent process modifies this new copy, while the original data remains available to the child process. Therefore, regardless of how the parent process modifies the data, it is constantly creating and modifying new copies, without affecting the original data seen by the child process. This temporary copying of small blocks of memory during writes is called "copy-on-write." It effectively divides the original memory copy into smaller, write-on-write copies. This ensures the "snapshot" functionality while further reducing the parent process's downtime caused by data persistence.
[0043] Regarding the aforementioned "small blocks of memory," in computers (such as those based on the x86 architecture), the finest granularity of memory banks, or physical memory, is not a single byte. Instead, it is divided into many small blocks called "pages" (each 4KB). Memory allocated to a process is allocated at this 4KB granularity, and each page can have its own control over access permissions and other attributes.
[0044] After a memory page is allocated to a process, the process accesses it through a memory address. Reading and writing this address allows access to the physical page. In computer systems, virtual addresses are typically used for data access. The computer system translates the virtual address accessed by the process into a physical address to access the physical page corresponding to the physical address.
[0045] The space composed of virtual addresses is called the virtual address range, and the space of physical addresses is the physical space, that is, the physical memory. The conversion process between virtual addresses and physical addresses requires the involvement of a multi-level address mapping table (also called a page table). Based on this multi-level address mapping table, the physical address corresponding to the accessed virtual address is queried, and then the physical memory is accessed. If the child process is to be able to access physical memory data, the parent process obviously needs to copy a copy of the address mapping table at each level to the child process, thereby enabling the parent and child processes to share memory data.
[0046] Typically, the mapping relationship between virtual addresses and physical addresses involves five levels of address mapping tables, namely the PGD table (Page Global Directory), the P4D table (Page 4th Directory), the PUD table (Page Upper Directory), the PMD table (Page Middle Directory), and the PT table (Page Table). Each of the four types of tables, the PGD table, the P4D table, the PUD table, and the PMD table, has 512 entries, called entries (each 8 bytes). The corresponding four types of entries are called pgde, p4de, pude, and pmde, respectively. Each entry points to a lower-level table, such as pgde pointing to a P4D table, pmde pointing to a PT table, and so on. The PT table is the lowest-level table, and its 512 entries point to 512 physical memory pages. It should be understood that the above-mentioned address mapping tables are merely exemplary, and the configurations of different systems may be different. For example, some systems merge the PGD table and the P4D table, etc., which will not be explained one by one here.
[0047] It should be understood that in this application, "copy" refers to the process of establishing the child process page table. Taking the above-mentioned five-level address mapping table as an example, during the child process page table creation process, the child process creates independent PGD, P4D, PUD, and PMD page tables that are different from the parent process. Although in the child process, the lower-level table pointed to by the upper-level page table entry corresponds to the parent process, because the page tables of the child process and the parent process are independent, the specific values of the table entries in the PGD, P4D, PUD, and PMD page tables in the parent and child processes are different. For example, the parent process's PGD table has a table entry pgde, which points to the corresponding parent process P4D page table. The child process creates a child process PGD' table corresponding to the parent process PGD table. The child process PGD' table has a table entry pgde', which points to the corresponding child process P4D' page table. Because the parent process P4D page table and the child process P4D' page table are different, the specific value of the table entry pgde in the parent process PGD page table is different from the table entry pgde' in the child process PGD' page table. That is, for the PGD, P4D, PUD, and PMD page tables, the child process copies the structural relationship between the page tables, rather than the specific table item values. However, for the PT page table, the table items in the PT page table point to the corresponding physical pages. Since the parent process and the child process share memory data, although the PT page tables in the parent process and the child process are also different page tables, the specific values of the table items in the PT page table of the child process are the same as the specific values of the table items in the PT page table of the parent process at the time of data persistence, so that the child process can copy the corresponding memory data. That is, in this application, for page tables other than the last-level page table, "copy" means copying the structure between the page tables (that is, the mapping relationship), and for the last-level page table, "copy" means copying the specific table item values to achieve memory data sharing. Although in the above comparative example, the parent and child processes share memory data, so that the data persistence process does not need to copy the entire memory data, the pause time of the parent process is shortened to the time of copying a parent process address mapping table at all levels, and the time consumption may be reduced to a few hundred milliseconds, but for services that are highly sensitive to delay (such as navigation, etc.), this delay will still cause serious impacts (for example, navigation reminder delays leading to missed intersections, etc.).
[0048] Furthermore, the relevant comparison ratio further optimizes the above-mentioned asynchronous page table replication. When forking, the parent process only copies a small amount of metadata that must be copied and part of the top-level page table structure (PGD, P4D, and PUD), and then quickly returns to user mode (meaning that it can continue to process user requests). Since the number of PGD, P4D, and PUD page tables is relatively small, far less than PMD and PT tables, the whole process will be faster, taking about a few milliseconds. The remaining page table copy tasks (PMD and PT levels) are asynchronously handed over to the child process to complete. On this basis, for the case where the parent process changes memory, this solution introduces an active synchronization mechanism: if the memory that the parent process needs to modify belongs to the PT table that has not been copied by the child process, the parent process will actively copy the contents of the original PT page table in the area to the child process before modifying it.
[0049] In this comparison, while asynchronous page table replication further reduces fork latency, the active synchronization mechanism introduced by this approach has certain drawbacks. Specifically, when the parent process needs to modify memory and the corresponding page table region has not yet been copied by the child process, the parent process must pause its current task (such as processing a user query) to perform an active synchronization operation. While this active synchronization avoids data inconsistencies, it involves building a high-level page table for the child process, copying the PT table to the child process, and incrementing the reference counts of the 512 physical pages pointed to by the PT table (indicating that the physical page has a new user, namely the child process). Incrementing the reference count is an atomic instruction at the hardware level, resulting in a relatively high performance penalty. Therefore, the overall cost of each active synchronization is not as low as expected and still blocks the parent process's service capabilities. Although this blocking time is short, active synchronization can be frequently triggered under high write loads or when the operating system is frequently performing background activities such as memory defragmentation and NUMA migration. This is especially true when the database is processing multiple requests in batches, where the latency of earlier requests can have a cumulative effect on later requests. This shows that this comparison only breaks up the latency of the original fork phase, transferring part of it to the child process and distributing part of it to each active synchronization process. The delay impact of this active synchronization will continue until the page table is completely copied. The accumulated delay still has a significant impact on highly latency-sensitive scenarios.
[0050] Therefore, an embodiment of the present invention provides a data persistence method, device, and electronic device, which, in response to a persistence instruction, creates a child process corresponding to a parent process, copies the memory metadata corresponding to the parent process to the child process, runs the child process to copy the address mapping table corresponding to the parent process at the time of data persistence based on the memory metadata and the corresponding query table, and in response to the completion of the child process copy, obtains the memory data pointed to by the multi-level address mapping table in the child process for persistence, wherein the query table is used to record the original table entry information of the table entry that has been updated in the address mapping table since the data persistence moment. Therefore, the embodiment of the present invention enables the child process to complete the copy operation of the address mapping table at each level, and records the table entry changes caused by the data operation processed by the parent process through the query table, thereby ensuring the integrity of the persistent data, reducing the parent process data processing delay caused by data persistence, and improving system performance.
[0051] Figure 1 This is a flow chart of the data persistence method according to an embodiment of the present invention. Figure 1 As shown, the data persistence method of the embodiment of the present invention includes the following steps:
[0052] Step S110 : In response to the persistence instruction, a child process corresponding to the parent process is created.
[0053] When performing data persistence, to ensure the accuracy of the backed-up data and avoid the occurrence of intermediate data (i.e., data that is not in the same state as the entire operation), which could lead to errors during future data recovery, it is necessary to select an appropriate time point (i.e., the data persistence moment) to perform data persistence and save the "memory snapshot" formed at that point in time to disk. Furthermore, at the data persistence moment, the persistence instruction is triggered, calling the fork system to create a child process corresponding to the parent process (i.e., the program responsible for handling user data processing operation requests).
[0054] Step S120: copy the memory metadata corresponding to the parent process to the child process, wherein the memory metadata includes the virtual memory range and attributes accessible to the parent process.
[0055] After creating a child process, the parent process traverses all corresponding virtual memory areas (VMAs) and copies each VMA structure to the child process. A VMA represents a data structure representing a continuous interval in the process's virtual address space, describing a continuous range of virtual memory and its data within the process's address space. Virtual memory ranges represented by the same VMA have the same access permissions, memory attributes, and backing store.
[0056] Step S130, run the child process to copy the address mapping table corresponding to the parent process at the time of data persistence based on the memory metadata and the corresponding query table. The child process determines the address mapping tables corresponding to the address range that needs to be copied based on the memory metadata. The query table is used to record the original table entry information of the table entries that have changed in the parent process address mapping table since the data persistence time. For example, record the underlying table entries corresponding to the physical pages that are changed when the parent process performs a write operation, or record empty information for the page tables or table entries added after the data persistence time to record that these page tables or table entries do not exist at the time of data persistence and do not need to be copied. Therefore, in this embodiment, the parent process will provide the original table entry information of the changed table entry for the child process to query when copying when executing the user's data operation request, so that the parent process does not need to suspend the current task to perform active synchronization operations, that is, there is no need to help the child process build high-level page tables and last-level page tables. Compared with the above-mentioned comparative example, the parent process of this embodiment only needs to save the changed table entry, which reduces the time consumption of table entry copying, and the physical memory page corresponding to the modified table entry only undergoes ownership transfer, without modifying the corresponding reference count, saving the corresponding atomic operation. While ensuring the data consistency between the backup data and the data persistence moment, the data request processing delay of the main process is further reduced, thereby improving system performance.
[0057] Furthermore, this embodiment executes the copy operation of each address mapping table in parallel to further improve the copy efficiency.
[0058] Step S140 , in response to completion of the child process copying, the memory data pointed to by the multi-level address mapping table in the child process is persisted.
[0059] In response to a persistence instruction, an embodiment of the present invention creates a child process corresponding to a parent process, copies the memory metadata corresponding to the parent process to the child process, runs the child process to copy the address mapping table corresponding to the parent process at the time of data persistence based on the memory metadata and the corresponding query table, and in response to the completion of the child process copy, obtains the memory data pointed to by the multi-level address mapping table in the child process for persistence, wherein the query table is used to record the original table entry information of the table entry that has been updated in the parent process address mapping table since the data persistence time. Thus, the embodiment of the present invention enables the child process to complete the copy operation of the address mapping table at each level, and records the table entry changes caused by the data operation processed by the parent process through the query table, thereby ensuring the integrity of the persistent data, reducing the parent process data processing delay caused by data persistence, and improving system performance.
[0060] In an optional implementation, before the child process runs, this embodiment sets each entry in the target page table in the parent process to read-only mode. The target page table is at least one level in the multi-level address mapping table corresponding to the memory metadata. Furthermore, before the child process runs, it can be any period from the time the persistence instruction is received to the time the child process runs, and this embodiment is not limited to this. Further optionally, this embodiment can use a reusable flag bit of the table entry of the target page table to mark it as read-only mode to indicate that the address space corresponding to the table entry is frozen, and change the mark of the reusable flag bit to mark it as writable mode when the address space corresponding to the table entry changes. Thus, when the child process copies the address mapping table, it can determine whether the parent process has changed the address space corresponding to each table entry by querying the operation mode of each table entry in the target page table, and then determine to perform the corresponding copy operation or retrieve the corresponding original table entry information in the query table.
[0061] Furthermore, the table entries in the address mapping table in the multi-level address mapping table point to the corresponding next-level address mapping table or physical page. Optionally, in this embodiment, the multi-level address mapping table includes a global page table (PGD), a four-level page table (P4D), an upper page table (PUD), a middle page table (PMD) and a last page table (PT). The table entries of the global page table point to the corresponding four-level page table, the table entries of the four-level page table point to the corresponding upper page table, the table entries of the upper page table point to the corresponding middle page table, the table entries of the middle page table point to the corresponding last page table, and the table entries of the last page table point to the corresponding physical page. It should be understood that the above-mentioned address mapping table is merely exemplary, and the configurations of different systems may be different. For example, some systems merge the PGD table and the P4D table, etc., which will not be explained one by one here.
[0062] In an optional implementation, before the child process runs, the target page table whose entries are set to read-only mode is the bottom-level page table. That is, this embodiment can set all entries in the bottom-level page table (e.g., each PTE entry in each PT table corresponding to the virtual address space corresponding to the parent process) to read-only mode. Thus, each time the parent process needs to change the physical page corresponding to the PTE entry during data processing (e.g., a write operation), a hardware-level page fault is triggered, causing the Linux kernel to take over the process. During the page fault processing process, the original entry information of the PTE entry to be modified is first backed up to the lookup table, and then the PTE entry is changed to writable mode, allowing the parent process to continue executing the corresponding data operation. Furthermore, if the parent process performs a write operation, it can use the aforementioned copy-on-write operation to generate a copy of the physical page corresponding to the PTE entry and point the PTE entry to the copy of the physical page, while the original entry information backed up in the lookup table still points to the original physical page. Thus, this embodiment can ensure that the data persisted by the child process is consistent with the data corresponding to the moment of data persistence. In this case, the parent process only needs to execute pagefault once, which improves the efficiency of the parent process in handling page faults.
[0063] For a multi-level address mapping table, the lower the level, the more page table data there is. Since there are too many page tables at the last level, there are also more corresponding last-level page table entries. Setting all of these last-level page table entries to read-only mode takes some time. Therefore, in another optional implementation, the target page table for setting each entry to read-only mode can be an intermediate page table.
[0064] Taking the multi-level address mapping table corresponding to the above example as an example, in this embodiment, before the child process runs, each pmde table item in the intermediate page table PMD is set to read-only. At this time, the attributes of each pte table item in the last-level page table pointed to by each pmde table item are not modified (that is, the operation mode is changed). Among them, the operation mode of the upper-level pmde table item represents the operation mode of each pte table item in the last-level page table pointed to by the pmde table item. In this case, when the child process queries a pmde table item as read-only, it indicates that each pte table item in the last-level page table pointed to by the pmde table item is in read-only mode, which has not been modified and can perform a copy operation. Since the number of intermediate page tables is much smaller than that of the last-level page tables, the setting operation of the read-only mode before the child process runs is relatively short, which further reduces the latency.
[0065] Furthermore, when the parent process performs a data operation such as a write operation that requires data change, a page operation error (page fault) will be triggered when the address query finds the corresponding pmde table entry in the intermediate page table. In the page fault processing process, the pmde table entry is changed to a writable mode, and each pte table entry in the last-level page table pointed to by the pmde table entry is set to read-only mode. Then, the pte table entry in the corresponding last-level page table is queried based on the operation address. Since the pte table entry is in read-only mode, the corresponding page fault is triggered. In the page fault processing process, the original table entry information of the pte table entry is backed up to the query table, and then the pte table entry is changed to a writable mode, so that the parent process continues to perform the corresponding data operation. Furthermore, if the parent process performs a write operation, it can use the above-mentioned write-time copy operation to generate a physical page copy corresponding to the pte table entry, and point the pte table entry to the physical page copy, while the original table entry information backed up to the query table still points to the original physical page. Therefore, this embodiment can ensure that the persisted data of the child process is consistent with the data corresponding to the data persistence time.
[0066] In other optional implementations, in this embodiment, before the child process runs, the target page table in which each table entry is set to read-only mode can also be other page tables above the intermediate page table, such as the upper page table, the fourth-level page table, etc. The adjustment of the read-only mode between each level when performing data operations such as write operations that require data changes is similar to the above embodiment (except that there are additional changes in the intermediate level), and will not be described in detail here.
[0067] Furthermore, in this embodiment, before the child process runs, the target page table in which each entry is set to read-only mode can also be a combination of multiple levels of page tables, such as an intermediate page table and a bottom-level page table. It should be understood that this embodiment does not limit the specific page table set to read-only mode, as long as it can achieve the corresponding function. In actual application, it can be configured based on specific circumstances.
[0068] Furthermore, in this embodiment, after completing the operation mode setting of each table entry in the target page table corresponding to the memory metadata corresponding to the parent process, the parent process places the child process in the corresponding run queue so that the child process begins execution. The parent process then returns to the user state to process the user's data operation request, which includes the operation address. The child process then begins running to copy the parent process's address mapping tables at all levels. Thus, after the parent process of this embodiment copies the memory metadata to the child process and completes the operation mode setting of each table entry in the target page table corresponding to the memory metadata, it can immediately return to the user state to execute the user's data operation request without occupying the parent process to copy the corresponding address mapping table. This further reduces the data processing pause time of the parent process, thereby improving the user experience.
[0069] Figure 2 This is a flow chart of the query table update method of an embodiment of the present invention. In this embodiment, after the parent process returns to the user state to execute the user's data operation request, the user's data operation request may change the memory data. This embodiment records the last-level page table entry corresponding to the changed memory data through the query table to ensure the consistency of the persisted data and the data at the time of data persistence. Figure 2 As shown, the query table updating method of this embodiment includes the following steps:
[0070] Step S210 : In response to the execution of the data operation request and the corresponding table entry to be changed, original table entry information is generated based on the corresponding operation address.
[0071] Furthermore, the operation address in the data operation request can be represented in hexadecimal. This embodiment converts the hexadecimal operation address into binary, wherein the binary operation address represents the table entry position in each level address mapping table and the corresponding byte offset within the physical page. Taking the multi-level address mapping table including the global page table, the four-level page table, the upper page table, the middle page table and the last page table as an example, the binary operation address includes the address bit range corresponding to the global page table, the address bit range corresponding to the four-level page table, the address bit range corresponding to the upper page table, the address bit range corresponding to the middle page table, the address bit range corresponding to the last page table, and the address bit range corresponding to the byte offset within the physical page. The address bit range corresponding to the global page table, the address bit range corresponding to the four-level page table, the address bit range corresponding to the upper page table, the address bit range corresponding to the middle page table, and the address bit range corresponding to the last page table are used to represent the table entry position of the operation address in the global page table, the four-level page table, the upper page table, the middle page table and the last page table respectively.
[0072] Figure 3 This is a schematic diagram of the operation address of an embodiment of the present invention. Figure 3As shown, this embodiment takes "000001001011001000111111110011001001111011101000000000000" as an example, which is a 57-bit binary addressing. Each address bit in binary form is split starting from the highest bit, and each split is 9 bits to obtain the address bit range "000001001" corresponding to the global page table, the address bit range "011001000" corresponding to the fourth-level page table, the address bit range "111111110" corresponding to the upper page table, the address bit range "011001001" corresponding to the middle page table, and the address bit range "111011101" corresponding to the last page table. The last 12 bits are the address bit range "000000000000" corresponding to the byte offset within the physical page. Furthermore, the above-mentioned address bit range can be calculated to obtain that when the current data operation request is addressing, it is necessary to query the global page table entry corresponding to PGD idx=9 in the global page table, obtain the four-level page table pointed to by the global page table entry corresponding to PGD idx=9, and query the four-level page table entry corresponding to P4D idx=200 in the four-level page table, obtain the upper page table pointed to by the four-level page table entry corresponding to P4D idx=200, query the upper page table entry corresponding to PUD idx=510 in the upper page table, obtain the intermediate page table pointed to by the upper page table entry corresponding to PUD idx=510, query the last page table entry corresponding to PMD idx=201 in the intermediate page table, obtain the last page table pointed to by the intermediate page table entry corresponding to PMD idx=201, and query the PT in the last page table. The physical page pointed to by the last page table entry corresponding to idx=477, and based on the address bit range "000000000000" corresponding to the byte offset within the physical page, the byte offset is determined to be 0, so the corresponding data processing can be started from the first address of the physical page pointed to by the last page table entry corresponding to PT idx=477.
[0073] This embodiment can generate index information corresponding to the original table entry information based on the operation address in binary form, so that when the operation mode of the child process querying the corresponding table entry is writable mode, the address information corresponding to the table entry can be used as index information to query the corresponding original table entry information, and then obtain the table entry information of the changed table entry at the time of data persistence.
[0074] Step S220: Insert the original table entry information into the query table and set the table entry to be changed to writable mode. Optionally, the query table can be a hash table with corresponding key-value pairs. The key represents the index information generated based on the corresponding table entry address, and the value represents the table entry information at the time of data persistence. The table entry information includes the next-level address mapping table pointed to by the table entry or the physical page pointed to.
[0075] Figure 4 This is a flowchart of another query table updating method according to an embodiment of the present invention. Figure 5 This is a schematic diagram of a process for changing the operation mode of an entry in an address mapping table according to an embodiment of the present invention. Further, as mentioned above, the strategy for setting the read-only mode by the parent process before the child process runs is different, and the data structure and update process of the query table are also different. Figure 4 As shown, before the child process runs, taking the target page table in which each entry is set to read-only mode as the intermediate page table as an example, the query table update process of this embodiment includes the following steps:
[0076] In step S310, in response to the execution of the data operation request, if the intermediate page table entry at the operation address has a corresponding entry to be changed and is in read-only mode, the intermediate page table entry at the operation address is changed to writable mode. It should be understood that the operation mode of the intermediate page table entry at the operation address can be changed at this time or after the original entry information is backed up, and this embodiment is not limited to this.
[0077] Step S320 , setting each last-level page table entry in the last-level page table corresponding to the middle page table entry of the operation address to a read-only mode.
[0078] like Figure 5 As shown, before the parent process returns to the user state, each table entry pmde in the intermediate page table (such as table entries pmde1-5, etc.) is set to read-only mode, wherein a reusable flag bit is adjusted to "ro" to set each table entry pmde to read-only mode. Among them, since the operation mode of each table entry pmde is read-only mode, even if the operation mode of each table entry pte in the PT table pointed to by each table entry pmde is the write mode "r / w", the table entries in the entire PT table are also in read-only mode. Among them, each table entry in the PT table points to the corresponding physical page phy page respectively, for example, the last-level table entries pte1-5 point to the corresponding physical pages phy page1-5 respectively.
[0079] Taking the current data operation request as a write request as an example, it needs to change the memory data. When the parent process queries the intermediate page table entry pmde3 of the operation address corresponding to the write request, it is in read-only mode, triggering a page operation error (page fault). In the page fault processing process, the table entry pmde3 is changed to the writable mode "r / w", and the last-level table entries pte (such as pte1-5, etc.) in the last-level page table corresponding to the table entry pmde3 are set to read-only mode "ro".
[0080] Step S330: Generate original entry information, wherein the original entry information includes index information and backup information of the last-level page table entry of the operation address, and the index information is determined based on the operation address.
[0081] Furthermore, based on the query of the last entry pte4 in the last page table corresponding to the write request, since the last entry pte4 is in read-only mode "ro", the corresponding page fault is triggered. In the page fault processing process, the original entry information of the last entry pte4 is generated and backed up to the query table.
[0082] In an optional implementation, the query table of this embodiment is a hash table. Furthermore, the hash table of this embodiment adopts a two-level query method. The original table entry information in the hash table has a corresponding primary index and secondary index, and the primary index and secondary index are determined based on the different address bit ranges in the table entry operation address corresponding to the original table entry information. The hash table includes multiple hash nodes (HashNode), each hash node is an array of a predetermined size, including a predetermined number of data slots, and each data slot can store backup information of a last-level page table entry. Optionally, the array size corresponding to the hash node can be 4k, which can include 512 data slots. Further optionally, each hash node of this embodiment corresponds to the last-level page table corresponding to an intermediate page table entry. That is, when the operation mode of a certain intermediate page table entry is changed to writable mode, this embodiment creates a hash node corresponding to the intermediate page table entry, and each data slot in the hash node corresponds to each entry of the last-level page table pointed to by the intermediate page table entry. Among them, the i-th (i≥1) data slot in the hash node is used to store the i-th table entry information in the last-level page table pointed to by its corresponding intermediate page table entry. That is to say, if the i-th table entry information in the last-level page table pointed to by the intermediate page table entry changes, the original table entry information of the i-th table entry is stored in the i-th data slot in the corresponding hash node, and the data slot corresponding to the last-level page table entry that has not changed is empty. It should be understood that this embodiment does not limit the array size, number of data slots, and positional relationship between the data slot and the last-level page table entry corresponding to the hash node, and it can be configured according to actual application conditions. Among them, in the hash table of this embodiment, the first-level index is used to locate the corresponding hash node, and the second-level index is used to locate the corresponding data slot in the hash node. Thus, the complexity of the hash table index can be reduced, and memory resources will not be wasted, further improving system performance.
[0083] In this embodiment, the parent process first sets the intermediate page table (PMD table) to read-only mode, and then, when a subsequent data operation request has a corresponding entry that needs to be changed, puts the read-only mode on the corresponding last-level page table (PT table). Thus, in this embodiment, the intermediate page table entries correspond to hash nodes, meaning each hash node locates an intermediate page table entry (i.e., a last-level page table entry), and the data slot in each hash node locates a last-level page table entry, which is a backup of the original last-level page table entry.
[0084] Furthermore, in this embodiment, the corresponding first-level index is determined based on the address bit range of the intermediate page table located in the operation address corresponding to the data operation request. Taking the binary operation address "000001001011001000111111110011001001111011101000000000000" as an example, when the data operation request has a corresponding table entry to be changed and the intermediate page table entry of the operation address is in read-only mode, a hash node corresponding to the intermediate page table in the operation address is created, and the first-level index is determined based on the address bit range of the intermediate page table located, that is, bit 21-bit 56, to thereby determine the hash node where the original table entry information corresponding to the operation address is located. Furthermore, this embodiment determines the corresponding second-level index based on the address bit range of the last-level page table of the operation address corresponding to the data operation request, for example, determining the second-level index based on bits 12-bit 20 of the above-mentioned operation address, thereby determining which data slot in the hash node the original table entry information corresponding to the operation address is located.
[0085] Figure 6 This is a query representation scheme of an embodiment of the present invention. The hash table includes a hash table header and a space corresponding to a hash node. The hash table header is used to store the index information of each hash node, that is, the first-level index. Figure 5 For example, Figure 5 and Figure 6As shown, assuming that the intermediate page table entry corresponding to the operation address of the current data operation request of the parent process is pmde3, a hash node HashNode2 corresponding to the intermediate page table entry pmde3 is created, and the backup information of the last-level page table entry pte4 corresponding to the operation address of the current data operation request of the parent process is stored in a data slot in the hash node HashNode2. Among them, the first-level index corresponding to the hash node HashNode2 is determined based on the address bit range located to pmde3 (for example, bit21-bit56 in the above operation address), and it is stored in the hash table header to locate the hash node HashNode2 corresponding to the intermediate page table entry pmde3 based on it, and the second-level index corresponding to the original table entry information is determined based on the address bit range corresponding to pte4 (for example, bit12-bit20 in the operation address in the above example), so as to locate the location of the backup information of the last-level page table entry of the operation address stored in the hash node HashNode2 based on it.
[0086] Further, if Figure 6 As shown in the figure, assuming that the first-level index determined based on the intermediate page table entry pmde3 is h1, then h1 stores information pointing to the hash node HashNode2. Assuming that the last-level page table entry corresponding to the operation address of the parent process's current data operation request is pte4, and based on the address bit range corresponding to pte4, its corresponding data slot is determined to be slot4, the backup information of the last-level page table entry for the operation address in the original entry information is stored in data slot slot4. At this time, the physical page pointed to by the backup information of the last-level page table entry in data slot 4 is page phy4. Therefore, when the child process copies the last-level page table entry pte4, it can retrieve the original entry information from the lookup table based on the address information corresponding to pte4, ensuring the accuracy of data persistence.
[0087] In another optional implementation, the query table of this embodiment may also adopt a first-level query method, that is, after the parent process determines which physical page corresponding to the last-level page table entry is changed, it uses the address bit range corresponding to the last-level page table entry (such as bit12-bit56 in the above example) to determine the index information, and inserts the original table entry information into the query table based on the index information.
[0088] Step S340 , changing the last page table entry of the operation address to a writable mode.
[0089] Further, in order to avoid the data in the physical page from being changed during the data persistence process, the embodiment adopts the write-once copy operation. Specifically, the embodiment copies the physical page corresponding to the last-level page table entry of the operation address corresponding to the data operation request, generates a corresponding physical page copy, and controls the last-level page table entry of the operation address to point to the corresponding physical page copy. Thus, the parent process of the embodiment can perform the corresponding data operation in the physical page copy, and the corresponding original entry information determined by the child process from the query table still points to the original physical page, thereby ensuring the accuracy of the persisted data.
[0090] As shown in Figure 5 and Figure 6 , while or after the original entry information of the last-level entry pte4 is backed up to the query table, the pte4 entry is changed to the writable mode "r / w", and the write-once copy operation is adopted to generate a physical page copy "Cow page" corresponding to the last-level entry pte4, the last-level entry pte4 is pointed to the physical page copy "Cow page", and the corresponding data in the physical page copy "Cow page" is processed based on the specific data operation corresponding to the data operation request, for example, the to-be-written data is written into the physical page copy "Cow page". At this time, the original entry information backed up to the query table still points to the original physical page phy4 page. Thus, the embodiment can ensure that the data persisted by the child process is consistent with the data corresponding to the data persistence moment.
[0091] In another optional implementation, if the target page table in which each entry is set to the read-only mode is the last-level page table before the child process runs, the embodiment generates the original entry information and stores the original entry information to the corresponding query table in response to the execution of the data operation request having the corresponding entry to be changed and the last-level page table entry corresponding to the data operation request being in the read-only mode, and changes the last-level page table entry of the operation address to the writable mode. The original entry information includes index information and backup information of the last-level page table entry of the operation address, and the index information is determined based on the operation address. Optionally, the embodiment can also adopt the similar two-level query or one-level query mode to determine the index information, which will not be described in detail here.
[0092] In an alternative implementation, when the data operation request is a read request or a write request or other request, if the intermediate page table entry corresponding to the data operation address or the last layer page table is empty, a page fault is triggered, at which time the parent process creates a new intermediate page table entry and the last layer page table thereunder. Since this part of address mapping table entry is created after the data is persisted, it should not be detected by the child process, and therefore, the embodiment inserts the corresponding empty information into the query table to represent that the intermediate page table corresponding to the operation address in the original data is empty. For example, if the intermediate page table entry corresponding to the data operation address is empty, a key-value pair <key, HashNode_NULL> can be created and inserted into the query table, as shown in Figure 6 When the child process scans the intermediate page table entry corresponding to the data operation address and finds that it is in writable mode, the query table is searched based on the index information corresponding to the data operation address, and if the corresponding information "HashNode_NULL" is found in the query table, it can be determined that the original intermediate page table entry of the data operation address is empty. The search information corresponding to the empty information is similar to the above embodiment, that is, it is determined based on the address bit range (for example, bit21-bit56) pointing to the corresponding intermediate page table entry. Correspondingly, if the corresponding last layer page table entry is empty, the empty information can be inserted into the corresponding data slot in the HashNode, that is, it represents that the original table entry information corresponding to the data slot is not mapped to any physical page, which will not be described in detail here.
[0093] Further alternatively, in response to the intermediate page table entry of the operation address of the current data operation request being in writable mode, the intermediate page table entry can be copied or the corresponding physical space can have been modified before. Further, in response to the intermediate page table entry of the operation address of the current data operation request being in writable mode and the corresponding last layer page table entry being in read-only mode, it is represented that the last layer page table corresponding to the intermediate page table entry has been copied or some entries in the last layer page table corresponding to the intermediate page table entry have been changed (for example, write operation is performed, etc.). If the last layer page table entry in read-only mode needs to change the data in the corresponding physical page, a corresponding physical page copy can be created based on the write-time copy operation. In response to the intermediate page table entry of the operation address of the current data operation request being in writable mode and the corresponding last layer page table entry being in writable mode, it is represented that the current last layer page table entry has performed the write-time copy operation, and it can perform the corresponding operation based on the data in the physical page copy pointed to by the last layer page table entry.
[0094] Furthermore, when the parent process returns to user mode to process a user request, the child process executes a copy operation of the address mapping table. Furthermore, the child process copies each address mapping table in parallel, for example, by copying the subordinate page tables corresponding to entries in each global page table in parallel. Parallel copying can also be used for each entry in the subordinate page table. The specific parallel implementation method is not limited herein and can be configured based on actual application conditions.
[0095] In this embodiment, before the child process copies the corresponding target page table entry and the physical page corresponding to the target page table entry has not been modified, the target page table entry is in read-only mode. The target page table is also the page table whose entry is set to read-only mode before the child process runs. It can be an intermediate page table or a last-layer page table, or an upper-layer page table before the intermediate page table, etc. For details, please refer to the above embodiments and will not be described in detail here. Therefore, in this embodiment, the child process copies the target page table entry and / or the next-level address mapping table pointed to by the target page table entry in response to the currently copied target page table entry being in read-only mode. Furthermore, the child process retrieves the corresponding query table to obtain the original entry information in response to the currently copied target page table entry being in writable mode to rebuild the historical page table, thereby ensuring the accuracy of the persistent data.
[0096] Figure 7 This is a flowchart of a table copying method for a child process according to an embodiment of the present invention. This embodiment takes the example of the parent process first setting the intermediate page table (PMD table) to read-only mode, and when the execution of subsequent data operation requests has corresponding table entries that need to be changed, the read-only mode is put into the corresponding last-level page table (PT table). This embodiment traverses the memory metadata to determine the address range that the child process needs to copy, and then determines the address mapping tables that need to be copied. In the process of the child process copying each address mapping table, a specific table entry is located in the intermediate page table of the parent process. For this table entry, Figure 7 As shown, the table replication method of the embodiment of the present invention includes the following steps:
[0097] In step S410 , the child process determines the operation mode of the target page table entry (ie, the intermediate page table entry) to be copied.
[0098] Step S420, determine whether the operation mode of the target page table entry is read-only mode or writable mode. In response to the operation mode of the target page table entry being read-only mode, execute steps S430-S440. In response to the operation mode of the target page table entry being writable mode, execute steps S450-S490.
[0099] In step S430, in response to the target page table entry being in read-only mode, the child process copies the target page table entry and each entry in the bottom-level page table pointed to by the target page table entry. That is, in response to the target page table entry being in read-only mode, the child process creates a corresponding child-process bottom-level page table for the target page table entry and copies the contents of each entry in the parent process bottom-level page table corresponding to the target page table entry to the child-process bottom-level page table.
[0100] In this embodiment, since the target page table entry operates in read-only mode, that is, the data in the physical pages corresponding to the entries in the bottom-level page table pointed to by the target page table entry has not changed, that is, the parent process has not modified the target page table entry and the entries in the bottom-level page table pointed to by it, the copy operation can be performed directly. It should be understood that the copy operation of the entries in the bottom-level page table pointed to by the target page table entry can be performed in parallel or serially, and this embodiment is not limited to this.
[0101] Step S440, after all the last-level page table entries pointed to by the target page table entry are obtained, the operation mode of the target page table entry in the parent process and the child process is changed from read-only mode to writable mode, and the operation mode of each page table in the last-level page table pointed to by the target page table entry in the parent process and the child process is changed to read-only mode, so that when the data in the database is changed before it is backed up to disk, the data at the historical moment can be maintained through the above-mentioned write-time copy operation.
[0102] In step S450 , in response to the target page table entry currently being copied being in a writable mode, the child process searches the query table according to the address information corresponding to the target page table entry currently being copied, and obtains the corresponding target hash node.
[0103] Further, as Figure 6 Taking the structure of the query table shown as an example, this embodiment can determine the first-level index key (such as bit21-bit56 in the above example) based on the address bit range corresponding to the current target page table entry, and determine the corresponding hash node based on the first-level index key.
[0104] Step S460 , copy the last-level page table entry corresponding to the empty data slot in the target hash node to the corresponding data slot.
[0105] Optionally, in this embodiment, when a parent process executes a user request and a change occurs to an entry in the final page table pointed to by an intermediate page table entry, a hash node corresponding to the intermediate page table entry is created. Each data slot in the hash node corresponds to each entry in the final page table pointed to by the intermediate page table entry. Therefore, when the child process copies the intermediate page table entry, if the operation mode of the intermediate page table entry is writable, it indicates that a data change has occurred. Based on the address information corresponding to the target page table entry, a query table is retrieved to obtain the corresponding target hash node. Furthermore, the child process scans each data slot in the target hash node. If a data slot is empty, it indicates that the final page table entry corresponding to the data slot has not undergone a data change. The final page table entry in the parent process is copied to the data slot. If the data slot is not empty, it indicates that a data change has occurred to the final page table entry in the parent process. The original entry information in the data slot is the final page table entry information before the data change. Therefore, this embodiment scans each data slot of the target hash node and copies the corresponding last-level page table entry to the empty data slot. The information in each data slot in the target hash node finally obtained is the same as the last-level page table corresponding to the target page table entry in the parent process at the time of data persistence.
[0106] Figure 8 Schematic diagram of the table copy process of the sub-process of the embodiment of the present invention. Figure 8 As shown, in this embodiment, the last-level table entry pointed to by the target page table entry is the PT2 table, and the target hash node corresponding to the target page table entry is HashNode2. The target hash node scanned by the child process is HashNode2. For example, the first data slot of the target hash node HashNode2 is empty. The address information of the first data slot (that is, the secondary index) is determined to be the last-level page table entry in the PT2 table (its address information is the same as or corresponds to the secondary index). The last-level page table entry (for example, pte1) in the determined PT2 table is copied to the first data slot of the target hash node HashNode2. Further, the child process scans and determines that the fourth data slot of the target hash node HashNode2 stores the original table entry information, and does not process it. Therefore, after the child process scans all the data slots in the target hash node HashNode2, the data slots in the target hash node HashNode2 store the table entry information of each item in the PT2 table, which can be used as the last-level table entry of the child process and point to the corresponding physical pages respectively.
[0107] In other optional implementations, this embodiment can also query the operation mode of each last-level page table entry of the last-level page table corresponding to the target page table entry, and copy the last-level page table entry in read-only mode to the corresponding data slot of the target hash node. Furthermore, this embodiment determines the secondary index sub_key based on the address bit range corresponding to the last-level page table entry in read-only mode (for example, bit12-bit20 in the above example), and based on the data slot position in the hash node corresponding to the last-level page table entry in read-only mode of the secondary index sub_key, stores the corresponding last-level page table entry in read-only mode in the data slot of the position. For example, assuming that the specific value of the address bit range corresponding to the last page table entry pte1 in read-only mode is "111011101", based on this, the secondary index sub_key is determined to be 477, that is, the last page table entry in read-only mode should be stored in the 477th data slot in the hash node corresponding to the target page table entry. In this case, the last page table entry pte1 in read-only mode is copied to the 477th data slot in the hash node. For the entries in the last page table in writable mode, their original entry information has been written to the corresponding data slot in the target hash node when the parent process makes memory changes, and no copying is required here.
[0108] Step S470: Remove the target hash node from the lookup table. In this embodiment, after the empty data slot in the target hash node is filled with the corresponding last-level page table entry, the target hash node is used as the last-level page table of the child process. Since the child process has completed the copy of the last-level page table corresponding to the target hash node, the target hash node can be removed from the lookup table.
[0109] Step S480: Point the sub-process target page table entry to the target hash node.
[0110] In this embodiment, the parent process stores the original entry information corresponding to the last-level page table entry where the memory modification occurs in the last-level page table pointed to by the intermediate page table entry where the memory modification occurs in the hash node corresponding to the intermediate page table entry. When the child process copies the last-level page table pointed to by the intermediate page table entry, the hash node corresponding to the intermediate page table entry where the memory modification occurs is determined, and the data slots in the hash node are scanned. The corresponding last-level page table entry is filled in the empty data slot (the corresponding relationship is determined based on the secondary index of the data slot and the address information of each entry in the last-level page table), the hash node is removed from the query table, and the filled hash node is used as the last-level page table of the child process. Therefore, this embodiment makes full use of the storage space of the hash node, improves space utilization, and improves copying efficiency.
[0111] Figure 9This is a flowchart of another table copying method for a child process according to an embodiment of the present invention. This embodiment takes the example of the parent process first setting the intermediate page table (PMD table) to read-only mode, and when the execution of subsequent data operation requests has corresponding table entries that need to be changed, the read-only mode is put into the corresponding last-level page table (PT table) for specific description. This embodiment traverses the memory metadata to determine the address range that the child process needs to copy, and then determines the address mapping tables that need to be copied. In the process of the child process copying each address mapping table, a specific table entry is located in the intermediate page table of the parent process. For this table entry, Figure 9 As shown, the table replication method of the embodiment of the present invention includes the following steps:
[0112] In step S510 , the child process determines the operation mode of the target page table entry (ie, the intermediate page table entry) to be copied.
[0113] Step S520, determine whether the operation mode of the target page table entry is read-only mode or writable mode. In response to the operation mode of the target page table entry being read-only mode, execute steps S530-S540. In response to the operation mode of the target page table entry being writable mode, execute steps S550-S590.
[0114] In step S530, in response to the target page table entry being in read-only operation mode, the child process copies the target page table entry and each entry in the bottom-level page table pointed to by the target page table entry. That is, in response to the target page table entry being in read-only operation mode, the child process creates a corresponding child-process bottom-level page table for the target page table entry and copies the contents of each entry in the parent-process bottom-level page table corresponding to the target page table entry to the child-process bottom-level page table.
[0115] In this embodiment, since the target page table entry operates in read-only mode, that is, the data in the physical pages corresponding to the entries in the bottom-level page table pointed to by the target page table entry has not changed, that is, the parent process has not modified the target page table entry and the entries in the bottom-level page table pointed to by it, the copy operation can be performed directly. It should be understood that the copy operation of the entries in the bottom-level page table pointed to by the target page table entry can be performed in parallel or serially, and this embodiment is not limited to this.
[0116] Step S540, after all the last-level page table entries pointed to by the target page table entry are obtained, the operation mode of the target page table entry in the parent process and the child process is changed from read-only mode to writable mode, and the operation mode of each page table in the last-level page table pointed to by the target page table entry in the parent process and the child process is changed to read-only mode, so that when the data in the database is changed before it is backed up to disk, the data at the historical moment can be maintained through the above-mentioned write-time copy operation.
[0117] In step S550, in response to the target page table entry being copied being in writable mode, the child process queries the operation mode of each of the last-level page table entries in the last-level page table corresponding to the target page table entry. It should be understood that the operation mode of each of the last-level page table entries in the last-level page table corresponding to the target page table entry can be queried in parallel or in series, and this embodiment is not limited to this.
[0118] Step S560, determine whether the operation mode of the last page table entry being queried is read-only mode or writable mode. In response to the operation mode of the last page table entry being read-only mode, execute step S570. In response to the operation mode of the last page table entry being writable mode, execute steps S580-S590.
[0119] Step S570, copying the last-level page table entry in read-only mode, that is, copying the last-level page table entry in read-only mode in the last-level page table of the parent process to the corresponding entry in the last-level page table of the child process. As described in the embodiment of the parent process performing the change operation on the address mapping table when the user requests, the parent process changes the operation mode of the last-level page table entry with data changes to writable mode. Therefore, when the child process finds that the last-level page table entry is in read-only mode, it indicates that the data corresponding to the last-level page table entry has not changed, that is, the parent process has not modified the last-level page table entry, and the copy operation can be performed directly.
[0120] Step S580 , searching the query table according to the operation address corresponding to the last page table entry in the writable mode, and obtaining the corresponding original entry information.
[0121] Further, as Figure 6 Taking the structure of the query table shown as an example, this embodiment can determine the first-level index key (such as bit21-bit56 in the above example) based on the address bit range corresponding to the current target page table entry, and determine the corresponding hash node based on the first-level index key, determine the second-level index sub_key based on the address bit range corresponding to the last page table entry in writable mode (such as bit12-bit20 in the above example), and determine the corresponding original table entry information in the hash node based on the second-level index sub_key. In other optional implementations, the query table can adopt a first-level query method. This embodiment can determine the index information (such as bit12-bit56 in the above example) based on the address bit range corresponding to the current last page table entry, and directly query the corresponding original table entry information based on the index information.
[0122] Step S590 , copy the last page table entry in the original entry information retrieved, that is, copy the last page table entry in the original entry information in the corresponding hash node to the corresponding entry in the last page table of the child process.
[0123] The child process of this embodiment allocates a child process last level page table for the current target page table entry, scans the parent process last level page table pointed to by the target page table entry, copies the content of the last level page table entry in read-only mode in the parent process last level page table to the corresponding entry in the child process last level page table, retrieves the target hash node based on the address information of the target page table entry, queries the target hash node based on the address information of the last level page table entry in writable mode in the parent process last level page table, determines the corresponding data slot, and copies the original entry information stored in the corresponding data slot to the corresponding entry in the child process last level page table. Thus, the child process of the embodiment of the present invention can obtain the corresponding data of the historical moment (that is, the moment when the persistent instruction is obtained), ensuring data consistency and accuracy.
[0124] Furthermore, after completing the copying of the last-level page table entry pointed to by the target page table entry, this embodiment can remove the hash node corresponding to the target page table entry from the query table to release storage space, thereby improving the utilization of the storage space.
[0125] In other optional implementations, for a method in which the parent process sets the last-level page table (PT table) to read-only mode before the child process runs, the table copying method of this embodiment may specifically be: in response to the target page table entry being copied being in writable mode, the child process retrieves the query table according to the operation address corresponding to the target page table entry, obtains the corresponding original table entry information, and copies the last-level page table entry corresponding to the retrieved original table entry information. This embodiment can adopt the above-mentioned first-level query or second-level query method based on the query table setting structure, and this embodiment will not be described in detail here.
[0126] In response to a persistence instruction, an embodiment of the present invention creates a child process corresponding to a parent process, copies the memory metadata corresponding to the parent process to the child process, runs the child process to copy the address mapping table corresponding to the parent process at the time of data persistence based on the memory metadata and the corresponding query table, and in response to the completion of the child process copy, obtains the memory data pointed to by the multi-level address mapping table in the child process for persistence, wherein the query table is used to record the original table entry information of the table entry that has been updated in the parent process address mapping table since the data persistence time. Thus, the embodiment of the present invention enables the child process to complete the copy operation of the address mapping table at each level, and records the table entry changes caused by the data operation processed by the parent process through the query table, thereby ensuring the integrity of the persistent data, reducing the parent process data processing delay caused by data persistence, and improving system performance.
[0127] Figure 10-11It is a schematic diagram of the data persistence process of an embodiment of the present invention. This embodiment takes the example of the parent process first setting the intermediate page table (PMD table) to read-only mode, and when the execution of subsequent data operation requests has corresponding table entries that need to be changed, the read-only mode is put into the corresponding last-level page table (PT table) for specific description. In this embodiment, before the child process runs, the parent process sets the corresponding intermediate page table entries in each intermediate page table to read-only mode to detect data changes such as write operations that may come in the future. Therefore, the parent process of this embodiment does not copy any table entry data in the stage before returning to the user state, but only sets the corresponding intermediate page table entries in each intermediate page table to read-only mode, which greatly improves the efficiency of the fork stage and reduces the pause of the parent process.
[0128] Furthermore, after the process starts running, the child process copies a last-level page table that has not been modified by the parent process. The specific operation process is that in response to the current intermediate page table entry being in read-only mode (i.e., no memory modification operation has been performed), the child process copies a last-level page table pointed to by the intermediate page table entry. After the copy is completed, the operation mode of the intermediate page table entry in the parent process and the child process is changed to writable mode, and the operation mode of each entry in the last-level page table pointed to by the intermediate page table entry in the parent process and the child process is changed to read-only mode.
[0129] Figure 10 The parent process and the child process in the above are displayed starting from the upper page table. It should be understood that the corresponding entries of the global page table and the four-level page table before the current upper page table (PUD table) corresponding to the parent process have been copied by the child process. Figure 10 It is not shown in the figure. The operation mode of the corresponding entries in the global page table and the fourth-level page table are both writable mode "r / w".
[0130] like Figure 10As shown, the child process copies the PUD table of the parent process to obtain the PUD' table in the child process. It should be understood that the mapping relationship between the PUD' table in the child process and the PUD table of the parent process is the same. The table item pud3 in the PUD table points to the corresponding intermediate page table (PMD table), and the child process copies the PMD table to obtain the PMD' table. Furthermore, before the table items in the PMD table are copied, the operation mode of each table item in the PMD table is set to read-only mode. When copying the PMD table, the child process traverses the operation mode of each table item therein. Taking the table item pmde2 in the PMD table as an example, the child process detects that the table item pmde2 is in read-only mode "ro" when traversing to it, indicating that the parent process has not performed a memory modification operation on it. The child process copies the PT1 table pointed to by the table item pmde2 to obtain the PT1' table in the child process. After the child process completes copying the PT1 table pointed to by the entry pmde2, the entry pmde2 in the parent process's PMD table is changed to write mode (r / w) to prevent the parent process's data processing operations from triggering a page fault at the intermediate page table entry after the copy is complete. This improves the parent process's request processing efficiency. The operation mode of each PTE entry in the parent process's PT1 table is changed to read-only mode (ro) to prevent data inconsistencies caused by the parent process performing memory modifications before data persistence is complete. Similarly, after the child process completes copying the PT1 table pointed to by the entry pmde2, the entry pmde2' in the child process's PMD' table is changed to write mode (r / w), and the operation mode of each PTE entry in the child process's PT1' table is changed to read-only mode (ro).
[0131] Furthermore, if the parent process receives a data write request and performs a write operation on the corresponding memory address, the address mapping table entry corresponding to the write operation address of the write request has not been copied by the child process. The address mapping table change process and the storage method of the original entry information can be referred to as follows: Figure 5 and Figure 6 The illustrated embodiment will not be described in detail here.
[0132] Furthermore, when the child process copies to the table entry whose memory is modified by the parent process, the original table entry information is obtained from the query table to reconstruct the corresponding PT table.
[0133] Specifically, if Figure 11As shown, when the child process copies the table entry pmde4 in the PMD table, the child process detects that the table entry pmde4 is in the writable mode "r / w" when traversing to it, indicating that the parent process has performed a memory modification operation on it. The child process determines the corresponding hash node HashNode2 based on the address bit range corresponding to the positioning table entry pmde4 (for example, bit21-bit56 of the above-mentioned binary bit operation address). Furthermore, the child process scans each data slot in the hash node HashNode2. When the data slot is empty, it indicates that the last-level page table entry corresponding to the data slot has not undergone data changes. The last-level page table entry in the parent process is copied to the data slot. When the data slot is not empty, it indicates that the last-level page table entry in the parent process has undergone data changes, and the original entry information in the data slot is the last-level page table entry information before the data change. Therefore, this embodiment scans each data slot of the target hash node and copies the corresponding last-level page table entry to the empty data slot. The information in each data slot in the target hash node finally obtained is the same as the last-level page table corresponding to the target page table entry in the parent process at the time of data persistence.
[0134] For example, the first data slot of the target hash node HashNode2 is empty, and the address information of the first data slot (that is, the secondary index) is determined to be "000000000", and the address information "000000000" is queried to determine that it is the first table entry pte1 in the last-level page table PT2 of the parent process, and the table entry pte1 in the PT2 table is copied to the first data slot slot in the hash node HashNode2. Furthermore, the child process scans and determines that the fourth data slot of the target hash node HashNode2 stores the original table entry information, and does not process it. It should be understood that the other data slots in the target hash node HashNode2 that are in an empty state are filled with table entries with reference to the above-mentioned similar operations. Therefore, after the child process scans all the data slots in the target hash node HashNode2, the data slots in the target hash node HashNode2 store the table entry information of each item in the PT2 table, which can be used as the last-level table entry of the child process and point to the corresponding physical pages respectively.
[0135] Furthermore, the child process removes hash node HashNode2 from the hash table and points the entry pmde4' in the PMD' table to hash node HashNode2. This means that hash node HashNode2 serves as the PT table corresponding to entry pmde4', with each entry pointing to the corresponding original physical page. This embodiment fully utilizes the storage space of the hash node. During child process copying, only the read-only PT page table entries need be copied, further improving efficiency and space utilization.
[0136] In other optional implementations, the child process can also create a PT2' table pointed to by the table entry pmde4' in the PMD' table, copy the table entries in read-only mode in the PT2 table in the parent process to the same position in the PT2' table, and for the table entry pte4 in writable mode in the PT2 table in the parent process, determine the primary index based on the address bit range of the table entry pmde4' to determine the corresponding hash node HashNode2, and determine the secondary index based on the address bit range of the table entry pte4, and query the corresponding original table entry information in the hash node HashNode2 based on the secondary index, and copy the original table entry information to the corresponding position in the PT2' table to complete the copying of the PT2 table in the parent process. After completing the copy operation, the hash node HashNode2 can be removed and deleted from the query table to free up space.
[0137] This embodiment of the present invention uses the aforementioned lookup table to implement table entry backup for memory modification. This allows the parent process to save only the modified single bottom-level page table entry, eliminating the time-consuming copying of the bottom-level page table entry in read-only mode. Furthermore, the physical page corresponding to the modified bottom-level page table entry undergoes only a transfer of ownership, without modifying the reference count. Furthermore, the reference counts of the bottom-level page table entries that do not need to be copied also do not need to be modified. Therefore, this embodiment eliminates the need for atomic operations, further improving system performance.
[0138] Furthermore, in this embodiment, the child process can automatically reconstruct the parent process's historical page table based on the parent process's latest page table and the data in the hash table, thereby ensuring the memory snapshot feature. As a result, this embodiment allows the parent process to perform various memory operations during the child process's page table copy without worrying about affecting the child process's memory view. This embodiment ensures the consistency of persistent data and historical data.
[0139] Furthermore, each node in the query table of this embodiment is configured as an array of a predetermined size, whose memory can be used as the page table space of the child process, eliminating memory waste and improving space utilization. Furthermore, the query table uses a quadratic query method, resulting in a low query algorithm time complexity of O(1).
[0140] Furthermore, when the parent process handles a page fault, it "drops" the read-only flag of the affected intermediate page table entries to each entry in the final page table. It then performs a copy-on-write operation on a specific final page table entry, gradually unfreezing only the necessary intermediate and final page table entries (i.e., removing read-only mode). This allows the child process to efficiently determine whether the parent's final page table entries have been modified, allowing it to decide whether to copy them as is or reconstruct the historical page table using a hash table. This further improves copying efficiency.
[0141] Figure 12 Schematic diagram of a data persistence device according to an embodiment of the present invention. Figure 12 As shown, the data persistence device 12 according to the embodiment of the present invention includes a creation unit 121 , a first replication unit 122 , a second replication unit 123 and a third replication unit 124 .
[0142] The creation unit 121 is configured to create a child process corresponding to the parent process in response to the persistence instruction;
[0143] The first copying unit 122 is configured to copy the memory metadata corresponding to the parent process to the child process;
[0144] The second copying unit 123 is configured to run the child process to copy the address mapping table corresponding to the parent process at the data persistence time based on the memory metadata and the corresponding query table, wherein the query table is used to record the original entry information of the table entry that has been changed in the address mapping table since the data persistence time;
[0145] The third copying unit 124 is configured to persist the memory data pointed to by the multi-level address mapping table in the sub-process in response to completion of copying the sub-process.
[0146] In an optional implementation, before running the child process, the data persistence device 12 also includes a mode setting unit, which is configured to set each table entry in the target page table in the parent process to read-only mode, and the target page table is at least one level in the multi-level address mapping table corresponding to the memory metadata.
[0147] In an optional implementation, the multi-level address mapping table includes a global page table, a four-level page table, an upper page table, an intermediate page table and a last page table. The table entries of the global page table point to the corresponding four-level page table, the table entries of the four-level page table point to the corresponding upper page table, the table entries of the upper page table point to the corresponding middle page table, the table entries of the middle page table point to the corresponding last page table, the table entries of the last page table point to the corresponding physical page, and the target page table is the middle page table or the last page table.
[0148] In an optional implementation, the data persistence device 12 further includes an operation control unit and a state switching unit. The operation control unit is configured to cause the parent process to place the child process in a corresponding run queue so that the child process begins execution. The state switching unit is configured to cause the parent process to return to user mode to process a user's data operation request, wherein the data operation request includes an operation address.
[0149] In an optional implementation, the data persistence device 12 further includes an information generation unit and an insertion unit. The information generation unit is configured to generate original entry information based on the operation address in response to the execution of the data operation request having a corresponding table entry to be changed. The insertion unit is configured to insert the original entry information into the query table and set the table entry to be changed to a writable mode.
[0150] In an optional implementation, the target page table is an intermediate page table, and the information generation unit is further configured to execute: in response to the intermediate page table entry of the operation address being in read-only mode, changing the intermediate page table entry of the operation address to a writable mode, setting each last-level page table entry in the last-level page table corresponding to the intermediate page table entry of the operation address to a read-only mode, generating the original table entry information, the original table entry information including index information and backup information of the last-level page table entry of the operation address, the index information being determined based on the operation address, and changing the last-level page table entry of the operation address to a writable mode.
[0151] In an optional implementation, the data persistence device 12 further includes a fourth copy unit and a control unit. The fourth copy unit is configured to copy the physical page corresponding to the last-level page table entry of the operation address to generate a corresponding physical page copy. The control unit is configured to control the last-level page table entry of the operation address to point to the corresponding physical page copy.
[0152] In an optional implementation, the second copying unit is further configured for the child process to copy the target page table entry and / or the next level address mapping table pointed to by the target page table entry in response to the target page table entry currently being copied being in read-only mode.
[0153] In an optional implementation, the target page table is an intermediate page table, and the second copying unit is further configured to execute: the child process responds to the current copied target page table entry being in writable mode, retrieves the query table according to the address information corresponding to the current copied target page table entry, obtains the corresponding target hash node, copies the last-level page table entry corresponding to the empty data slot in the target hash node to the corresponding data slot, removes the target hash node from the query table, and points the target page table entry copied by the child process to the target hash node.
[0154] In an optional implementation, the query table is a hash table, and the original table entry information in the hash table has corresponding primary index and secondary index, and the primary index and secondary index are determined based on different address bit ranges in the table entry operation address corresponding to the original table entry information.
[0155] In response to a persistence instruction, the embodiment of the application creates a child process corresponding to a parent process, copies memory metadata of the parent process to the child process, runs the child process to copy an address mapping table of the parent process at a data persistence time based on the memory metadata and a corresponding query table, and in response to completion of copying by the child process, persists memory data pointed to by the multi-level address mapping table in the child process, wherein the query table is used to record original table item information of a table item in the parent process address mapping table that has changed since the data persistence time. Thus, the embodiment of the application enables the child process to complete copying of the address mapping tables at all levels, and records table item changes caused by data operations processed by the parent process through the query table, thereby ensuring data persistence integrity, reducing parent process data processing delay caused by data persistence, and improving system performance.
[0156] Figure 13 is a schematic diagram of an electronic device according to an embodiment of the application. As shown in Figure 13 The electronic device 130 is a general-purpose data processing apparatus, which includes a general-purpose computer hardware structure including at least a processor 131 and a memory 132. The processor 131 and the memory 132 are connected by a bus 133. The memory 132 is adapted to store instructions or programs executable by the processor 131. The processor 131 can be a stand-alone microprocessor or a collection of one or more microprocessors. Thus, the processor 131 performs processing of data and control of other apparatuses by executing instructions stored in the memory 132, thereby implementing the method flow of the embodiment of the application as described above. The bus 133 connects the above components together, and connects the above components to a display controller 134 and a display apparatus, and input / output (I / O) devices 135. The input / output (I / O) devices 135 can be a mouse, a keyboard, a modem, a network interface, a touch input device, a body sense input device, a printer, and other apparatuses known in the art. Typically, the input / output devices 135 are connected to the system through an input / output (I / O) controller 136.
[0157] Those skilled in the art should understand that embodiments of the present application can be provided as a method, apparatus (device) or computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-readable storage media (including, but not limited to, disk memory, CD-ROM, optical memory, etc.) containing computer usable program code.
[0158] The present application is described with reference to flowcharts according to the method, apparatus (device) and computer program product of the embodiments of the present application. It should be understood that each flow in the flowcharts can be implemented by computer program instructions.
[0159] These computer program instructions may be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device that implements the process Figure 1 A function specified in a process or multiple processes.
[0160] These computer program instructions can also be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce the instructions for implementing the process Figure 1 A device that specifies functions in a process or multiple processes.
[0161] Another embodiment of the present invention relates to a non-volatile storage medium for storing a computer-readable program, wherein the computer-readable program is used to enable a computer to execute part or all of the above method embodiments.
[0162] That is, those skilled in the art will understand that all or part of the steps in the above-mentioned embodiments can be implemented by specifying relevant hardware through a program, which is stored in a storage medium and includes a number of instructions for causing a device (which may be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., various media that can store program code.
[0163] The foregoing is merely a preferred embodiment of the present application and is not intended to limit the present application. Persons skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application are intended to be within the scope of protection of the present application.
Claims
1. A data persistence method, characterized in that: The method comprises: In response to the persistence instruction, a child process corresponding to the parent process is created; Copy the memory metadata corresponding to the parent process to the child process; Running the child process to copy the address mapping table corresponding to the parent process at the data persistence time based on the memory metadata and the corresponding query table, wherein the query table is used to record original entry information of entries in the address mapping table of the parent process that have changed since the data persistence time; In response to completion of the copying of the sub-process, the memory data pointed to by the multi-level address mapping table in the sub-process is persisted.
2. The method according to claim 1, characterized in that Before running the sub-process, the method further includes: Each table entry in the target page table in the parent process is set to read-only mode, and the target page table is at least one level in the multi-level address mapping table corresponding to the memory metadata.
3. The method according to claim 2, characterized in that The multi-level address mapping table includes a global page table, a four-level page table, an upper page table, an intermediate page table and a last page table. The table entries of the global page table point to the corresponding four-level page table, the table entries of the four-level page table point to the corresponding upper page table, the table entries of the upper page table point to the corresponding middle page table, the table entries of the middle page table point to the corresponding last page table, the table entries of the last page table point to the corresponding physical pages, and the target page table is the middle page table or the last page table.
4. The method according to claim 2, characterized in that The method further comprises: The parent process places the child process in a corresponding run queue so that the child process starts execution; The parent process returns to the user state to process the user's data operation request, where the data operation request includes an operation address.
5. The method according to claim 4, characterized in that The method further comprises: In response to the execution of the data operation request having a corresponding table entry to be changed, generating original table entry information based on the operation address; The original entry information is inserted into the query table, and the entry to be changed is set to a writable mode.
6. The method according to claim 5, characterized in that The target page table is an intermediate page table, and generating original table entry information based on the operation address includes: In response to the intermediate page table entry of the operation address being in a read-only mode, changing the intermediate page table entry of the operation address to a writable mode; Setting each last-level page table entry in the last-level page table corresponding to the middle page table entry of the operation address to read-only mode; Generate the original table entry information, the original table entry information including index information and backup information of the last page table entry of the operation address, the index information being determined based on the operation address; The last page table entry of the operation address is changed to a writable mode.
7. The method according to claim 6, characterized in that The method further comprises: Copying the physical page corresponding to the last-level page table entry of the operation address to generate a corresponding physical page copy; The last-level page table entry of the operation address is controlled to point to the corresponding physical page copy.
8. The method according to claim 2, characterized in that The running of the child process to copy the address mapping table corresponding to the parent process at the data persistence time based on the memory metadata and the corresponding query table includes: In response to the target page table entry currently being copied being in read-only mode, the child process copies the target page table entry and / or a next-level address mapping table pointed to by the target page table entry.
9. The method according to claim 5, characterized in that The target page table is an intermediate page table, and running the child process to copy the address mapping table corresponding to the parent process at the data persistence time based on the memory metadata and the corresponding query table includes: In response to the target page table entry currently being copied being in a writable mode, the child process searches the query table according to address information corresponding to the target page table entry currently being copied, and obtains a corresponding target hash node; Copy the last page table entry corresponding to the empty data slot in the target hash node to the corresponding data slot; Remove the target hash node from the query table; Point the sub-process target page table entry to the target hash node.
10. The method according to claim 5, characterized in that The query table is a hash table, and the original table entry information in the hash table has corresponding primary indexes and secondary indexes, and the primary indexes and secondary indexes are determined based on different address bit ranges in the table entry operation address corresponding to the original table entry information.
11. A data persistence device, characterized in that: The device comprises: A creation unit, configured to create a child process corresponding to the parent process in response to the persistence instruction; A first copying unit is configured to copy the memory metadata corresponding to the parent process to the child process; a second copying unit configured to run the child process to copy the address mapping table corresponding to the parent process at the data persistence time based on the memory metadata and the corresponding query table, wherein the query table is used to record original entry information of entries in the address mapping table of the parent process that have been changed since the data persistence time; The third copying unit is configured to persist the memory data pointed to by the multi-level address mapping table in the sub-process in response to completion of the copying of the sub-process.
12. An electronic device comprising a memory and a processor, characterized in that: The memory is configured to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
14. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to perform the method according to any one of claims 1 to 10.