WO2023035694A1 - 业务系统、内存管理方法及装置 - Google Patents

业务系统、内存管理方法及装置 Download PDF

Info

Publication number
WO2023035694A1
WO2023035694A1 PCT/CN2022/096400 CN2022096400W WO2023035694A1 WO 2023035694 A1 WO2023035694 A1 WO 2023035694A1 CN 2022096400 W CN2022096400 W CN 2022096400W WO 2023035694 A1 WO2023035694 A1 WO 2023035694A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
memory
service node
resources
resource
Prior art date
Application number
PCT/CN2022/096400
Other languages
English (en)
French (fr)
Inventor
任仁
刘川
赵玥
崔文林
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2023035694A1 publication Critical patent/WO2023035694A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]

Definitions

  • the present application relates to the field of computers, in particular to a business system, memory management method and device.
  • memory resource pooling has gradually developed into a new trend.
  • memory resources of multiple business nodes can be used to construct a global memory resource pool, and each business node can share memory resources in the global memory resource pool.
  • the application provides a service system, a memory management method and a device, which solve the problem of memory performance damage.
  • a service system in a first aspect, includes a plurality of service nodes.
  • the memory of at least one of the multiple service nodes is divided into local resources and global resources.
  • the local resources are used to provide memory storage space for local service nodes;
  • the global resources in at least one service node form a memory pool, and the memory pool is used to provide memory storage space for multiple service nodes.
  • the name of the above memory pool can be set arbitrarily according to actual needs, for example, the upload memory pool can also be called a memory resource pool, a global memory resource pool, etc., which is not limited in this application.
  • each service node is balanced by constructing a memory pool that can be used by each service node in the service system.
  • business nodes also include local resources. When each business node accesses local resources, it will not conflict with other business nodes. Therefore, each business node can load data into local resources to avoid conflicts with other business nodes. Nodes collide, reducing loss of memory performance and cost.
  • each service node can load data into local resources, the access speed of service nodes when accessing local resources will not be affected by communication delay between service nodes.
  • the service system further includes: a memory management device.
  • the memory management device is used to adjust the storage space size of local resources and global resources of each service node in at least one service node.
  • the memory management device can control the storage space of local resources and global resources, so that more memory resources can be allocated to local resources when the demand for local resources is large, and more memory resources can be allocated when the demand for global resources is large. Allocate memory resources to global resources to achieve a more reasonable allocation of memory resources and improve system performance.
  • the memory management device is used to adjust the storage space size of local resources and global resources of each service node in at least one service node, and specifically includes at least one of the following: the memory management device is used to When the global resource of the service node is exhausted and there is free space in the local resource of at least one service node, the free space in the local resource of the at least one service node is transferred to the global resource of at least one service node. Or, the memory management device is used to transfer the free space in the global resources of at least one service node to the at least one service node when the local resources of at least one service node are exhausted and there is free space in the global resources of at least one service node. local resources.
  • the memory management device is used to reclaim the memory resource with the lowest value in the memory of at least one service node when both the global resource and the local resource of at least one service node are exhausted, transfer the reclaimed memory resource to the global resource, or Reclaimed memory resources are transferred to local resources.
  • the free space in the local resource is transferred to the global resource when the global resource is exhausted, and the idle space in the global resource is transferred to the local resource when the local resource is exhausted.
  • a balance point of resource allocation can be found between local resources and global resources, so as to achieve a more reasonable allocation of memory resources and improve system performance.
  • the above design can also reclaim memory resources with the lowest value in memory and transfer the reclaimed memory resources to global resources or local resources, thereby improving the effect of system performance.
  • the above-mentioned memory management device is also used to maintain the local resources of each service node in at least one service node when adjusting the storage space of the local resources of each service node in at least one service node and the storage space of global resources
  • the storage space of is not less than the preset threshold.
  • the memory management device is further configured to determine the memory resource loaded with the first data from local resources or global resources of at least one service node according to the accessed information of the first data.
  • the accessed information of the first data may include various information used to reflect the times or frequencies of the target data being accessed by each service node.
  • appropriate memory resources can be allocated for the first data according to the accessed information of the data (that is, the first data). For example, if according to the accessed information of the first data, it is determined that the first data was only accessed by one service node before, then the first data is loaded into the local resource of the service node, so that the service node can quickly access it in subsequent processing The first data, and prevent the process of the service node accessing the first data from conflicting with other service nodes. If, according to the accessed information of the first data, it is determined that the first data has been accessed by multiple service nodes before, the first data can be loaded into the global resource so that multiple service nodes can access the first data in subsequent processing. a data.
  • the memory management device is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: If according to the accessed information of the first data, it is determined that the first data has been accessed by m service nodes, then it is determined to load the first data into the global resources of at least one service node; m is a positive integer greater than 1, and m A service node is included in multiple service nodes.
  • the first data when the first data is accessed by multiple service nodes before the first data is determined, the first data is loaded into the global resource so that multiple service nodes can access the first data through the global resource in subsequent processing .
  • the memory management device is configured to determine to load the first data to the global resource of at least one service node if it is determined that the first data has been accessed by m service nodes according to the access information of the first data wherein, the memory management device is configured to determine, according to the accessed information of the first data, that the first data has been accessed by m service nodes, then according to the affinity between the first data and each of the m service nodes, It is determined to load the first data into the global resource of at least one service node.
  • the first data can be loaded into the global resource in the service node with a higher affinity with the first data, so that the usage efficiency of the memory pool is higher.
  • the memory management device is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: If it is determined according to the accessed information of the first data that the first data has been accessed by at least one service node, it is determined to load the first data into the local resource of the at least one service node.
  • the service node when it is determined that the first data is accessed by the service node, the service node can quickly access the first data in subsequent operations by loading the first data into the local resource of the service node.
  • the memory management device is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: If according to the accessed information of the first data, it is determined that the first data has been accessed by m service nodes, and there are n service nodes among the m service nodes whose affinity with the first data is greater than the affinity threshold, then determine Loading the first data into the local resources of n service nodes; wherein, m is a positive integer greater than 1, n is a positive integer less than or equal to m, and the m service nodes are included in the plurality of service nodes.
  • the first data when it is determined that the affinity between the first data and the n service nodes is relatively high, the first data can be respectively loaded into the local resources of the n service nodes, so that the n service nodes can run Both can quickly access the first data.
  • the first data has an access parameter, and the access parameter is used to indicate whether data copies of the first data in the memories of multiple service nodes are available.
  • the above-mentioned memory management device is further used for: acquiring a read request for the first data. An access parameter corresponding to the first data is determined, where the access parameter is used to indicate whether data copies of the first data in the memories of multiple service nodes are available. According to the access parameter, the first data is obtained from the memory of multiple service nodes or other storage locations outside the memory of multiple service nodes.
  • the access parameter can indicate whether the data copy of the data in the memory is available. For example, when a service node writes new data content to the target data, the access parameter of the target data is set to the "unavailable" state until the data copy of the target data recorded in the memory of each service node is invalidated. After processing, the access parameter of the target data is set to "available". In this way, when the service node accesses the target data in the memory, it can first obtain the access parameters corresponding to the target data, and determine whether the data copy of the target data recorded in the memory is available according to the access parameters. If the access parameter indicates the "available” state, read the data copy data of the target data in the memory; if the access parameter indicates the "unavailable” state, then the target data can be read from the hard disk bypassing the memory.
  • the memory management device is further configured to perform a preset operation on the access parameter when the first data changes, so that the access parameter indicates that the data corresponding to the access parameter is in the memory of multiple service nodes A copy of the data for is not available.
  • the preset operation may be to increase or decrease a preset value.
  • the memory management device is further configured to perform an inverse operation of the preset operation on the access parameters after the data copy of the first data is invalidated or reloaded.
  • the value of the access parameter when the first data is changed, the value of the access parameter is changed by making a preset budget for the access, so that the value of the access parameter indicates that the first data in the memory is unavailable. And after the data copy of the first data in the memory is invalidated or reloaded, the access parameter is restored to the previous state by performing an inverse operation on the access parameter, wherein when the access parameter is restored to indicate that the data copy is available After the state, the data copy data of the first data can be obtained from the memory during the subsequent access process.
  • performing a preset operation on the access parameter includes: performing a preset operation on the access parameter according to a compare and exchange CAS mechanism.
  • the preset operation of the access parameters according to the CAS mechanism can ensure the atomicity of each preset operation of the access parameters. For example, when multiple service nodes modify the access parameters at the same time, due to the use of CAS mechanism, so each service node will modify the access parameters in sequence without interfering with each other.
  • the present application provides a memory management method, which is applied to a business system, and the business system includes multiple business nodes; the method includes: dividing the memory of at least one of the multiple business nodes into local resources and Global resources; among them, local resources are used to provide memory storage space for local business nodes; global resources in at least one business node form a memory pool, and the memory pool is used to provide memory storage space for multiple business nodes; when certain conditions are met, At least a part of the space in the local resource will be transferred to the memory pool, or at least a part of the space in the memory pool will be transferred to the local resource; adjust the storage space size of the local resource and the global resource in at least one business node.
  • adjusting the storage space of local resources and global resources in at least one service node specifically includes at least one of the following: the global resources of at least one service node are exhausted and the local resources of at least one service node When free space exists, the free space in the local resource of at least one service node is transferred to the global resource of at least one service node. Or, when the local resource of at least one service node is exhausted and the global resource of at least one service node has free space, the free space in the global resource of at least one service node is transferred to the local resource of at least one service node.
  • the method further includes: when adjusting the storage space of the local resources of each service node in at least one service node and the storage space of global resources, maintaining the storage space of the local resources of each service node in at least one service node not less than the preset threshold.
  • the method further includes: determining a memory resource loaded with the first data from local resources or global resources of at least one service node according to the accessed information of the first data.
  • the memory resource to load the first data including: if according to the accessed information of the first data If it is determined that the first data has been accessed by m service nodes, it is determined to load the first data into the global resources of at least one service node; m is a positive integer greater than 1, and m service nodes are included in multiple service nodes.
  • the memory resource to load the first data including: if according to the accessed information of the first data If it is determined that the first data has been accessed by at least one service node, then it is determined to load the first data into a local resource of at least one service node.
  • the accessed information of the first data from local resources or global resources of at least one service node, determine the memory resource to load the first data, including: if according to the accessed information of the first data , it is determined that the first data has been accessed by m service nodes, and there are n service nodes among the m service nodes whose affinity with the first data is greater than the affinity threshold, then it is determined to load the first data to n service nodes In the local resources of ; wherein, m is a positive integer greater than 1, n is a positive integer less than or equal to m, and m service nodes are included in multiple service nodes.
  • the first data has an access parameter, and the access parameter is used to indicate whether data copies of the first data in the memories of multiple service nodes are available.
  • the method also includes: obtaining a read request for the first data; determining the access parameters corresponding to the first data; the access parameters are used to indicate whether the data copies of the first data in the memories of multiple service nodes are available; according to the access parameters, from The first data is obtained from the memory of multiple service nodes or other storage locations outside the memory of multiple service nodes.
  • the method further includes: when the first data changes, performing preset calculations on the access parameters, so that the access parameters indicate the number of data corresponding to the access parameters in the memory of multiple service nodes Data copy is not available.
  • the method further includes: after the data copy of the first data is invalidated or reloaded, performing an inverse operation of the preset operation on the access parameter.
  • performing a preset operation on the access parameter includes: performing a preset operation on the access parameter according to a compare and exchange CAS mechanism.
  • a memory management device which is located in a service system, and the service system includes a plurality of service nodes.
  • the memory management device includes: a resource dividing unit, which is used to divide the memory of at least one service node among multiple service nodes into local resources and global resources; wherein, the local resources are used to provide memory storage space for the local service nodes; at least one service node
  • the global resources in the node form a memory pool, which is used to provide memory storage space for multiple business nodes; when certain conditions are met, at least part of the space in the local resources will be transferred to the memory pool, or at least part of the memory pool The space will be transferred to local resources; the resource adjustment unit is used to adjust the storage space size of local resources and global resources in at least one service node.
  • the resource adjustment unit is specifically configured to allocate the free space in the local resource of at least one service node to Transferring the global resources of at least one service node; or, the resource adjustment unit is specifically configured to transfer the global resources of at least one service node to The free space in at least one service node is transferred to the local resource; or, the resource adjustment unit is specifically used to reclaim the memory with the lowest value in at least one service node when both the global resource and the local resource of at least one service node are exhausted. Memory resources, transfer reclaimed memory resources to global resources, or transfer reclaimed memory resources to local resources.
  • the resource adjustment unit is also used to maintain the local resources of each service node in at least one service node when adjusting the storage space size of the local resources and global resources of each service node in at least one service node.
  • the storage space is not less than the preset threshold.
  • the memory management device further includes: a memory allocation unit; the memory allocation unit is configured to determine, from local resources or global resources of at least one service node, to load the first The memory resource for the data.
  • the memory allocation unit is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: the memory allocation unit , if it is determined according to the accessed information of the first data that the first data has been accessed by m service nodes, it is determined to load the first data into the global resource of at least one service node; m is a positive integer greater than 1, The m service nodes are included in multiple service nodes.
  • the memory allocation unit is configured to determine to load the first data to the global
  • the resources include: a memory allocation unit, specifically used to determine that the first data has been accessed by m service nodes according to the accessed information of the first data, then according to the affinity between the first data and each service node in the m service nodes And, determine to load the first data into the global resource of at least one service node.
  • the memory allocation unit is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: the memory allocation unit , if it is determined according to the accessed information of the first data that the first data has been accessed by at least one service node, then determine to load the first data into a local resource of at least one service node.
  • the memory allocation unit is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: the memory allocation unit , specifically if, according to the accessed information of the first data, it is determined that the first data has been accessed by m service nodes, and there are n service nodes among the m service nodes whose affinity with the first data is greater than the affinity threshold , it is determined to load the first data into the local resources of n service nodes; wherein, m is a positive integer greater than 1, n is a positive integer less than or equal to m, and m service nodes are included in multiple service nodes.
  • the first data has an access parameter
  • the access parameter is used to indicate whether data copies of the first data in the memories of multiple service nodes are available.
  • the memory management device also includes: a read-write unit; a read-write unit, configured to obtain a read request for the first data; a read-write unit, configured to determine the access parameters corresponding to the first data; the access parameters are used to indicate that the access parameters correspond to Whether the data copy of the data in the memory of multiple service nodes is available; the read-write unit is also used to obtain the first a data.
  • the read-write unit is also used to perform a preset operation on the access parameter when the first data changes, so that the access parameter indicates that the data corresponding to the access parameter is stored in the memory of multiple service nodes A copy of the data in is not available.
  • the read-write unit is further configured to perform an inverse operation of the preset operation on the access parameters after the data copy of the first data is invalidated or reloaded.
  • performing a preset operation on the access parameter includes: performing a preset operation on the access parameter according to a compare and exchange CAS mechanism.
  • a memory management device including: a processor and a communication interface, the processor receives or sends data through the communication interface, and the processor is used to implement the memory in the method designed in any one of the second aspect or the second aspect. Manage the functionality of the device.
  • a computer-readable storage medium is provided, and a computer program is stored in the storage medium.
  • the computer program is executed by a processor, the memory management device in the method designed in any one of the above-mentioned second aspect or the second aspect is implemented. function.
  • a computer program product includes instructions. When the instructions are run on a processor, the function of the memory management device in the method according to the second aspect or any one of the second aspects is realized.
  • FIG. 1 is one of the schematic structural diagrams of a business system provided by the present application.
  • Fig. 2 is the second structural diagram of a business system provided by the present application.
  • Fig. 3A is the third structural diagram of a business system provided by this application.
  • Fig. 3B is the fourth schematic structural diagram of a business system provided by the present application.
  • Fig. 4 is the fifth structural diagram of a business system provided by the present application.
  • Fig. 5 is the sixth structural diagram of a business system provided by the present application.
  • FIG. 6 is a schematic flowchart of a method for allocating memory resources provided by the present application.
  • FIG. 7 is one of the schematic diagrams of memory resource allocation provided by the present application.
  • FIG. 8 is a second schematic diagram of memory resource allocation provided by the present application.
  • FIG. 9 is a third schematic diagram of memory resource allocation provided by the present application.
  • FIG. 10 is one of the schematic flow charts of a data processing method provided by the present application.
  • FIG. 11 is one of the schematic diagrams of data processing provided by the present application.
  • Figure 12 is the second schematic diagram of a data processing provided by this application.
  • Figure 13 is the third schematic diagram of a data processing provided by this application.
  • Figure 14 is the fourth schematic diagram of a data processing provided by this application.
  • FIG. 15 is the second schematic flow diagram of a data processing method provided by the present application.
  • FIG. 16 is a schematic flowchart of a data writing method provided by the present application.
  • FIG. 17 is a schematic diagram of a failure treatment provided by the present application.
  • FIG. 18 is a schematic structural diagram of a counting array provided by the present application.
  • FIG. 19 is one of the structural schematic diagrams of a memory management device provided by the present application.
  • FIG. 20 is the second structural schematic diagram of a memory management device provided by the present application.
  • FIG. 1 it is a schematic diagram of a system architecture of a service system provided by this embodiment.
  • the service system 10 includes one or more service nodes (three service nodes are exemplarily listed in FIG. 1 , namely, service node 11 , service node 12 and service node 13 ).
  • each service node may specifically be a server, a desktop computer, or a controller of a storage array, and other hardware devices with data processing and storage functions.
  • each service node includes a processor, memory and hard disk.
  • service node 11 includes processor 111 , memory 112 and hard disk 113
  • service node 12 includes processor 121 , memory 122 and hard disk 123
  • service node 13 includes processor 131 , memory 132 and hard disk 133 .
  • the processor 111 may be one or more devices, circuits and/or processing cores for processing data (such as computer program instructions). Specifically, the processor 111 is configured to execute computer instructions to process data generated inside the service node 11 .
  • the processor 11 may include a central processing unit (Central Processing Unit, CPU), and the processor 11 may also include a microprocessor, a field programmable gate array (field programmable gate array, FPGA), a digital signal processor (digital signal processor) signal processing (DSP) or application-specific integrated circuit (ASIC), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • CPU central processing unit
  • the processor 11 may also include a microprocessor, a field programmable gate array (field programmable gate array, FPGA), a digital signal processor (digital signal processor) signal processing (DSP) or application-specific integrated circuit (ASIC), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • DSP digital signal processor
  • the memory 112 can be understood as a storage space for directly exchanging data with the processor 111 . It can read and write data at any time, and is fast, and can be used as a temporary data storage for the operating system or other running programs.
  • the memory 112 may include one or more types of memory, for example, the memory may be a random access memory or a read only memory (ROM).
  • the random access memory can be dynamic random access memory (dynamic random access memory, DRAM), storage class memory (storage class memory, SCM), or static random access memory (static random access memory). memory, SRAM), etc.
  • DRAM is a kind of semiconductor memory, and like most random access memory (random access memory, RAM), it belongs to a kind of volatile memory (volatile memory) device.
  • SCM is a composite storage technology that combines the characteristics of traditional storage devices and memory.
  • Storage-class memory can provide faster read and write speeds than hard disks, but the access speed is slower than DRAM, and the cost is also cheaper than DRAM.
  • the read-only memory may be programmable read-only memory (programmable read only memory, PROM), erasable programmable read-only memory (erasable programmable read only memory, EPROM) and the like.
  • the memory can also be a dual in-line memory module or a dual in-line memory module (DIMM for short), that is, a module composed of dynamic random access memory (DRAM).
  • DIMM dual in-line memory module
  • the hard disk 113 is a memory for persistently storing data. Different from the memory 112 , the speed of reading and writing data of the hard disk 113 is slower than that of the memory 112 .
  • One or more hard disks 113 may be provided inside the service node 11, or a hard disk enclosure may be mounted outside the service node 11, and multiple hard disks 113 may be provided in the hard disk enclosure. Regardless of the deployment method, these hard disks can be regarded as hard disks included in the service node 11 .
  • the hard disk 113 may specifically include a solid state disk. Mechanical hard drive or other type of hard drive.
  • the hard disk 113 may also have a memory interface, so that the processor 111 can directly access it.
  • part or all of the storage resources in the hard disk 113 may also be as part of memory 112.
  • the hard disk 113 may be a persistent storage with a byte access interface. Through the byte access interface, the processor 111 can directly access storage resources in the hard disk 113 . At this time, part or all of the storage resources in the hard disk 113 may be used as a part of the memory 112 to expand the memory storage space of the service node 11 .
  • each service node in the service system 10 runs application programs (abbreviated as applications) for realizing corresponding service functions.
  • applications application programs
  • the application 114 runs on the service node 11
  • the application 124 runs on the service node 12
  • the application 134 runs on the service node 13 .
  • the application running on each service node may be a database application.
  • each service node can be used to implement application functions.
  • hardware such as the processor 111 , the memory 112 and the hard disk 113 are used to realize the function of the application 114 .
  • each business node is independent of each other and processes its own data, and the processed results can be used for upper-layer application summary or transfer between business nodes.
  • each application runs independently on the local hardware resource of a single service node, there may be a problem of unbalanced load, so that the hardware resources of each service node cannot be efficiently utilized.
  • each service node in the business system 10 in order to avoid the problem of unbalanced load of each service node in the business system 10, as shown in FIG.
  • the processor in the service system 10) is decoupled from the memory resource (that is, the memory in each service node), and a global memory resource pool is constructed by utilizing the memory resources in multiple service nodes in the service system 10.
  • Each service node can share resources in the global memory resource pool. In this way, the memory load of each service node can be balanced.
  • the memory resource in the service node is divided into two parts. For the convenience of description, these two parts are called “local resource” and “global resource” respectively.
  • Local resources refer to the memory storage space dedicated to its own use in a business node.
  • Global resources refer to the memory storage space provided by a business node to the global memory resource pool, which can be shared by itself or other business nodes.
  • the memory 112 in the service node 11 is divided into two parts: a local resource 1121 and a global resource 1122 .
  • the memory 122 in the service node 12 is divided into local resources 1221 and global resources 1222
  • the memory 132 in the service node 12 is divided into local resources 1321 and global resources 1322 .
  • a physical division method may be used, for example, a service node consists of multiple memories (each memory can be For DRAM, SCM, or hard disks of different types or the same type of memory), the storage space of part of the memory can be used as a local resource, and the storage space of another part of the memory can be used as a global resource; in another implementation, you can By logical division, for example, the memory storage space in a service node can be divided into two parts according to the logical address corresponding to the storage space, one part is used as a local resource, and the other part is used as a global resource. For this, there may be no limitation in this embodiment.
  • global resources in multiple service nodes can form a global memory resource pool. All business nodes in the business system can share resources in the global memory resource pool. As shown in FIG. 3A , the global resource 1122 , the global resource 1222 and the global resource 1322 form a global memory resource pool 14 , wherein each service node in the service system 10 shares resources in the global memory resource pool 14 .
  • each segment of space (specifically) in the global memory resource pool 14 has a unique global address.
  • the space here may use “page (page)” to represent the minimum access granularity of the global memory resource pool 14 .
  • the so-called global address refers to the unique address indicating that the storage space indicated by the address is in the global memory resource pool 14, and each service node can know the meaning of the address.
  • the global address of the space After a physical space is allocated to a section of the global memory resource pool, the global address of the space has its corresponding physical address, which indicates which memory of which service node the space represented by the global address is actually located in. And the offset in the memory, that is, the location in the physical space.
  • the processor 111 can use the global address of each space in the global memory resource pool 14 to access the data stored in the global memory resource pool 14 .
  • the processor 111 can use technologies such as remote direct memory access (RDMA) or memory interconnection (compute express link, CXL) to realize access to the global resource 1222.
  • RDMA remote direct memory access
  • CXL compute express link
  • unilateral access can be understood as realizing fast access to the global resource 1222 through the network card (not shown in the figure) of the service node 12 without the processor 121 of the service node 12 being aware.
  • the local resources in each service node are mainly used to support the access of the local service nodes.
  • the local resource 1121 is used to provide storage space for the processor of the local service node (ie, the processor 111 ) to process data during the operation of the local service node (ie, the service node 11 ).
  • Local resources do not have a global address as described above.
  • the processor 111 in the service node 11 when the processor 111 in the service node 11 needs to access the local resource 1121, it can directly access the data in the local resource 1121 in a conventional way of accessing the local memory.
  • remote service nodes cannot use the global address to access the local resource 1121.
  • RPC remote procedure call
  • the remote service node sends an access request to the program on the service node 11, and the program on the service node 11 The program accesses the data in the local resource 1121 and then feeds it back to the remote node.
  • the local service node that is, the service node 11
  • the memory resource in the service node is divided into two parts, wherein:
  • a part of memory resources is used to build a global memory resource pool that can be used by all business nodes in the business system, so that global resources can be directly accessed by remote business nodes in the business system.
  • technologies such as RDMA and CXL can be used to enable the remote service node to directly access global resources on the local service node without the processor of the local service node being aware of it.
  • Another part of memory resources is not part of the global memory resource pool, and is used to support data processing of the local service node (such as providing cache for the processor of the local service node).
  • a remote node needs to access local resources, it needs to call the program on the local service node to access the local resource, and then feed back the access result to the remote node.
  • each service node in addition to global resources, each business node also includes local resources, and each business node will not conflict with other business nodes when accessing local resources. Therefore, each business node can avoid conflicts with other business nodes by loading data into local resources. Conflicts occur on other service nodes, thereby reducing the loss of memory performance and cost.
  • each service node since each service node can load data into local resources, the access speed of service nodes when accessing local resources will not be affected by communication delay between service nodes.
  • FIG. 3A merely provides an exemplary system architecture to which the technical solution provided by this embodiment can be applied. In an actual application process, the technical solution provided by this embodiment can also be applied to other system architectures.
  • the service system 10 further includes a storage system 15 .
  • the storage system 15 can be used to persist All kinds of data required by each business node to run applications are stored in a centralized manner.
  • the storage system 15 can be connected to each service node through various transmission networks, so as to realize data exchange between each service node and the storage system 15 .
  • the storage system 15 may be a centralized storage system, that is, the storage system 15 may be a central node composed of one or more storage devices, and data is centrally stored in the central node.
  • the storage system 15 may also be a distributed storage system composed of multiple independent storage nodes.
  • the architecture of the storage system 15 may not be limited in this embodiment.
  • FIG. 4 is a schematic structural diagram of another system architecture provided in this embodiment.
  • the service system 20 includes one or more front-end nodes (such as the front-end node 25 and the front-end node 26 in FIG. 4 ) and one or more service nodes (such as the service node 21 and the service node 22 in FIG. 4 ).
  • Each front-end node includes hardware components such as a processor and a memory (not shown in the figure).
  • Each front-end node runs an application for realizing business functions (such as application 241 and application 251 in FIG. 4 ), and a client for supporting data interaction between the application and each service node (such as client 242 and client 242 in FIG. 4 ). 252).
  • the service node 21 and the service node 22 respectively include a memory 212 and a memory 222 providing memory storage space for the front-end nodes, and a hard disk 213 and a hard disk 223 for persistently storing data.
  • memory 212 and memory 222 can be divided into local resources (such as local resources 2121 and local resources 2221 in FIG. 4) and global resources (such as global resources in FIG. 4). 2122 and global resources 2222).
  • the local resource is used to provide a memory storage space exclusively for a front-end node
  • the global resource is used to build a global memory resource pool 23 to share the memory storage space with multiple front-end nodes.
  • the local resource 2121 is used to provide memory storage space for the front-end node 24, and the global resource 2122 can be jointly used by the front-end node 24 and the front-end node 25 as a memory storage space.
  • this embodiment provides a memory resource allocation method for how to allocate shares of local resources and global resources in memory resources in service nodes.
  • this memory resource allocation method by dynamically adjusting the shares of local resources and global resources in memory resources, more memory resources are allocated to local resources when the demand for local resources is large, and more memory resources are allocated when the demand for global resources is large. Allocate memory resources to global resources, so as to achieve a more reasonable allocation of memory resources and improve system performance.
  • this embodiment provides a data processing method for which memory resource (local resource or global resource) is used to load data.
  • memory resource local resource or global resource
  • each service node in the service system 10 (two service nodes are shown in the figure: service node 11 and service node 12 ) respectively includes memory resources capable of managing memory resources in the service nodes.
  • management device namely, the memory management device 115 and the memory management device 125 in the figure.
  • the memory management device 115 can implement according to the method provided in this embodiment: divide the memory 112 into local resources 1121 and global resources 1122, adjust the shares of the local resources 1121 and the global resources 1122 in the memory 112, And functions such as loading data into memory 112 .
  • the function of the memory management device included in each service node may be realized by hardware or by software program.
  • the memory management device is a program code stored in the memory 112, and the processor 111 runs the program code to divide the memory 112 into local resources 1121 and global resources 1122, and adjust the local resources 1121 and global resource 1122 shares.
  • the memory management device can also be a hardware acceleration card, such as a neural network processing unit (Neural networks process units, NPU), a tensor processing unit (tensor processing unit, TPU), a field programmable logic gate array (Field Programmable Gate Array) , FPGA) or application-specific integrated circuit (application-specific integrated circuit, ASIC), etc.
  • a hardware acceleration card such as a neural network processing unit (Neural networks process units, NPU), a tensor processing unit (tensor processing unit, TPU), a field programmable logic gate array (Field Programmable Gate Array) , FPGA) or application-specific integrated circuit (application-specific integrated circuit, ASIC), etc.
  • the memory management device is located inside the service node 11 and can also access the memory 112 through the bus.
  • the structure of the hardware accelerator card is not shown in FIG. 1 and will be described in subsequent embodiments.
  • the service system 10 also includes a management node (not shown in the figure) that can communicate with each service node, wherein the management node can manage each service node. For example, each service node reports information such as the capacity and address of the global resource to the management node, and the management node uniformly addresses the reported global resource and then notifies each service node.
  • the management node can be any service node in the service system 10, and can also be a server independent of multiple service nodes.
  • the memory management device 115 divides the memory 112 into local resources 1121 and global resources 1122 according to the initial shares.
  • an initial share may be preset (for example, the initial share is 50% for the local resource 1121 and the global resource 1122 ) and recorded in the configuration information of the service node 11 .
  • the memory management device 115 takes 50% of the memory resource in the memory 112 as a global resource by loading the configuration information, and compiles it together with the global resources in other service nodes to establish a global memory resource pool 14 .
  • the other 50% memory resources are not compiled uniformly, but are used as local resources 1121 only used by local service nodes.
  • the memory management device 115 regards pages 1 to 8 as local resources 1121 and pages 9 to 16 as global resources 1122 according to the initial shares.
  • the above-mentioned initial share may be a fixed value preset by a technician; in another example, the above-mentioned initial share may also be based on the current The value determined by the operating environment of the service node 11 (for example, the type or attribute of the application run by the service node 11, and the information of the hardware type of the service node 11).
  • the method for determining the initial share may not be limited in this embodiment.
  • the initial share may not be set.
  • all the memory resources of the memory 112 can be used as local resources 1121, or all as global resources 1122, or randomly divided according to a certain share Local resources 1121 and global resources 1122 .
  • the shares of the local resources 1121 and the global resources 1122 in the memory resources are dynamically adjusted (ie S302 below), so as to achieve a more reasonable proportion of memory resources. Understandably, in this scenario, the content of S301 may not be executed.
  • the memory management device 115 adjusts the shares of the local resources 1121 and the global resources 1122 in memory resources according to the demands of the local resources 1121 and the global resources 1122 .
  • S302 may specifically include:
  • the memory management device 115 transfers the free space in the local resource 1121 to the global resource 1122.
  • the space of the global resource 1122 is expanded, so that the above data pages are loaded into the global resource 1122 .
  • the local resource 1121 includes page 1-page 8
  • the global resource 1122 includes page 9-page 16.
  • page 3-page 8 in the local resource 1121 are free spaces, and the global resource 1122 has been exhausted, that is, page 9-page 16 are all occupied.
  • the free space page 8 in the local resource 1121 is transferred to the global resource 1122, and the data page to be loaded is loaded Go to page 8.
  • the transfer of the storage space of a local resource on a service node to a global resource can be specifically expressed as changing the access mode of the storage space, so that the storage space is changed from the access mode of the local resource to the global resource. How the resource is accessed.
  • local resources and global resources are assigned addresses according to different addressing modes.
  • Local resources are allocated with local addresses so that local service nodes can access local resources according to local addresses;
  • global resources are allocated with unique addresses (also called global addresses) in the global memory resource pool, which are used for each service node to access global resources according to the global addresses.
  • assign a unique address in the global memory resource pool that is, a global address
  • the free space page 8 in the local resource 1121 can be transferred to the global resource 1122 by assigning the global address in the global memory resource pool to the page 8 .
  • each service node can access page 8 through technologies such as RDMA according to the global address.
  • the resource exhaustion in this embodiment can be understood as the resource has no free space, or the free space in the resource is smaller than the threshold space size.
  • the similarities in the following can be understood in the same way, and the repetitions will not be repeated.
  • S302 may also include:
  • the memory management device 115 reclaims the memory resource of the page with the lowest value in the memory 112 (that is, the local resource 1121 and the global resource 1122 ) and transfers it to the global resource 1122 .
  • the memory resource of the page with the lowest value in the memory 112 is reclaimed, and the reclaimed memory resource is transferred to the global resource 1122, thereby expanding the free space of the global resource 1122, so that the above data pages can be loaded into the global resource 1122 middle.
  • both the local resource 1121 and the global resource 1122 are occupied, and the data loaded in page 7 is the page with the lowest value in the memory 112 .
  • the data page is to be loaded into the global resource 1122, as shown in (b) in FIG.
  • the data page loads in page 7.
  • the page with the lowest value may specifically be the page with the least number of visits in the memory 112, the page with the longest time interval from the last visit, etc.
  • the evaluation of the value of the page Standards are not limited.
  • both the local resource 1121 and the global resource 1122 are occupied, and the data loaded on page 15 is the page with the lowest value in the memory 112 .
  • the data page is to be loaded into the global resource 1122, as shown in (b) in FIG. Page 15 is not converted to a global resource), and the data page to be loaded is loaded into page 15.
  • a minimum resource threshold may be set for the local resource 1121, so that the local resource 1121 retains at least a part of memory resources (ie, the size of the memory resource indicated by the minimum resource threshold).
  • the specific value of the minimum resource threshold may be configured according to actual needs, and may not be limited in this embodiment.
  • S302 may specifically include:
  • the memory management device 115 may transfer the free space in the global resource 1122 to the local resource 1121.
  • the transfer of the storage space of the global resource on a service node to the local resource can be specifically expressed as changing the access mode of the storage space, so that the storage space is changed from the access mode of the global resource to the access mode of the storage space. How to access local resources.
  • transferring the storage space of a global resource on a service node to a local resource can be implemented by assigning a local address to the storage space and deleting or invalidating the global address of the storage space. After the local address is assigned to the storage space and the global address of the storage space is deleted or invalidated, each service node cannot use the global address to access the storage space, so that the storage space is specially used to provide memory storage space for the local service node.
  • S302 may also include:
  • the memory management device 115 may reclaim the resource of the page with the lowest value in the memory 112 (that is, the local resource 1121 and the global resource 1122) and transfer it to the local resource 1121.
  • all the memory resources of the global resource 1122 can be transferred to the local resource 1121 when data is continuously loaded to the local resource 1121;
  • a minimum resource threshold may be set for the global resource 1122, so that the global resource 1122 reserves at least a part of memory resources.
  • the process of loading data into the memory of the business node in the scenario where the memory resources in the business node are divided into local resources and global resources that is, the data processing method provided in the second aspect above) ) for introduction.
  • the method includes:
  • the service node 11 acquires a data processing instruction.
  • the data processing instruction may be an instruction instructing the service node 11 to process the target data in the hard disk (which may be the hard disk 113, the hard disk 123 or the hard disk 133 in the service system 10).
  • the data processing instruction can be an instruction to instruct the processor 111 to run the program code stored in the hard disk, and the program code is the above target data; Instructions for processing images, texts and other data stored in , and the images and texts are the above target data.
  • the service node 11 loads the target data from the hard disk into the memory resource.
  • the memory management device 115 may temporarily load the target data into the local resource 1121 or the global memory resource pool 14, so that the processor 111 can process the target data. After that, according to the step of S404 below, the target data is migrated to the appropriate memory resources according to the accessed information of the target data (including which nodes access the target data, the frequency of each node accessing the target data, etc.).
  • S402 may specifically include:
  • the service node 11 loads the target data from the hard disk to the local resource 1121.
  • the service node 11 may also load the target data into the global memory resource pool 14 .
  • the service node 11 may load the target data into the global resource 1122 , or the service node 11 may load the target data into the global resources (eg, the global resource 1222 ) of other service nodes.
  • the above step S4021 may not be executed. In this regard, this embodiment may not make a limitation.
  • the above step S3023 can be used to load the global resource 1122 The free space in is transferred to the local resource 1121, so as to load the above target data into the local resource 1121.
  • the above step S3024 can be used to reclaim the memory 112 (that is, the local resource 1121 and the global resource 1122), the resources of the page with the lowest value, so as to load the above-mentioned target data into the reclaimed memory resources.
  • the service node 11 detects the accessed information of the target data.
  • the accessed information of the target data may include various information used to reflect the times or frequencies that the target data is accessed by each service node.
  • the accessed information of the target data may specifically include information such as the number of times the target data is accessed by each service node within a period of time, the interval between two consecutive accesses of the target data, and the like.
  • each service node in the service system 10 can access the target data by accessing the local resource 1121 .
  • the processor 111 in the service node 11 can access the target data in the local resource 1121 through a conventional access method; the remote service node (that is, the service node 12, the service node 13, etc.) can access the local resource 1121 through the RPC mode to access the target data .
  • the service node 11 can detect the accessed information of the target data by recording the conditions of each service node accessing the target data within a period of time.
  • the service node 11 re-allocates memory resources for the target data according to the accessed information of the target data.
  • S404 may include the following S4041-S4042:
  • the target data can be loaded into memory resources in the global memory resource pool 14 according to the affinity between the target data and each service node.
  • the target data can be preferentially loaded into the global resource of the service node with the highest affinity, so that the access efficiency of the target data can be improved.
  • the affinity between the data and the business node in this embodiment can also be understood as the value of the data to the business node, wherein the greater the value of the data to the business node, the higher the affinity, and vice versa.
  • the affinity between data and service nodes can be reflected in information such as the number and frequency of access to the data by the service node, wherein the more times and higher the frequency of access to the data by the service node, the higher the affinity; On the contrary, the less the number of times and the lower the frequency, the lower the affinity.
  • the target data can be preferentially loaded to In the global resources of the business node; further, when the memory resources of the business nodes with higher affinity are exhausted, the memory resources with lower value in the memory resources of the business nodes with higher affinity can be recovered, Then use the reclaimed memory resource to load the target data; alternatively, the target data can also be loaded into the global resource of the service node with lower affinity.
  • the specific implementation process of allocating memory resources for the target data is described in detail below, and the implementation process may specifically include:
  • S4042a Determine the affinity between the target data and each service node according to the accessed information of the target data.
  • step S4042b-S4042e After the affinity between the target data and each service node is determined, part or all of the steps in the following steps S4042b-S4042e can be performed on each service node in order of affinity from high to low until the target data is loaded into In the global memory resource pool 14:
  • S4042b Determine whether the current service node is the service node 11 (that is, the service node that loads the target data for the first time).
  • the current service node is the service node 11 (that is, the service node that loads the target data for the first time), execute the following S4042c; on the other hand, if the current service node is not the service node 11, execute the following S4042d.
  • the page can be migrated to the global resource 1122 by modifying the address of the page where the target data is loaded from the address in the local resource 1121 to the address in the global memory resource pool 14 .
  • the effect of loading the target data into the global resource 1122 of the service node 11 can be achieved without reclaiming resources on the page where the target data is loaded, and without copying the target data.
  • the target data is loaded into the global resources of the current service node (ie S4042e in the figure). If the current service node does not meet the preset conditions, the next service node is traversed in order of affinity from high to low.
  • the preset conditions may specifically include any of the following:
  • the service node 11 first loads the target data into page 1 in the local resource 1121 according to S402 .
  • the service node 12 is the service node with the highest affinity with the target data.
  • there is free space in the global resource 1222 of the service node 12 page 32 in the figure), that is, the service node 12 satisfies the above 1) and has the ability to load target data.
  • the target data is loaded into the page 32 .
  • the memory management device 125 in the service node 12 loads the target data from the hard disk to the page 32 of the global resource 1222 through the data page loading process, thereby realizing loading the target data into the page 32 .
  • the memory management device 115 in the service node 11 can reclaim the page 1 by executing the data page elimination process.
  • the service node 11 first loads the target data into page 1 in the local resource 1121 according to S402 .
  • the service node 12 is the service node with the highest affinity with the target data.
  • there is no free space in the global resource 1222 of the service node 12 but there is free space in the local resource 1221 (page 23 and page 24 in the figure), that is, the service node 12 meets the above 2) and has the ability to load target data.
  • the page 24 can be transferred into the global resource 1222 and the target number can be loaded into the page 24 .
  • the service node 11 first loads the target data into page 1 in the local resource 1121 according to S402 .
  • the service node 12 is the service node with the highest affinity with the target data.
  • neither the local resource 1221 nor the global resource 1222 of the service node 12 has free space.
  • the page 31 of the global resource 1222 is loaded with data whose value is lower than the target data.
  • the target data can be loaded into the page 31 after reclaiming the memory resources of the page 31 .
  • the service node 11 first loads the target data into page 1 in the local resource 1121 according to S402 .
  • the service node 12 is the service node with the highest affinity with the target data.
  • neither the local resource 1221 nor the global resource 1222 of the service node 12 has free space. But the page 21 of the global resource 1221 is loaded with data whose value is lower than the target data.
  • the target data can be loaded into page 21 .
  • the method may further include:
  • the n service nodes are n service nodes whose affinity with the target data is greater than an affinity threshold, and n is a positive integer.
  • the target data when there are n business nodes whose affinity with the target data is higher than the affinity threshold, the target data can be respectively loaded in the local resources of the n business nodes, so that the n business nodes can The nodes access the target data to improve the operating efficiency of the n business nodes.
  • each service node can also periodically detect the accessed information of each data page in the memory resource of the node, and according to the accessed information of each data page, follow the method described in S404 above , to re-allocate memory resources for each data page.
  • each service node can access the memory of each local or remote node. Therefore, when a business node updates data through the writing process, if the data copy of the data in the memory is not invalidated, when the local business node or remote business node accesses the data again, it may appear that the data is read from the memory to data that has expired. Therefore, in order to avoid the above situation, this embodiment also provides a data writing method, as shown in FIG. 16 , the method includes:
  • the service node 11 acquires a write request.
  • the write request is used to update certain data (hereinafter referred to as target data).
  • the write request carries the logical address of the target data and update data of the target data.
  • the logical address can be the address identification of the target data used by the upper layer application, for example, the logical address can include the logical unit number (logical unit number, LUN), logical block address (logical block address, LBA) and data corresponding to the target data length.
  • the service node 11 writes the update data into the hard disk (specifically, the hard disk 113, the hard disk 123, or the hard disk 133) according to the write request.
  • the service node 11 performs invalidation processing on the data copy of the target data recorded in the internal memory of each service node.
  • the invalidation processing may specifically include deleting the data copy in the memory or modifying the bitmap of the data copy in the memory.
  • the service node 11 can perform failure processing or reload processing in a conventional manner to release the invalid data in the memory copy; for the data copy of the target data recorded in the memory resource of the remote service node, on the one hand, the service node 11 can trigger the network card of the remote service node to global resources (such as the service node 12) through unilateral access methods such as RDMA and CXL.
  • the copy data of the target data recorded in the global resource 1222) is invalidated or reloaded.
  • the service node 11 can send a message to the remote service node through RPC, etc., to trigger the remote service node to execute the local resource ( For example, the data copy of the target data recorded in the local resource 1221 of the service node 12 is invalidated or reloaded.
  • data copies of data C are loaded on page 3 , page 17 and page 25 .
  • the memory management device 115 in the service node 11 can invalidate page 3 in a conventional manner, trigger the network card of the service node 12 to invalidate the cache of page 25 through unilateral access methods such as RDMA and CXL, and A message is sent to the service node 12 through RPC to trigger the service node 12 to invalidate the cache of the page 17 .
  • a data copy of the data in the memory (specifically, it can be loaded in the global memory resource pool 14 of the business system 10 , or loaded in the data copy of the local resources of each service node in the service system 10) for invalidation processing.
  • an access parameter can be set in this embodiment, and the access parameter can indicate whether the data copy of the data in the memory is available.
  • the access parameter of the target data is set to the "unavailable” state until the data copy of the target data recorded in the memory of each service node is invalidated, and then the The access parameter of the target data is set to "available".
  • the service node accesses the target data in the memory, it can first obtain the access parameters corresponding to the target data, and determine whether the data copy of the target data recorded in the memory is available according to the access parameters. If the access parameter indicates the "available” state, the data copy of the target data in the memory is read; if the access parameter indicates the "unavailable” state, the target data can be read from the hard disk bypassing the memory.
  • a count array may be constructed, where each item in the count array represents the corresponding data access parameters.
  • a hash value can be calculated through the identification of the target data, and then the corresponding item in the count array can be located by the hash value.
  • the access parameters of the target data can be determined.
  • the counting auto-increment operation can be performed on the item in the counting array through the mechanism of remote direct memory access compare and swap (RDMA CAS);
  • RDMA CAS remote direct memory access compare and swap
  • each item in the counting array is zero.
  • the item in the counting array is added by 1 through the CAS mechanism; After the invalidation processing or reloading is completed, the item in the count array is decremented by 1 through the CAS mechanism. That is to say, if the item corresponding to the data in the count array is not 0, it means that the data corresponding to the item may be invalidated in the memory cache of each service node; if the item corresponding to the data in the count array is 0, It means that the data corresponding to this item is available in the cache in the memory of each service node.
  • the above-mentioned counting array can be stored in each service node in the service system 10, so that each service node can access the data in the memory according to the locally stored An array of counts to determine whether a cache of the accessed data is available in memory.
  • the above-mentioned count array can be stored in the management node in the service system 10. When each service node accesses the data in the memory, the service node can first visit the management node to determine the accessed data in the count array Corresponding access parameters, and then determine whether the cache of the accessed data in the memory is available according to the access parameters.
  • the storage location of the count array may not be limited in this embodiment.
  • this embodiment also provides a memory management device, which can be applied in a business system, so that the above business system can realize part or all of the effects of the above embodiments.
  • the device can be used to execute some or all of the steps in the operation process of the above-mentioned business system.
  • the memory management device can be used to execute some or all of the steps in FIG. 6, FIG. 10, FIG. 15 and FIG. , in order to achieve the corresponding technical effect.
  • the memory management device includes corresponding hardware structures and/or software modules for performing various functions.
  • the technical solutions provided in this embodiment can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software drives the hardware depends on the specific application scenario and design constraints of the technical solution.
  • the data access device can be located on a service node in the service system; or, the data access device can adopt a distributed structure, so that it can be jointly realized by hardware structures and/or software modules of multiple service nodes
  • the function of the data access device; or, the function of the data access device may also be realized by a hardware structure and/or software module independent of each service node in the service system.
  • FIG. 19 is a schematic structural diagram of the memory management device provided by the present application.
  • the memory management device 60 includes:
  • the resource division unit 601 is configured to divide the memory of at least one of the multiple service nodes in the service node into local resources and global resources. Wherein, for the relevant content of local resources and global resources, reference may be made to the above description of each operation process in the business system 10 , and details are not repeated here.
  • a resource adjustment unit 602 configured to adjust the storage space size of local resources and global resources in at least one service node.
  • the resource adjustment unit 602 is configured to adjust the storage space size of local resources and global resources in at least one service node, specifically including at least one of the following:
  • the resource adjustment unit 602 is also configured to maintain the local resources of each service node in at least one service node when adjusting the storage space of the local resources of each service node in at least one service node and the storage space of global resources The storage space of is not less than the preset threshold.
  • the memory management device 60 further includes: a memory allocation unit 603 .
  • the memory allocation unit 603 is configured to determine a memory resource loaded with the first data from local resources or global resources of at least one service node according to the accessed information of the first data.
  • the memory allocation unit 603 is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: memory allocation Unit 603, configured to determine that the first data has been accessed by m service nodes according to the accessed information of the first data, then determine to load the first data into the global resource of at least one service node; m is a positive value greater than 1 Integer, m service nodes are contained in multiple service nodes.
  • the memory allocation unit 603 is configured to determine that the first data has been accessed by m service nodes according to the accessed information of the first data, then determine to load the first data to at least one service node
  • the global resources include: a memory allocation unit 603, which is specifically used to determine that the first data has been accessed by m service nodes according to the accessed information of the first data, then according to the first data and each service node in the m service nodes affinity, determine to load the first data into the global resource of at least one service node.
  • the memory allocation unit 603 is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: memory allocation The unit 603 is configured to determine to load the first data into a local resource of at least one service node if it is determined according to the accessed information of the first data that the first data has been accessed by at least one service node.
  • the memory allocation unit 603 is configured to determine the memory resource for loading the first data from local resources or global resources of at least one service node according to the accessed information of the first data, including: memory allocation Unit 603 is specifically used to determine, according to the accessed information of the first data, that the first data has been accessed by m service nodes, and among the m service nodes, there are n service nodes whose affinity with the first data is greater than the affinity If the property threshold is determined, it is determined to load the first data into the local resources of n service nodes; wherein, m is a positive integer greater than 1, n is a positive integer less than or equal to m, and m service nodes are included in multiple service nodes.
  • the first data has an access parameter, and the access parameter is used to indicate whether data copies of the first data in the memories of multiple service nodes are available.
  • the memory management device 60 also includes: a read-write unit 604; the read-write unit 604 is used to obtain a read request for the first data; the read-write unit 604 is also used to determine the access parameters corresponding to the first data; the access parameters are used for Indicates whether the data corresponding to the access parameter is available in caches in the memory of multiple service nodes; the read-write unit 604 is also used to read and write from the memory of multiple service nodes or other storage locations outside the memory of multiple service nodes according to the access parameters , get the first data.
  • the read-write unit 604 is further configured to perform a preset operation on the access parameter when the first data changes, so that the access parameter indicates that the data corresponding to the access parameter is stored in multiple service nodes. In-memory cache is not available.
  • the read-write unit 604 is further configured to perform an inverse operation of the preset operation on the access parameter after cache invalidation or reloading is completed on the cache of the first data.
  • performing a preset operation on the access parameter includes: performing a preset operation on the access parameter according to a compare and exchange CAS mechanism.
  • FIG. 20 is a schematic structural diagram of another memory management device provided by the present application.
  • the memory management device 70 is located in the service node shown in FIG. 1 and is used to implement the method provided in this application.
  • the memory management device 70 may be a chip or a system on a chip.
  • the memory management device 70 may include: a processing unit 701 and at least one communication interface 702 .
  • processing unit 701 is configured to execute the method provided in this embodiment.
  • the processing unit 701 may include a neural network processor (neural networks process units, NPU), a tensor processing unit (tensor processing unit, TPU), a field programmable gate array (field programmable gate array, FPGA) or a specific application Integrated circuits (application-specific integrated circuit, ASIC), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a neural network processor neural networks process units, NPU
  • tensor processing unit tensor processing unit
  • TPU field programmable gate array
  • FPGA field programmable gate array
  • ASIC application-specific integrated circuit
  • the processing unit 701 when the processing unit 701 includes processors such as NPU and TPU, the processing unit 701 also includes a memory.
  • the processor in the processing unit 701 executes the computer-executed instructions stored in the memory to execute the method provided in the present application.
  • the communication interface 702 is used to communicate with other devices.
  • the memory management device 70 may communicate with other hardware devices of the service node through the communication interface 702, so as to execute the method provided in this embodiment.
  • the communication interface 702 may be an interface circuit or a transceiver.
  • the computer-executed instructions in this embodiment may also be referred to as application code, which is not specifically limited in this embodiment.
  • the memory management device 70 is used to implement the corresponding processes of the methods in FIG. 6 , FIG. 10 , FIG. 15 and FIG. 16 , and details are not repeated here for the sake of brevity.
  • all or part of them may be implemented by software, hardware, firmware or any combination thereof.
  • software When implemented using software, it 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 programs or instructions. When the computer program or instructions are loaded and executed on the computer, the processes or functions described in this embodiment are executed in whole or in part.
  • the computer may be a general purpose computer, a special purpose computer, a computer network, network equipment, user equipment, or other programmable devices.
  • the computer program or instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program or instructions may be downloaded from a website, computer, A server or data center transmits to another website site, computer, server or data center by wired or wireless means.
  • 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 a data center integrating one or more available media.
  • the available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disc (digital video disc, DVD); it may also be a semiconductor medium, such as an SSD.
  • “at least one” means one or more
  • “multiple” means two or more
  • other quantifiers are similar.
  • “And/or” describes the association relationship of associated objects, indicating that there may be three kinds of relationships, for example, A and/or B may indicate: A exists alone, A and B exist simultaneously, and B exists independently.
  • the singular forms “a”, “an” and “the” do not mean “one or only one” but “one or more” unless the context clearly dictates otherwise. in one".
  • “a device” means reference to one or more such devices.
  • At least one (at least one of). «" means one or any combination of subsequent associated objects, such as "at least one of A, B and C” includes A, B, C, AB, AC, BC, or ABC.
  • character “/” generally represents that the associated object before and after is a kind of "or” relation; In the formula of the present embodiment, character “/”, Indicates that the associated objects before and after are a kind of "division" relationship.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种业务系统、内存管理方法及装置,涉及计算机领域。本申请一方面能够均衡业务系统中各业务节点的内存负载,另一方面可以避免内存性能和成本上的损耗,提高内存资源的使用性能。该业务系统,包括多个业务节点;多个业务节点中至少一个业务节点的内存被划分为本地资源和全局资源;其中,本地资源用于为本地业务节点提供内存存储空间;至少一个业务节点中的所述全局资源构成内存池,内存池用于为多个业务节点提供内存存储空间;当一定条件满足时,本地资源中的至少一部分空间会被转入所述内存池;或者内存池中的至少一部分空间会被转入所述本地资源。

Description

业务系统、内存管理方法及装置
本申请要求于2021年9月11日提交国家知识产权局、申请号为202111064929.7、申请名称为“一种支持流动的分层全局内存资源池管理方法”的中国专利申请的优先权,本申请还要求于2021年9月30日提交国家知识产权局、申请号为202111165165.0、申请名称为“业务系统、内存管理方法及装置”的中国专利申请的优先权,这些申请的全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机领域,尤其涉及一种业务系统、内存管理方法及装置。
背景技术
随着高速网络和新内存技术的发展,内存资源池化逐渐发展成一种新的趋势。例如,在业务系统中,可以利用多个业务节点的内存资源构建全局内存资源池,各业务节点可以共享全局内存资源池中的内存资源。
与各业务节点独立使用各业务节点的内存资源的技术方案相比,上述构建全局内存资源池的技术方案,虽然可以均衡各业务节点内存资源的负载,但也存在一些问题。
例如,在上述构建全局内存资源池的技术方案中,为了避免各业务节点在访问全局内存资源池中的数据时发生冲突,就需要保证全局内存资源池中的被访问数据不在同一时间被两个应用访问,这就会带来内存性能和成本上的损耗。再例如,业务节点之间的通信时延会影响内存的访问速度,无法发挥出内存的性能优势。
发明内容
本申请提供一种业务系统、内存管理方法及装置,解决了内存性能受损的问题。
为达到上述目的,本申请采用如下技术方案:
第一方面,提供一种业务系统,该业务系统包括多个业务节点。其中,多个业务节点中至少一个业务节点的内存被划分为本地资源和全局资源。其中,本地资源用于为本地业务节点提供内存存储空间;至少一个业务节点中的全局资源构成内存池,内存池用于为多个业务节点提供内存存储空间。当一定条件满足时,本地资源中的至少一部分空间会被转入内存池;或者内存池中的至少一部分空间会被转入本地资源。其中,在实际应用中,上述内存池的名称可以根据实际需要任意设定,例如上传内存池也可称为内存资源池、全局内存资源池等等,对此本申请不做限制。
本申请上述方法中,一方面,通过构建业务系统中各业务节点均可以使用的内存池,从而均衡各业务节点的负载。另一方面,业务节点中除全局资源外还包括本地资源,各业务节点访问本地资源并不会与其他业务节点发生冲突,因此各业务节点可以通过将数据加载在本地资源中,避免与其他业务节点发生冲突,从而降低内存性能和成本的损耗。又一方面,由于各业务节点可以将数据加载在本地资源中,因此业务节点在访问本地资源时的访问速度也不会受到业务节点之间通信时延的影响。
在一种可能的设计中,该业务系统还包括:内存管理装置。其中,内存管理装置,用于调整至少一个业务节点中各业务节点的本地资源和全局资源的存储空间大小。
上述设计中,内存管理装置可以控制本地资源和全局资源的存储空间大小,从而可以使得在本地资源的需求大时将更多的内存资源分配给本地资源,在全局资源的需求大时将更多 的内存资源分配给全局资源,以达到更加合理的分配内存资源、提升系统性能的效果。
在一种可能的设计中,内存管理装置,用于调整至少一个业务节点中各业务节点的本地资源和全局资源的存储空间大小,具体包括以下至少一项:内存管理装置,用于在至少一个业务节点的全局资源耗尽并且至少一个业务节点的本地资源存在空闲空间时,将至少一个业务节点的本地资源中的空闲空间转入至少一个业务节点的全局资源。或者,内存管理装置,用于在至少一个业务节点的本地资源耗尽并且至少一个业务节点的全局资源存在空闲空间时,将至少一个业务节点的全局资源中的空闲空间转入至少一个业务节点的本地资源。或者,内存管理装置,用于在至少一个业务节点的全局资源和本地资源都耗尽时,回收至少一个业务节点的内存中价值最低的内存资源,将回收的内存资源转入全局资源,或者将回收的内存资源转入本地资源。
上述设计中,通过当全局资源耗尽时将本地资源中的空闲空间转入全局资源,当本地资源耗尽时将全局资源中的空闲空间转入本地资源。从而在本地资源和全局资源之间找到资源分配的平衡点,达到更加合理的分配内存资源、提升系统性能的效果。另外,当全局资源和本地资源都耗尽时,上述设计中还可以通过回收内存中价值最低的内存资源并将回收的内存资源转入全局资源或本地资源,从而提升系统性能的效果。
在一种可能的设计中,上述内存管理装置,还用于在调整至少一个业务节点中各业务节点的本地资源和全局资源的存储空间大小时,保持至少一个业务节点中各业务节点的本地资源的存储空间不小于预设阈值。
上述设计中,考虑到业务节点在运行过程中通常还是需要将数据加载在内存的本地资源中以便本地业务节点对数据进行快速访问,因此通过使本地资源至少保有一部分内存资源,从而保证业务节点对数据进行快速访问。
在一种可能的设计中,内存管理装置还用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源。
其中,第一数据的被访问信息中,可以包括各种用于反映目标数据被各个业务节点访问的次数或频率的信息。
上述设计中,可以根据数据(即上述第一数据)的被访问信息,为第一数据分配合适的内存资源。例如,若根据第一数据的被访问信息,确定第一数据之前只被一个业务节点访问,则将第一数据加载至该业务节点的本地资源中,以便该业务节点在后续处理中可以快速访问该第一数据,并且避免该业务节点访问该第一数据的过程与其他业务节点发生冲突。若根据第一数据的被访问信息,确定第一数据之前被多个业务节点访问,则可以将该第一数据加载至全局资源中,以便多个业务节点在后续处理中都能够访问到该第一数据。
在一种可能的设计中,内存管理装置用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存管理装置用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则确定将第一数据加载至至少一个业务节点的全局资源中;m为大于1的正整数,m个业务节点包含于多个业务节点。
上述设计中,在确定第一数据之前被多个业务节点访问时,通过将该第一数据加载至全局资源中,以便多个业务节点在后续处理中都能够通过全局资源访问到该第一数据。
在一种可能的设计中,内存管理装置用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则确定将第一数据加载至至少一个业务节点的全局资源中,包括; 内存管理装置用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则根据第一数据与m个业务节点中各业务节点的亲和性,确定将第一数据加载至至少一个业务节点的全局资源中。
通过上述设计中,可以将第一数据加载至与第一数据的亲和性更高的业务节点中的全局资源中,从而使得内存池的使用效率更高。
在一种可能的设计中,内存管理装置用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存管理装置用于若根据第一数据的被访问信息,确定第一数据曾被至少一个业务节点访问,则确定将第一数据加载至至少一个业务节点的本地资源中。
上述设计中,当确定第一数据被业务节点访问时,通过将第一数据加载至该业务节点的本地资源中,从而使该业务节点在后续运行中能够快速访问该第一数据。
在一种可能的设计中,内存管理装置用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存管理装置用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,并且m个业务节点中存在n个业务节点与第一数据的亲和性大于亲和性阈值,则确定将第一数据加载至n个业务节点的本地资源中;其中,m为大于1的正整数,n为小于等于m的正整数,m个业务节点包含于上述多个业务节点。
上述设计中,当确定第一数据与n个业务节点的亲和性都比较高时,可以将第一数据分别加载到n个业务节点的本地资源中,从而使这n个业务节点在后续运行中都能够快速访问该第一数据。
在一种可能的设计中,第一数据具有访问参数,访问参数用于指示第一数据在多个业务节点的内存中的数据副本是否可用。上述内存管理装置还用于:获取对第一数据的读请求。确定第一数据对应的访问参数,其中访问参数用于指示第一数据在多个业务节点的内存中的数据副本是否可用。根据访问参数,从多个业务节点的内存或者多个业务节点的内存外的其他存储位置中,获取第一数据。
上述设计中,通过设置一种访问参数,该访问参数能够指示内存中数据的数据副本是否可用。例如,当有业务节点对目标数据写入新的数据内容时,则将该目标数据的访问参数置为“不可用”状态,直至对各个业务节点的内存中记录的目标数据的数据副本进行失效处理后,再将该目标数据的访问参数置为“可用”状态。这样一来,当业务节点访问内存中的目标数据时,便可以先获取该目标数据对应的访问参数,并根据访问参数确定内存中记录的目标数据的数据副本是否可用。若访问参数指示“可用”状态,则读取内存中目标数据的数据副本数据;若访问参数指示“不可用”状态,则可以绕过内存,从硬盘中读取目标数据。
在一种可能的设计中,内存管理装置还用于在第一数据发生改变的情况下,对访问参数进行预设运算,以使得访问参数指示访问参数对应的数据在多个业务节点的内存中的数据副本不可用。例如,预设运算可以为增加或减小预设值。
在一种可能的设计中,内存管理装置还用于在对第一数据的数据副本完成失效处理或重加载后,对访问参数进行预设运算的逆运算。
在上述设计中,在第一数据发生改变时,通过对访问是进行预设预算,从而改变访问参数的值,以使该访问参数的值指示内存中第一数据不可用。并在对内存中第一数据的数据副本完成失效处理或重加载后,通过对访问参数进行逆运算,以使该访问参数恢复到之前的状 态,其中当该访问参数恢复到指示数据副本可用的状态后,在后续访问过程中便可以从内存中获取第一数据的数据副本数据。
在一种可能的设计中,对访问参数进行预设运算,包括:按照比较和交换CAS机制,对访问参数进行预设运算。
在上述设计中,按照CAS机制对访问参数进行预设运算,可以保证每次对访问参数进行预设运算的原子性,例如当有多个业务节点同时对访问参数进行修改时,由于采用了CAS机制,因此各业务节点会按顺序依次对访问参数进行修改,相互之间不会产生干扰。
第二方面,本申请提供一种内存管理方法,该方法应用于业务系统,该业务系统包括多个业务节点;该方法包括:将多个业务节点中至少一个业务节点的内存划分为本地资源和全局资源;其中,本地资源用于为本地业务节点提供内存存储空间;至少一个业务节点中的全局资源构成内存池,内存池用于为多个业务节点提供内存存储空间;当一定条件满足时,本地资源中的至少一部分空间会被转入内存池,或者内存池中的至少一部分空间会被转入本地资源;调整至少一个业务节点中的本地资源和全局资源的存储空间大小。
在一种可能的设计中,调整至少一个业务节点中的本地资源和全局资源的存储空间大小,具体包括以下至少一项:在至少一个业务节点的全局资源耗尽并且至少一个业务节点的本地资源存在空闲空间时,将至少一个业务节点的本地资源中的空闲空间转入至少一个业务节点的全局资源。或者,在至少一个业务节点的本地资源耗尽并且至少一个业务节点的全局资源存在空闲空间时,将至少一个业务节点的全局资源中的空闲空间转入至少一个业务节点的本地资源。或者,在至少一个业务节点的全局资源和本地资源都耗尽时,回收至少一个业务节点的内存中价值最低的内存资源,将回收的内存资源转入全局资源,或者将回收的内存资源转入本地资源。
在一种可能的设计中,该方法还包括:在调整至少一个业务节点中各业务节点的本地资源和全局资源的存储空间大小时,保持至少一个业务节点中各业务节点的本地资源的存储空间不小于预设阈值。
在一种可能的设计中,该方法还包括:根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源。
在一种可能的设计中,根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则确定将第一数据加载至至少一个业务节点的全局资源中;m为大于1的正整数,m个业务节点包含于多个业务节点。
在一种可能的设计中,若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则确定将第一数据加载至至少一个业务节点的全局资源中,包括;若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则根据第一数据与m个业务节点中各业务节点的亲和性,确定将第一数据加载至至少一个业务节点的全局资源中。
在一种可能的设计中,根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:若根据第一数据的被访问信息,确定第一数据曾被至少一个业务节点访问,则确定将第一数据加载至至少一个业务节点的本地资源中。
在一种可能的设计中,根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:若根据第一数据的被访问信息,确定第 一数据曾被m个业务节点访问,并且m个业务节点中存在n个业务节点与第一数据的亲和性大于亲和性阈值,则确定将第一数据加载至n个业务节点的本地资源中;其中,m为大于1的正整数,n为小于等于m的正整数,m个业务节点包含于多个业务节点。
在一种可能的设计中,第一数据具有访问参数,访问参数用于指示第一数据在多个业务节点的内存中的数据副本是否可用。该方法还包括:获取对第一数据的读请求;确定第一数据对应的访问参数;访问参数用于指示第一数据在多个业务节点的内存中的数据副本是否可用;根据访问参数,从多个业务节点的内存或者多个业务节点的内存外的其他存储位置中,获取第一数据。
在一种可能的设计中,该方法还包括:在第一数据发生改变的情况下,对访问参数进行预设运算,以使得访问参数指示访问参数对应的数据在多个业务节点的内存中的数据副本不可用。
在一种可能的设计中,该方法还包括:在对第一数据的数据副本完成失效处理或重加载后,对访问参数进行预设运算的逆运算。
在一种可能的设计中,对访问参数进行预设运算,包括:按照比较和交换CAS机制,对访问参数进行预设运算。
第三方面,提供一种内存管理装置,位于业务系统中,业务系统包括多个业务节点。该内存管理装置包括:资源划分单元,用于将多个业务节点中至少一个业务节点的内存划分为本地资源和全局资源;其中,本地资源用于为本地业务节点提供内存存储空间;至少一个业务节点中的全局资源构成内存池,内存池用于为多个业务节点提供内存存储空间;当一定条件满足时,本地资源中的至少一部分空间会被转入内存池,或者内存池中的至少一部分空间会被转入本地资源;资源调整单元,用于调整至少一个业务节点中的本地资源和全局资源的存储空间大小。
在一种可能的设计中,资源调整单元,具体用于在至少一个业务节点的全局资源耗尽并且至少一个业务节点的本地资源存在空闲空间时,将至少一个业务节点的本地资源中的空闲空间转入至少一个业务节点的全局资源;或者,资源调整单元,具体用于在至少一个业务节点的本地资源耗尽并且至少一个业务节点的全局资源存在空闲空间时,将至少一个业务节点的全局资源中的空闲空间转入至少一个业务节点的本地资源;或者,资源调整单元,具体用于在至少一个业务节点的全局资源和本地资源都耗尽时,回收至少一个业务节点的内存中价值最低的内存资源,将回收的内存资源转入全局资源,或者将回收的内存资源转入本地资源。
在一种可能的设计中,资源调整单元,还用于在调整至少一个业务节点中各业务节点的本地资源和全局资源的存储空间大小时,保持至少一个业务节点中各业务节点的本地资源的存储空间不小于预设阈值。
在一种可能的设计中,内存管理装置还包括:内存分配单元;内存分配单元,用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源。
在一种可能的设计中,内存分配单元,用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存分配单元,用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则确定将第一数据加载至至少一个业务节点的全局资源中;m为大于1的正整数,m个业务节点包含于多个业务节点。
在一种可能的设计中,内存分配单元,用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则确定将第一数据加载至至少一个业务节点的全局资源中,包括;内存分配单元,具体用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则根据第一数据与m个业务节点中各业务节点的亲和性,确定将第一数据加载至至少一个业务节点的全局资源中。
在一种可能的设计中,内存分配单元,用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存分配单元,用于若根据第一数据的被访问信息,确定第一数据曾被至少一个业务节点访问,则确定将第一数据加载至至少一个业务节点的本地资源中。
在一种可能的设计中,内存分配单元,用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存分配单元,具体用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,并且m个业务节点中存在n个业务节点与第一数据的亲和性大于亲和性阈值,则确定将第一数据加载至n个业务节点的本地资源中;其中,m为大于1的正整数,n为小于等于m的正整数,m个业务节点包含于多个业务节点。
在一种可能的设计中,第一数据具有访问参数,访问参数用于指示第一数据在多个业务节点的内存中的数据副本是否可用。内存管理装置,还包括:读写单元;读写单元,用于获取对第一数据的读请求;读写单元,还用于确定第一数据对应的访问参数;访问参数用于指示访问参数对应的数据在多个业务节点的内存中的数据副本是否可用;读写单元,还用于根据访问参数,从多个业务节点的内存或者多个业务节点的内存外的其他存储位置中,获取第一数据。
在一种可能的设计中,读写单元,还用于在第一数据发生改变的情况下,对访问参数进行预设运算,以使得访问参数指示访问参数对应的数据在多个业务节点的内存中的数据副本不可用。
在一种可能的设计中,读写单元,还用于在对第一数据的数据副本完成失效处理或重加载后,对访问参数进行预设运算的逆运算。
在一种可能的设计中,对访问参数进行预设运算,包括:按照比较和交换CAS机制,对访问参数进行预设运算。
第四方面,提供一种内存管理装置,包括:处理器和通信接口,处理器通过通信接口接收或发送数据,处理器用于实现如上述第二方面或第二方面中任一设计的方法中内存管理装置的功能。
第五方面,提供一种计算机可读存储介质,存储介质中存储有计算机程序,当计算机程序被处理器执行时,实现如上述第二方面或第二方面中任一设计的方法中内存管理装置的功能。
第六方面,提供一种计算机程序产品,计算机程序产品包括指令,当指令在处理器上运行时,实现如上述第二方面或第二方面中任一设计的方法中内存管理装置的功能。
上述第二方面至第六方面的有益效果可以参加第一方面和第一方面中各设计的有益效果,在此不再赘述。
附图说明
图1为本申请提供的一种业务系统的结构示意图之一;
图2为本申请提供的一种业务系统的结构示意图之二;
图3A为本申请提供的一种业务系统的结构示意图之三;
图3B为本申请提供的一种业务系统的结构示意图之四;
图4为本申请提供的一种业务系统的结构示意图之五;
图5为本申请提供的一种业务系统的结构示意图之六;
图6为本申请提供的一种内存资源分配方法的流程示意图;
图7为本申请提供的一种内存资源分配的示意图之一;
图8为本申请提供的一种内存资源分配的示意图之二;
图9为本申请提供的一种内存资源分配的示意图之三;
图10为本申请提供的一种数据处理方法的流程示意图之一;
图11为本申请提供的一种数据处理的示意图之一;
图12为本申请提供的一种数据处理的示意图之二;
图13为本申请提供的一种数据处理的示意图之三;
图14为本申请提供的一种数据处理的示意图之四;
图15为本申请提供的一种数据处理方法的流程示意图之二;
图16为本申请提供的一种数据写入方法的流程示意图;
图17为本申请提供的一种失效处理的示意图;
图18为本申请提供的一种计数数组的结构示意图;
图19为本申请提供的一种内存管理装置的结构示意图之一;
图20为本申请提供的一种内存管理装置的结构示意图之二。
具体实施方式
下面结合附图,对本实施例中的技术方案进行描述。
本实施例描述的系统架构以及业务场景是为了更加清楚的说明本实施例的技术方案,并不构成对于本实施例提供的技术方案的限定,本领域普通技术人员可知,随着系统架构的演变和新业务场景的出现,本实施例提供的技术方案对于类似的技术问题,同样适用。
如图1所示,为本实施例提供的一种业务系统的系统架构示意图。该业务系统10中包括一个或多个业务节点(图1中示例性的列出三个业务节点,即业务节点11、业务节点12和业务节点13)。其中,各业务节点具体可以为服务器、台式计算机或存储阵列的控制器等各类具有数据处理、存储功能的硬件设备。
在硬件上,各业务节点包括处理器、内存和硬盘。例如图1中,业务节点11包括处理器111、内存112和硬盘113,业务节点12包括处理器121、内存122和硬盘123,业务节点13包括处理器131、内存132和硬盘133。
以业务节点11为例,其中处理器111可以为一个或多个设备、电路和/或用于处理数据(例如计算机程序指令)的处理核。具体的,处理器111用于执行计算机指令,以处理业务节点11内部生成的数据。具体的,处理器11可以包含中央处理器(Central Processing Unit,CPU),处理器11还可以包含微处理器、现场可编程逻辑门阵列(field programmable gate array,FPGA)、数字信号处理器(digital signal processing,DSP)或者特定应用集成电路(application-specific integrated circuit,ASIC)、或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。作为一种示例,图1中各业务节点中仅示出一个处理器,以便进行示例性介绍。可以理解的是,在具体实施过程中,业务节点中还可以包括多个处理器。 其中每个处理器可以是单核(single-CPU)处理器,也可以是多核(multi-CPU)处理器。
内存112可以理解为与处理器111直接交换数据的存储空间。它可以随时读写数据,并且速度很快,可以作为操作系统或其他正在运行中的程序的临时数据存储器。其中,在内存112中,可以包括一种或多种类型的存储器,例如内存既可以是随机存取存储器,也可以是只读存储器(read only memory,ROM)。举例来说,随机存取存储器可以是动态随机存取存储器(dynamic random access memory,DRAM),也可以是存储级存储器(storage class memory,SCM),也可以是静态随机存取存储器(static random access memory,SRAM)等。其中,DRAM是一种半导体存储器,与大部分随机存取存储器(random access memory,RAM)一样,属于一种易失性存储器(volatile memory)设备。SCM是一种同时结合传统储存装置与存储器特性的复合型储存技术,存储级存储器能够提供比硬盘更快速的读写速度,但存取速度上比DRAM慢,在成本上也比DRAM更为便宜。对于只读存储器,举例来说,可以是可编程只读存储器(programmable read only memory,PROM)、可抹除可编程只读存储器(erasable programmable read only memory,EPROM)等。另外,内存还可以是双列直插式存储器模块或双线存储器模块(dual In-line memory module,简称DIMM),即由动态随机存取存储器(DRAM)组成的模块。
硬盘113为用于持久性存储数据的存储器。与内存112不同的是,硬盘113的读写数据速度比内存112慢。在业务节点11内部可以设置有一个或多个硬盘113,或者在业务节点11的外部还可以挂载一个硬盘框,在硬盘框中设置多个硬盘113。无论哪种部署方式,这些硬盘都可以视为业务节点11所包含的硬盘。其中,硬盘113具体可以包括固态硬盘。机械硬盘或其他类型的硬盘。
可以理解的是,在一些应用场景下,硬盘113也可以具有内存接口,从而使处理器111可以直接对其进行访问,在这种应用场景下,也可以将硬盘113中的部分或全部存储资源作为内存112的一部分。例如,硬盘113可以为具有字节访问接口的持久化存储器。通过字节访问接口,可以使处理器111直接对硬盘113中的存储资源进行访问。则此时,可以将硬盘113中的部分或全部存储资源作为内存112的一部分,以扩展业务节点11的内存存储空间。
其中,在软件层面上,业务系统10中在各业务节点上分别运行有实现相应业务功能的应用程序(简称应用)。例如,图1中业务节点11上运行有应用114,业务节点12上运行有应用124,业务节点13上运行有应用134。具体的,各业务节点上运行的应用,可以为数据库应用。
在一种可能的设计中,在业务系统10中,可以分别利用各业务节点内部的本地硬件资源来实现应用的功能。例如,业务节点11上,利用处理器111、内存112和硬盘113这些硬件来实现应用114的功能。在这种情况下,各业务节点相互独立,各自处理自己的数据,处理后的结果可以用于向上层应用汇总或在业务节点之间流转。上述这种设计中,由于各应用独立运行在单个业务节点的本地硬件资源上,因此可能存在负载不均衡的问题,从而无法高效利用各业务节点的硬件资源。
在另一种可能的设计中,为了避免业务系统10中各业务节点负载不均衡的问题,如图2所示,在业务系统10中,将业务系统10中的数据运算资源(即各业务节点中的处理器)和内存资源(即各业务节点中的内存)解耦合,利用业务系统10中的多个业务节点中的内存资源,构建全局内存资源池。各业务节点可以共享全局内存资源池中的资源。这样一来,可以均衡各业务节点的内存负载。
上述这种设计中,一方面,为了避免不同业务节点在访问全局内存资源池时发生冲突,就需要保证全局内存资源池中的被访问数据不能在同一时间被两个应用访问。为了达到这一目的,通常情况下可以使各业务节点对全局内存资源池中的数据的访问操作保持独立,不要相互干扰。但这种方式会限制全局内存资源池的并行处理能力,从而会带来性能和成本上的损耗。另一方面,由于全局内存资源池是跨越多个业务节点的,那么在业务系统中对于一个业务节点而言,该业务节点将要访问的数据可能存储在它本地的内存中,也可能存储在其他业务节点的内存中。当该数据存储在其他业务节点的内存中时,该业务节点将不得不访问所述其他业务节点,由此,业务节点之间通信时延会对全局内存资源池的性能发挥有较大影响。
为了避免业务节点共享全局内存资源池的情况下,并行处理能力差、业务节点之间通信时延影响内存性能发挥等问题,本实施例中提供一种技术方案。该技术方案中通过将业务节点中的内存资源,划分为两个部分,下文为便于描述,将这两部分分别称为“本地资源”和“全局资源”。本地资源是指一个业务节点中专用于自己使用的内存存储空间。全局资源是指一个业务节点中用于向全局内存资源池提供的,可供自己或其他业务节点共同使用的内存存储空间。
示例性的,如图3A所示,将业务节点11中内存112划分为本地资源1121和全局资源1122两部分。同理,业务节点12中内存122划分为本地资源1221和全局资源1222、业务节点12中内存132划分为本地资源1321和全局资源1322。
需要说明的是,本实施例中在将业务节点的内存资源划分为两部分的过程中,一种实现方式中,可以采用物理划分的方式,例如一个业务节点中由多个存储器(各存储器可以为DRAM、SCM或硬盘等不同类型或相同类型的存储器)构成内存,则可以将其中部分存储器的存储空间作为本地资源,将另一部分存储器的存储空间作为全局资源;另一种实现方式中,可以采用逻辑划分的方式,例如可以将一个业务节点中的内存的存储空间,按照存储空间对应的逻辑地址划分为两部分,其中一部分作为本地资源,将另一部分作为全局资源。对此,本实施例中可以不做限制。
该技术方案中,一方面多个业务节点中的全局资源,可以组成一个全局内存资源池。业务系统中各业务节点可以共享该全局内存资源池中的资源。如图3A中,全局资源1122、全局资源1222和全局资源1322组成全局内存资源池14,其中业务系统10中各业务节点共享全局内存资源池14中的资源。
其中,纳入全局内存资源池14的存储空间需进行统一编制。经过统一编制,全局内存资源池14的每段空间(具体)都有唯一的全局地址。这里的空间可以用“页面(page)”表示全局内存资源池14的最小访问粒度。所谓全局地址,即指示该地址所指示的存储空间在全局内存资源池14中时唯一的地址,并且每个业务节点都可以知道该地址的含义。在给全局内存资源池的一段空间分配了物理空间后,该空间的全局地址就拥有了其对应的物理地址,该物理地址指示了该全局地址所代表的空间实际位于哪个业务节点的哪个存储器上以及在该存储器中的偏移量,即物理空间的位置。有了全局地址,如图3A中,业务节点11在运行过程中,处理器111可以利用全局内存资源池14中各段空间的全局地址,访问全局内存资源池14中存储的数据了。具体的,如果待访问数据具体位于全局资源1222中,处理器111可以利用远程直接数据存取(remote direct memory access,RDMA)或内存互联(compute express link,CXL)等技术,实现对全局资源1222的单边访问。其中,单边访问可以理解为在业务节点12的处理器121不感知的情况下,而通过业务节点12的网卡(图中未示出)实现对全局资 源1222的快速访问。
另一方面,与全局内存资源池14中的内存资源不同的是,各业务节点中的本地资源主要用于支持本地业务节点的访问。
例如图3A中,本地资源1121用于在本地业务节点(即业务节点11)运行过程中,为本地业务节点的处理器(即处理器111)处理数据提供存储空间。本地资源不具有上文描述的全局地址。
其中,在一种示例中,当业务节点11中处理器111需要访问本地资源1121时,可以直接按照常规访问本地内存的方式,直接访问本地资源1121中的数据。
在另一种示例中,由于本地资源1121独立于全局内存资源池14,因此,远程业务节点无法利用全局地址对本地资源1121进行访问。若要让远程节点访问本地资源1121中的数据,则需要采用例如远程过程调用(remote procedure call,RPC)方式,由远程业务节点向业务节点11上的程序发送访问请求,由业务节点11上的程序访问本地资源1121中的数据后再反馈给远程节点,这种方式本质上还是由本地业务节点(即业务节点11)完成对本地资源1121的访问。
换句话讲,本实施例所提供的上述技术方案中,采用将业务节点中的内存资源划分为两部分,其中:
一部分内存资源,即全局资源,用于构建业务系统中各业务节点均可以使用的全局内存资源池,使得全局资源可以由业务系统中远端业务节点直接访问。例如,可以通过RDMA、CXL等技术,使远端业务节点在本地业务节点的处理器不感知的情况下实现对本地业务节点上的全局资源的直接访问。
另一部分内存资源,即本地资源,不作为全局内存资源池的一部分,用于支持本地业务节点的数据处理(如为本地业务节点的处理器提供缓存)。当远程节点需要访问本地资源时,需要先调用本地业务节点上的程序访问本地资源,再将访问结果反馈给远程节点。
这样一来,一方面,上述技术方案中,通过构建业务系统中各业务节点均可以使用的全局内存资源池,从而均衡各业务节点的负载。另一方面,各业务节点中除全局资源外还包括本地资源,各业务节点访问本地资源并不会与其他业务节点发生冲突,因此各业务节点可以通过将数据加载在本地资源中,来避免与其他业务节点发生冲突,从而降低内存性能和成本的损耗。又一方面,由于各业务节点可以将数据加载在本地资源中,因此业务节点在访问本地资源时的访问速度也不会受到业务节点之间通信时延的影响。
需要说明的是,上述图3A仅示例性的提供了一种能够应用本实施例所提供技术方案的系统架构。在实际应该过程中,本实施例所提供的技术方案也可以应用在其他的系统架构中。
示例性的,在一些应用场景中,如图3B所示,业务系统10还包括存储系统15。与图3A中将持久化存储数据存储在各业务节点的硬盘(即图3A中硬盘113、硬盘123和硬盘133)中不同,在图3B所示业务系统10中,可以利用存储系统15来持久化存储各业务节点运行应用所需的各种数据。具体的,存储系统15可以通过各类传输网络与各业务节点进行连接,以实现各业务节点与存储系统15的数据交换。
其中,在实际应用过程中,存储系统15可以为集中式存储系统,即该存储系统15可以是由一台或多台存储设备组成的一种中心节点,数据集中存储于该中心节点中。另外,存储系统15还可以为由多个独立的存储节点构成的分布式存储系统。对于存储系统15的架构,本实施例可以不做限制。
再示例性的,如图4所示,为本实施例提供的另一种系统架构的结构示意图。其中,业务系统20中,包括一个或多个前端节点(如图4中前端节点25和前端节点26)以及一个或多个业务节点(如图4中业务节点21和业务节点22)。
其中各前端节点分别包括处理器、存储器等硬件组件(图中未示出)。各前端节点上分别运行有实现业务功能的应用(如图4中应用241和应用251),以及用于支持应用与各业务节点进行数据交互的客户端(如图4中客户端242和客户端252)。
业务节点21和业务节点22中,分别包括为前端节点提供内存存储空间的内存212和内存222,以及用于持久化存储数据的硬盘213和硬盘223。
其中,与图3A中内存112、内存122和内存132类似,内存212和内存222可以被划分为本地资源(如图4中本地资源2121和本地资源2221)和全局资源(如图4中全局资源2122和全局资源2222)。其中,本地资源用于专门为一个前端节点提供内存存储空间,全局资源用于构建全局内存资源池23以向多个前端节点共享内存存储空间。
以业务节点21为例,本地资源2121用于专门为前端节点24提供内存存储空间,全局资源2122可以被前端节点24、前端节点25共同作为内存存储空间。
其中,对于将内存212和内存222划分为本地资源和全局资源的相关描述,可参照上文对图3A中各业务节点中相应组件以及组件功能的描述,在此不再赘述。
下文中主要以图3A所示系统架构,对本实施例所提供技术方案的具体实施过程进行介绍。具体的,下面分别从两个方面来对本实施例所提供技术方案的具体实施过程进行介绍:
第一方面,针对在业务节点中如何分配本地资源和全局资源在内存资源中的份额,本实施例提供一种内存资源分配方法。该内存资源分配方法中通过动态调节本地资源和全局资源在内存资源中的份额,使得在本地资源的需求大时将更多的内存资源分配给本地资源,在全局资源的需求大时将更多的内存资源分配给全局资源,从而达到更加合理的分配内存资源、提升系统性能的效果。
第二方面,在将数据加载至业务节点的内存资源的过程中,针对采用哪种内存资源(本地资源或全局资源)来加载数据,本实施例提供一种数据处理方法。该数据处理方法中,能够在将业务节点的内存资源分为本地资源和全局资源的情况下,确定出合适的内存资源用于加载数据。
下面对将业务节点中的内存资源划分为本地资源和全局资源的场景下分配内存资源的方法(即上述第一方面所提供的内存资源分配方法)的具体实现过程进行介绍。
在一种实现方式中,如图5所示,业务系统10中各业务节点(图中示出两个业务节点:业务节点11、业务节点12)中分别包括能够管理业务节点中内存资源的内存管理装置(即图中内存管理装置115和内存管理装置125)。以内存管理装置115为例,内存管理装置115能够按照本实施例所提供的方法实现:将内存112划分为本地资源1121和全局资源1122、调整本地资源1121和全局资源1122占内存112的份额,以及将数据加载至内存112等功能。
其中,在实际应用过程中,各个业务节点所包括的内存管理装置的功能可以由硬件方式来实现,也可以由软件程序的方式来实现。
具体的,以业务节点11为例,内存管理装置为存储在内存112中的程序代码,由处理器111运行该程序代码以将内存112划分为本地资源1121和全局资源1122,以及调整本地资源1121和全局资源1122的份额。
另外,内存管理装置也可以是一个硬件加速卡,例如神经网络处理单元(Neural networks  process units,NPU)、张量处理器(tensor processing unit,TPU)、现场可编程逻辑门阵列(Field Programmable Gate Array,FPGA)或者特定应用集成电路(application-specific integrated circuit,ASIC)等。此时,内存管理装置位于业务节点11内部,也可以通过总线访问内存112。关于硬件加速卡的结构,图1中没有示出,将在后续的实施方式中予以说明。
此外,业务系统10中还包括可以与各业务节点进行通信的管理节点(图中未示出),其中该管理节点可以对各业务节点进行管理。例如,各个业务节点将全局资源的容量、地址等信息上报给管理节点,由管理节点对上报的全局资源进行统一编址再通知各个业务节点。管理节点可以由业务系统10中的任意业务节点担任,也可以是独立于多个业务节点之外的服务器。
可以理解的是,本实施例所示业务系统10中,只要具有能够按照本实施例所提供的方法实现:将内存112划分为本地资源1121和全局资源1122、调整本地资源1121和全局资源1122占内存112的份额,以及将数据加载至内存112等功能的硬件或软件装置(如上文示例的内存管理装置、管理节点)即可。对于该硬件或软件装置在业务系统10中部署的位置,本实施例可以不做限制。
下面以业务节点11为例,对本实施例所提供的分配内存资源的方法进行介绍,如图6所示,该方法可以包括:
S301、内存管理装置115根据初始份额,将内存112划分为本地资源1121和全局资源1122。
例如,在业务节点11中,可以预先设置一个初始份额(例如初始份额为本地资源1121和全局资源1122各占50%)并将该初始份额记录在业务节点11的配置信息中。在业务节点11上线运行时,内存管理装置115通过加载该配置信息,将内存112中的50%内存资源作为全局资源,与其他业务节点中的全局资源进行统一编制,以建立全局内存资源池14。另外50%内存资源则不进行统一编制,而是作为仅供本地业务节点使用的本地资源1121。
示例性的,如图5中,业务节点11的内存112中共有16个页面(即页1-页16)。其中内存管理装置115按照初始份额,将页1-页8被作为本地资源1121,页9-页16作为全局资源1122。
可以理解的是,在实际应用过程中,一种示例中,上述初始份额可以是由技术人员预先设定好的固定数值;另一种示例中,上述初始份额也可以是根据业务节点11中当前的运行环境(例如业务节点11所运行的应用的种类或属性,以及业务节点11的硬件类型的信息)确定出的数值。对于初始份额的确定方式,本实施例可以不做限制。
另外,在一些场景中,也可以不设置初始份额,例如在业务节点11上线运行时可以将内存112的所有内存资源全部作为本地资源1121,或者全部作为全局资源1122,或者随机按照某个份额划分本地资源1121和全局资源1122。之后,在业务节点11运行过程中,再通过动态调节本地资源1121和全局资源1122在内存资源中的份额(即下文S302),从而达到更加合理的内存资源份额占比。可以理解的,在这种场景下,也可以不执行S301的内容。
S302、在业务节点11运行过程中,内存管理装置115根据本地资源1121和全局资源1122的需求量,调整本地资源1121和全局资源1122在内存资源中的份额。
具体的,在一种实现方式中,在需要加载数据页面到全局资源1122的场景下,S302具体可以包括:
S3021、若全局资源1122耗尽,并且本地资源1121中存在空闲空间,则内存管理装置 115将本地资源1121中的空闲空间转入全局资源1122。
具体的,通过将本地资源1121中的空闲空间转入全局资源1122,从而扩大全局资源1122的空间,以便将上述数据页面加载到全局资源1122中。
示例性的,如图7中(a)所示,业务节点11的内存112中,本地资源1121包括页1-页8,全局资源1122包括页9-页16。其中,本地资源1121中页3-页8为空闲空间,全局资源1122已经耗尽,即页9-页16均被占用。此时,若要加载数据页面到全局资源1122中,则如图7中(b)所示,将本地资源1121中的空闲空间页8转入全局资源1122中,并将待加载的数据页面加载到页8中。
本实施例中所称将一个业务节点上本地资源的存储空间转入全局资源,具体可以表现为改变该存储空间的访问方式,以使该存储空间从原本按照本地资源的访问方式改变为按照全局资源的访问方式。
例如,对于一个业务节点而言,本地资源和全局资源分别按照不同的编址方式分配地址。其中本地资源分配有本地地址以便本地业务节点按照本地地址访问本地资源;全局资源分配有全局内存资源池中的唯一地址(也称全局地址),用于各业务节点根据该全局地址访问全局资源。那么,将一个业务节点上本地资源的存储空间转入全局资源,具体可以通过为该存储空间分配全局内存资源池中的唯一地址(即全局地址),以及删除、失效该存储空间的本地地址的方式来实现。
以图7中(a)为例,可以通过为页8分配全局内存资源池中的全局地址,来将本地资源1121中的空闲空间页8转入全局资源1122。进而,各业务节点可以根据该全局地址,通过RDMA等技术访问页8。
另外,需要说明的是,本实施例中所称资源耗尽(例如S3021中全局资源1122耗尽),可以理解为资源没有空闲空间,或者资源中的空闲空间小于阈值空间大小。下文中类似之处,可做同样理解,重复之处不再赘述。
在另一种实现方式中,在需要加载数据页面到全局资源1122的场景下,S302还可以包括:
S3022、若全局资源1122和本地资源1121都耗尽,则内存管理装置115回收内存112(即本地资源1121和全局资源1122)中价值最低的页面的内存资源并转入全局资源1122。
其中,若回收的内存资源原本就属于全局资源1122,则可以不用再次将该内存资源转入全局资源1122。
上述实现方式中,通过回收内存112中价值最低的页面的内存资源,并将回收的内存资源转入全局资源1122中,从而扩大全局资源1122的空闲空间,以便将上述数据页面加载到全局资源1122中。
示例性的,如图8中(a)所示,本地资源1121和全局资源1122均被占用,其中页7中加载的数据为内存112中价值最低的页面。此时若要加载数据页面到全局资源1122中,如图8中(b)所示,则业务节点11回收页7的内存资源,并将页7转入全局资源1122中,并将待加载的数据页面加载到页7中。
需要说明的是,本实施例中,价值最低的页面,具体可以是内存112中访问次数最少的页面、距离上次访问间隔时间最长的页面等等,本实施例中对于页面价值高低的评价标准可以不做限制。
再示例性的,如图9中(a)所示,本地资源1121和全局资源1122均被占用,其中页15 中加载的数据为内存112中价值最低的页面。此时若要加载数据页面到全局资源1122中,如图9中(b)所示,则业务节点11回收页15的内存资源(由于页15原本就是全局资源1122中的资源,因此这种情况下不用将页15转换为全局资源),并将待加载的数据页面加载到页15中。
在上述S3021和S3022的实现方式中,在一种可能的设计中,在不断有数据加载至全局资源1122的情况下,如果没有数据加载至本地资源1121,则可以将本地资源1121的全部内存资源转入全局资源1122中,以便充分利用内存资源。另一种设计中,可以为本地资源1121设置最小资源门限,以使得本地资源1121至少保有一部分内存资源(即最小资源门限所指示的内存资源大小)。其中,最小资源门限的具体数值可以根据实际需要配置,本实施例中可以不做限制。
在又一种实现方式中,在需要加载数据页面到本地资源1121的场景下,S302具体可以包括:
S3023、若本地资源1121耗尽,而全局资源1122中存在空闲空间,则内存管理装置115可以将全局资源1122中的空闲空间转入本地资源1121。
本实施例中所称将一个业务节点上全局资源的存储空间转入本地资源,具体可以表现为改变该存储空间的访问方式,以使该存储空间从原本按照全局资源的访问方式,改变为按照本地资源的访问方式。
例如,将一个业务节点上全局资源的存储空间转入本地资源,具体可以通过为该存储空间分配本地地址,以及删除或失效该存储空间的全局地址的方式来实现。在为该存储空间分配本地地址以及删除或失效该存储空间的全局地址后,各业务节点无法利用全局地址访问该存储空间,从而使该存储空间专门用于为本地业务节点提供内存存储空间。下文中类似之处,可以做相同理解,下文对此不再赘述。
其中,S3023的具体实现过程可参照上文S3021,在此不再赘述。
或者,S302还可以包括:
S3024、若此时本地资源1121和全局资源1122都耗尽,则内存管理装置115可以回收内存112(即本地资源1121和全局资源1122)中价值最低的页面的资源并转入本地资源1121。
其中,S3024的具体实现过程可参照上文S3022,在此不再赘述。
可以理解的是,与上文S3023和S3024类似,在一种可能的设计中,在不断有数据加载至本地资源1121的情况下,可以将全局资源1122的全部内存资源转入本地资源1121中;在另一种可能的设计中,可以为全局资源1122设置最小资源门限,以使得全局资源1122至少保有一部分内存资源。
本实施例上述内存资源分配方法中,通过动态调节本地资源和全局资源在内存资源中的份额,使得在本地资源的需求大时将更多的内存资源分配给本地资源,在全局资源的需求大时将更多的内存资源分配给全局资源,从而达到更加合理的分配内存资源、提升系统性能的效果。
下面以业务系统10为例,对将业务节点中的内存资源划分为本地资源和全局资源的场景下,将数据加载至业务节点的内存中的过程(即上述第二方面所提供的数据处理方法)进行介绍。具体的,如图10所示,该方法包括:
S401、业务节点11获取数据处理指令。
其中,该数据处理指令,可以为指示业务节点11对硬盘(可以为业务系统10中硬盘113、 硬盘123或硬盘133)中目标数据进行处理的指令。
例如,该数据处理指令,可以是指示处理器111运行硬盘中存储的程序代码的指令,该程序代码即为上文目标数据;再例如,该数据处理指令,还可以是指示处理器111对硬盘中存储的图像、文字等数据进行处理的指令,该图像、文字即为上文目标数据。
S402、业务节点11将目标数据从硬盘加载至内存资源中。
具体的,在业务节点11首次加载目标数据至内存资源时,可以通过内存管理装置115先将目标数据临时加载至本地资源1121或全局内存资源池14中,以便处理器111对目标数据进行处理。之后,再按照下文S404的步骤,根据目标数据的被访问信息(包括访问目标数据的节点有哪些、各节点访问目标数据的频次等信息),将目标数据迁移至合适的内存资源中。
在一种实现方式中,本实施例中考虑到:一方面,被业务节点11加载到内存资源中的数据,至少会被业务节点11访问。另一方面,在将该数据加载到内存资源中后,其他业务节点可能会访问该数据,也可能不会访问该数据。因此,在首次加载数据至内存资源时,可以先将该数据加载至本地资源中,以便于本地业务节点(即业务节点11)快速访问该目标数据。因此,S402具体可以包括:
S4021、业务节点11将目标数据从硬盘加载至本地资源1121中。
需要说明的是,在实际应用过程中,业务节点11也可以将目标数据加载至全局内存资源池14中。例如业务节点11可以将目标数据加载至全局资源1122中,或者业务节点11可以将目标数据加载至其他业务节点的全局资源(例如全局资源1222)中。当业务节点11将目标数据加载至全局内存资源池14的情况下,则可以不执行上述S4021的步骤。对此,本实施例可以不做限制。
在一种可能的设计中,在将上述目标数据加载至本地资源1121的过程中,若本地资源1121用尽,但全局资源1122中有空闲空间,则可采用上述S3023的步骤,将全局资源1122中的空闲空间转入本地资源1121中,以便将上述目标数据加载至本地资源1121中。
在另一种可能的设计中,在将上述目标数据加载至本地资源1121的过程中,若本地资源1121和全局资源1122均用尽,则可以采用上述S3024的步骤,回收内存112(即本地资源1121和全局资源1122)中价值最低的页面的资源,以便将上述目标数据加载至回收的内存资源中。
上述两种设计的具体实现过程,可参照上文S3023和S3024的相关描述,在此不再赘述。
S403、业务节点11检测目标数据的被访问信息。
其中,目标数据的被访问信息,可以包括各种用于反映目标数据被各个业务节点访问的次数或频率的信息。例如,目标数据的被访问信息,具体可以包括在一段时间内目标数据被各个业务节点访问的次数,目标数据相邻两次被访问的间隔时长等信息。
具体的,在通过S4021将目标数据加载至本地资源1121后,业务系统10中各业务节点可以通过访问本地资源1121来访问目标数据。例如,业务节点11中处理器111可以通过常规访问方式访问本地资源1121中的目标数据;远端业务节点(即业务节点12、业务节点13等)可以通过RPC方式访问本地资源1121来访问目标数据。进而,业务节点11可以通过记录一段时间内各业务节点访问目标数据的情况,从而检测到目标数据的被访问信息。
S404、业务节点11根据目标数据的被访问信息,重新为目标数据分配内存资源。
具体的,S404可以包括以下S4041-S4042:
S4041、若根据目标数据的被访问信息,确定目标数据只被业务节点11访问,则将目标数据加载到业务节点11的本地资源1121中。
其中,若在首次加载目标数据时就已经将目标数据加载在了本地资源1121中(即S4021),则可以不用再次加载目标数据,即不执行S4041中将目标数据加载到业务节点11的本地资源1121的步骤。
S4042、若根据目标数据的被访问信息,确定目标数据被多个业务节点访问,则将目标数据加载到全局内存资源池14中。
在一种可能的设计中,本实施例中可以根据目标数据与各业务节点的亲和性,将目标数据加载至全局内存资源池14中的内存资源中。例如,可以将目标数据优先加载至亲和性最高的业务节点的全局资源中,从而可以提高目标数据的访问效率。
其中,本实施例中数据与业务节点的亲和性,也可以理解为该数据对于该业务节点的价值大小,其中该数据对于该业务节点的价值越大则亲和性越高,反之价值越小则亲和性越小。例如,数据与业务节点的亲和性可以反映为该业务节点访问该数据的次数、频率等信息,其中,该业务节点访问该数据的次数越多、频率越高,则亲和性越高;反之则次数越少、频率越低,则亲和性越低。
具体的,在根据目标数据与业务节点的亲和性,为目标数据分配内存资源的过程中,首先,为了提高目标数据的访问效率,本实施例中可以优先将目标数据加载至亲和性较高的业务节点的全局资源中;进一步的,当亲和性较高的业务节点的内存资源耗尽时,则可以采用回收亲和性较高的业务节点的内存资源中价值较低的内存资源,再利用该回收的内存资源加载目标数据;或者,也可以将目标数据加载至亲和性较次一些的业务节点的全局资源中。下面对上述为目标数据分配内存资源的具体实现过程进行详细介绍,该实现过程具体可以包括:
S4042a、根据目标数据的被访问信息,确定目标数据与各业务节点的亲和性。
在确定目标数据与各业务节点的亲和性后,可以按照亲和性从高到低的顺序,对各业务节点分别执行以下步骤S4042b-S4042e中的部分或全部步骤,直至将目标数据加载到全局内存资源池14中:
S4042b、确定当前业务节点是否为业务节点11(即首次加载目标数据的业务节点)。
其中,一方面,若当前业务节点是业务节点11(即首次加载目标数据的业务节点),则执行下文S4042c;另一方面,若当前业务节点不是业务节点11,则执行下文S4042d。
S4042c、将业务节点11中加载目标数据的页面迁移至业务节点11的全局资源1122中。
例如,可以通过修改加载目标数据的页面的地址,将该页面的地址由本地资源1121中的地址修改为全局内存资源池14中的地址,从而实现将该页面迁移至全局资源1122中。这一过程中,可以不需要对加载目标数据的页面进行资源回收,也不需要对目标数据进行拷贝,即可达到将目标数据加载至业务节点11的全局资源1122中的效果。
S4042d、确定当前业务节点是否符合预设条件。
若确定当前业务节点符合预设条件,则将目标数据加载至当前业务节点的全局资源中(即图中S4042e)。若当前业务节点不符合预设条件,则按照亲和性从高到低的顺序,遍历下一个业务节点。
其中,预设条件具体可以包括以下任一项:
1)当前业务节点的全局资源中存在空闲空间。
2)当前业务节点的全局资源没有空闲空间,但本地资源中存储空闲空间。
3)当前业务节点的内存资源(即全局资源和本地资源)中均没有空闲空间,但该业务节点的内存资源中加载了价值低于目标数据的其他数据。
示例性的,下面以与目标数据亲和性最高的业务节点为例,对S4042d和S4042e的具体实现过程进行介绍:
例如图11所示,在图11的(a)中,业务节点11先按照S402将目标数据加载在本地资源1121中的页1中。其中,若根据目标数据的被访问信息确定目标数据被多个业务节点访问,并且根据目标数据与各业务节点的亲和性,确定业务节点12为与目标数据亲和性最高的业务节点。另外,业务节点12的全局资源1222中存在空闲空间(图中页32),即业务节点12满足上述1)具有加载目标数据的能力。
则如图11中(b)所示,将目标数据加载至页32中。例如,业务节点12中内存管理装置125通过数据页面加载流程将目标数据从硬盘加载至全局资源1222的页32中,从而实现将目标数据加载至页32中。另外,业务节点11中内存管理装置115可以通过执行数据页面淘汰流程回收页1。
再例如图12所示,在图12的(a)中,业务节点11先按照S402将目标数据加载在本地资源1121中的页1中。其中,若根据目标数据的被访问信息确定目标数据被多个业务节点访问,并且根据目标数据与各业务节点的亲和性,确定业务节点12为与目标数据亲和性最高的业务节点。另外,业务节点12的全局资源1222中没有空闲空间,但本地资源1221中有空闲空间(图中页23和页24),即业务节点12满足上述2)具有加载目标数据的能力。则如图12中(b)所示,可以将页24转入全局资源1222中,并将目标数加载至页24中。
又例如图13所示,在图13的(a)中,业务节点11先按照S402将目标数据加载在本地资源1121中的页1中。其中,若根据目标数据的被访问信息确定目标数据被多个业务节点访问,并且根据目标数据与各业务节点的亲和性,确定业务节点12为与目标数据亲和性最高的业务节点。另外,业务节点12的本地资源1221和全局资源1222中均没有空闲空间。但全局资源1222的页31中加载了价值低于目标数据的数据。则如图13中(b)所示,可以在回收页31的内存资源后,并将目标数据加载至页31中。其中,对于各页面价值的评价标准,可参照上文S3022的相关描述,重复内容在此不再赘述。
又例如图14所示,在图14的(a)中,业务节点11先按照S402将目标数据加载在本地资源1121中的页1中。其中,若根据目标数据的被访问信息确定目标数据被多个业务节点访问,并且根据目标数据与各业务节点的亲和性,确定业务节点12为与目标数据亲和性最高的业务节点。另外,业务节点12的本地资源1221和全局资源1222中均没有空闲空间。但全局资源1221的页21中加载了价值低于目标数据的数据。则如图14中(b)所示,可以在回收页21的内存资源并将页21转入全局资源1222后,并将目标数据加载至页21中。
在一种可能的设计中,如图15所示,在确定目标数据与各业务节点的亲和性(即S4042a)之后,该方法还可以包括:
S4042f、确定与目标数据的亲和性大于亲和性阈值的n个业务节点。
S4042g、将目标数据加载至n个业务节点的本地资源中。
其中,n个业务节点为与目标数据的亲和性大于亲和性阈值的n个业务节点,n为正整数。
上述设计中,当存在与目标数据的亲和性高于亲和性阈值的n个业务节点时,可以通过在这n个业务节点的本地资源中分别加载该目标数据,以便于这n个业务节点访问目标数据,提高这n个业务节点的运行效率。
需要说明的是,上述图11和图15所描述流程图中,主要是以将目标数据首次从硬盘加载至业务节点的内存资源后,根据目标数据的被访问信息重新为目标数据分配内存资源的这 一场景,对本实施例所提供的方法进行介绍。可以理解的是,在实际应用中,各业务节点还可以周期性检测本节点的内存资源中各数据页面的被访问信息,并根据各数据页面的被访问信息,按照上文S404所描述的方式,重新为各数据页面分配内存资源。
另外,在一种实现方式中,考虑到:在业务系统10中,各业务节点均可以对本地或远端各节点的内存进行访问。因此,当一个业务节点通过写流程更新数据时,如果没有对内存中该数据的数据副本进行失效处理的话,则本地业务节点或远端业务节点再次访问该数据时,可能出现从内存中读取到已经失效的数据的情况。因此,为了避免上述情况发生,本实施例还提供一种数据写入方法,如图16所示,该方法包括:
S501、业务节点11获取写请求。
其中,该写请求用于更新某个数据(下文称为目标数据)。
具体的,该写请求中携带有目标数据的逻辑地址以及目标数据的更新数据。其中,逻辑地址可以为上层应用所使用的目标数据的地址标识,例如,逻辑地址可以包括目标数据对应的逻辑单元号(logical unit number,LUN)、逻辑块地址(logical block address,LBA)和数据长度。
S502、业务节点11根据写请求,将更新数据写入硬盘(具体可以是硬盘113、硬盘123或硬盘133)。
S503、业务节点11对各个业务节点的内存中记录的目标数据的数据副本进行失效处理。
其中,失效处理具体可以包括删除内存中的数据副本或者修改内存中的数据副本的位图等。
例如,对于本地业务节点的内存资源(可以为本地资源或全局资源)中记录的目标数据的数据副本,业务节点11可以通过常规方式进行失效处理或重加载处理,以释放内存中已经失效的数据副本;对于远端业务节点的内存资源中记录的目标数据的数据副本,一方面业务节点11可以通过RDMA、CXL等单边访问方式触发远端业务节点的网卡对全局资源(例如业务节点12的全局资源1222)中记录的目标数据的副本数据进行失效处理或重加载处理,另一方面,业务节点11可以通过RPC等方式向远端业务节点发送消息,以触发远端业务节点对本地资源(例如业务节点12的本地资源1221)中记录的目标数据的数据副本进行失效处理或重加载处理。
示例性的,如图17所示,其中页3、页17和页25中加载了数据C的数据副本。则在数据C被更新后,业务节点11中内存管理装置115可以通过常规方式对页3进行失效处理、通过RDMA、CXL等单边访问方式触发业务节点12的网卡对页25进行缓存失效,以及通过RPC方式向业务节点12发送消息以触发业务节点12对页17进行缓存失效。
另外,在一种实现方式中,考虑到:在业务系统10中,当目标数据被更新时,就需要对内存中该数据的数据副本(具体可以是加载在业务系统10的全局内存资源池14中,或者加载在业务系统10中各业务节点的本地资源的数据副本)进行失效处理。但在实际应用过程中,对内存中的数据副本进行失效处理需要花费一定的时间,因此本实施例中可以设置一种访问参数,该访问参数能够指示内存中数据的数据副本是否可用。例如,当有业务节点更新目标数据时,则将该目标数据的访问参数置为“不可用”状态,直至对各个业务节点的内存中记录的目标数据的数据副本进行失效处理后,再将该目标数据的访问参数置为“可用”状态。
这样一来,当业务节点访问内存中的目标数据时,便可以先获取该目标数据对应的访问参数,并根据访问参数确定内存中记录的目标数据的数据副本是否可用。若访问参数指示“可 用”状态,则读取内存中目标数据的数据副本;若访问参数指示“不可用”状态,则可以绕过内存,从硬盘中读取目标数据。
在一种可能的设计中,可以构建一种计数数组,其中计数数组中各项分别表示对应的数据的访问参数。当需要查找某个数据(例如目标数据)的访问参数时,如图18所示,可以通过该目标数据的标识计算一个哈希值,再通过该哈希值定位到计数数组中对应的项,即可确定目标数据的访问参数。
其中,计数数组中各项,在该项所对应的数据被更新时,可以通过比较与交换(remote direct memory access compare and swap,RDMA CAS)机制,对计数数组中该项进行计数自增运算;在对各业务节点的内存中的数据副本完成失效处理或重加载时,再通过CAS机制,对计数数组中该项进行计数自减运算。
例如,计数数组中各项的初始值为零,当计数数组中一项所对应的数据写入新的数据内容时,通过CAS机制对计数数组中该项加1;在对该数据的数据副本完成失效处理或重加载后,再通过CAS机制对计数数组中该项减1。也就是说,若计数数组中数据所对应的项不为0,则表示该项对应的数据在各业务节点的内存中的缓存存在失效的可能;若计数数组中数据所对应的项为0,则表示该项对应的数据在各业务节点的内存中的缓存可用。
可以理解的是,在实际应用中,在一种实现方式中,上述计数数组可以存储在业务系统10中的各个业务节点中,以便各业务节点在访问内存中的数据时,可以根据本地存储的计数数组,确定内存中被访问数据的缓存是否可用。在另一种实现方式中,上述计数数组可以存储在业务系统10中的管理节点中,在各业务节点在访问内存中的数据时,业务节点可先访问管理节点以确定计数数组中被访问数据对应的访问参数,进而根据访问参数确定内存中被访问数据的缓存是否可用。对于计数数组的存储位置,本实施例可以不做限定。
另外,本实施例还提供一种内存管理装置,该内存管理装置可以应用在业务系统中,以使上述业务系统实现上述实施例中的部分或全部效果。具体的,该装置可以用于执行上述业务系统的运行流程中的部分或全部步骤。例如,该内存管理装置可以用于执行图6、图10、图15以及图16中划分本地资源和全局资源、调整本地资源和全局资源的空间大小以及将数据加载至内存中的部分或全部步骤,以实现相应的技术效果。
可以理解的是,内存管理装置包括了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本实施例中描述的各示例的单元及方法步骤,本实施例所提供技术方案能够以硬件或硬件和计算机软件相结合的形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用场景和设计约束条件。
在本实施例中,该数据访问装置可以位于业务系统中的一个业务节点上;或者,该数据访问装置可以采用分布式结构,从而可以由多个业务节点的硬件结构和/或软件模块共同实现数据访问装置的功能;再或者,该数据访问装置的功能也可以由独立于业务系统中各业务节点的硬件结构和/或软件模块来实现。
图19为本申请提供的一种该内存管理装置的结构示意图。其中,该内存管理装置60包括:
资源划分单元601,用于将业务节点中多个业务节点中至少一个业务节点的内存划分为本地资源和全局资源。其中,对于本地资源和全局资源的相关内容,可参照上文对业务系统10中各运行过程的描述,在此不再赘述。
资源调整单元602,用于调整至少一个业务节点中的本地资源和全局资源的存储空间大 小。
在一种可能的设计中,资源调整单元602,用于调整至少一个业务节点中的本地资源和全局资源的存储空间大小,具体包括以下至少一项:
在至少一个业务节点的全局资源耗尽并且至少一个业务节点的本地资源存在空闲空间时,将至少一个业务节点的本地资源中的空闲空间转入至少一个业务节点的全局资源;
或者,在至少一个业务节点的本地资源耗尽并且至少一个业务节点的全局资源存在空闲空间时,将至少一个业务节点的全局资源中的空闲空间转入至少一个业务节点的本地资源;
或者,在至少一个业务节点的全局资源和本地资源都耗尽时,回收至少一个业务节点的内存中价值最低的内存资源,将回收的内存资源转入全局资源,或者将回收的内存资源转入本地资源。
在一种可能的设计中,资源调整单元602,还用于在调整至少一个业务节点中各业务节点的本地资源和全局资源的存储空间大小时,保持至少一个业务节点中各业务节点的本地资源的存储空间不小于预设阈值。
在一种可能的设计中,内存管理装置60还包括:内存分配单元603。
内存分配单元603,用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源。
在一种可能的设计中,内存分配单元603,用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存分配单元603,用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则确定将第一数据加载至至少一个业务节点的全局资源中;m为大于1的正整数,m个业务节点包含于多个业务节点。
在一种可能的设计中,内存分配单元603,用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则确定将第一数据加载至至少一个业务节点的全局资源中,包括;内存分配单元603,具体用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,则根据第一数据与m个业务节点中各业务节点的亲和性,确定将第一数据加载至至少一个业务节点的全局资源中。
在一种可能的设计中,内存分配单元603,用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存分配单元603,用于若根据第一数据的被访问信息,确定第一数据曾被至少一个业务节点访问,则确定将第一数据加载至至少一个业务节点的本地资源中。
在一种可能的设计中,内存分配单元603,用于根据第一数据的被访问信息,从至少一个业务节点的本地资源或全局资源中,确定加载第一数据的内存资源,包括:内存分配单元603,具体用于若根据第一数据的被访问信息,确定第一数据曾被m个业务节点访问,并且m个业务节点中存在n个业务节点与第一数据的亲和性大于亲和性阈值,则确定将第一数据加载至n个业务节点的本地资源中;其中,m为大于1的正整数,n为小于等于m的正整数,m个业务节点包含于多个业务节点。
在一种可能的设计中,第一数据具有访问参数,访问参数用于指示第一数据在多个业务节点的内存中的数据副本是否可用。内存管理装置60,还包括:读写单元604;读写单元604,用于获取对第一数据的读请求;读写单元604,还用于确定第一数据对应的访问参数;访问参数用于指示访问参数对应的数据在多个业务节点的内存中的缓存是否可用;读写单元604, 还用于根据访问参数,从多个业务节点的内存或者多个业务节点的内存外的其他存储位置中,获取第一数据。
在一种可能的设计中,读写单元604,还用于在第一数据发生改变的情况下,对访问参数进行预设运算,以使得访问参数指示访问参数对应的数据在多个业务节点的内存中的缓存不可用。
在一种可能的设计中,读写单元604,还用于在对第一数据的缓存完成缓存失效或重加载后,对访问参数进行预设运算的逆运算。
在一种可能的设计中,对访问参数进行预设运算,包括:按照比较和交换CAS机制,对访问参数进行预设运算。
图20为本申请提供的另一种内存管理装置的结构示意图。该内存管理装置70位于图1所述的业务节点中,用于实现本申请所提供的方法。具体的,内存管理装置70可以为芯片或片上系统。其中,其中,该内存管理装置70可以包括:处理单元701、以及至少一个通信接口702。
其中,处理单元701用于执行本实施例所提供的方法。
具体的,处理单元701可以包含神经网络处理器(neural networks process units,NPU)、张量处理器(tensor processing unit,TPU)、现场可编程逻辑门阵列(field programmable gate array,FPGA)或者特定应用集成电路(application-specific integrated circuit,ASIC)、或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。
在一些场景中,例如处理单元701包含NPU、TPU等处理器时,处理单元701还包括存储器。处理单元701中处理器通过执行存储器中存储的计算机执行指令,以执行本申请所提供的方法。
通信接口702用于与其他装置进行通信。例如,内存管理装置70可以通过通信接口702与业务节点其他硬件装置通信,以执行本实施例所提供的方法。在实际应用顾聪中,通信接口702可以为接口电路或收发器等。
可选的,本实施例中的计算机执行指令也可以称之为应用程序代码,本实施例对此不作具体限定。
应理解,根据本实施例的内存管理装置70用于实现图6、图10、图15和图16中的各个方法的相应流程,为了简洁,在此不再赘述。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机程序或指令。在计算机上加载和执行所述计算机程序或指令时,全部或部分地执行本实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、网络设备、用户设备或者其它可编程装置。所述计算机程序或指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机程序或指令可以从一个网站站点、计算机、服务器或数据中心通过有线或无线方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是集成一个或多个可用介质的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,例如,软盘、硬盘、磁带;也可以是光介质,例如,数字视频光盘(digital video disc,DVD);还可以是半导体介质,例如,SSD。
在本实施例中,如果没有特殊说明以及逻辑冲突,不同的实现方式之间的术语和/或描述 具有一致性、且可以相互引用,不同的实施例中的技术特征根据其内在的逻辑关系可以组合形成新的实施例。
本实施例中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上,其它量词与之类似。“和/或”描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。此外,对于单数形式“a”,“an”和“the”出现的元素(element),除非上下文另有明确规定,否则其不意味着“一个或仅一个”,而是意味着“一个或多于一个”。例如,“a device”意味着对一个或多个这样的device。再者,至少一个(at least one of).......”意味着后续关联对象中的一个或任意组合,例如“A、B和C中的至少一个”包括A,B,C,AB,AC,BC,或ABC。在本实施例的文字描述中,字符“/”,一般表示前后关联对象是一种“或”的关系;在本实施例的公式中,字符“/”,表示前后关联对象是一种“相除”的关系。

