Memory resource management and control method and device

By introducing the main process into the data processing module to uniformly manage and release the memory resources of the slave process, the memory leakage problem caused by slave process exceptions is solved, and efficient utilization and recycling of memory resources is achieved.

CN119396606APending Publication Date: 2025-02-07LENOVO (BEIJING) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411515107.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the multi-process data processing module, the slave process may experience abnormalities due to the complexity of business logic, resulting in the occupied memory blocks being unable to be released in time, increasing the risk of memory leakage.

Method used

Through the target communication connection between the main process and the slave process, the main process is responsible for managing the memory pool, confirming the memory usage requirements of the slave process and allocating memory blocks, and timely releasing the memory blocks that meet the conditions of the slave process.

Benefits of technology

Effectively manage and release memory blocks occupied by the process, reduce the risk of memory leakage, and ensure the rational utilization and recycling of memory resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396606A_ABST
    Figure CN119396606A_ABST
Patent Text Reader

Abstract

The invention discloses a memory resource management and control method and device.The method comprises the steps that target communication connection between a master process of a data processing module and at least one slave process is established, the master process maintains a memory pool allocated by the data processing module, and the data processing module can directly conduct data interaction with a physical network card of electronic equipment; if the master process confirms that the slave process has the memory use requirement, at least one memory block needing to be allocated to the slave process in a memory pool is determined through the master process; allocating at least one memory block to the slave process; and if the master process confirms that the slave process meets the memory release condition, releasing the memory block allocated to the slave process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a memory resource management method and device. Background Art

[0002] In order to improve the efficiency of data packet processing, data processing modules running in user mode are often deployed in electronic devices such as servers or nodes of system platforms. The data processing module can communicate directly with the physical network card, thereby bypassing the kernel protocol stack's processing of data packets and improving the efficiency of data packet processing.

[0003] The data processing module generally adopts a multi-process mode, such as a master process and at least one slave process managed by the master process. On this basis, the master process and the slave process in the multi-process mode share resources such as the memory pool. However, due to the relatively high complexity of the business logic that the slave process needs to process, it is easy for the slave process to have exceptions. Once the slave process has an exception, the memory block occupied by the slave process may not be released in time or even cannot be released, resulting in the risk of memory leakage. Summary of the invention

[0004] On the one hand, the present application provides a memory resource management method, including:

[0005] Establishing a target communication connection between a master process of a data processing module and at least one slave process, wherein the master process maintains a memory pool allocated by the data processing module, and the data processing module can directly interact with a physical network card of the electronic device for data;

[0006] If the master process confirms that the slave process has a memory usage requirement, determine, through the master process, at least one memory block in the memory pool to be allocated to the slave process;

[0007] Allocating the at least one memory block to the slave process;

[0008] If the master process confirms that the slave process meets the memory release condition, the memory block allocated to the slave process is released.

[0009] In a possible implementation, if the master process confirms that the slave process meets the memory release condition, releasing the memory block allocated to the slave process includes:

[0010] If the master process confirms that the slave process has finished running based on the target communication connection, each memory block allocated to the slave process is released.

[0011] In another possible implementation, if the master process confirms that the slave process has a memory usage requirement, determining, by the master process, at least one memory block in the memory pool to be allocated to the slave process includes:

[0012] If the master process obtains a first data packet to be allocated to the slave process through the physical network card, at least one first memory block in the memory pool for caching the first data packet is determined as at least one memory block to be allocated to the slave process.

[0013] In another possible implementation, if the master process confirms that the slave process has a memory usage requirement, determining, by the master process, at least one memory block in the memory pool to be allocated to the slave process includes:

[0014] Based on the target communication connection, obtaining the memory requirement of the slave process through the master process;

[0015] Based on the memory requirement, the master process determines from the memory pool at least one memory block to be allocated to the slave process.

[0016] In yet another possible implementation, if the master process confirms that the slave process satisfies a memory release condition, releasing the memory block allocated to the slave process includes:

[0017] If the master process obtains a data packet sending request from the slave process, based on the data packet sending request, at least one second memory block where a second data packet to be sent is located is determined from the memory blocks allocated to the slave process;

[0018] The at least one second memory block allocated to the slave process is released by the master process.

[0019] In yet another possible implementation, if the master process confirms that the slave process satisfies a memory release condition, releasing the memory block allocated to the slave process includes:

[0020] If the master process obtains the memory release request of the slave process, confirms that the slave process meets the memory release condition, and releases the memory block allocated to the slave process, the memory release request indicates that there is no free memory block in the memory block allocated to the slave process.

[0021] In another possible implementation, if the master process confirms that the slave process has terminated execution based on the target communication connection, releasing each memory block allocated to the slave process includes:

[0022] If the master process detects that the slave process disconnects the target communication connection with the master process, it is confirmed that the slave process ends running, and each memory block allocated to the slave process is released.

[0023] In another possible implementation, the process further includes: sending a heartbeat message to the master process through the slave process based on a heartbeat message sending cycle;

[0024] If the master process confirms that the slave process has terminated execution based on the target communication connection, releasing each memory block allocated to the slave process comprises:

[0025] If the master process does not receive the heartbeat message sent by the slave process for more than a set period of time, it is confirmed that the slave process has ended its operation and each memory block allocated to the slave process is released.

