Data access method, medium, and electronic device
By determining the read and write strategy for each node device based on the read and write characteristics of the memory block, the problem of high latency between nodes in the global memory system is solved, and more efficient memory access and business operation efficiency is achieved.
Patent Information
- Application Number
- PCT/CN2024/081208
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-25
- Filing Date
- 2024-03-12
- Publication Date
- 2025-03-06
AI Technical Summary
In global memory systems, the data communication latency between nodes is high, resulting in inefficient frequent access to data in global memory, especially in services such as big data computing and high-performance computing.
By determining a read and write strategy for each node device according to the read and write characteristics of the memory block, most read and write operations can be performed in local memory, reducing communication between nodes. The specific method includes obtaining the read and write operation information of the node device to the memory block, determining the read and write operation characteristics, and distinguishing the node device into a primary node and a secondary node to optimize the read and write strategy.
It effectively reduces communication between nodes, reduces the communication delay of reading and writing data in the global memory system, improves the access speed of node devices to memory, and improves business operation efficiency, such as high-performance computing services.
Smart Images

Figure CN2024081208_06032025_PF_FP_ABST
Abstract
Description
Data access method, medium and electronic device
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on August 25, 2023, with application number 202311087063.0 and application name “A Data Access Method, Medium and Electronic Device”. The entire contents of the above application are incorporated by reference into this application. Technical Field
[0002] The present invention relates to the field of computer technology, and in particular to a data access method, medium and electronic equipment. Background Art
[0003] Currently, memory resource pooling is increasingly being used in business systems such as big data computing and high-performance computing (HPC). Memory resource pooling involves building a global memory resource pool (hereinafter referred to as global memory) across multiple nodes (e.g., servers), while retaining the remaining memory resources as local memory resources within each node (hereinafter referred to as local memory). As shown in Figure 1, taking the global memory system consisting of nodes A through C as an example, nodes A through C can share memory resources in global memory and access memory resources in their own local memory.
[0004] Because the latency of data communication between nodes is higher than the latency of a node accessing its own memory, to avoid frequent access to global memory belonging to other nodes, nodes will pre-store the data they need to access recently in global memory in their local memory. Furthermore, to prevent conflicts when nodes access data in global memory, a cache consistency protocol (modified-shared-invalid, MSI) is typically used to mark memory blocks that nodes read from global memory to their local memory. Specifically, memory blocks can be marked as modified (M), shared (S), or invalid (I). A memory block is the smallest unit for reading and writing data in memory, also known as a "page," and can range from 4 kilobytes (KB) to 8KB.
[0005] For example, when both Node A and Node B read the data of memory block X from global memory into their local memory, the data of memory block X in the local memory of Node A and Node B is consistent with the data in global memory, so both are recorded in the S state. If Node A modifies the data of memory block X in its local memory, the state of Node A for memory block X changes to M. Node A also sends an invalidation request to Node B, causing the state of Node B for memory block X to change to I. When Node B needs to retrieve the data of memory block X again, it needs to send a request to Node A, causing Node A to send the modified data of memory block X to Node B.
[0006] The MSI protocol can prevent inconsistencies between local memory and data stored in other nodes after memory block data is modified in the local memory. The MSI protocol ensures that all nodes can obtain the latest global memory data.
[0007] However, after using the MSI protocol, nodes still need to send each other memory block status requests and the latest data, and there is a high communication delay between nodes, which leads to low efficiency in node access to data in global memory, making the efficiency of businesses such as big data computing also low.
[0008] Summary of the Invention
[0009] The present application provides a data access method, medium and electronic device, which can determine the read and write strategy for each node device based on the read and write characteristics of the memory block, which can better adapt to the actual situation of each memory block, so that most read and write operations can be performed in the local memory of the node, reducing communication between nodes.
[0010] In a first aspect, a data access method is provided, which is applied to a global memory system, wherein the global memory system includes a first device and multiple node devices, the node devices include local memory and global memory, the multiple node devices share the global memory, and the global memory includes a first memory block, wherein the method includes: the first device obtains operation information of read and write operations performed by multiple node devices on the first memory block, the operation information is used to represent the access rate of the read and write operations on the first memory block; the first device determines the read and write operation characteristics of the multiple node devices corresponding to the first memory block based on the operation information; the first device determines the read and write strategy of the multiple node devices corresponding to the first memory block based on the read and write operation characteristics, and the read and write strategy includes distinguishing the multiple node devices into primary nodes and secondary nodes for performing read and write operations.
[0011] In the above method, the first device determines the read and write strategy for each node device based on the read and write characteristics of the memory block, which can better adapt to the actual situation of each memory block, rather than simply classifying the memory block into M state, S state, and I state based on whether it has been modified. Furthermore, most read and write operations performed by the node device can be executed in local memory, which can reduce inter-node communication, reduce the communication latency of reading and writing data in the global memory system, and improve the node device's access speed to memory. In addition, it can also improve the operating efficiency of the services performed by the node device, such as high-performance computing services.
[0012] In combination with the first aspect, in some implementations, the access rate is determined based on the number and / or time of read and write operations performed by multiple node devices on the first memory block.
[0013] In the above method, the access rate can be the ratio of the number or duration of read and write operations to all access operations, and whether the read and write operations to the memory block originate from multiple node devices or are mostly from the same node device. Furthermore, the first device can determine a read and write strategy for each node device based on the read and write characteristics of the memory block, thereby better adapting to the actual situation of each memory block.
[0014] In combination with the first aspect, in some implementations, the type of primary node includes a metadata node that stores the first memory block.
[0015] In combination with the first aspect, in some implementations, the type of the main node includes a read master node whose operation information of the read operation meets a first condition, and the first condition includes that the value of the access rate of the node device's read operation on the first memory block meets a first preset condition.
[0016] In combination with the first aspect, in some implementations, the type of the main node includes a write master node whose operation information of the write operation meets a second condition, and the second condition includes that the value of the access rate of the node device's write operation on the first memory block meets a second preset condition.
[0017] In combination with the first aspect, in some implementations, the types of main nodes include read-write main nodes whose operation information of read operations and write operations meets a third condition, and the third condition includes that the value of the access rate of the node device's read operation on the first memory block meets the first preset condition, and the value of the access rate of the write operation on the first memory block meets the second preset condition.
[0018] In the above method, the first device identifies specific nodes among the node devices based on read / write characteristics, such as metadata nodes, read master nodes, write master nodes, and read / write master nodes. Determining the node type for each node device based on the read / write characteristics of the memory block can better adapt to the actual situation of each memory block.
[0019] In combination with the first aspect, in some implementations, the read and write operation characteristics include a read-write ratio, and the method further includes: the first device determines that the read-write operation ratio of the first memory block is read-mostly based on that the value of the access rate of read operations of multiple node devices to the first memory block is greater than the value of the access rate of write operations to the first memory block; or the first device determines that the read-write operation ratio of the first memory block is write-mostly based on that the value of the access rate of read operations to the first memory block is less than or equal to the value of the access rate of write operations to the first memory block.
[0020] In the above method, the read-write ratio in the read-write characteristics can include more read operations than write operations (read more / write less) or more write operations than read operations (read less / write more). In this way, determining the node device type for each node device based on the read-write characteristics of the memory block can better adapt to the actual situation of each memory block.
[0021] In combination with the first aspect, in some implementations, the read and write operation characteristics include read and write distribution, and the method also includes: the first device determines that the read and write distribution of the first memory block is read exclusive based on the existence of a read master node in multiple node devices; or, the first device determines that the read and write distribution of the first memory block is read shared based on the absence of a read master node in multiple node devices.
[0022] In combination with the first aspect, in some implementations, the read and write operation characteristics include read and write distribution, and the method also includes: the first device determines that the read and write distribution of the first memory block is write-exclusive based on the existence of a write master node in multiple node devices; or, the first device determines that the read and write distribution of the first memory block is write-shared based on the absence of a write master node in multiple node devices.
[0023] In combination with the first aspect, in some implementations, the read and write operation characteristics include read and write distribution, and the method also includes: the first device determines that the read and write distribution of the first memory block is exclusive access based on the existence of a read and write master node in multiple node devices; or, the first device determines that the read and write distribution of the first memory block is shared access based on the absence of a read and write master node in multiple node devices.
[0024] In the above method, read and write distribution can include being written by multiple node devices (write sharing), having most write operations originate from the same node device (write exclusive), having most read operations originate from the same node device (read exclusive), having data read by multiple node devices (read sharing), having most read and write operations originate from the same node device (access exclusive), and having read and write operations originate from different node devices (access sharing). In this way, determining the node device type for each memory block based on its read and write characteristics can better adapt to the actual situation of each memory block.
[0025] In combination with the first aspect, in some implementations, the method also includes: the first device determines that the read and write operation characteristics of the first memory are read-mostly based on the read-write ratio of the first memory block being read-mostly and the read-write distribution being read-shared, write-shared, write-exclusive, or access-shared; the first device determines that the read and write operation characteristics of the first memory are access-exclusive based on the read and write ratio of the first memory block being read-mostly and the read-write distribution being read-exclusive or access-exclusive, or the read and write ratio of the first memory block being write-mostly and the read-write distribution being write-exclusive or access-exclusive; the first device determines that the read and write operation characteristics of the first memory are write-shared based on the read and write ratio of the first memory block being write-mostly and the read-write distribution being write-shared or access-shared.
[0026] In the above method, the corresponding read-write strategy can also be determined in combination with the read-write ratio and the read-write distribution. In this way, the type of node device is determined for each node device according to the read-write characteristics of the memory block, which can better adapt to the actual situation of each memory block.
[0027] In combination with the first aspect, in some implementations, the method further includes: the first device determines that the read and write operation characteristics of the first memory are write-exclusive based on the fact that the value of the access rate of the write operation of the first memory block is greater than the first threshold and less than or equal to the second threshold, and the read-write distribution is write-exclusive; the first device determines that the read and write operation characteristics of the first memory are read-exclusive based on the fact that the value of the access rate of the read operation of the first memory block is greater than the third threshold and less than or equal to the fourth threshold, and the read-write distribution is read-exclusive.
[0028] In the above method, the corresponding read-write strategy can also be determined in combination with the read-write ratio and the read-write distribution. In this way, the type of node device is determined for each node device according to the read-write characteristics of the memory block, which can better adapt to the actual situation of each memory block.
[0029] In combination with the first aspect, in some implementations, the method also includes: the first device determines a metadata node among multiple node devices based on the read and write operation characteristics being write sharing, and determines other node devices except the metadata node as write sharing nodes among secondary nodes; based on the first write sharing node among the write sharing nodes receiving a write request corresponding to the first memory block, the first write sharing node updates the write node of the first memory block in the metadata node to the first write sharing node; and based on the second write sharing node among the write sharing nodes receiving a read request, the second write sharing node obtains the write node of the first memory block from the metadata node; based on the second write sharing node obtaining the write node as the first write sharing node, the second write sharing node obtains data corresponding to the first memory block from the first write sharing node.
[0030] In this method, the requesting node does not need to send invalidation requests to every other node device when writing data, reducing communication overhead. After updating data, the requesting node only needs to update the latest write node to the metadata node. This allows the next node device that needs to read or write data to know the node where the latest data is located through the metadata node.
[0031] In combination with the first aspect, in some implementations, the method also includes: the first device determines a read-write master node among multiple node devices based on the read-write operation characteristic being access exclusive, and determines the node devices other than the read-write master node as access secondary nodes among the secondary nodes; based on the access shared node receiving a read request, the access secondary node requests the data of the first memory block from the read-write master node; and based on the access shared node receiving a write request corresponding to the first memory block, the access secondary node sends the data corresponding to the write request to the read-write master node; and based on the read-write master node receiving a read request corresponding to the first memory block, the read-write master node reads the data of the first memory block in the local memory; and based on the read-write master node receiving a write request corresponding to the first memory block, the read-write master node reads and updates the data of the first memory block in the local memory.
[0032] In the above method, since in the case of exclusive access, the node device that mainly performs read and write operations on the memory block is the read-write master node, when ensuring that the read-write master node has the latest data, the read-write master node can directly read or write the data of the memory block, which can reduce communication between nodes.
[0033] In combination with the first aspect, in some implementations, the method further includes: the first device determines a write master node among multiple node devices based on the read and write operation characteristics being write exclusive, and determines node devices other than the write master node as write secondary nodes among the secondary nodes; based on the write master node receiving a read request corresponding to the first memory block, the write master node reads data of the first memory block in the local memory; and based on the write master node receiving a write request corresponding to the first memory block, the write master node sends an invalidation request to the write secondary node; and based on the non-invalidated write secondary node receiving a read request corresponding to the first memory block, The non-invalidated write secondary node reads the data of the first memory block in the local memory, wherein the non-invalidated write secondary node refers to a write secondary node that has not received the invalidation request sent by the write master node; and, based on the invalidated write secondary node receiving the read request corresponding to the first memory block, the invalidated write secondary node requests the data of the first memory block from the write master node, wherein the invalidated write secondary node refers to the write secondary node that received the invalidation request sent by the write master node; and, based on the write secondary node receiving the write request corresponding to the first memory block, the write secondary node sends the data corresponding to the write request to the write master node.
[0034] In the above method, after updating data, the secondary write node sends the updated data to the primary write node, ensuring that the primary write node has the latest data. In the case of exclusive write, the primary write node performs most write operations. If the primary write node can store the latest data, it can directly perform write operations, reducing inter-node communication.
[0035] In combination with the first aspect, in some implementations, the method also includes: the first device determines a read master node among multiple node devices based on the read and write operation characteristics being read exclusive, and determines the node devices other than the read master node as read secondary nodes among the secondary nodes; based on the read master node receiving a read request corresponding to the first memory block, the read master node reads the data of the first memory block in the local memory; and, based on the read master node receiving a write request corresponding to the first memory block, the read master node sends an invalidation request to the read secondary node; and, based on the read secondary node receiving a read request corresponding to the first memory block, the read secondary node requests the data of the first memory block from the read master node; and, based on the read secondary node receiving a write request corresponding to the first memory block, the read secondary node sends the data corresponding to the write request to the read master node.
[0036] In this method, after a secondary node updates data, it synchronizes the updated data with the read master node, ensuring that the read master node's local memory always stores the latest data. In the case of exclusive reads, the read master node performs most read operations. If the read master node stores the latest data, it can directly perform read operations, reducing inter-node communication.
[0037] In combination with the first aspect, in some implementations, the method also includes: based on the read-write operation characteristic being read-most, multiple node devices receive a read request corresponding to a first memory block, and multiple node devices read the data of the first memory block in the corresponding local memory; and, a fourth node device among the multiple node devices receives a write request corresponding to the first memory block, and the fourth node device sends the data corresponding to the write request to other node devices.
[0038] In the above method, any node device that performs a write operation can synchronize the latest data to other node devices, so that each node device can directly read the data in the local memory when performing a read operation, thereby reducing communication between nodes.
[0039] In combination with the first aspect, in some implementations, the method also includes: the first device obtains location information of data read by multiple node devices in the first memory block; the first device divides the first memory block into multiple sub-blocks according to the location information corresponding to the multiple node devices; the first device determines the read and write operation characteristics of the multiple sub-blocks in the first memory block based on the operation information; the first device determines the read and write strategies of the multiple node devices corresponding to the multiple sub-blocks based on the read and write operation characteristics of the multiple sub-blocks.
[0040] In the above method, by dividing the sub-blocks, the amount of data required to store node information is reduced, and the problem of frequent modification of node information in the memory block when multiple node devices 200 access different locations of the same memory block is avoided.
[0041] In combination with the first aspect, in some implementations, the method further includes: within a preset time when the node device performs read and write operations on the data of the first memory block in the local memory, the node device determines a read and write policy corresponding to the first memory block; based on the node device determining that the data of the first memory block in the local memory is a new value according to the read and write policy, the node device continues to perform the read and write operations; based on the node device determining that the data of the first memory block in the local memory is an old value according to the read and write policy, the node device re-executes the read and write operations according to the read and write policy.
[0042] In the above method, if the speculation is successful, it means that the node device can directly access the data, which consumes less time and saves data access time.
[0043] In combination with the first aspect, in some implementations, the method further includes: the first device determines the read and write operation characteristics of multiple memory blocks based on the operation information of the read operations of the multiple memory blocks; the first device determines the read and write strategies of the multiple memory blocks based on the read and write operation characteristics of the multiple memory blocks; the fifth node device determines the number of memory blocks in the local memory of the fifth node device that are out-of-bounds values based on the read and write operation characteristics of the multiple memory blocks, wherein the out-of-bounds value means that after the fifth node device reads the memory block data, the number of times the memory block data is updated by other node devices exceeds a preset number, or the fifth node device does not update the memory block data for a preset period of time; based on the fact that the number of memory blocks in the fifth node device that are out-of-bounds values does not exceed the preset number, the fifth node device performs a read operation or a write operation on the data of the multiple memory blocks in the local memory of the fifth node device; or, based on the fact that the number of memory blocks in the fifth node device that are out-of-bounds values exceeds the preset number, the fifth node device performs a read operation or a write operation on the data of the multiple memory blocks in the local memory of the fifth node device according to the read and write strategy of the multiple memory blocks.
[0044] In the above method, by determining the number of bounded values, the situation where node devices execute read and write strategies to obtain the latest data can be effectively reduced. In some cases, node devices can directly use data in local memory, reducing communication between nodes.
[0045] In a second aspect, the present application provides an electronic device, characterized in that it includes a processor and a memory, the memory is used to store instructions, and the processor is used to execute instructions. When the processor executes the instruction, it performs the method described in the first aspect.
[0046] In a third aspect, the present application provides a computer-readable storage medium, characterized in that instructions are stored in the computer-readable storage medium, and when the instructions are run on a computing device, the method described in the first aspect is executed.
[0047] In a fourth aspect, the present application provides a computer program product, characterized in that the computer program product includes computer instructions, and when executed by a computing device, the computing device performs the method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments.
[0049] FIG1 is a schematic diagram of a system structure of a global direct-attached memory provided by an embodiment of the present application;
[0050] FIG2 is a schematic diagram of a server shared global memory structure provided in an embodiment of the present application;
[0051] FIG3 is a schematic diagram of an interaction of read and write operations corresponding to an MSI protocol provided in an embodiment of the present application;
[0052] FIG4 is a schematic diagram of an interaction of read and write operations corresponding to another MSI protocol provided in an embodiment of the present application;
[0053] FIG5A is a schematic diagram of the system structure of another global direct-attached memory provided in an embodiment of the present application;
[0054] FIG5B is a schematic diagram of the structure of a data access system provided in an embodiment of the present application;
[0055] FIG6 is a schematic diagram of the structure of another server shared global memory provided in an embodiment of the present application;
[0056] FIG7 is a schematic diagram of determining a read / write strategy based on read / write characteristics according to an embodiment of the present application;
[0057] FIG8 is a schematic diagram of the interaction of read and write operations corresponding to a write sharing strategy provided in an embodiment of the present application;
[0058] 9 is a schematic diagram of an interaction between read and write operations corresponding to an access exclusive policy provided in an embodiment of the present application;
[0059] FIG10 is a schematic diagram of an interaction between read and write operations corresponding to a write exclusive policy provided in an embodiment of the present application;
[0060] FIG11 is a schematic diagram of an interaction between read and write operations corresponding to a read exclusive policy provided in an embodiment of the present application;
[0061] FIG12 is a schematic diagram of an interaction between read and write operations corresponding to a read-multiple strategy provided in an embodiment of the present application;
[0062] FIG13 is a schematic diagram of evenly dividing memory blocks provided in an embodiment of the present application;
[0063] FIG14 is a schematic diagram of another method of evenly dividing memory blocks provided in an embodiment of the present application;
[0064] FIG15 is a schematic diagram of dividing memory blocks according to node read positions provided by an embodiment of the present application;
[0065] FIG16 is a schematic diagram of another method of dividing memory blocks according to node read positions provided by an embodiment of the present application;
[0066] FIG17 is a schematic diagram of a speculative delay provided by an embodiment of the present application;
[0067] FIG18 is a schematic diagram of an adaptive speculation system provided by an embodiment of the present application;
[0068] FIG19 is a schematic diagram of a bounded inconsistency method provided by an embodiment of the present application;
[0069] FIG20 is a flow chart of a data access method provided in an embodiment of the present application;
[0070] FIG21 is a schematic structural diagram of a data access device provided in an embodiment of the present application;
[0071] FIG22 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0072] Illustrative embodiments of the present application include, but are not limited to, data access methods, media, and electronic devices.
[0073] First, the global memory system involved in the embodiment of the present application is introduced in conjunction with Figure 2, wherein Figure 2 uses a server as an example for illustration. The global memory system includes servers 1 to 3, and server 1 is used as an example for illustration to perform high-performance computing.
[0074] Server 1 includes a high-performance computing platform 210, specifically including an application programming interface (API) 211, a global memory directory entry 212, a runtime engine 213, a memory management unit 214, and a communication management unit 215. Server 1 also includes hardware resources: a processor 216, local memory 217, global memory 218, and a network interface card 219. Processor 216, local memory 217, global memory 218, and network interface card 219 can be interconnected via an internal bus or communicate via other means such as wireless transmission, which are not shown in FIG.
[0075] The structures of Server 2 and Server 3 can refer to those of Server 1, and may also include more or fewer modules than Server 1. This application does not impose any specific limitations on this. Furthermore, Servers 1 through 3 are interconnected via network switch 201, and Servers 1 through 3 can share global memory. For example, Server 1 uses a portion of its memory as global memory 218, and Servers 1 through 3 can all use the storage space of global memory 218.
[0076] Among them, the high-performance computing platform 210 is run by the processor 216, and can be specifically used to provide model training or reasoning services such as image processing and autonomous driving, and this application does not impose specific restrictions on this. The programming interface 211 in the high-performance computing platform 210 can be used to transmit information between different programs, for example, a program function in high-performance computing obtains the calculation results generated by another program function, or writes the calculation results to the local memory 217 through the programming interface 211. The global memory directory entry 212 is used to represent the attribute information of the memory block contained in the global memory in the global memory system, such as the metadata node to which the memory block belongs, the MSI status, etc. The runtime engine 213 may include functional functions that need to be called by the programming language, etc.
[0077] The memory management module 214 may include a memory sequential consistency model and a local memory consistency protocol.
[0078] The memory sequential consistency model is used to manage the order in which the processor 216 performs a series of read and write operations on the local memory 217 or the global memory 218. For example, if the processor 216 executes multiple threads, the memory sequential consistency model is used to determine the execution order of the multiple threads to avoid reordering of memory operations. The memory sequential consistency model can specifically adopt the sequential consistency memory model (SC), the relaxed memory model (RMM), and the total store order (TSO).
[0079] The local memory consistency protocol ensures that data read from global memory by different servers is consistent. This is typically implemented using the MSI protocol, which handles cache consistency in multi-core processors. In the MSI protocol, cache corresponds to local memory, and memory in the MSI protocol corresponds to global memory. The MSI protocol is explained in detail below, with reference to Figure 3.
[0080] The communication management unit 215 is used to manage the communication of server 1, so that server 1 can communicate with the hardware devices within server 1 through the communication interface, as well as communicate with other devices. For example, server 1 can communicate with other servers through the network card 219 and the network switch 201, and can then access the global memory of other servers.
[0081] Processor 216 can be composed of at least one general-purpose processor, such as a central processing unit (CPU), or a combination of a CPU and a hardware chip. The hardware chip can be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. Processor 216 executes various types of digitally stored instructions, such as software or firmware programs stored in local memory 217, enabling server 1 to provide high-performance computing services.
[0082] Local memory 217 and global memory 218 may include volatile memory, such as dynamic random access memory (DRAM); non-volatile memory, such as flash memory, phase change memory (PCM), and resistive random-access memory (RRAM); or a combination of these. Local memory 217 and global memory 218 may be used to store data required by the high-performance computing platform 210. Local memory 217 may also be used to store program code, and processor 216 controls execution of the program code.
[0083] It is worth noting that Figure 2 is merely a schematic diagram of a global memory system and server architecture provided by an embodiment of the present application. The positional relationships between the devices, components, modules, etc. shown in the figure do not constitute any limitation. For example, in Figure 2, servers 1 to 3 are used as an example. In other cases, other servers may also be included. This application does not impose specific limitations on this.
[0084] The following is a detailed introduction to the MSI protocol involved in this application. As can be seen from the above, the MSI protocol will mark the memory blocks read from the global memory to the local memory of the node, specifically marking them as modified (M), shared (S) and invalid (I).
[0085] The following describes, with reference to Figures 3 (A) through (E), the process of each node reading and writing to a memory block Y in global memory when the data in each node's local memory is in the M, S, and I states, respectively. Furthermore, for ease of description, in Figures 3 (A) through (E), the corresponding nodes are denoted as M-node, S-node, and I-node, respectively, when the data in memory block Y is in the M, S, and I states, respectively, in the local memory of each node.
[0086] (1) Perform a read operation on the S node.
[0087] An S node refers to a node whose data in the local memory is consistent with the data of memory block Y in the global memory. That is, after the S node reads the data of memory block Y from the global memory, no other node has modified the data of memory block Y. It should be understood that there can be multiple S nodes for memory block Y. Therefore, the local memory of the S node contains the latest data of memory block Y. As shown in (A) in Figure 3, when the S node receives a request to read data (hereinafter referred to as a read request), the S node can directly read its own local memory to obtain the data of memory block Y.
[0088] (2) Perform write operations on the S node.
[0089] When an S node receives a request to write local data to memory block Y (hereinafter referred to as a write request), it will invalidate other S nodes, so that other S nodes can know that the data in memory block Y has been modified, and the state of the S node performing the write operation will also be updated to M state. As shown in (B) in Figure 3, it includes:
[0090] 3B-1: Node S receives the write request.
[0091] 3B-2: The S-node will send an invalidation request to the other S-nodes. (B) in Figure 3 uses two S-nodes as an example. It should be understood that if there are three or more S-nodes, the S-node will also send an invalidation request to the other S-nodes.
[0092] 3B-3: Other S nodes will change their status to I nodes. I nodes indicate that the data in memory block Y has been modified by other nodes, and the data in memory block Y in the local memory of I nodes is no longer the latest data.
[0093] 3B-4: The other S nodes send a reply to the S node, indicating that the other S nodes have been invalidated as I nodes.
[0094] 3B-5: The S node changes its status to an M node. The S node also executes the data write operation based on the write request and changes its status to an M node. An M node indicates that the data in memory block Y in the node's local memory is the latest data. It should be understood that when there is only one M node for memory block Y, all other nodes are I nodes.
[0095] (3) Perform read and write operations on the M node.
[0096] Since the M node indicates that the data of the memory block Y in the local memory of the node is the latest data, as shown in (C) in FIG3 , the M node can directly read and write the data in the local memory.
[0097] (4) Perform a read operation on the I node.
[0098] The I node indicates that the data of memory block Y has been invalidated in this node, and other nodes have modified the data of memory block Y. Therefore, as shown in (D) in Figure 3, when the I node needs to read the data of memory block Y, the following steps are included:
[0099] 3D-1: The I node receives a read request.
[0100] 3D-2: Node I requests the latest data from node M. Node M is the node that most recently modified the data in memory block Y. Therefore, node I can obtain the latest data in memory block Y from node M.
[0101] 3D-3: Node M sends the latest data to node I.
[0102] (5) Perform write operation on the I node.
[0103] The I node does not have the latest data for memory block Y, so it needs to obtain the latest data from the M node before it can perform a write operation. After the I node performs a write operation, the I node will be updated to the M node, and the previous M node will be invalidated as an I node. As shown in (E) in Figure 3, this process may include:
[0104] 3E-1: The I node receives a write request.
[0105] 3E-2: The I node requests the latest data from the M node.
[0106] 3E-3: Node M sends the latest data to node I.
[0107] 3E-4: Node M changes its status to Node I. After Node M sends the latest data in memory block Y to Node I, Node I performs a write operation, causing the data currently in Node M to become outdated. Therefore, Node M must change its status to Node I. It should be understood that this step can also be performed after Node I completes the write operation, and this is not specifically limited in this application.
[0108] 3E-5: The I node changes to an M node. After the I node obtains the latest data, it writes the corresponding data according to the write request, making the current node the latest data. The I node then changes its status to an M node.
[0109] In some embodiments, a node's global memory directory entry stores only the state data for each memory block for that node and the metadata node for that memory block. The metadata node refers to the node where the memory block is actually stored. The metadata node stores the state of the memory block actually stored in the node's global memory for each node.
[0110] For example, the I-node only knows that the memory block's status for this node is I and the metadata node where the memory block is actually stored. It does not know which M-node stores the latest data for the memory block. Therefore, when performing read and write operations on the I-node, the I-node needs to send a request to the metadata node to obtain the M-node for the memory block.
[0111] For example, as shown in FIG4 , a global memory system including nodes A to D is used as an example. For example, memory block Y is stored in node D, i.e., node D is a metadata node. Furthermore, for memory block Y, when the state of node A is M, and both nodes B and C are I, the process of performing a write operation on node B (I state) includes:
[0112] 4-1: Node B receives a write request.
[0113] 4-2: Node B requests the latest data from the metadata node. Node B only knows the metadata node where memory block Y is actually stored, and does not know the node M that stores the latest data for memory block Y. Therefore, it needs to send a request to the metadata node.
[0114] 4-3: The metadata node forwards the request to node A. The metadata node queries the global memory directory entry and determines that the status of node A is M. It then forwards the request for node B to obtain the latest data to node A.
[0115] 4-4: Node A sends the latest data to node B. Node A reads the latest data corresponding to memory block Y from its local memory and sends it to node B. Node B can then perform a write operation based on the latest data in memory block Y. After node B completes the write operation, its state changes to M and node A's state changes to I.
[0116] If the state of node B is M and both nodes A and C are I, then if a write operation is performed on node C (I state), the process includes:
[0117] 4-5: Node C receives the write request.
[0118] 4-6: Node C requests the metadata node M to send the latest data.
[0119] 4-7: The metadata node forwards the request to node B.
[0120] 4-8: Node B sends the latest data to node C. Node C can then perform a write operation based on the current latest data. After node C completes the write operation, the state of node C changes to M and the state of node B changes to I.
[0121] In summary, the MSI protocol ensures that all nodes retrieve the latest data from their local memory. This prevents situations where, after a node's local memory is modified, other nodes retrieve the same, unmodified data from their local memory. The MSI protocol ensures that all nodes read consistent data from the same memory block. Furthermore, each node can pre-store data from global memory in its local memory, eliminating the need to communicate with other nodes each time it reads global memory.
[0122] However, the MSI protocol still involves a significant amount of inter-node communication, especially when a memory block is in the I state or when a write operation is required on a memory block in the S state. For details, see Figures 3(B), 3(D), 3(E), and 4 and their related descriptions. Due to the large amount of inter-node communication in the MSI protocol, such as sending state change requests and the latest data, significant communication latency still exists in the global memory system, resulting in relatively slow node access to memory.
[0123] In order to solve the problem of slow access speed of nodes to global memory in a global memory system, the present application provides a data access method that can be applied to the global memory system and electronic device 100 as shown in Figure 1. The global memory system includes multiple node devices 200, and the electronic device 100 can be any node device in the global memory system, or it can be a management device of the global memory system, that is, a device connected to the global memory system but not sharing memory with the node devices 200 in the global memory system.
[0124] The electronic device 100 can collect statistics on the access rates of the read and write operations of each memory block by each node device 200 in the global memory system to obtain the read and write characteristics of each memory block. For example, the read and write characteristics may include the proportion of the number or time of read operations and write operations of the memory block to all access operations (hereinafter referred to as the read and write ratio), and may also include whether the read and write operations of the memory block come from multiple node devices 200 or whether most of them come from the same node device 200 (hereinafter referred to as the read and write distribution). The electronic device 100 then determines the strategy for performing read and write operations on each node device 200 (hereinafter referred to as the read and write strategy) based on the read and write characteristics of each memory block by each node device 200.
[0125] Optionally, the electronic device 100 may determine the read / write strategy for the memory block by the node device 200 based on the read / write ratio or the read / write distribution. The electronic device 100 may also determine the read / write strategy for the memory block by the node device 200 based on the read / write ratio and the read / write distribution. This application does not impose any specific restrictions on the specific type of read / write characteristics.
[0126] For example, for a memory block with a high number of read operations, after a node device 200 writes the local memory data corresponding to the memory block, the latest data will be synchronized to other node devices 200 that have read the memory block. In this way, when each node device 200 wants to read the data of the memory block, it can directly read the latest data of the memory block from the local memory, reducing the communication between nodes.
[0127] For another example, if most of the read and write operations for a memory block come from the same node device 200, the node device 200 that performs a large number of read / write operations on the memory block will be used as the master node of the memory block, and the other node devices 200 that perform a small number of read and write operations will be used as secondary nodes. When the secondary node wants to write the local memory data corresponding to the memory block, it will send the latest written data to the master node, so that the local memory of the master node records the latest data of the memory block. In this way, the master node can read and write the latest data directly from its own local memory, and most operations for this type of memory block also come from the master node, thereby reducing communication between nodes.
[0128] In this way, determining the read / write strategy for each node device 200 based on the read / write characteristics of the memory block is more adaptable to the actual situation of each memory block, rather than simply classifying memory blocks into M, S, and I states based on whether they have been modified. Furthermore, most read and write operations performed by node device 200 can be performed in local memory, reducing inter-node communication, lowering the communication latency for reading and writing data in the global memory system, and improving the access speed of node device 200 to memory. Furthermore, it can also improve the operational efficiency of services performed by node device 200, such as high-performance computing services.
[0129] In some embodiments, the data access method involved in the present application can be applied to a distributed computing system, which refers to a system in which multiple electronic devices 100 manage and connect multiple node devices 200 (including node A, node B, and node C, etc.), as shown in Figure 5A, and multiple node devices 200 share global memory.
[0130] Figure 5B shows a structural diagram of a data access system provided by the present application when applied to distributed computing. As shown in Figure 5B, the data access system includes a user layer, a distributed scheduling layer, and a global direct memory layer. The user layer is used to provide computing data and computing tasks, and the distributed scheduling layer is used by the electronic device 100 to distribute computing tasks and computing data to multiple node devices 200 for processing based on the computing data and computing tasks. The global direct memory layer is used to ensure that data remains consistent within multiple node devices 200, specifically including strong data consistency and weak data consistency schemes. Strong data consistency includes a memory sequential consistency model, a local memory consistency protocol, and the local memory consistency protocol is implemented through a local memory synchronization module. The local memory synchronization module specifically includes a read-write feature module 510, a read-write strategy module 520, a sub-block partitioning module 530, and an adaptive speculation module 540. Weak data consistency includes a bounded inconsistency module 550.
[0131] The read / write feature module 510 is used to determine the read / write features based on the access rates of read and write operations of the memory block. The read / write strategy module 520 is used to determine the corresponding read / write strategy based on the read / write features of the memory block. For details, please refer to Figures 7 to 12 below and the related descriptions.
[0132] When a memory block is accessed by multiple node devices 200, the sub-block partitioning module 530 dynamically partitions the memory block into multiple sub-blocks based on the locations accessed by the multiple node devices 200 and determines the read / write characteristics of each sub-block. This allows for different read / write strategies to be employed for different sub-blocks. For details, see Figures 13 to 16 and their related descriptions.
[0133] The adaptive speculative module 540 is used by the node device 200 to perform speculative reads and writes when accessing data. After the speculative delay, the node device 200 then determines whether to re-read or re-write the data according to the read / write policy. If the data during the speculative read / write operation is determined to be the latest data, the speculation is successful, thereby reducing the time wasted in determining the read / write policy. For more details, please refer to Figures 17 and 18 and the related descriptions.
[0134] When a certain node device 200 needs to obtain multiple memory block data, the bounded inconsistency module 550 will determine the proportion of bounded values in the current node device 200 among the required multiple memory block data, wherein the bounded value refers to the memory block data whose number of times modified by other node devices or the time of reading is within a preset range. For example, after a certain node device 200 reads the memory block data, other node devices 200 have modified the memory block more than 5 times or the node device 200 has obtained the memory block for more than 1 hour, then the memory block data in the node device 200 is not a bounded value (i.e., an out-of-bounds value). If the proportion of bounded values is greater than the threshold, then there are many bounded values in the required multiple memory block data, and the latest data can be obtained without using the read-write strategy. If the proportion of bounded values is less than or equal to the threshold, that is, the number of out-of-bounds values is large, then the node device 200 needs to update the memory block data through the corresponding read-write strategy mentioned above. For details, please refer to Figure 19 and its related description.
[0135] The data access system shown in FIG5B can also be applied to the architecture shown in FIG2 . As shown in FIG6 , taking server 1 as an example, server 1 includes a high-performance computing platform 610, specifically including a programming interface 611, a global memory directory entry 612, a runtime engine 613, a memory management unit 614, and a communication management unit 615. Server 1 also includes hardware resources: a processor 616, local memory 617, global memory 618, a network card 619, and hardware transactional memory (HTM) 620. The structure of the memory management unit 614 can be referred to in FIG5B and its related description, and the remaining structure can be referred to in FIG2 and its related description, and will not be repeated here.
[0136] The read / write feature module 510 and the read / write strategy module 520 involved in FIG. 5B are described in detail below.
[0137] The read-write feature module 510 is used to determine the read-write features of the memory block, and the read-write features include a read-write ratio and a read-write distribution. The read-write ratio in the read-write feature can include more read operations than write operations (read more / write less), more write operations than read operations (read less / write more). The read-write distribution can include being written by multiple node devices 200 (write sharing), most of the write operations come from the same node device 200 (write exclusive), most of the read operations come from the same node device 200 (read exclusive), data is read by multiple node devices 200 (read sharing), most of the read operations and write operations come from the same node device 200 (access exclusive), read operations and write operations come from different node devices 200 (access sharing), etc.
[0138] The following takes memory block L as an example to describe the read-heavy and write-heavy situations respectively.
[0139] The electronic device 100 can determine whether the memory block L is read-mostly or write-mostly by comparing the number of read operations and write operations performed on the memory block L. When the number of read operations performed on the memory block L is greater than the number of write operations performed on the memory block L, the memory block L is read-mostly. Conversely, when the number of read operations performed on the memory block L is less than the number of write operations performed on the memory block L, the memory block L is write-mostly.
[0140] Specifically, the electronic device 100 can compare the number of read operations and write operations performed on the memory block L with a preset threshold. For example, the case where the read-write characteristic is mostly read may include: the number of read operations on the memory block L is greater than the threshold δ1, wherein δ1 can be the number of read operations, or the ratio of the number of read operations to the total number of accesses. The number of accesses refers to the sum of the number of read operations and write operations. For example, δ1 can be taken as 90%. The case where the read-write characteristic is mostly write may include the number of write operations on the memory block L being greater than δ2, wherein the second threshold can be the number of write operations, or the ratio of the number of write operations to the total number of accesses, and δ2 can be taken as 90%.
[0141] In the above description, for the convenience of explanation, the number of read operations and write operations is used as an example of the access rate, but the present application is not limited to this. The electronic device 100 can make a judgment based on the number of read and write operations, or based on the time of the read and write operations, or based on the number and time of the read and write operations. When making a judgment based on the number and time of read and write operations, the number and time of each read and write operation can also be converted. For example, an access by a node device exceeding a predetermined time period can be regarded as multiple read and write operations on the memory block L, or a node device's continuous multiple reads and writes to the memory block L within a certain period of time can be regarded as one read and write operation, etc.
[0142] In some embodiments, the electronic device 100 may also count the number of read operations and the number of write operations within a preset time. That is, "read more" means the number of read operations within the preset time is greater than δ1. "Write more" means the number of write operations within the preset time is greater than δ2.
[0143] In other embodiments, the electronic device 100 may also determine the access rate based on the time taken by the node device 200 for read operations and write operations, respectively. For example, "read more" may mean that the node device 200 spends more time performing read operations than write operations. Alternatively, "read more" may mean that the node device 200 spends more time performing read operations than write operations. Alternatively, "read more" may mean that the node device 200 spends more time performing read operations than a threshold value T1, and "write more" may mean that the node device 200 spends more time performing write operations than a threshold value T2.
[0144] Taking memory block L as an example, the following describes write sharing, write exclusive, read exclusive, read sharing, access exclusive, and access sharing respectively.
[0145] The electronic device 100 determines the read / write distribution of memory block L by counting the devices that perform read and write operations on memory block L. Specifically, the electronic device 100 counts the access rate of each node device 200 performing read operations on memory block L and sorts the node devices 200 according to the read access rate. As described above, the access rate can be the number of read operations, the duration of the read operations, or the number of read operations within a preset time period. The number N of nodes with a read access rate that accounts for a preset proportion δ3 is calculated, and 1 / N is the read exclusive index. A larger read exclusive index indicates a more concentrated distribution of read operations. δ3 can also be 90%. The electronic device 100 also determines whether memory block L is read exclusively by determining whether the read exclusive index is greater than a threshold δ4. If it is greater than the threshold δ4, memory block L is read exclusively, meaning that memory block L is read by a small number of node devices 200. If it is less than the threshold δ4, memory block L is read shared, meaning that memory block L is read by a large number of node devices 200. Similarly, the above method can be used for write operations and all access operations to determine whether the memory block L is write-exclusive and access-exclusive, which will not be repeated here.
[0146] In some embodiments, if there is a node device 200 whose access rate of the read operation on the memory block L is greater than the threshold δ6, it can also be determined that the memory block L is read-exclusive.
[0147] Similarly, the above method can be used for write operations and all access operations to determine whether the memory block L is write-exclusive and access-exclusive. This application does not specifically limit the determination method of read-exclusive, write-exclusive, and access-exclusive.
[0148] The read / write strategy module 520 is used to determine the read / write strategy according to the read / write characteristics. The read / write strategies corresponding to different read / write characteristics are described below.
[0149] The electronic device 100 can determine the read-write strategy based on the read-write ratio and / or read-write distribution, where the read-write strategy may include a read-most strategy (read mostly), a write-shared strategy (write shared), an access-exclusive strategy (access exclusive), a write-exclusive strategy (write exclusive), a read-exclusive strategy (read exclusive), and an MSI strategy. The specific method of the MSI strategy can be referred to (A) to (E) in the aforementioned Figure 3. The methods of the other read-write strategies will be described in detail below in conjunction with Figures 8 to 12.
[0150] In some embodiments, the electronic device 100 may determine the read / write strategy based solely on the read / write ratio. For example, as shown in Table 1 below, if the memory block L is read-mostly, the read-most strategy is determined to be adopted, and if the memory block is write-mostly, the MSI strategy may be adopted.
[0151] Table 1
[0152] In other embodiments, the electronic device 100 may determine the read / write policy based solely on the read / write distribution. For example, as shown in Table 2 below, if the memory block L is read-shared, the MSI policy is determined to be adopted; if the memory block L is read-exclusive, the read-exclusive policy is determined to be adopted; if the memory block L is write-shared, the write-shared policy is determined to be adopted; if the memory block L is write-exclusive, the write-exclusive policy is determined to be adopted; if the memory block L is access-shared, the MSI policy is determined to be adopted; and if the memory block L is access-exclusive, the access-exclusive policy is determined to be adopted.
[0153] Table 2
[0154] In other embodiments, the electronic device 100 may also comprehensively consider the read-write ratio and the read-write distribution to determine the read-write strategy. For example, as shown in Table 3 below, when the read-write ratio is read-most, if the read-write distribution is read-shared, write-shared, write-exclusive or access-shared, the read-most strategy may be adopted. When the read-write ratio is read-most and the read-write distribution is read-exclusive or access-exclusive, or when the read-write ratio is write-most and the read-write distribution is write-exclusive or access-exclusive, the access-exclusive strategy may be adopted. When the read-write ratio is write-most and the read-write distribution is write-shared or access-shared, the write-shared strategy may be adopted. When the read-write ratio is write-most and the read-write distribution is read-shared or access-shared, the MSI strategy may be adopted.
[0155] Table 3
[0156] In other embodiments, the electronic device 100 determines the ratio of the number / time of read operations to all access operations (read ratio) and the ratio of the number / time of write operations to all access operations (write ratio) for the memory block L. The read ratio, write ratio, read exclusive index, write exclusive index, and access exclusive index are then compared with an upper threshold and a lower threshold, respectively, to determine a corresponding read and write strategy.
[0157] For example, as shown in (A) of Figure 7, if the read ratio is less than the lower threshold RM1, the MSI strategy is adopted. If the read ratio is greater than the lower threshold RM1 and less than the upper threshold RM2, and the read exclusive index is less than the upper threshold RE2, the MSI strategy is adopted. If the read exclusive index is greater than the upper threshold RE2, the read exclusive strategy is adopted.
[0158] As shown in (B) of Figure 7, if the write-exclusive index is less than the lower threshold WE1, the write-sharing strategy can be adopted. If the write-exclusive index is greater than the lower threshold WE1, and the write ratio is less than the lower threshold WM1, the read-multiple strategy can be adopted. If the write ratio is greater than the lower threshold WM1, the MSI strategy can be adopted. If the write ratio is greater than the lower threshold WM1, the write-exclusive strategy can be adopted. If the write ratio is greater than the upper threshold WE2, and the write ratio is less than WM1, the read-multiple strategy can be adopted. If the write ratio is greater than WM1 and less than WM2, the write-exclusive strategy can be adopted. If the write ratio is greater than WM2, the access-exclusive strategy can be adopted.
[0159] As shown in (C) of Figure 7, when the read-based ratio is less than the upper threshold RM2 and the access exclusivity index is less than AE2, the MSI protocol can be used. When the read-based ratio is greater than RM2 and the access exclusivity index is less than AE2, the read-sharing strategy can be used. When the access exclusivity index is greater than AE2, the access exclusivity strategy can be used.
[0160] In summary, as shown in Table 4 below, if memory block L is written by multiple node devices 200, a write-sharing strategy can be adopted. If most of the access operations to memory block L come from the same node device 200, an access-exclusive strategy can be adopted. If most of the write operations to memory block L come from the same node device 200, a write-exclusive strategy can be adopted. If there are many read operations on memory block L, a read-multiple strategy can be adopted. If most of the read operations on memory block L come from the same node device 200, a read-exclusive strategy can be adopted. For other situations, the MSI strategy can be adopted.
[0161] Table 4
[0162] The following describes in detail the processes of the above-mentioned write sharing strategy, access exclusive strategy, write exclusive strategy, read exclusive strategy, and read multiple strategy during read and write operations, wherein the memory block L is also used as an example for illustration.
[0163] The write sharing strategy divides node devices 200 into metadata nodes and request nodes. Metadata nodes are node devices 200 that actually store memory blocks L, and request nodes are node devices 200 that receive write or read requests. Figure 8 shows the process of reading and writing data using the write sharing strategy.
[0164] As shown in (A) in FIG8 , the requesting node receives a write request, including:
[0165] 8A-1: The requesting node receives a write request.
[0166] 8A-2: The requesting node updates the metadata node with the latest write node of the memory block. The latest write node refers to the data that was most recently modified in the memory block L.
[0167] 8A-3: The metadata node returns a successful write to the requesting node.
[0168] As shown in (B) of FIG8 , the requesting node receives a write request, including:
[0169] 8B-1: The requesting node receives a read request.
[0170] 8B-2: The requesting node queries the metadata node for the latest write node of the memory block.
[0171] 8B-3: The metadata node feeds back node information to the requesting node.
[0172] 8B-4: The requesting node sends a data request to the latest writing node.
[0173] 8B-5: The latest writing node sends the latest data to the requesting node.
[0174] In this way, the requesting node does not need to send invalidation requests to each other node device 200 when writing data, reducing communication overhead. After updating the data, the requesting node only needs to update the latest write node to the metadata node, so that the next node device 200 that needs to read or write data can know the node where the latest data is located through the metadata node.
[0175] The exclusive access policy divides node devices 200 into read-write primary nodes and secondary nodes. A read-write primary node is a node whose access rate (e.g., number of times or time) for reading and writing memory block L is greater than a preset value, such as δ3, i.e., the node device 200 that primarily performs read and write operations on memory block L. Alternatively, it can be the node device 200 that performs the most read and write operations on memory block L or has the longest access time. In other words, there can be only one read-write primary node or multiple read-write primary nodes.
[0176] As shown in (A) in FIG9 , the read / write master node receives a write request, including:
[0177] 9A-1: The read / write master node receives a read / write request. The read / write master node stores the latest data of memory block L, so the read / write master node can directly read or write the data of memory block L.
[0178] As shown in (B) of FIG9 , the secondary node receives a write request, including:
[0179] 9B-1: The secondary node receives a read / write request.
[0180] 9B-2: The secondary node forwards the request to the read-write primary node.
[0181] 9B-3: The read / write master node sends the latest data to the secondary node / feeds back a successful write. Since the read / write master node stores the latest data of memory block L, other secondary nodes need to send a request to the read / write master node when they need to read or update data.
[0182] In this way, since in the case of exclusive access, the node device 200 that mainly performs read and write operations on the memory block L is the read-write master node, when ensuring that the read-write master node can have the latest data, the read-write master node can directly read or write the data of the memory block L, which can reduce communication between nodes.
[0183] The write-exclusive policy divides node devices 200 into write-primary nodes and secondary nodes, and records the MSI status of the secondary nodes. A write-primary node is a node device 200 whose write access rate (e.g., number of times or time) is greater than a preset value, such as δ3, i.e., the node device 200 that primarily performs write operations on memory block L. Alternatively, it can be the node device 200 that performs the most write operations on memory block L or the node device 200 that takes the longest time to write. In other words, there can be only one write-primary node or multiple write-primary nodes.
[0184] As shown in (A) in FIG10 , the write master node receives a read request, including:
[0185] 10A-1: The write master node receives a read request. The write master node stores the latest data of memory block L, so the write master node can directly read the data of memory block L.
[0186] As shown in (B) in FIG10 , the write master node receives a write request, including:
[0187] 10B-1: The write master node receives the write request.
[0188] 10B-2: The write master node sends an invalidation request to the secondary node. After the write master node updates the data, it invalidates the secondary node, causing the secondary node to change to the I state. The secondary node (I state) then knows that the data in the current local memory is not the latest data.
[0189] 10B-3: The secondary node reports success to the primary node.
[0190] As shown in (C) in FIG10 , the secondary node (S state) receives a read request, including:
[0191] 10C-1: The secondary node (S state) receives a read request. The secondary node (S state) has not yet been written to the primary node, so the data in memory block L can be directly read.
[0192] As shown in (D) in FIG10 , the secondary node (I state) receives a read request, including:
[0193] 10D-1: The secondary node (I state) receives a read request.
[0194] 10D-2: The secondary node (I state) forwards the request to the write master node. Since the secondary node (I state) has been invalidated, the node data in the local memory is no longer the latest data. Therefore, the data request needs to be sent to the write master node that stores the latest data.
[0195] 10D-3: The write master node sends the latest data to the secondary node (I state).
[0196] As shown in (E) in FIG10 , the secondary node (I state / S state) receives a write request, including:
[0197] 10E-1: The secondary node receives the write request.
[0198] 10E-2: The secondary node forwards the request to the write primary node.
[0199] 10E-3: The primary node sends a successful write signal to the secondary node.
[0200] In this way, after updating data, the secondary node will send the updated data to the write master node, so that the write master node has the latest data. In the case of exclusive write, most operations are performed by the write master node. When the write master node can store the latest data, the write master node can directly perform the write operation, reducing inter-node communication.
[0201] The read-exclusive policy divides node devices 200 into primary read nodes and secondary read nodes. A primary read node is a node device 200 whose read access rate (e.g., number of read operations or duration) is greater than a preset value, such as δ3. This node device 200 primarily performs read operations on memory block L. Alternatively, it can be the node device 200 that performs the most read operations on memory block L or takes the longest time to read. In other words, there can be only one primary read node or multiple primary read nodes.
[0202] As shown in (A) in FIG11 , the read master node receives a read request, including:
[0203] 11A-1: The read master node receives the read request. The read master node stores the latest data of memory block L, so the read master node can directly read the data of memory block L in its local memory.
[0204] As shown in (B) in FIG11 , the read master node receives a write request, including:
[0205] 11B-1: The read master node receives the write request.
[0206] 11B-2: The primary read node sends an invalidation request to the secondary node. After the primary read node updates the data, it invalidates the secondary node so that the secondary node knows that the data in the local memory is not the latest data.
[0207] 11B-3: The secondary node reports success to the read primary node.
[0208] As shown in (C) in FIG11 , the secondary node receives a read request, including:
[0209] 11C-1: The secondary node receives a read request.
[0210] 11C-2: The secondary node forwards the request to the read primary node.
[0211] 11C-3: The read primary node sends the latest data to the secondary node.
[0212] As shown in (D) in FIG11 , the secondary node receives a write request, including:
[0213] 11D-1: The secondary node receives a write request.
[0214] 11D-2: The secondary node updates and reads the data of the primary node.
[0215] 11D-3: The primary node reads the update successfully and sends feedback to the secondary node.
[0216] This way, after a secondary node updates data, it synchronizes the updated data with the read master node, ensuring that the read master node's local memory always holds the latest data. In read-only scenarios, the read master node performs most read operations. If the read master node holds the latest data, it can directly perform read operations, reducing inter-node communication.
[0217] The read-multiple strategy corresponds to the situation where there are many read requests and a large number of node devices 200 perform read operations on the memory block L. Therefore, it is necessary to ensure that each node device 200 has the latest data, so that each node device 200 can read data directly from the local memory.
[0218] As shown in FIG12(A), the requesting node receives a read request, including:
[0219] 12A-1: The requesting node receives a read request. Each node device has the latest data, so the requesting node can directly perform the read operation.
[0220] As shown in FIG12(B), the requesting node receives a read request, including:
[0221] 12B-1: The requesting node receives the write request.
[0222] 12B-2: The request node updates the data of other data nodes.
[0223] 12B-3: Other data nodes report success to the requesting node.
[0224] In this way, any node device 200 that performs a write operation can synchronize the latest data to other node devices 200, so that each node device 200 can directly read the data in the local memory when performing a read operation, thereby reducing communication between nodes.
[0225] The details of the sub-block division module 530 are introduced below. Since the electronic device 100 uses memory blocks as units, the read and write characteristics of the memory blocks and the corresponding read and write policies are marked. However, in some cases, a node device 200 may only access part of the data in a certain memory block, such as part of the data in memory block L. If multiple node devices 200 respectively access data at different locations in memory block L, then after each node device 200 accesses memory block L, the electronic device 100 needs to re-determine the read and write characteristics of memory block L and determine the read and write policy of memory block L for each node device 200. In this way, the electronic device 100 will need to frequently modify the read and write status of memory block L in the global memory directory 612.
[0226] Especially for the write-sharing state, if the read-write policy adopts the MSI policy, the electronic device 100 also needs to determine the M, S, and I states of each node device 200 corresponding to the memory block L. When a node A modifies the data corresponding to the memory block in the local memory, the states of all node devices 200 except node A are modified to the I state, so that other node devices 200 cannot directly read the data.
[0227] In some embodiments, the electronic device 100 divides the memory block L into multiple sub-blocks and can mark the read and write status of each sub-block. For example, as shown in FIG13 , when nodes 1 to 5 access data at different locations in the memory block L, since there are 5 nodes, log5=3 bits of data are required for each sub-block.
[0228] As shown in Figure 13, if memory block L is divided into two equal blocks, a total of 2*3=6 bits of data is required. However, nodes 1 to 4 are still in the same block, and the above problem still exists. If memory block L is divided into four equal blocks, a total of 4*3=12 bits of data is required. However, nodes 1 to 3 are still in the same block. If memory block L is divided into eight equal blocks, a total of 8*3=24 bits of data is required. However, nodes 1 and 2 are still in the same block. Therefore, if memory block L is divided into 16 equal blocks, a total of 16*3=48 bits of data is required. In this case, all nodes correspond to different blocks. However, the amount of data required to store the node information corresponding to memory block L is relatively large.
[0229] Refer also to Figure 14. As shown in Figure 14, if a memory block is divided into 16 sub-blocks, when only two nodes access the memory block, each sub-block needs to record the corresponding node information, including the node to which the latest data belongs. For example, sub-blocks 0 to 7 have their latest data updated by node A, and sub-blocks 8 to 15 have their data updated by node B. When node C modifies the data in sub-blocks 8 to 15, sub-blocks 8 to 15 will modify their node information to node C. In this case, it is necessary to record the node information corresponding to each sub-block, and the amount of data required to be recorded is relatively large.
[0230] In other embodiments, to address the problem of multiple node devices 200 accessing data at different locations in the same memory block, requiring frequent modification of memory block information, the electronic device 100 divides the memory block into sub-blocks based on the location at which each node device 200 accesses the memory block. For example, as shown in FIG15 , the electronic device 100 divides memory block L into five sub-blocks based on the starting locations of the data accessed by nodes 1 through 5 in memory block L. This reduces the amount of data required to store node information and avoids the problem of multiple node devices 200 accessing different locations in the same memory block, requiring frequent modification of the node information in the memory block.
[0231] For example, as shown in Figure 16, for the situation shown in Figure 14 above, the present application can divide the memory block into two sub-blocks based on the locations accessed by nodes A and B. The latest writer of the first sub-block is node A, and the latest writer of the second sub-block is node B. When node C modifies the data corresponding to the second sub-block, the latest writer of the second sub-block will be changed to node C. Furthermore, compared to Figure 14, which requires storing information for 16 nodes, Figure 16 only needs to store information for 2 nodes, reducing the amount of data required to store node information.
[0232] The following describes the details of the adaptive speculation module 540. When the node device 200 accesses data, it also needs to obtain the read / write characteristics and read / write strategy determined by the electronic device 100 for the memory block corresponding to the data. Then, the node device 200 accesses the data according to the read / write strategy, including requesting the latest data from other node devices 200. As shown in (A) of Figure 17, the time when the node device 200 obtains the read / write strategy can be recorded as T D1 .
[0233] The adaptive speculation module 540 is used to directly access the data in the local memory when the node device 200 needs to access data. D2 After that, the node device 200 determines the read / write policy corresponding to the memory block and judges whether the data in the current local memory is the latest data. If the read / write policy indicates that the data corresponding to the memory block in the current local memory is the latest data, the node device 200 maintains the previously executed access operation. If the read / write policy indicates that the data corresponding to the memory block in the current local memory is not the latest data, the node device 200 re-acquires the latest data according to the read / write policy.
[0234] In this way, as shown in (B) in FIG17 , if the speculation is successful, it means that the node device 200 can directly access the data, and the time consumed at this time is T D2 Less than T D1, saving data access time. If speculation fails, it means that the node device 200 needs to access the data again according to the read-write strategy, and the time required is T D3 , T D3 Greater than T D1 .
[0235] The details of the adaptive speculation module 540 are described below in conjunction with Figure 18. Figure 18 is a structural diagram of the adaptive speculation system, which includes the adaptive speculation module 540. The adaptive speculation module 540 includes a transaction acquisition module 1810, a speculation probability adjustment module 1820, and a conflict detection module 1830.
[0236] The transaction acquisition module 1810 is used to obtain access operations that the node device 200 needs to execute and then encapsulate these access operations into transactions. Transactions include function transactions and regular transactions. Function transactions are transactions that require cyclic execution. These functions are encapsulated by placing them in a transaction executor and using the Exec(Func) function. Regular transactions encapsulate code into transactions using the begin_trans and end_trans functions, or the system automatically splits the program into multiple transactions.
[0237] The speculation probability adjustment module 1820 is used to obtain the difference value P1 obtained from the last conflict detection based on the local memory data and the latest data, as well as the write-shared memory block P2 of the memory block to be accessed this time. The probability P of the current speculation is then adjusted based on P1 and P2. When P1 and P2 are higher, data updates are likely to be fast and frequent. Consequently, if speculation is executed, the probability of failure is higher, which will reduce the probability P. When P1 and P2 are lower, data updates are likely to be slow, the probability of success is higher, and the probability P can be higher.
[0238] Conflict detection module 1830 can determine whether the data in node device 200's local memory is the latest data by obtaining node information for the memory block. Alternatively, node device 200 can obtain the latest data in the memory block from global memory and compare the latest data in the memory block with the data in the local memory to determine whether the data in the local memory is the latest data. If the data in the local memory is not the latest data, node device 200 is required to cancel the access operation performed and re-access according to the read / write policy. If the data in the local memory is the latest data, node device 200 can maintain the original access operation.
[0239] In this way, the node device 200 has a greater probability of succeeding in speculation. When the speculation succeeds, the data access time is shortened, thereby improving the data calculation efficiency.
[0240] The following describes the details of the bounded inconsistency module 550. The bounded inconsistency module 550 is used to determine whether each memory block data is a bounded value when the node device 200 uses multiple memory block data. The bounded value can refer to the memory block data being the latest data in the local memory, or the value being within a preset time T. D4 The bounded inconsistency module 550 can determine whether the memory block data has been modified multiple times by other node devices 200 based on the node information recorded in the global memory directory entry 612, or determine whether it is a bounded value based on the node device 200's self-recorded memory block read time.
[0241] The node device 200 will then determine whether to execute the read / write strategy based on the ratio of bounded value memory blocks to the total number of memory blocks that need to be used. If the node device 200 determines that the bounded value ratio exceeds the threshold α, it means that most of the data is relatively new bounded value data. Furthermore, for a small amount of out-of-bounds value data in the data of multiple memory blocks, it is not necessary to execute the read / write strategy to update the data. If the node device 200 determines that the bounded value ratio does not exceed the threshold α, it means that a large amount of data is out-of-bounds value, and the node device 200 needs to execute the read / write strategy to update the data.
[0242] For example, as shown in Figure 19, for computing tasks that require multiple iterations, if there are individual outliers in some of the iterative calculations, it will not have a significant impact on the final result. For example, take the case where the number of outliers is at most 1. Among them, in the first round of iterations, when there is one outlier, the node device 200 can directly perform calculations based on the data in the local memory. Before the second round of iterations, other node devices 200 modify the data again, so that the node device 200 has two outliers. Furthermore, the node device 200 needs to update the data according to the read-write strategy so that there is at most one outlier in the multiple data. When in the third round of iterations, when there is only one outlier again, the node device 200 can directly perform calculations based on the data in the local memory.
[0243] In this way, the situation where the node device 200 executes the read-write strategy to obtain the latest data can be effectively reduced. The node device 200 can directly use the data in the local memory, reducing the communication between nodes.
[0244] The following introduces a data access method provided in an embodiment of the present application. The data access method can be applied to the above-mentioned global memory system including the electronic device 100 and multiple node devices 200.
[0245] S2001: The electronic device 100 obtains operation information of the node device 200 performing read operations and write operations on each memory block.
[0246] When the node device 200 performs a read or write operation on data in the global memory or on data after reading data from the global memory into the local memory, the electronic device 100 records its operation information. The operation information is used to indicate the access rate of the node device 200 to the memory block. Specifically, it can be the number of write and read operations. For example, it can be the number of write and read operations performed within a preset time, or it can be the time taken for each read and write operation. The electronic device 100 can also make judgments based on the number and time of read and write operations, and can also convert the number and time of each read and write operation. For example, an access by the node device 200 that exceeds a predetermined time period can be regarded as multiple read and write operations on the memory block. Alternatively, multiple consecutive read and write operations by the node device 200 within a certain period of time can be regarded as a single read and write operation on the memory block, etc. For details, please refer to the aforementioned description of the read and write feature module 510.
[0247] Optionally, the electronic device 100 may also obtain the time and number of times each node device 200 performs access operations on each memory block through the network switch 601 or other buses as shown in FIG. 6 .
[0248] S2002: The electronic device 100 determines the read and write characteristics of each memory block based on the operation information.
[0249] The electronic device 100 determines the read and write characteristics of each memory block based on the operation information of each memory block. The read and write characteristics may include a read-write ratio and a read-write distribution. The read-write ratio specifically includes read-mostly and write-mostly, and the read-write distribution may include write-shared, write-exclusive, read-exclusive, read-shared, access-exclusive, and access-shared. The specific method for determining the read and write characteristics can be referred to the relevant description of the aforementioned read and write feature module 510, which will not be repeated here.
[0250] S2003: The electronic device 100 determines a read / write strategy for each node device 200 to perform read / write operations on each memory block based on the read / write characteristics of each memory block and the operation information of each node device 200 on the memory block.
[0251] After determining the read / write characteristics of each memory block, the electronic device 100 may also determine a corresponding read / write policy based on preset regulations. The correspondence between read / write characteristics and read / write policies can be found in Tables 1 through 4, Figure 7, and their related descriptions, and will not be further described here. Furthermore, the electronic device 100 also determines the type of each node for each memory block based on the read / write policy and marks the node type in the global memory directory entry 612.
[0252] Node types include primary nodes and secondary nodes. Primary nodes can specifically include metadata nodes, read / write master nodes, read master nodes, write master nodes, etc. Secondary nodes are node devices other than primary nodes. The node type corresponding to each read / write strategy, as well as the method for confirming the node type, can also be found in Figures 3, 8 to 12 and their related descriptions.
[0253] Optionally, when a memory block is accessed by multiple node devices 200 and the locations of the accessed memory blocks are different, the electronic device 100 may further divide the memory block into multiple sub-blocks based on the location accessed by each node device 200, and separately count the read and write characteristics of each sub-block and separately mark the node information of each node device 100. For details, please refer to the aforementioned description of the sub-block division module 530, which will not be repeated here.
[0254] S2004: The node device 200 accesses the corresponding memory block according to the read / write policy.
[0255] When the node device 200 needs to access the data of the global memory pre-read in the local memory, it will first determine the read and write strategy for performing the access operation based on the read and write characteristics of the memory block corresponding to the data to be obtained in the global memory directory entry 612 and the node information.
[0256] Optionally, when node device 200 needs to access data, it may first directly access the data in local memory. After a preset time TD2 after node device 200 begins data access, it determines the read / write policy corresponding to the memory block and determines whether the data currently in local memory is the latest data. If the read / write policy indicates that the data corresponding to the memory block in the current local memory is the latest data, node device 200 maintains the previously executed access operation. If the read / write policy indicates that the data corresponding to the memory block in the current local memory is not the latest data, node device 200 re-acquires the latest data according to the read / write policy. For details, please refer to the relevant description of adaptive speculation module 540.
[0257] Optionally, if the node device 200 wants to use multiple memory block data, it will determine whether each memory block data is a bounded value. Then the node device 200 will also determine whether to execute the read-write strategy based on the proportion of memory blocks with bounded values to the memory blocks that need to be used. If the node device 200 determines that the bounded value ratio exceeds the threshold value α, it means that most of the data is relatively new data, and then, there is no need to execute the read-write strategy to update the data. If the node device 200 determines that the bounded value ratio does not exceed the threshold value α, it means that more data is out-of-bounds value, and the node device 200 needs to execute the read-write strategy to update the data. For details, please refer to the relevant description of the bounded inconsistency module 550.
[0258] In summary, through the data access method provided by this application, a read and write strategy can be determined for each node device 200 based on the read and write characteristics of the memory block, which can better adapt to the actual situation of each memory block, rather than simply dividing the memory block into M state, S state, and I state according to whether it has been modified. Furthermore, most of the read and write operations performed by the node device 200 can be performed in the local memory, which can reduce inter-node communication, reduce the communication delay of reading and writing data in the global memory system, and improve the access speed of the node device 200 to the memory. In addition, it can also improve the operating efficiency of the services performed by the node device 200, such as high-performance computing services.
[0259] In order to solve the above-mentioned problem of slow access speed of nodes to global memory in a global memory system, the present application also provides a data access device 2100, including an acquisition unit 2110, a determination unit 2120, an update unit 2130, a sending unit 2140, and a reading unit 2150.
[0260] The acquisition unit 2110 is used to obtain operation information of read and write operations performed by multiple node devices on the first memory block, and the operation information is used to represent the access rate of the read and write operations on the first memory block; the determination unit 2120 is used to determine the read and write operation characteristics of the multiple node devices corresponding to the first memory block; the determination unit 2120 is also used to determine the read and write strategies of the multiple node devices corresponding to the first memory block based on the read and write operation characteristics, and the read and write strategies include distinguishing the multiple node devices into primary nodes and secondary nodes for performing read and write operations.
[0261] In some embodiments, the access rate is determined based on the number and / or time of read and write operations performed by multiple node devices on the first memory block.
[0262] In other embodiments, the type of primary node includes a metadata node that stores the first memory block.
[0263] In other embodiments, the type of main node includes a read master node whose operation information of the read operation meets a first condition, and the first condition includes that the value of the access rate of the node device's read operation on the first memory block meets a first preset condition.
[0264] In other embodiments, the type of main node includes a write master node whose operation information of the write operation meets the second condition, and the second condition includes that the value of the access rate of the node device's write operation on the first memory block meets the second preset condition.
[0265] In other embodiments, the types of main nodes include read-write master nodes whose operation information of read operations and write operations meets a third condition, and the third condition includes that the value of the access rate of the node device's read operation to the first memory block meets the first preset condition, and the value of the access rate of the write operation to the first memory block meets the second preset condition.
[0266] In other embodiments, the read and write operation characteristics include a read-write ratio, and the determination unit 2120 is further used to determine that the read-write operation ratio of the first memory block is mostly read based on the fact that the value of the access rate of the read operation of multiple node devices to the first memory block is greater than the value of the access rate of the write operation to the first memory block; or the determination unit 2120 is further used to determine that the read-write operation ratio of the first memory block is mostly write based on the fact that the value of the access rate of the read operation of the first memory block is less than or equal to the value of the access rate of the write operation to the first memory block.
[0267] In other embodiments, the determination unit 2120 is also used to determine that the read and write distribution of the first memory block is read exclusive based on the existence of a read master node in multiple node devices; or to determine that the read and write distribution of the first memory block is read shared based on the absence of a read master node in multiple node devices.
[0268] In other embodiments, the determination unit 2120 is also used to determine that the read and write distribution of the first memory block is write-exclusive based on the existence of a write master node in multiple node devices; or to determine that the read and write distribution of the first memory block is write-shared based on the absence of a write master node in multiple node devices.
[0269] In other embodiments, the determination unit 2120 is also used to determine that the read and write distribution of the first memory block is exclusive access based on the existence of a read and write master node in multiple node devices; or to determine that the read and write distribution of the first memory block is shared access based on the absence of a read and write master node in multiple node devices.
[0270] In other embodiments, the determination unit 2120 is further used to determine that the read and write operation characteristics of the first memory are read-mostly based on the read-write ratio of the first memory block being read-mostly and the read-write distribution being any one of read sharing, write sharing, write exclusive or access sharing; and to determine that the read and write operation characteristics of the first memory are access exclusive based on the read and write ratio of the first memory block being read-mostly and the read-write distribution being read exclusive or access exclusive, or the read and write ratio of the first memory block being write-mostly and the read-write distribution being write exclusive or access exclusive; and to determine that the read and write operation characteristics of the first memory are write sharing based on the read and write ratio of the first memory block being write-mostly and the read-write distribution being write sharing or access sharing.
[0271] In other embodiments, the method further includes: the determination unit 2120 is also used to determine that the read and write operation characteristics of the first memory are write-exclusive based on the fact that the value of the access rate of the write operation of the first memory block is greater than the first threshold and less than or equal to the second threshold, and the read and write distribution is write-exclusive; the determination unit 2120 is also used to determine that the read and write operation characteristics of the first memory are read-exclusive based on the fact that the value of the access rate of the read operation of the first memory block is greater than the third threshold and less than or equal to the fourth threshold, and the read and write distribution is read-exclusive.
[0272] In other embodiments, the determination unit 2120 is also used to determine the metadata node among multiple node devices based on the read and write operation characteristics being write sharing, and determine other node devices except the metadata node as write sharing nodes among the secondary nodes; the update unit 2130 is used to update the write node of the first memory block in the metadata node to the first write sharing node based on the first write sharing node among the write sharing nodes receiving a write request corresponding to the first memory block; and the acquisition unit 2110 is used to obtain the write node of the first memory block from the metadata node based on the second write sharing node among the write sharing nodes receiving a read request; the acquisition unit 2110 is used to obtain the data corresponding to the first memory block from the first write sharing node based on the write node obtained from the second write sharing node as the first write sharing node.
[0273] In other embodiments, the determination unit 2120 is also used to determine the read-write master node among multiple node devices based on the read-write operation characteristic being access exclusive, and determine the node devices other than the read-write master node as access secondary nodes among the secondary nodes; the acquisition unit 2110 is also used to request the data of the first memory block from the read-write master node based on the access shared node receiving a read request; the sending unit 2140 is used to determine to send the data corresponding to the write request to the read-write master node based on the access shared node receiving a write request corresponding to the first memory block; and the reading unit 2150 is used to read the data of the first memory block in the local memory based on the read-write master node receiving the read request corresponding to the first memory block; and the update unit 2130 is also used to read and update the data of the first memory block in the local memory based on the read-write master node receiving the write request corresponding to the first memory block.
[0274] In other embodiments, the method further includes: the determination unit 2120 is further used to determine a write master node among multiple node devices based on the read and write operation characteristics being write exclusive, and determine the node devices other than the write master node as write secondary nodes among the secondary nodes; the reading unit 2150 is further used to read the data of the first memory block in the local memory based on the write master node receiving a read request corresponding to the first memory block; and the sending unit 2140 is further used to send an invalidation request to the write secondary node based on the write master node receiving a write request corresponding to the first memory block; and the reading unit 2150 is further used to send an invalidation request to the write secondary node based on the non-invalidated write secondary node A read request corresponding to a first memory block is received, and the data of the first memory block in the local memory is read, wherein a non-invalidated write secondary node refers to a write secondary node that has not received an invalidation request sent by the write primary node; and, the acquisition unit 2110 is also used to request the data of the first memory block from the write primary node based on the invalidated write secondary node receiving a read request corresponding to the first memory block, wherein the invalidated write secondary node refers to a write secondary node that receives an invalidation request sent by the write primary node; and, based on the write secondary node receiving the write request corresponding to the first memory block, the write secondary node sends the data corresponding to the write request to the write primary node.
[0275] In other embodiments, the determination unit 2120 is also used to determine a read master node among multiple node devices based on the read and write operation characteristics being read exclusive, and determine the node devices other than the read master node as read secondary nodes among the secondary nodes; the reading unit 2150 is also used to read the data of the first memory block in the local memory based on the read master node receiving a read request corresponding to the first memory block; and the sending unit 2140 is also used to send an invalidation request to the read secondary node based on the read master node receiving a write request corresponding to the first memory block; and the acquisition unit 2110 is also used to request the data of the first memory block from the read master node based on the read secondary node receiving a read request corresponding to the first memory block; and the sending unit 2140 is also used to send the data corresponding to the write request to the read master node based on the read secondary node receiving a write request corresponding to the first memory block.
[0276] In other embodiments, the acquisition unit 2110 is also used to receive a read request corresponding to the first memory block and read the data of the first memory block in the corresponding local memory based on the read-write operation characteristic being read-most; and the acquisition unit 2110 is also used to receive a write request corresponding to the first memory block, and the sending unit 2140 is also used to send the data corresponding to the write request to other node devices.
[0277] In other embodiments, the acquisition unit 2110 is further configured to acquire location information of data read from the first memory block by multiple node devices. The determination unit 2120 is further configured to divide the first memory block into multiple sub-blocks based on the location information corresponding to the multiple node devices. The determination unit 2120 is further configured to determine read and write operation characteristics of the multiple sub-blocks in the first memory block based on the operation information. The determination unit 2120 is further configured to determine read and write strategies corresponding to the multiple sub-blocks by the multiple node devices based on the read and write operation characteristics of the multiple sub-blocks.
[0278] In other embodiments, within a preset time of performing read and write operations on the data of the first memory block in the local memory, the determination unit 2120 is also used to determine the read and write policy corresponding to the first memory block; the determination unit 2120 is also used to determine that the data of the first memory block in the local memory is a new value based on the read and write policy of the node device, and determine to keep performing the read and write operations; the determination unit 2120 is also used to determine that the data of the first memory block in the local memory is an old value based on the read and write policy of the node device, and re-execute the read and write operations according to the read and write policy.
[0279] In other embodiments, the determination unit 2120 is further used to determine the read and write operation characteristics of multiple memory blocks based on the operation information of the read operations of the multiple memory blocks; and to determine the read and write strategies of the multiple memory blocks based on the read and write operation characteristics of the multiple memory blocks; the determination unit 2120 is further used to determine the number of memory blocks in the local memory of the fifth node device that are out-of-bounds values based on the read and write operation characteristics of the multiple memory blocks, wherein an out-of-bounds value means that after the fifth node device reads the memory block data, the number of times the memory block data is updated by other node devices exceeds a preset number, or the fifth node device does not update the memory block data for a preset period of time; the determination unit 2120 is further used to determine to perform a read operation or a write operation on the data of the multiple memory blocks in the local memory of the fifth node device based on the fact that the number of memory blocks in the fifth node device that are out-of-bounds values does not exceed a preset number; or, the determination unit 2120 is further used to determine to perform a read operation or a write operation on the data of the multiple memory blocks in the local memory of the fifth node device according to the read and write strategies of the multiple memory blocks based on the fact that the number of memory blocks in the fifth node device that are out-of-bounds values exceeds a preset number.
[0280] In summary, through the data access device 2100 provided by the present application, a read and write strategy can be determined for each node device based on the read and write characteristics of the memory block, which can better adapt to the actual situation of each memory block, rather than just dividing the memory block into M state, S state, and I state according to whether it has been modified. Furthermore, most of the read and write operations performed by the node device can be performed in the local memory, which can reduce inter-node communication, reduce the communication delay of reading and writing data in the global memory system, and improve the access speed of the node device to the memory. In addition, it can also improve the operating efficiency of the services performed by the node device, such as high-performance computing services.
[0281] The above describes in detail the method of the embodiment of the present application. In order to facilitate better implementation of the above scheme of the embodiment of the present application, correspondingly, related equipment for cooperating in implementing the above scheme is also provided below.
[0282] Figure 22 is a structural diagram of an electronic device 2200 provided by the present application, and the electronic device 2200 can be the data access device 2100 in the aforementioned content. As shown in Figure 22, the electronic device 2200 includes: a processor 2210, a communication interface 2220 and a memory 2230. Among them, the processor 2210, the communication interface 2220 and the memory 2230 can be interconnected through an internal bus 2240, or communication can be achieved through other means such as wireless transmission. The embodiment of the present application takes the connection through the bus 2240 as an example. The bus 2240 can be a peripheral component interconnect Express (PCIe) bus, or an extended industry standard architecture (EISA) bus, a unified bus (Ubus or UB), a computer express link (CXL), a cache coherent interconnect for accelerators (CCIX), etc. The bus 2240 can be divided into an address bus, a data bus, a control bus, etc. In addition to the data bus, the bus 2240 may also include a power bus, a control bus, a status signal bus, etc. However, for the sake of clarity, various buses are labeled as the bus 2240 in the figure.
[0283] The memory 2230 is used to store program code and is controlled by the processor 2210 to execute the processing steps of the data access method in the above embodiment. The program code may include one or more software modules, which may be the software modules provided in the embodiment of Figure 21.
[0284] It should be noted that this embodiment can be implemented by a general physical server, for example, an ARM server or an X86 server, or it can be implemented by a virtual machine based on a general physical server combined with NFV technology. A virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. This application does not make any specific restrictions.
[0285] Memory 2230 may include volatile memory, such as random access memory (RAM); non-volatile memory, such as read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); or a combination thereof. Memory 2230 may store program code to specifically execute steps S2001 to S2004 and their optional steps in the embodiment of FIG. 20 , which will not be further described here.
[0286] The communication interface 2220 can be a wired interface (such as an Ethernet interface), an internal interface (such as a high-speed serial computer expansion bus interface), a wired interface (such as an Ethernet interface) or a wireless interface (such as a cellular network interface or a wireless local area network interface) for communicating with other devices or modules.
[0287] It should be noted that FIG22 is only one possible implementation of the embodiment of the present application. In actual applications, the electronic device 2200 may also include more or fewer components, which is not limited here. For matters not shown or described in the embodiment of the present application, please refer to the relevant description in the embodiment of FIG20 above, which will not be repeated here.
[0288] It should be understood that the electronic device shown in FIG. 22 may also be a computer cluster consisting of at least one server, and this application does not make any specific limitation.
[0289] An embodiment of the present application also provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium runs on a processor, the method flow shown in Figure 20 is implemented.
[0290] An embodiment of the present application also provides a computer program product. When the computer program product runs on a processor, the method flow shown in Figure 20 is implemented.
[0291] The above embodiments may be implemented in whole or in part through software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product comprises one or more computer instructions. When the computer program instructions are loaded or executed on a computer, the processes or functions described in accordance with the embodiments of the present invention are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes a collection of one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a high-density digital video disc (DVD), or a semiconductor medium. The semiconductor medium may be an SSD.
[0292] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A data access method, characterized in that: Applied to a global memory system, the global memory system includes a first device and multiple node devices, the node devices include local memory and global memory, the multiple node devices share the global memory, the global memory includes a first memory block, the method includes: The first device obtains operation information of read and write operations performed by the multiple node devices on the first memory block, where the operation information is used to indicate an access rate of the read and write operations on the first memory block; The first device determines, based on the operation information, read and write operation characteristics of the plurality of node devices corresponding to the first memory block; The first device determines the read and write strategies of the multiple node devices corresponding to the first memory block based on the read and write operation characteristics, and the read and write strategies include dividing the multiple node devices into primary nodes and secondary nodes for performing read and write operations.
2. The method according to claim 1, characterized in that The access rate is determined based on the number and / or time of read and write operations performed by the multiple node devices on the first memory block.
3. The method according to claim 1, characterized in that The type of the primary node includes a metadata node storing the first memory block.
4. The method according to claim 1, characterized in that The type of the primary node includes a read primary node whose operation information of the read operation meets the first condition, and The first condition includes that a value of an access rate of a read operation of a node device on the first memory block satisfies a first preset condition.
5. The method according to claim 1, characterized in that The type of the primary node includes a write primary node whose operation information of the write operation meets the second condition, The second condition includes that the value of the access rate of the node device's write operation on the first memory block meets the second preset condition.
6. The method according to claim 1, characterized in that The types of the main nodes include read-write main nodes whose operation information of read operations and write operations meets the third condition, The third condition includes that the value of the access rate of the node device's read operation on the first memory block meets the first preset condition, and the value of the access rate of the node device's write operation on the first memory block meets the second preset condition.
7. The method according to any one of claims 3 to 6, characterized in that: The read / write operation characteristics include a read / write ratio, and the first device determines the read / write operation characteristics of the plurality of node devices corresponding to the first memory block based on the operation information, including: The first device determines that the ratio of read operations to the first memory block is more than read operations based on the fact that a value of an access rate of read operations to the first memory block by the multiple node devices is greater than a value of an access rate of write operations to the first memory block; or The first device determines that the ratio of read and write operations of the first memory block is more write based on the value of the access rate of the read operation of the first memory block being less than or equal to the value of the access rate of the write operation to the first memory block.
8. The method according to claim 4, characterized in that The read / write operation characteristics include read / write distribution, and the first device determines the read / write operation characteristics of the plurality of node devices corresponding to the first memory block based on the operation information, including: The first device determines that the read and write distribution of the first memory block is read exclusive based on the presence of the read master node in the multiple node devices; or The first device determines that the read and write distribution of the first memory block is read sharing based on the fact that the read master node does not exist in the multiple node devices.
9. The method according to claim 5, characterized in that The read / write operation characteristics include read / write distribution, and the first device determines the read / write operation characteristics of the plurality of node devices corresponding to the first memory block based on the operation information, including: The first device determines that the read and write distribution of the first memory block is write-exclusive based on the existence of the write master node in the multiple node devices; or, The first device determines that the read-write distribution of the first memory block is write-sharing based on the absence of the write master node among the multiple node devices.
10. The method according to claim 6, characterized in that The read / write operation characteristics include read / write distribution, and the first device determines the read / write operation characteristics of the plurality of node devices corresponding to the first memory block based on the operation information, including: The first device determines that the read and write distribution of the first memory block is exclusive access based on the existence of a read and write master node in the multiple node devices; or, The first device determines that the read and write distribution of the first memory block is access sharing based on the absence of a read and write master node among the multiple node devices.
11. The method according to any one of claims 7 to 10, characterized in that: The first device determines, based on the operation information, read and write operation characteristics of the plurality of node devices corresponding to the first memory block, including: The first device determines that the read and write operation characteristics of the first memory are read-mostly based on that the read-write ratio of the first memory block is read-mostly and the read-write distribution is any one of read-shared, write-shared, write-exclusive, or access-shared; The first device determines that the read and write operation characteristics of the first memory are access exclusive based on the read-write ratio of the first memory block being read-mostly and the read-write distribution being read-exclusive or access-exclusive, or the read-write ratio of the first memory block being write-mostly and the read-write distribution being write-exclusive or access-exclusive; The first device determines that the read and write operation characteristics of the first memory are write sharing based on the read-write ratio of the first memory block being write-dominated and the read-write distribution being write sharing or access sharing.
12. The method according to claim 11, characterized in that The first device determines, based on the operation information, read and write operation characteristics of the plurality of node devices corresponding to the first memory block, further comprising: The first device determines that the read and write operation characteristics of the first memory are write-exclusive based on the value of the access rate of the write operation of the first memory block being greater than the first threshold and less than or equal to the second threshold, and the read and write distribution being write-exclusive; The first device determines that the read and write operation characteristics of the first memory are read exclusive based on the fact that the value of the access rate of the read operation of the first memory block is greater than a third threshold and less than or equal to a fourth threshold, and the read and write distribution is read exclusive.
13. The method according to claim 9, characterized in that The first device determines, based on the read / write operation characteristics, the read / write strategies of the plurality of node devices corresponding to the first memory block, including: The first device determines a metadata node among the plurality of node devices based on the read / write operation characteristic being the write sharing, and determines other node devices except the metadata node as write sharing nodes among the secondary nodes; Based on a first write sharing node among the write sharing nodes receiving a write request corresponding to the first memory block, the first write sharing node updates the write node of the first memory block in the metadata node to the first write sharing node; and Based on a second write sharing node among the write sharing nodes receiving a read request, the second write sharing node obtaining a write node of the first memory block from the metadata node; Based on the second write sharing node obtaining that the write node is the first write sharing node, the second write sharing node obtains data corresponding to the first memory block from the first write sharing node.
14. The method according to claim 10, characterized in that The first device determines, based on the read / write operation characteristics, the read / write strategies of the plurality of node devices corresponding to the first memory block, including: The first device determines the read-write master node among the plurality of node devices based on the read-write operation characteristic being the access exclusive, and determines the node devices other than the read-write master node as access secondary nodes among the secondary nodes; Based on the access sharing node receiving the read request, the access secondary node requests the read-write primary node for data of the first memory block; and Based on the access shared node receiving the write request corresponding to the first memory block, the access secondary node sends data corresponding to the write request to the read-write primary node; and Based on the read / write master node receiving a read request corresponding to the first memory block, the read / write master node reads data of the first memory block in the local memory; and Based on the read-write master node receiving a write request corresponding to the first memory block, the read-write master node reads and updates the data of the first memory block in the local memory.
15. The method according to claim 9, characterized in that The first device determines, based on the read / write operation characteristics, the read / write strategies of the plurality of node devices corresponding to the first memory block, including: The first device determines the write master node among the multiple node devices based on the read / write operation characteristic being write exclusive, and determines the node devices other than the write master node as write secondary nodes among the secondary nodes; Based on the write master node receiving a read request corresponding to the first memory block, the write master node reads data of the first memory block in the local memory; and, Based on the write master node receiving the write request corresponding to the first memory block, the write master node will send an invalidation request to the write secondary node; and, Based on the non-invalidated write secondary node receiving a read request corresponding to the first memory block, the non-invalidated write secondary node reads the data of the first memory block in the local memory, wherein the non-invalidated write secondary node refers to a write secondary node that has not received the invalidation request sent by the write primary node; and, Based on the invalidated write secondary node receiving a read request corresponding to the first memory block, the invalidated write secondary node requests the data of the first memory block from the write primary node, wherein the invalidated write secondary node refers to the write secondary node that receives the invalidation request sent by the write primary node; and, Based on the write secondary node receiving the write request corresponding to the first memory block, the write secondary node sends data corresponding to the write request to the write primary node.
16. The method according to claim 8, characterized in that The first device determines, based on the read / write operation characteristics, the read / write strategies of the plurality of node devices corresponding to the first memory block, including: The first device determines the read master node among the multiple node devices based on the read-write operation characteristic being read exclusive, and determines the node devices other than the read master node as read secondary nodes among the secondary nodes; Based on the read master node receiving the read request corresponding to the first memory block, the read master node reads the data of the first memory block in the local memory; and Based on the read master node receiving a write request corresponding to the first memory block, the read master node will send an invalidation request to the read secondary node; and, Based on the read secondary node receiving the read request corresponding to the first memory block, the read secondary node requests the data of the first memory block from the read primary node; and, Based on the read secondary node receiving the write request corresponding to the first memory block, the read secondary node sends the data corresponding to the write request to the read primary node.
17. The method according to any one of claims 11 to 12, characterized in that: The first device determines, based on the read / write operation characteristics, the read / write strategies of the plurality of node devices corresponding to the first memory block, including: Based on the read-write operation characteristic being read-most, the multiple node devices receive a read request corresponding to the first memory block, and the multiple node devices read data of the first memory block in the corresponding local memory; and A fourth node device among the multiple node devices receives a write request corresponding to the first memory block, and the fourth node device sends data corresponding to the write request to other node devices.
18. The method according to claim 1, characterized in that The method further comprises: The first device obtains location information of the data of the first memory block read by the multiple node devices; The first device divides the first memory block into a plurality of sub-blocks according to the position information corresponding to the plurality of node devices; The first device determines, based on the operation information, read and write operation characteristics of the plurality of node devices corresponding to the first memory block, including: The first device determines, based on the operation information, read and write operation characteristics of a plurality of sub-blocks in the first memory block; The first device determines, based on the read / write operation characteristics, the read / write strategies of the plurality of node devices corresponding to the first memory block, including: The first device determines the read and write strategies of the multiple node devices corresponding to the multiple sub-blocks respectively based on the read and write operation characteristics of the multiple sub-blocks.
19. The method according to claim 1, characterized in that The method further comprises: Within a preset time when the node device performs a read and write operation on data of a first memory block in a local memory, the node device determines a read and write strategy corresponding to the first memory block; Based on the node device determining that the data of the first memory block in the local memory is a new value according to the read-write strategy, the node device keeps executing the read-write operation; Based on the node device determining, according to the read-write policy, that the data of the first memory block in the local memory is an old value, the node device re-executes the read-write operation according to the read-write policy.
20. The method according to claim 1, characterized in that The multiple node devices include a fifth node device, the local memory of the fifth node device includes data of multiple memory blocks, and the method further includes: The first device determines read and write operation characteristics of the plurality of memory blocks according to operation information of read operations of the plurality of memory blocks; The first device determines the read and write strategies of the multiple memory blocks according to the read and write operation characteristics of the multiple memory blocks; The fifth node device determines, according to the read and write operation characteristics of the multiple memory blocks, the number of memory blocks in the local memory of the fifth node device that are out-of-bounds values, wherein the out-of-bounds value means that after the fifth node device reads the memory block data, the number of times the memory block data is updated by other node devices exceeds a preset number of times, or the fifth node device fails to update the memory block data for more than a preset time period; Based on the fact that the number of memory blocks in the fifth node device that are out-of-bounds values does not exceed a preset number, the fifth node device performs a read operation or a write operation on the data of the multiple memory blocks in the local memory of the fifth node device; or, Based on the fact that the number of memory blocks in the fifth node device that are out-of-bounds values exceeds a preset number, the fifth node device performs a read operation or a write operation on the data of the multiple memory blocks according to the read and write policies of the multiple memory blocks.
21. A readable medium, characterized in that The readable medium contains instructions, which, when executed by a processor of an electronic device, enable the electronic device to implement the method of any one of claims 1 to 20.
22. An electronic device, characterized in that: include: a memory for storing instructions to be executed by one or more processors of the electronic device; and a processor, which is one of the processors of the electronic device, configured to execute the instructions so that the electronic device implements the method according to any one of claims 1 to 20.
Citation Information
Patent Citations
Method and system for active replication for Cache of multi-core processor
CN102117262A
Multi-core processor system and cache coherency processing method
CN104991868A
Multi-core processor supporting cache consistency, reading and writing methods and apparatuses as well as device
CN105740164A
L1 Cache management method of GPGPU based on the number of data accesses
CN109408411A
Data access and storage method and data access and storage device
CN112416259A