Claims (23)

  1. 一种业务系统,其特征在于,包括多个业务节点;所述多个业务节点中至少一个业务节点的内存被划分为本地资源和全局资源;
    其中,所述本地资源用于为本地业务节点提供内存存储空间;所述至少一个业务节点中的所述全局资源构成内存池,所述内存池用于为所述多个业务节点提供内存存储空间;
    当一定条件满足时,所述本地资源中的至少一部分空间会被转入所述内存池;或者所述内存池中的至少一部分空间会被转入所述本地资源。
  2. 根据权利要求1所述的业务系统,其特征在于,所述业务系统还包括:内存管理装置;
    所述内存管理装置,用于调整所述至少一个业务节点中的本地资源和全局资源的存储空间大小。
  3. 根据权利要求2所述的业务系统,其特征在于,
    所述内存管理装置,具体用于在所述至少一个业务节点的全局资源耗尽并且所述至少一个业务节点的本地资源存在空闲空间时,将所述至少一个业务节点的本地资源中的空闲空间转入所述至少一个业务节点的全局资源;或者
    所述内存管理装置,具体用于在所述至少一个业务节点的本地资源耗尽并且所述至少一个业务节点的全局资源存在空闲空间时,将所述至少一个业务节点的全局资源中的空闲空间转入所述至少一个业务节点的本地资源;或者
    所述内存管理装置,具体用于在所述至少一个业务节点的全局资源和本地资源都耗尽时,回收所述至少一个业务节点的内存中价值最低的内存资源,将回收的内存资源转入全局资源,或者将回收的内存资源转入本地资源。
  4. 根据权利要求2-3任一项所述的业务系统,其特征在于,所述内存管理装置,还用于在调整所述至少一个业务节点中各业务节点的本地资源和全局资源的存储空间大小时,保持所述至少一个业务节点中各业务节点的本地资源的存储空间不小于预设阈值。
  5. 根据权利要求1-4任一项所述的业务系统,其特征在于,所述业务系统还包括:内存管理装置;
    所述内存管理装置用于根据第一数据的被访问信息,从所述至少一个业务节点的本地资源或全局资源中,确定加载所述第一数据的内存资源。
  6. 根据权利要求5所述的业务系统,其特征在于,所述内存管理装置具体用于:
    若根据所述第一数据的被访问信息,确定所述第一数据曾被m个业务节点访问,则确定将所述第一数据加载至所述至少一个业务节点的全局资源中;m为大于1的正整数,所述m个业务节点包含于所述多个业务节点。
  7. 根据权利要求6所述的业务系统,其特征在于,所述内存管理装置具体用于:
    若根据所述第一数据的被访问信息,确定所述第一数据曾被m个业务节点访问,则根据所述第一数据与所述m个业务节点中各业务节点的亲和性,确定将所述第一数据加载至所述至少一个业务节点的全局资源中。
  8. 根据权利要求5所述的业务系统,其特征在于,所述内存管理装置具体用于:
    若根据所述第一数据的被访问信息,确定所述第一数据曾被所述至少一个业务节点访问,则确定将所述第一数据加载至所述至少一个业务节点的本地资源中。
  9. 根据权利要求5所述的业务系统,其特征在于,所述内存管理装置具体用于:
    若根据所述第一数据的被访问信息,确定所述第一数据曾被m个业务节点访问,并且所 述m个业务节点中存在n个业务节点与所述第一数据的亲和性大于亲和性阈值,则确定将所述第一数据加载至所述n个业务节点的本地资源中;其中,m为大于1的正整数,n为小于等于m的正整数,所述m个业务节点包含于所述多个业务节点。
  10. 根据权利要求5-9任一项所述的业务系统,其特征在于,所述第一数据具有访问参数,所述访问参数用于指示所述第一数据在所述多个业务节点的内存中的数据副本是否可用。
  11. 一种内存管理方法,其特征在于,所述方法应用于业务系统,所述业务系统包括多个业务节点,所述方法包括:
    将所述多个业务节点中至少一个业务节点的内存划分为本地资源和全局资源;其中,所述本地资源用于为本地业务节点提供内存存储空间;所述至少一个业务节点中的所述全局资源构成内存池,所述内存池用于为所述多个业务节点提供内存存储空间;当一定条件满足时,所述本地资源中的至少一部分空间会被转入所述内存池,或者所述内存池中的至少一部分空间会被转入所述本地资源;
    调整所述至少一个业务节点中的本地资源和全局资源的存储空间大小。
  12. 根据权利要求11所述的方法,其特征在于,所述调整所述至少一个业务节点中的本地资源和全局资源的存储空间大小,具体包括以下至少一项:
    在所述至少一个业务节点的全局资源耗尽并且所述至少一个业务节点的本地资源存在空闲空间时,将所述至少一个业务节点的本地资源中的空闲空间转入所述至少一个业务节点的全局资源;或者
    在所述至少一个业务节点的本地资源耗尽并且所述至少一个业务节点的全局资源存在空闲空间时,将所述至少一个业务节点的全局资源中的空闲空间转入所述至少一个业务节点的本地资源;或者
    在所述至少一个业务节点的全局资源和本地资源都耗尽时,回收所述至少一个业务节点的内存中价值最低的内存资源,将回收的内存资源转入全局资源,或者将回收的内存资源转入本地资源。
  13. 根据权利要求11-12任一项所述的方法,其特征在于,所述方法还包括:
    在调整所述至少一个业务节点中各业务节点的本地资源和全局资源的存储空间大小时,保持所述至少一个业务节点中各业务节点的本地资源的存储空间不小于预设阈值。
  14. 根据权利要求11-13任一项所述的方法,其特征在于,所述方法还包括:
    根据第一数据的被访问信息,从所述至少一个业务节点的本地资源或全局资源中,确定加载所述第一数据的内存资源。
  15. 根据权利要求14所述的方法,其特征在于,所述根据第一数据的被访问信息,从所述至少一个业务节点的本地资源或全局资源中,确定加载所述第一数据的内存资源,包括:
    若根据所述第一数据的被访问信息,确定所述第一数据曾被m个业务节点访问,则确定将所述第一数据加载至所述至少一个业务节点的全局资源中;m为大于1的正整数,所述m个业务节点包含于所述多个业务节点。
  16. 根据权利要求15所述的方法,其特征在于,所述若根据所述第一数据的被访问信息,确定所述第一数据曾被m个业务节点访问,则确定将所述第一数据加载至所述至少一个业务节点的全局资源中,包括;
    若根据所述第一数据的被访问信息,确定所述第一数据曾被m个业务节点访问,则根据所述第一数据与所述m个业务节点中各业务节点的亲和性,确定将所述第一数据加载至所述 至少一个业务节点的全局资源中。
  17. 根据权利要求14所述的方法,其特征在于,所述根据第一数据的被访问信息,从所述至少一个业务节点的本地资源或全局资源中,确定加载所述第一数据的内存资源,包括:
    若根据所述第一数据的被访问信息,确定所述第一数据曾被所述至少一个业务节点访问,则确定将所述第一数据加载至所述至少一个业务节点的本地资源中。
  18. 根据权利要求14所述的方法,其特征在于,所述根据第一数据的被访问信息,从所述至少一个业务节点的本地资源或全局资源中,确定加载所述第一数据的内存资源,包括:
    若根据所述第一数据的被访问信息,确定所述第一数据曾被m个业务节点访问,并且所述m个业务节点中存在n个业务节点与所述第一数据的亲和性大于亲和性阈值,则确定将所述第一数据加载至所述n个业务节点的本地资源中;其中,m为大于1的正整数,n为小于等于m的正整数,所述m个业务节点包含于所述多个业务节点。
  19. 根据权利要求14-18任一项所述的方法,其特征在于,所述第一数据具有访问参数,所述访问参数用于指示所述第一数据在所述多个业务节点的内存中的数据副本是否可用。
  20. 一种内存管理装置,其特征在于,位于业务系统中,所述业务系统包括多个业务节点;所述内存管理装置,包括:
    资源划分单元,用于将所述多个业务节点中至少一个业务节点的内存划分为本地资源和全局资源;其中,所述本地资源用于为本地业务节点提供内存存储空间;所述至少一个业务节点中的所述全局资源构成内存池,所述内存池用于为所述多个业务节点提供内存存储空间;当一定条件满足时,所述本地资源中的至少一部分空间会被转入所述内存池,或者所述内存池中的至少一部分空间会被转入所述本地资源;
    资源调整单元,用于调整所述至少一个业务节点中的本地资源和全局资源的存储空间大小。
  21. 一种内存管理装置,其特征在于,包括:处理器和通信接口,所述处理器通过所述通信接口接收或发送数据,所述处理器用于实现如权利要求11-19中任一项所述的方法中内存管理装置的功能。
  22. 一种计算机可读存储介质,其特征在于,所述存储介质中存储有计算机程序,当所述计算机程序被处理器执行时,实现如权利要求11-19中任一项所述的方法中内存管理装置的功能。
  23. 一种计算机程序产品,其特征在于,所述计算机程序产品包括指令,当所述指令在处理器上运行时,实现如权利要求11-19中任一项所述的方法中内存管理装置的功能。