[0026] In yet another possible implementation, after allocating the at least one memory block to the slave process, the method further includes:

[0027] Storing, by the master process, an association relationship between the slave process and at least one memory block allocated for the slave process;

[0028] The releasing of the memory block allocated to the slave process comprises:

[0029] The association relationship between the slave process and the memory block allocated to the slave process stored by the master process is deleted.

[0030] On the other hand, the present application also provides a memory resource management and control device, including:

[0031] A connection establishing unit, used to establish a target communication connection between a main process of a data processing module and at least one slave process, wherein the main process maintains a memory pool allocated by the data processing module, and the data processing module can directly interact with a physical network card of the electronic device for data;

[0032] a memory determining unit, configured to determine, through the master process, at least one memory block in the memory pool to be allocated to the slave process if the master process confirms that the slave process has a memory usage requirement;

[0033] A memory allocation unit, configured to allocate the at least one memory block to the slave process;

[0034] A memory release unit is used to release the memory block allocated to the slave process if the master process confirms that the slave process meets the memory release condition. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0036] Figure 1 A flowchart of the memory resource management method provided in this application;

[0037] Figure 2 Another flowchart of the memory resource management method provided in this application;

[0038] Figure 3 Another flowchart of the memory resource management method provided in this application;

[0039] Figure 4 This is an interactive framework diagram for sending and receiving data packets and allocating memory blocks between the master process and the slave process in this application;

[0040] Figure 5 A schematic diagram of the composition structure of the memory resource control device provided in this application;

[0041] Figure 6 A schematic diagram of the composition architecture of an electronic device provided in this application. DETAILED DESCRIPTION

[0042] The embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation mode of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0043] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0044] like Figure 1, shows a flow chart of a memory resource management method according to an embodiment of the present application. The method according to this embodiment can be applied to an electronic device in which a data processing module can be deployed.

[0045] The data processing module can directly interact with the physical network card of the electronic device. For example, the data processing module runs in user mode, moves the processing of data packets to user space, bypasses the processing of data packets by the operating system kernel, thereby avoiding some processing of data packets based on the protocol stack in the kernel mode, and improving the efficiency of data packet processing.

[0046] For example, the data processing module may be a data plane development kit (Data Plane Development Kit). Of course, the data processing module may have other possibilities, which are not limited.

[0047] In the present application, the electronic device may be a server, or a device node in a distributed or cluster system, or other computer devices. For example, with the continuous development of technology, the electronic device may also be a terminal device such as a laptop or a mobile phone, without limitation.

[0048] The method of this embodiment may include:

[0049] S101, establishing a target communication connection between a master process of a data processing module and at least one slave process.

[0050] Among them, the data processing module supports multi-process mode, and the multi-process of the data processing module is divided into a master process and a slave process.

[0051] The master process is used to manage the slave process. The slave process can join or leave the management of the master process at any time. When the slave process needs to join the management of the master process, the slave process needs to establish a target communication connection with the master process.

[0052] Wherein, information transmission between the master process and the slave process is realized based on the target communication connection.

[0053] In a possible implementation, the target communication connection may include a first communication connection channel and a second communication connection channel. The first communication connection channel may be used to transmit messages between the master process and the slave process for indicating the sending and receiving of data packets. Of course, the first communication connection channel may be further subdivided into a receiving channel for the master process to notify the slave process to receive data and a sending channel for the slave process to notify the master process to send data. The second communication connection channel may be used for parameter negotiation between the master process and the slave process or for maintaining a heartbeat mechanism. The parameter negotiation between the master process and the slave process may include negotiation of memory requirements and data distribution rules, etc., without limitation.

[0054] Among them, the main process maintains a memory pool allocated by the data processing module, and the memory pool includes multiple memory blocks.

[0055] S102: If the master process confirms that the slave process has a memory usage requirement, the master process determines at least one memory block in the memory pool that needs to be allocated to the slave process.

[0056] In this application, the master process is responsible for unified management of memory resources and for memory allocation and release of each slave process. Based on this, in this application, when the master process confirms that the slave process has memory usage requirements, the master process will allocate memory blocks to the slave process based on the actual memory usage requirements of the slave process.

[0057] S103: Allocate at least one memory block to the slave process.

[0058] For example, the master process notifies the slave process of the address information of each memory block allocated to the slave process through the target communication connection, so that the slave process can confirm each memory block allocated to the slave process.

[0059] After the memory block is allocated to the slave process, the slave process obtains the right to use the memory block. On this basis, the slave process can cache the data to be sent, the intermediate link data in the business processing process, the result data or other data that needs to be cached in the memory block according to the actual business data processing request, without any restrictions.

[0060] It is understandable that there may be multiple slave processes managed by the master process, and the memory blocks and the number of memory blocks allocated to the same or different slave processes each time may be different. Based on this, in order to facilitate the master process to determine the memory blocks allocated to each slave process and achieve more efficient management and control of memory blocks, when or after the master process allocates at least one memory block to a slave process, the master process will also store the association relationship between the slave process and at least one memory block allocated to the slave process.

[0061] For example, the master process may maintain memory block allocation information of each slave process, and the memory block allocation information of the slave process includes identification information of each memory block allocated to the slave process. The identification information of the memory block may be a sequence number or unique address information of the memory block, etc., without limitation.