PCT/CN2022/096400 2021-09-11 2022-05-31 业务系统、内存管理方法及装置 WO2023035694A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202111064929.7 2021-09-11
CN202111064929 2021-09-11
CN202111165165.0A CN115794368A (zh) 2021-09-11 2021-09-30 业务系统、内存管理方法及装置
CN202111165165.0 2021-09-30

Publications (1)

Publication Number Publication Date
WO2023035694A1 true WO2023035694A1 (zh) 2023-03-16

Family

ID=85417275

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/096400 WO2023035694A1 (zh) 2021-09-11 2022-05-31 业务系统、内存管理方法及装置

Country Status (2)

Country Link
CN (1) CN115794368A (zh)
WO (1) WO2023035694A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117407042A (zh) * 2023-11-01 2024-01-16 广州国测规划信息技术有限公司 一种国土空间基础信息平台的扩展设计方法和系统

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6848033B2 (en) * 2001-06-07 2005-01-25 Hewlett-Packard Development Company, L.P. Method of memory management in a multi-threaded environment and program storage device
CN105094997A (zh) * 2015-09-10 2015-11-25 重庆邮电大学 一种云计算主机节点间物理内存共享方法和系统
CN108139969B (zh) * 2015-10-28 2021-06-08 华为技术有限公司 一种内存配置方法、装置及系统
CN113204407A (zh) * 2021-04-22 2021-08-03 新华三大数据技术有限公司 一种内存超配管理方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6848033B2 (en) * 2001-06-07 2005-01-25 Hewlett-Packard Development Company, L.P. Method of memory management in a multi-threaded environment and program storage device
CN105094997A (zh) * 2015-09-10 2015-11-25 重庆邮电大学 一种云计算主机节点间物理内存共享方法和系统
CN108139969B (zh) * 2015-10-28 2021-06-08 华为技术有限公司 一种内存配置方法、装置及系统
CN113204407A (zh) * 2021-04-22 2021-08-03 新华三大数据技术有限公司 一种内存超配管理方法及装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117407042A (zh) * 2023-11-01 2024-01-16 广州国测规划信息技术有限公司 一种国土空间基础信息平台的扩展设计方法和系统
CN117407042B (zh) * 2023-11-01 2024-04-05 广州国测规划信息技术有限公司 一种国土空间基础信息平台的扩展设计方法和系统