[0062] Furthermore, in order to enable the slave process to more conveniently confirm the memory block allocated to the slave process by the master process, after the master process allocates at least one memory block to the slave process, the slave process may also record the status information of each memory block allocated to the slave process by the master process, and the status information of the memory block includes at least the identification information of the memory block, and may also include the usage status of the memory block. The usage status of the memory block is used to indicate whether the memory block is in an idle state, for example, the usage status of the memory block may be that the memory block is occupied or that the memory block is idle.

[0063] S104: If the master process confirms that the slave process meets the memory release condition, the memory block allocated to the slave process is released.

[0064] Among them, the fact that the slave process meets the memory release condition indicates that the slave process has at least one memory block that needs to be released. In other words, the slave process no longer needs to use at least part of the memory blocks allocated to it.

[0065] It is understandable that since the memory block allocated to the slave process is always in the memory pool, and allocating a memory block to a slave process is merely allocating the right to use the memory block to the slave process, the master process releasing the memory block allocated to the slave process is actually reclaiming the slave process's right to use the allocated memory block.

[0066] In one possible implementation, when the master process records and manages the usage permissions of each memory block by storing the association relationship between the slave process and at least one memory block allocated to the slave process, releasing the memory block may be deleting the association relationship between the slave process and the memory block allocated to the slave process stored by the master process.

[0067] Furthermore, when the slave process meets the memory release condition, if the master process confirms that the slave process is still in normal operation, the master process can also send a memory release notification to the slave process, and the memory release notification is used to inform the slave process of at least one memory block that needs to be released. On this basis, in order to enable the slave process to update the information of each memory block that it has the right to use in real time, the slave process can also delete the status information of at least one memory block to be released. On this basis, the slave process will not be able to query the status information of each memory block that has been released from the status information of each memory block that it maintains. Therefore, the slave process can confirm that it does not have the right to use these released memory blocks.

[0068] It is understandable that there may be multiple possible situations for a process to meet the memory release condition, which can be set specifically as needed. The following will be explained in conjunction with several possible situations, which will not be repeated here.

[0069] From the above, it can be seen that in the present application, after the master process and the slave process establish a target communication connection, if the master process confirms that the slave process has a memory usage demand, the master process will allocate a memory block to the slave process, and release the memory block allocated to the slave process when it is confirmed that the slave process meets the memory release conditions, thereby realizing the unified control of the memory blocks in the memory pool by the master process. Therefore, even if an abnormality occurs in the slave process, the master process can still control the release of the memory blocks occupied by the slave process, thereby reducing the situation where the memory blocks are not released in time or cannot be released due to the abnormality of the slave process.

[0070] The following describes several possible situations where the slave process meets the memory release conditions:

[0071] In the first possible case, if the master process confirms that the slave process has terminated its operation based on the target communication connection, it can be confirmed that the slave process meets the memory release condition, and each memory block allocated to the slave process is released.

[0072] The slave process may terminate its operation by itself, in which case the slave process actively communicates with the target of the master process to exit the management of the master process. For example, if the slave process completes business processing or does not need to continue to run for other reasons, the slave process may be terminated to disconnect from the master process.

[0073] The slave process may terminate its operation passively, for example, the slave process is interrupted due to a fault or other abnormal reason, or the target communication connection with the master process is disconnected.

[0074] Based on this, there may be multiple implementations for determining that the slave process has terminated operation. For example, if the master process detects that the slave process has disconnected the target communication connection with the master process, the master process confirms that the slave process has terminated operation.

[0075] For another example, the master process and the slave process can also use heartbeat messages to determine whether the target communication connection between the two parties is normal. Accordingly, the slave process can send heartbeat messages to the master process based on the heartbeat message sending cycle. On this basis, if the master process does not receive the heartbeat message sent by the slave process for more than the set time, the master process can confirm that the slave process has ended and release the memory blocks allocated to the slave process.

[0076] In the second possible situation, if the master process obtains a data packet sending request from the slave process, it can also be confirmed that the slave process meets the memory release condition. On this basis, based on the data packet sending request, the master process determines at least one memory block where the data packet to be sent is located from the memory blocks allocated to the slave process, and releases the at least one memory block allocated to the slave process.

[0077] It is understandable that after the master process allocates a memory block to the slave process, the slave process has the authority to use the memory block allocated to it, and the slave process can cache the data packets to be sent and other data that need to be cached in the memory block. Since the master process is responsible for the distribution of data packets such as messages and the transmission of data packets such as messages to be sent to the physical network card in the data processing module, after the slave process caches the data packets to be sent in the memory block, the slave process can send a data packet sending request to the master process, and the data packet sending request can indicate at least one memory block where the data packets to be sent are located.

[0078] After the master process obtains the data packet sending request, the master process needs to reclaim the permission in the at least one memory block so that the master process can send data for the data packet to be sent in the at least one memory block. Based on this, the master process will release the at least one memory block allocated to the slave process so that the master process can access the data packet to be sent in the at least one memory block and forward it to the physical network card.

[0079] It can be understood that the slave process will also be involved in receiving data packets assigned by the master process. Based on this, for the sake of ease of distinction, in the present application, the data packet assigned by the master process to the slave process can also be referred to as the first data packet, and the at least one memory block where the first data packet is located can be referred to as the first memory block. The data packet to be sent by the slave process can be referred to as the second data packet, and the at least one memory block where the second data packet is located can be referred to as the second memory block.

[0080] In the third possible situation, if the master process obtains a memory release request from the slave process, it can also be confirmed that the slave process meets the memory release condition. Based on this, the master process will release the memory blocks allocated to the slave process. The memory release request indicates that there are no free memory blocks in the memory blocks allocated to the slave process. For example, when the slave process confirms that the memory blocks allocated to the slave process by the master process have been fully occupied and there are no free memory blocks, the slave process sends the memory release request to the master process so that the master process reclaims the memory blocks corresponding to the slave process, so that the slave process can continue to apply for new memory blocks later.

[0081] It is understandable that there may be many possible situations in which a process has memory usage requirements, and several possible situations are described below.

[0082] In one possible scenario, if the master process obtains a first data packet to be allocated to the slave process through a physical network card, at least one first memory block in the memory pool for caching the first data packet is determined as at least one memory block to be allocated to the slave process.

[0083] It is understandable that after the master process obtains the first data packet to be processed through the physical network, the master process will cache the first data packet to at least one free first memory block in the memory pool. Since the master process is not responsible for business processing, and only the slave process is responsible for business data, the master process needs to determine the slave process responsible for processing the first data packet, and in order to enable the slave process to have the authority to process the first data packet, the master process will allocate at least one first memory block where the first data packet is located to the slave process.

[0084] On this basis, the slave process can process the first data packet in the at least one memory block. According to the data content of the first data packet and the different services that the slave process is responsible for, the slave process may process the first data packet differently, and this application does not impose any restrictions on this.

[0085] Furthermore, after the slave process processes the first data packet, it may be necessary to send the processed first data packet, and the processed first data packet is actually the second data packet to be sent by the slave process. At the same time, since the processed first data packet is still cached in at least one first memory block, the at least one first memory block is also the at least one second memory block where the second data packet to be sent is located.

[0086] On this basis, the slave process may send a data packet sending request to the master process, the data packet sending request is used to request to send the second data packet and indicates at least one second memory block where the second datagram is located. When the master process receives the data packet sending request sent by the slave process, it may be processed according to the description of the previous embodiment.

[0087] To facilitate understanding of this situation, a possible implementation method is introduced below. Figure 2 , shows another flow chart of the memory resource management method provided in an embodiment of the present application. This example can be applied to an electronic device on which a data processing module is deployed. The details are as described above and will not be repeated here.

[0088] The method of this embodiment may include:

[0089] S201, establishing a target communication connection between a master process of a data processing module and at least one slave process.

[0090] For example, the data processing module will first start the main process. When the main process has been started, if the slave process is started, the slave process can apply to establish a target communication connection with the main process.

[0091] Among them, the main process maintains a memory pool allocated by a data processing module, and the data processing module can directly interact with the physical network card of the electronic device for data.

[0092] S202: If the master process obtains a first data packet through the physical network card, the first data packet is cached in at least one free first memory block in the memory pool, and a slave process that needs to process the first data packet is determined.

[0093] For example, the master process may determine a slave process suitable for processing the data packet according to a set data packet distribution rule or a data packet distribution rule pre-negotiated with each slave process.

[0094] Of course, the master process may also use other methods to determine the slave process to which the first data packet needs to be assigned, and there is no specific limitation.

[0095] The first memory block in the memory pool refers to a memory block that has not stored any data and has not been allocated to a slave process.

[0096] S203: Allocate at least one first memory block for caching the first data packet to the slave process through the master process, and record an association relationship between the slave process, the at least one first memory block, and the slave process.

[0097] For example, the master process sends a memory block allocation notification to the slave process, and the memory block allocation notification indicates information about the at least one first memory block allocated to the slave process, so that the slave process confirms that the at least one first memory block is allocated to itself. For example, the memory block allocation notification indicates identification information of the first memory block.

[0098] S204: After the slave process confirms at least one first memory block allocated by the master process to the slave process, the slave process records status information of the at least one first memory block.

[0099] If the slave process maintains the status information of a memory block, it means that the slave process has the permission to use the memory block. Conversely, if the memory block does not belong to the memory block for which the slave process maintains the status information, it means that the memory block is not allocated to the slave process and the slave process does not have the permission to use the memory block.

[0100] S205: After the slave process processes the first data packet in the at least one first memory block into a second data packet, if the slave process needs to send the second data packet, the slave process sends a data packet sending request to the master process.

[0101] The data packet sending request indicates information of at least one first memory block where the second data packet to be sent is located.

[0102] It can be understood that, in the case of this embodiment, since the second data packet to be sent is obtained based on the first data packet assigned by the main process to the slave process for processing, the at least one second memory block where the second data packet is located is actually the at least one first memory block where the first data packet is located.

[0103] In this embodiment, after the slave process obtains the permission to use the at least one first memory block, the slave process also has the permission to process the first data packet cached in the at least one first memory block, and can perform corresponding processing on the first data packet based on the business processing rules configured by the slave process.