Also Published As

Publication number Publication date
CN115794368A (zh) 2023-03-14

Similar Documents

Publication Publication Date Title
US11151029B2 (en) Computing system and method for controlling storage device
US11748256B2 (en) Memory system and method for controlling nonvolatile memory
US11467955B2 (en) Memory system and method for controlling nonvolatile memory
US11797436B2 (en) Memory system and method for controlling nonvolatile memory
US11593186B2 (en) Multi-level caching to deploy local volatile memory, local persistent memory, and remote persistent memory
JP7467593B2 (ja) リソース割振り方法、記憶デバイス、および記憶システム
US10802972B2 (en) Distributed memory object apparatus and method enabling memory-speed data access for memory and storage semantics
US20230122315A1 (en) Data Management Method for Application, System, and Computer Device
WO2023035694A1 (zh) 业务系统、内存管理方法及装置
US10802748B2 (en) Cost-effective deployments of a PMEM-based DMO system
CN113138851B (zh) 一种数据管理方法、相关装置及系统
EP3249539A1 (en) Method and device for accessing data visitor directory in multi-core system
WO2023000696A1 (zh) 一种资源分配方法及装置
US11928336B2 (en) Systems and methods for heterogeneous storage systems
WO2020024591A1 (en) Cost-effective deployments of a pmem-based dmo system
CN115878514A (zh) 一种锁管理方法、装置、计算设备和分布式系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22866172

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2022866172

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022866172

Country of ref document: EP

Effective date: 20240320

NENP Non-entry into the national phase

Ref country code: DE