[0104] In an optional manner, in order to be able to timely and effectively trigger the slave process to process the data of the first data packet, after the main process determines the slave process suitable for processing the first data packet, the main process can also send a data reception indication to the slave process, and the data reception indication is used by the slave process to process the first data packet, and the data reception indication includes information of at least one first memory block where the first data packet is located.

[0105] For example, while or after the master process allocates at least one first memory block to the slave process, the data reception indication is sent to the slave process, so that the slave process processes the first data packet with the permission to use the at least one first memory block.

[0106] It is understandable that after the slave process obtains the first data packet and processes the first data packet into the second data packet, it may not need to send the second data packet. This application is only for the purpose of facilitating understanding of a possible implementation of the master process releasing the memory block allocated to the slave process, and takes the slave process needing to send the second data packet as an example.

[0107] S206, the master process responds to the data packet sending request, determines at least one first memory block where the second data packet is located, deletes the association between the at least one first memory block and the slave process, and sends a release notification of the at least one first memory block to the slave process.

[0108] It can be understood that after the main process deletes the association between the at least one first memory block and the slave process, since the information of the slave process corresponding to the at least one first memory block is not maintained in the main process, the main process can confirm that the at least one first memory block is an allocatable memory block, so that the main process can subsequently allocate the at least one first memory block to the required slave process, which naturally realizes the recovery of the at least one first memory block, that is, releases the at least one first memory block corresponding to the slave process.

[0109] It should be noted that step S206 is an example of an implementation of the master process releasing the first memory block. Other methods of releasing at least one first memory block allocated to the slave process are also applicable to this embodiment.

[0110] It is understandable that after the master process deletes the association between the at least one first memory block and the slave process and releases the at least one first memory block allocated to the slave process, the master process can also forward the first data packet to the physical network card to send the first data packet. Of course, the specific implementation of the master process sending the first data packet through the physical network card is not limited in this application.

[0111] S207: In response to the release notification, the slave process deletes the state information of the at least one first memory block maintained by the slave process to release the at least one first memory block.

[0112] As mentioned above, the memory blocks with status information maintained by the slave process are all memory blocks that the slave process has permission to use. After the slave process deletes the status information of the at least one first memory block, the slave process naturally cannot query the information of the at least one first memory block from the status information of the memory blocks it maintains for use, and the slave process naturally will not use the at least one first memory block.

[0113] It can be understood that after the main process allocates at least one first memory block in the memory pool for caching the first data packet to the slave process, if the target communication connection between the slave process and the main process is disconnected or the slave process meets other memory release conditions, the main process will also release the at least one first memory block allocated to the slave process.

[0114] For example, after the main process has not allocated at least one first memory block to the slave process, the slave process exits due to a failure or other abnormality. In this case, the main process can also confirm the exit of the slave process through the several methods mentioned above and release the at least one first memory block allocated to the slave process.

[0115] Of course, if the master process allocates other memory blocks to the slave process before the master process allocates the first memory block to the slave process, the master process will also release other allocated memory blocks when the slave process meets other memory release conditions.

[0116] It is understandable that, in addition to receiving and processing data packets assigned by the master process, the slave process may also generate data packets according to business processing requirements or generate data packets that need to be stored in other ways. Based on this, in order to avoid affecting the normal business processing of the slave process, the slave process can also apply for a memory block from the master process.

[0117] Based on this, another possible situation in which the master process confirms that the slave process has a memory usage requirement is: based on the target communication connection, the master process obtains the memory requirement of the slave process. Accordingly, based on the memory requirement, the master process can determine at least one memory block to be allocated to the slave process from the memory pool.

[0118] There are many possibilities for the slave process to send the memory demand to the master process. For example, after the slave process confirms that the target communication connection is established with the master process, the slave process can send the required memory demand to the master process. For another example, after the slave process confirms that there is no free memory block in the memory blocks allocated to the slave process, the slave process can send the required memory demand to the master process.

[0119] In this possible situation, after the master process allocates a memory block to the slave process, the master process can also record the association between the slave process and at least one memory block allocated to the slave process. Correspondingly, the slave process can also record the status information of at least one memory block allocated to it by the master process.

[0120] It is understandable that in this possible situation, at least one memory block allocated by the master process to the slave process is a free memory block. Therefore, the slave process can cache data packets generated or produced by other means and need to be stored in the allocated free memory block.

[0121] On this basis, if the data packet to be sent is cached in the memory block allocated to it by the slave process, then the slave process can also send a data packet sending request to the main process. In this case, the main process can also process the data packet sending request to implement data packet sending and release the memory block where the data packet is located. For details, please refer to the previous introduction of the main process processing data packet sending request, which will not be repeated here.

[0122] It is understandable that in this case, if the slave process meets other memory release conditions, the master process can also release the memory blocks allocated to the slave process. For example, if the master process confirms that the slave process has ended its operation based on the target communication connection, the master process releases the memory blocks allocated to the slave process. Alternatively, if the master process obtains a memory release request from the slave process, the master process releases the memory blocks allocated to the slave process.

[0123] In order to facilitate understanding of the solution of the present application, the memory resource management method of the present application is introduced below by taking an implementation method as an example. Figure 3 , shows another flow chart of the memory resource management method provided in an embodiment of the present application. The method of this embodiment may include:

[0124] S301, establishing a target communication connection between a master process of a data processing module and at least one slave process.

[0125] Among them, the main process maintains a memory pool allocated by the data processing module, and the data processing module can directly interact with the physical network card of the electronic device for data.

[0126] S302, after the slave process confirms that the target communication connection with the master process is established, the slave process sends the master process the memory requirement required by the slave process.

[0127] For example, after the master process and the slave process establish a target communication connection, the master process and the slave process can negotiate the relevant parameters required for business processing, such as the memory requirement and the data packet distribution rules. Therefore, during the parameter negotiation stage between the master process and the slave process, the slave process can feedback the memory requirement to the master process.

[0128] Combination Figure 4 The interactive framework diagram shown is used to illustrate:

[0129] Depend on Figure 4 It can be seen that after slave process 1 and slave process 2 are started, each slave process can establish a socket connection as a client with the master process as a server. Through the socket connection, the master process and the slave process can negotiate parameters.

[0130] Of course, in addition to establishing the socket connection between the master process and the slave process, a connection based on other protocols can also be established to achieve other data transmission between the master process and the slave process.

[0131] The memory requirement of the slave process may be determined based on the type of business that the slave process needs to process, etc., and there is no specific restriction on this.

[0132] S303, the master process determines at least one third memory block to be allocated to the slave process from the memory pool based on the memory demand, allocates the at least one third memory block to the slave process, and stores an association relationship between the at least one third memory block and the slave process.

[0133] S304: After the slave process confirms the at least one third memory block allocated by the master process to the slave process, the slave process records the status information of the at least one third memory block.

[0134] For the sake of distinction, in this embodiment, the memory block allocated by the master process to the slave process based on the memory requirement of the slave process is referred to as the third memory block.

[0135] Among them, in steps S303 and S304, the main process stores the association relationship and the slave process records the status information of the third memory block and the previous Figure 2 The corresponding operations in the embodiment are similar and will not be described in detail.

[0136] For ease of understanding, combined Figure 4 The interactive framework diagram is used to illustrate:

[0137] Figure 4The data interaction relationship between the master process and the two slave processes in the process of allocating memory and sending and receiving data is shown in FIG. For ease of understanding, only the interaction process between slave process 1 and the master process is described.

[0138] Depend on Figure 4 It can be seen that the main process can schedule and allocate memory blocks in the memory pool.

[0139] After the main process determines the memory requirement of slave process 1, the main process can allocate a memory block (the third memory block in this embodiment) for slave process 1. On this basis, the main process will record information such as the identifier of each third memory block allocated to slave process 1 in the memory block allocation information corresponding to slave process 1.

[0140] After the slave process 1 confirms each third memory block allocated by the master process, the slave process also adds the status information of each third memory block to the memory block status record maintained by the slave process.

[0141] S305: If the master process obtains a first data packet through the physical network card, the first data packet is cached in at least one free first memory block in the memory pool, and a slave process that needs to process the first data packet is determined.

[0142] S306: Allocate at least one first memory block for caching the first data packet to the slave process through the master process, and record an association relationship between the slave process, the at least one first memory block, and the slave process.

[0143] S307: After the slave process confirms at least one first memory block allocated to the slave process by the master process, the slave process records status information of the at least one first memory block.

[0144] The above steps S305 to S307 can refer to the previous Figure 2 The relevant introduction of the embodiments will not be repeated here.

[0145] For ease of understanding, we still combine Figure 4 To explain:

[0146] Depend on Figure 4 It can be seen that after the master process obtains the data packet to be processed from the physical network card, if it is confirmed that the data packet needs to be processed by slave process 1, the master process will allocate the memory blocks storing the data packet (i.e., the first memory block in this embodiment) to slave process 1, and the master process will record the memory blocks where the data packet is located in the memory block allocation information of slave process 1. At the same time, the master process notifies the slave process that the memory blocks where the data packet is located have been allocated to it, such as sending information such as the identifier of the memory block where the data packet is located to the slave process. Correspondingly, the slave process will also add the status information of the memory blocks where the data packet is located in the memory block status information.

[0147] At the same time, in order to enable the slave process to know in time that the data packet needs to be processed, the master process can also send a data reception indication to the slave process, and the data reception indication is used to instruct the slave process to process the data packet. Of course, the data reception indication can indicate the information of the memory block where the data packet is located. Correspondingly, the slave process will process the data packet based on the business logic configured by itself.

[0148] S308: There is a second data packet to be sent in the memory block corresponding to the slave process, and the slave process sends a data packet sending request to the master process.

[0149] The data packet sending request indicates that there is at least one second memory block where the second data packet is located.

[0150] In this embodiment, there are at least two possibilities for the slave process to confirm that there is a second data packet to be sent:

[0151] One possible situation is as described above, when the slave process completes the processing of the first data packet and determines that the processed first data packet needs to be sent, the processed first data packet in the at least one first memory is determined as the second data packet to be sent. Figure 2 The relevant introduction will not be repeated here.

[0152] Another possible situation is that a second data packet to be sent is generated from the process and cached into an idle third memory block, or the data packet to be sent is added to the third memory block by other means. In this case, the process can confirm the second data packet to be sent and determine at least one third memory block where the second data packet is located as at least one second memory block.

[0153] It is understandable that since the slave process may need to send data packets at multiple different times, the order of step S308 and steps S305 to S307 in this embodiment is not limited to Figure 3 As shown, in actual application, step S308 may be performed first, and then steps S305 to S307 may be performed; or, step S308 may be performed during the process of performing steps S305 to S307.

[0154] S309, the main process responds to the data packet sending request, determines at least one second memory block where the second data packet is located, deletes the association between the at least one second memory block and the slave process, and sends a release notification of the at least one second memory block to the slave process.

[0155] S310: In response to the release notification, the slave process deletes the state information of the at least one second memory block maintained by the slave process to release the at least one second memory block.

[0156] Still combined Figure 4 Description, by Figure 4 It can be seen that after slave process 1 confirms based on business logic that there is a data packet to be sent cached in its corresponding memory block, slave process 1 will send a data packet sending request to the master process so that the master process obtains the data packet to be sent from slave process 1. On this basis, the master process confirms that it needs to revoke the slave process's permission to use the memory block where the data packet is located. Accordingly, the master process will delete the information corresponding to the memory block where the data packet is located in the memory block allocation information of process 1. In addition, the master process will also notify slave process 1 to release the memory blocks where the data packet is located. Based on this, slave process 1 will delete the status information of the memory blocks where the data packet is located in the memory block status information.

[0157] exist Figure 3 In an embodiment, during the business data processing of the slave process, if the available memory blocks of the slave process are insufficient, the slave process can also apply for memory blocks from the main process. At this time, the slave process can also inform the main process of the memory demand of the main process, and the main process can also allocate memory blocks to the slave process. The specific details are similar to the previous steps S303 and S304 and will not be repeated here.

[0158] It can be understood that, in steps S308 to S310, the master process only releases the second memory blocks corresponding to the slave process that cache the data packets to be sent, but does not release other memory blocks that have been allocated to the slave process.

[0159] In addition to the case of releasing the memory blocks allocated to the slave process in steps S308 to S310, when the master process confirms that the slave process meets other memory release conditions, the master process will release part or all of the memory blocks of the slave process according to different memory release conditions.

[0160] For example, if the master process confirms that the slave process has ended based on the target communication connection, the master process confirms that the slave process does not currently need any memory blocks, so the master process releases all memory blocks allocated to the slave process. In this case, since the slave process has ended, the master process does not need to notify the slave process to release the memory blocks.

[0161] For another example, if the master process obtains a memory release request from the slave process, the master process may release a memory block that has been allocated to the slave process and corresponds to the memory release request according to the difference in the memory release request.

[0162] Corresponding to a memory resource control method of the present application, the present application also provides a memory resource control device.

[0163] like Figure 5 , shows a schematic diagram of a composition structure of a memory resource control device provided by the present application. The device of this embodiment may include:

[0164] A connection establishing unit 501 is used to establish a target communication connection between a master process of a data processing module and at least one slave process, wherein the master process maintains a memory pool allocated by the data processing module, and the data processing module can directly interact with a physical network card of the electronic device for data;

[0165] A memory determining unit 502 is configured to determine, through the master process, at least one memory block in the memory pool to be allocated to the slave process if the master process confirms that the slave process has a memory usage requirement;

[0166] A memory allocation unit 503, configured to allocate the at least one memory block to the slave process;

[0167] The memory release unit 504 is configured to release the memory block allocated to the slave process if the master process confirms that the slave process meets the memory release condition.

[0168] In a possible implementation, the memory determination unit includes:

[0169] The first memory determination subunit is used to determine at least one first memory block in the memory pool for caching the first data packet as at least one memory block to be allocated to the slave process if the master process obtains the first data packet to be allocated to the slave process through the physical network card.

[0170] In yet another possible implementation, the memory determination unit includes:

[0171] A demand determination subunit, configured to obtain the memory demand of the slave process through the master process based on the target communication connection;

[0172] The second memory determination subunit is used to determine at least one memory block to be allocated to the slave process from the memory pool through the master process based on the memory demand.

[0173] In a possible implementation, in any of the above device embodiments, the memory release unit includes:

[0174] a released block determination subunit, configured to determine, if the master process obtains a data packet sending request from the slave process, at least one second memory block where a second data packet to be sent is located from the memory blocks allocated to the slave process based on the data packet sending request;

[0175] The first releasing subunit is used to release the at least one second memory block allocated to the slave process through the master process.

[0176] In another possible implementation, in any of the above device embodiments, the memory release unit includes:

[0177] The second release sub-unit is used to release the memory block allocated to the slave process if the main process obtains the memory release request of the slave process, confirms that the slave process meets the memory release condition, and releases the memory block allocated to the slave process, and the memory release request indicates that there is no free memory block in the memory block allocated to the slave process.

[0178] In another possible implementation, the memory release unit includes:

[0179] The third releasing subunit is used to release each memory block allocated to the slave process if the master process confirms that the slave process has finished running based on the target communication connection.

[0180] In yet another possible implementation, the third releasing subunit includes:

[0181] The first termination and release subunit is used to confirm that the slave process has terminated its operation and release each memory block allocated to the slave process if the master process detects that the slave process has disconnected the target communication connection with the master process.

[0182] In yet another possible implementation, the device further includes: a heartbeat sending unit, configured to send a heartbeat message to the master process through the slave process based on a heartbeat message sending cycle;

[0183] The end release subunit includes:

[0184] The second termination and release subunit is used to confirm that the slave process has terminated its operation and release each memory block allocated to the slave process if the master process does not receive the heartbeat message sent by the slave process for more than a set period of time.

[0185] In yet another possible implementation, the device may further include: a relationship storage unit, configured to store, through the master process, an association relationship between the slave process and the at least one memory block allocated to the slave process after the memory determination unit allocates the at least one memory block to the slave process;

[0186] When releasing the memory block allocated to the slave process, the memory release unit is specifically used to delete the association relationship between the slave process stored by the master process and the memory block allocated to the slave process.

[0187] The present application also provides an electronic device. Figure 6 , which shows a schematic diagram of a composition structure of the electronic device, and the electronic device at least includes a processor 601 and a memory 602;

[0188] The processor 601 is used to execute the memory resource management method described in any one of the above embodiments;

[0189] The memory 602 is used to store the program required by the processor to perform operations

[0190] It can be understood that the electronic device may further include a display unit 603 and an input unit 604 .

[0191] Of course, the electronic device may also have Figure 6 There may be more or fewer components, without limitation.

[0192] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any memory resource management method provided in the embodiment of the present application.

[0193] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any memory resource management method provided in an embodiment of the present application.

[0194] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0195] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0196] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0197] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A memory resource management method, comprising: Establishing a target communication connection between a master process of a data processing module and at least one slave process, wherein the master process maintains a memory pool allocated by the data processing module, and the data processing module can directly interact with a physical network card of the electronic device for data; If the master process confirms that the slave process has a memory usage requirement, determine, through the master process, at least one memory block in the memory pool to be allocated to the slave process; Allocating the at least one memory block to the slave process; If the master process confirms that the slave process meets the memory release condition, the memory block allocated to the slave process is released.

2. The memory resource management method according to claim 1, wherein if the master process confirms that the slave process meets the memory release condition, releasing the memory block allocated to the slave process comprises: If the master process confirms that the slave process has finished running based on the target communication connection, each memory block allocated to the slave process is released.

3. The memory resource management method according to claim 1, if the master process confirms that the slave process has a memory usage demand, determining, by the master process, at least one memory block in the memory pool to be allocated to the slave process, comprises: If the master process obtains a first data packet to be allocated to the slave process through the physical network card, at least one first memory block in the memory pool for caching the first data packet is determined as at least one memory block to be allocated to the slave process.

4. The memory resource management method according to claim 1, if the master process confirms that the slave process has a memory usage demand, determining, by the master process, at least one memory block in the memory pool to be allocated to the slave process, comprises: Based on the target communication connection, obtaining the memory requirement of the slave process through the master process; Based on the memory requirement, the master process determines from the memory pool at least one memory block to be allocated to the slave process.

5. The memory resource management method according to claim 1, 3 or 4, wherein if the master process confirms that the slave process meets the memory release condition, releasing the memory block allocated to the slave process comprises: If the master process obtains a data packet sending request from the slave process, based on the data packet sending request, at least one second memory block where a second data packet to be sent is located is determined from the memory blocks allocated to the slave process; The at least one second memory block allocated to the slave process is released by the master process.

6. The memory resource management method according to claim 1 or 4, wherein if the master process confirms that the slave process meets the memory release condition, releasing the memory block allocated to the slave process comprises: If the master process obtains the memory release request of the slave process, confirms that the slave process meets the memory release condition, and releases the memory block allocated to the slave process, the memory release request indicates that there is no free memory block in the memory block allocated to the slave process.

7. The memory resource management method according to claim 2, wherein if the master process confirms that the slave process has terminated execution based on the target communication connection, releasing each memory block allocated to the slave process comprises: If the master process detects that the slave process disconnects the target communication connection with the master process, it is confirmed that the slave process ends running, and each memory block allocated to the slave process is released.

8. The memory resource management method according to claim 2, further comprising: Sending a heartbeat message to the master process through the slave process based on a heartbeat message sending cycle; If the master process confirms that the slave process has terminated execution based on the target communication connection, releasing each memory block allocated to the slave process comprises: If the master process does not receive the heartbeat message sent by the slave process for more than a set period of time, it is confirmed that the slave process has ended its operation and each memory block allocated to the slave process is released.

9. The memory resource management method according to claim 1, after allocating the at least one memory block to the slave process, further comprising: Storing, by the master process, an association relationship between the slave process and at least one memory block allocated for the slave process; The releasing of the memory block allocated to the slave process comprises: The association relationship between the slave process and the memory block allocated to the slave process stored by the master process is deleted.

10. A memory resource management and control device, comprising: A connection establishing unit, used to establish a target communication connection between a main process of a data processing module and at least one slave process, wherein the main process maintains a memory pool allocated by the data processing module, and the data processing module can directly interact with a physical network card of the electronic device for data; a memory determining unit, configured to determine, through the master process, at least one memory block in the memory pool to be allocated to the slave process if the master process confirms that the slave process has a memory usage requirement; A memory allocation unit, configured to allocate the at least one memory block to the slave process; A memory release unit is used to release the memory block allocated to the slave process if the master process confirms that the slave process meets the memory release condition.