Multi-process index allocation method and device, chip, network interface card, equipment and medium

By creating an index pool and state storage unit in shared memory, the problems of low efficiency and poor flexibility in multi-process index resource allocation are solved, realizing efficient allocation and sharing of index resources among multiple processes, and improving system stability and data consistency.

CN121326608BActive Publication Date: 2026-03-20SHENZHEN JAGUAR MICROSYSTEMS CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511904164.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-03-20
Estimated Expiration
2045-12-17

AI Technical Summary

Technical Problem

In existing technologies, multi-process index resource allocation methods suffer from low efficiency, inability to meet high-performance requirements, and poor flexibility. In particular, locking allocation and segmented allocation methods cannot effectively solve the problem of efficient allocation and sharing of index resources among multiple processes.

Method used

By creating an index pool in shared memory, and utilizing the index pool management module and state storage unit, process identifier management and state recognition are achieved. The shared memory index pool is initialized, allowing multiple processes to acquire index blocks in batches. The efficient allocation and release of index resources are achieved through Linux semaphores and DPU aging mechanisms.

Benefits of technology

It enables efficient allocation of index resources across multiple processes, improves the flexibility of index resource allocation and system stability, ensures data consistency and integrity, and avoids resource waste and conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121326608B_ABST
    Figure CN121326608B_ABST
Patent Text Reader

Abstract

The application discloses a multi-process index allocation method, device, chip, network interface card, equipment and medium, and the method comprises the following steps: after a first process is started, it is judged whether an index pool exists; if the index pool exists, the first process obtains a process identifier from an index pool management module, creates a state storage unit according to the process identifier, and obtains an index block from the index pool; when a second process obtains an index block from the index pool and there is no unallocated index block in the index pool, the second process identifies online or offline state information of the first process from the state storage unit of the first process; if the first process is in an offline state, the second process obtains an index block allocated to the first process. According to the application, an index resource is stored in a shared memory, and multiple processes obtain indexes in batches through the shared index pool; meanwhile, indexes used by any process can be released and used by other processes, so that efficient allocation of indexes among multiple processes is realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of indexing, in particular to a multi-process index allocation method, device, chip, network interface card, equipment and medium. BACKGROUND

[0002] In the field of network data processing, especially in application scenarios such as Data Processing Unit (DPU), how to efficiently allocate index resources to multiple processes is a technical problem to be solved. In the prior art, there are two ways to allocate index resources to multiple processes, namely locking allocation method and segmentation allocation method.

[0003] The locking allocation method means that if there is a common index library, process A will be locked when applying for an index, and process B will wait for process A to finish applying for an index before continuing to apply for an index. This method is simple to operate, but the efficiency is low, which seriously affects the performance and cannot meet the application scenarios of high performance requirements. The segmentation allocation method is to segment the index resources in order, such as process A applying for an index, allocating the fixed segment [0, 500,000) index to process A, and process B applying for an index, allocating the fixed segment [50, 1,000,000) index to process B. This method meets the application scenarios of high performance requirements, but since it is fixed allocation, it may occur that the index of process A occupies too large a segment and does not meet the requirements, or the index of process B occupies too small a segment, resulting in waste of index resources, and the index resources between segments cannot be shared, which is poor in flexibility.

[0004] Therefore, there is an urgent need for a multi-process index allocation method to realize efficient allocation of indexes among multiple processes. SUMMARY

[0005] In view of the above problems, the present application is proposed to provide a multi-process index allocation method, device, chip, network interface card, equipment and medium which can overcome the above problems or at least partially solve the above problems.

[0006] Other characteristics and advantages of the present application will become apparent from the following detailed description, or will be learned by practice of the present application.

[0007] According to a first aspect of an embodiment of the present application, a multi-process index allocation method is provided, the method comprising:

[0008] After the first process is started, it is judged whether an index pool exists, wherein the index pool is configured in a shared memory and includes an index pool management module and a plurality of index blocks.

[0009] If the index pool exists, the first process obtains a process identifier from the index pool management module, and creates a state storage unit according to the process identifier, and obtains an index block from the index pool, wherein the state storage unit is configured in the shared memory, and is used for storing online or offline state information of the first process, for identification by a second process;

[0010] When the second process obtains the index block from the index pool, and there is no unallocated index block in the index pool, the second process identifies the online or offline state information of the first process from the state storage unit of the first process;

[0011] If the first process is in the offline state, the second process obtains the index block allocated to the first process.

[0012] In some embodiments of the present application, the method further comprises:

[0013] The first process obtains a memory configuration file, and determines whether the index pool exists according to the memory configuration file, wherein the memory configuration file comprises identification information of the index pool.

[0014] In some embodiments of the present application, the determination of whether the index pool exists according to the memory configuration file comprises:

[0015] The memory configuration file is parsed, and the identification information of the index pool included in the memory configuration file is extracted;

[0016] The identification information of the index pool is verified to determine whether the index pool configured in the shared memory is included in the memory.

[0017] In some embodiments of the present application, the method further comprises:

[0018] If the index pool does not exist, the first process creates and initializes the index pool in the shared memory.

[0019] In some embodiments of the present application, the index pool management module comprises an index management header and a process management header, the index management header comprises a bitmap, the bitmap comprises a plurality of bit positions, each bit position is marked as free or occupied, and the process management header comprises a plurality of process identifiers, the plurality of bit positions correspond to the plurality of process identifiers one by one,

[0020] The first process obtains the process identifier from the index pool management module, comprising:

[0021] The first process applies for the process identifier from the index management header;

[0022] The index management header traverses the bitmap to find the bit position marked as free;

[0023] If the index pool management head finds a bit marked as free, the process management head configures the process identification corresponding to the bit marked as free to the first process, and marks the bit corresponding to the process identification as occupied.

[0024] In some embodiments of the present application, the first process obtains the process identification from the index pool management module, and the method further comprises:

[0025] If the index pool management head does not find a bit marked as free, the index pool management head traverses the bits marked as occupied, and uses the process identification corresponding to the bit marked as occupied to identify the online or offline state information of the corresponding process from the state storage unit of the corresponding process.

[0026] If the corresponding process is identified as offline, the process management head configures the process identification corresponding to the bit marked as occupied to the first process.

[0027] If the corresponding process is identified as online, the method repeats the steps of traversing the bits marked as occupied, and using the process identification corresponding to the bit marked as occupied to identify the online or offline state information of the corresponding process from the state storage unit of the corresponding process, until all the bits marked as occupied in the bitmap are traversed.

[0028] In some embodiments of the present application, when the second process applies for an index block from the index pool, and there is no unallocated index block in the index pool, the second process identifies the online or offline state information of the first process from the state storage unit of the first process, and the method comprises:

[0029] When the second process applies for an index block from the index pool, the index pool allocates an unallocated index block to the second process first. If there is no unallocated index block, the index pool traverses the bits marked as occupied by the index pool management head, and uses the process identification of the first process corresponding to the bit marked as occupied to identify the online or offline state information of the corresponding first process from the state storage unit of the corresponding first process.

[0030] If the corresponding first process is identified as online, the method repeats the steps of traversing the bits marked as occupied, and using the process identification of the first process corresponding to the bit marked as occupied to identify the online or offline state information of the corresponding first process from the state storage unit of the corresponding first process, until all the bits marked as occupied in the bitmap are traversed.

[0031] In some embodiments of the present application, the method further comprises:

[0032] When the first process is started, and the state storage unit is created according to the process identification, the online state information is stored in the state storage unit.

[0033] When the first process exits, the offline state information is stored in the state storage unit according to the process identifier of the first process.

[0034] According to a second aspect of the embodiments of the present application, a multi-process index allocation apparatus is provided, comprising:

[0035] The judging module is configured to judge whether the index pool exists after the first process is started, wherein the index pool is configured in the shared memory and comprises an index pool management module and a plurality of index blocks.

[0036] The first obtaining module is configured to, if the index pool exists, obtain the process identifier from the index pool management module by the first process, create a state storage unit according to the process identifier, and obtain the index block from the index pool, wherein the state storage unit is configured in the shared memory and is used to store the online or offline state information of the first process for the second process to identify.

[0037] The identifying module is configured to, when the second process obtains the index block from the index pool and there is no unallocated index block in the index pool, identify the online or offline state information of the first process from the state storage unit of the first process by the second process.

[0038] The second obtaining module is configured to, if the first process is in the offline state, obtain the index block allocated to the first process by the second process.

[0039] According to a third aspect of the embodiments of the present application, a chip is provided, comprising a memory and a processor, the memory stores a computer program, and the processor implements the steps of the method according to any one of the above aspects when executing the computer program.

[0040] According to a fourth aspect of the embodiments of the present application, a network interface card is provided, comprising the chip and an interface, and the chip communicates with the outside through the interface.

[0041] According to a fifth aspect of the embodiments of the present application, a computing device is provided, comprising a processor, the chip or the network interface card, the chip or the network interface card is used to dispatch a packet to the processor or the chip or the network interface card itself for processing, and the processor is used to process the packet dispatched from the chip or the network interface card.

[0042] According to a sixth aspect of the embodiments of the present application, a computer readable storage medium is provided, the computer readable storage medium stores computer program instructions, the computer program instructions are loaded and executed by a processor to implement the operations performed by the method according to any one of the above aspects.

[0043] The technical scheme provided in the embodiment of the present application has at least the following technical effects or advantages.

[0044] The multi-process index allocation method, device, chip, network interface card, equipment and medium provided by the embodiment of the present application have the following technical effects or advantages.

[0045] The above description is only a summary of the technical scheme of the present application, in order to more clearly understand the technical means of the present application, the content of the specification can be implemented, and in order to make the above and other purposes, characteristics and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application are described below. BRIEF DESCRIPTION OF DRAWINGS

[0046] In order to more clearly illustrate the technical scheme in the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0047] Figure 1 The flowchart of the multi-process index allocation method provided by the embodiment of the present application is shown in the figure.

[0048] Figure 2 The reference diagram of the bitmap corresponding to the process identifier is shown in the figure.

[0049] Figure 3 The principle structure diagram of the multi-process index allocation device provided by the embodiment of the present application is shown in the figure.

[0050] Figure 4 The internal structure diagram of the computer equipment in an embodiment is shown in the figure. DETAILED DESCRIPTION

[0051] The exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings.

[0052] In the drawings, various structural diagrams according to the embodiments of the present disclosure are shown. These drawings are not drawn to scale, in which certain details are exaggerated for the purpose of clear expression, and certain details can be omitted. The shapes of various regions, layers shown in the drawings and their relative size, positional relationship are only exemplary, and in actuality, there can be deviations due to manufacturing tolerances or technical limitations, and those skilled in the art can additionally design regions / layers with different shapes, sizes, relative positions according to actual needs.

[0053] In the context of the present application, similar or identical components can be denoted by the same or similar reference numerals.

[0054] In order to better understand the above technical solutions, the above technical solutions will be described in detail below in combination with specific embodiments. It should be understood that the embodiments of the present disclosure and the specific features in the embodiments are detailed descriptions of the technical solutions of the present application, rather than limitations of the technical solutions of the present application. In the case of no conflict, the technical features in the embodiments of the present application and the embodiments can be combined with each other.

[0055] The embodiment of the present application provides a multi-process index allocation method, which is used for index allocation in a multi-process scenario. The index is used to realize fast data access, and the mapping relationship between a key identifier and a data position is established to improve data retrieval efficiency. The allocation of the index can be applied to database management systems, file systems, network protocol stacks, cache systems and other aspects. For example, in the field of network data processing, especially in the application scenario of DPU (Data Processing Unit), it is necessary to maintain millions or even tens of millions of concurrent network sessions, each session corresponding to a session table item. These table items are organized and managed through the index. Each process needs independent resource space to ensure stability, but needs to share some key resources (such as session tables) to realize collaborative work. When multiple processes operate on the index resource at the same time, a complex synchronization mechanism is needed to ensure data consistency and avoid problems such as repeated allocation and access conflicts. For example, when a process abnormally exits, the index resource occupied by the process needs to be recycled in time, otherwise resource leakage will occur, affecting the overall capacity of the system. The embodiment of the present application can release and recycle the index resource by determining the state (online or offline) of the process, or directly release the index entry corresponding to the index after any process reads and uses the index, thereby realizing reasonable allocation of index resources in a multi-process scenario.

[0056] Figure 1 is a flowchart of a multi-process index allocation method provided by the embodiment of the present application, as shown in Figure 1 The multi-process index allocation method comprises the following steps:

[0057] S1, after the first process is started, it is judged whether the index pool exists, wherein the index pool is configured in the shared memory, including: an index pool management module and a plurality of index blocks;

[0058] The shared memory refers to a large-capacity memory that can be accessed by different central processing units (CPUs) in a multi-processor computer system; when the shared memory is created, it is necessary to ensure that the shared memory is exclusively available for running software and is not affected by other software, and after the shared memory is created, the address information of the shared memory is returned, and the address information (address ID) of the shared memory is transmitted to each process as a process parameter, so that each process can access the shared memory in real time according to the address information of the shared memory, and initiate a data reading / writing request for the shared memory.

[0059] In the embodiment of the application, the index pool comprises an index pool management module and a plurality of index blocks; each index block can comprise a plurality of index entries for storing indexes; the index pool management module comprises an index management header and a process management header, the index management header comprises a bitmap, the bitmap comprises a plurality of bits, each bit is marked as free (for example, 0) or occupied (for example, 1), and the process management header comprises a plurality of process identifiers, the plurality of bits correspond to the plurality of process identifiers one by one; the process identifier (or process ID) is a logical number (for example, ID 0, ID 1, ID 2, and the like) allocated by the index pool management module, which is used to uniquely identify a registered process instance in the system.

[0060] After the first process is started, the embodiment of the application further comprises that the first process acquires a memory configuration file, and judges whether the index pool exists according to the memory configuration file, wherein the memory configuration file comprises identification information of the index pool; specifically, after the first process acquires the memory configuration file, the first process can extract the identification information of the index pool included in the memory configuration file by analyzing the acquired memory configuration file, and then verify the identification information of the index pool to determine whether the index pool configured in the shared memory exists in the memory.

[0061] The identification information of the index pool is, for example, an shmid generated by a shmget system call, the shmid is a unique identifier (that is, the identification information of the index pool) for applying for or acquiring a shared memory segment, and the identification information of the index pool is used as a unique identifier of the shared memory during inter-process communication, so as to ensure that different processes can find the same shared resource.

[0062] The embodiment of the application verifies and queries by using the identification information of the index pool, if the shmid returned by the query result is valid, it is determined that the index pool has been created, and if the shmid returned by the query result is invalid, it is determined that the index pool has not been created; accordingly, if the index pool does not exist, the first process creates and initializes the index pool in the shared memory.

[0063] The creating and initializing the index pool refers to partitioning the index pool to obtain the index pool management module and multiple index blocks, and before the index pool is initialized, the embodiment of the application comprises: parsing a memory configuration file, and extracting configuration parameters, the configuration parameters at least comprising a total number of index entries and a number of corresponding index entries in a single index block;

[0064] The configuration of the total number of index entries in the memory configuration file is, for example, "em_session_num": 4194304 / / 4M entries, that is, the total number of index entries is 4M session entries; and the configuration of the number of corresponding index entries in a single index block in the memory configuration file is, for example, "block_index_num": 1024, that is, the number of corresponding index entries in a single index block is 1024; the number of index blocks can be determined by the total number of index entries and the number of corresponding index entries in a single index block, for example, the number of index blocks = ceil(4M / 1024) = 4096 index blocks; the total number of index entries and the number of corresponding index entries in a single index block can be determined according to actual application requirements, and the embodiment of the application does not limit this.

[0065] S2, if the index pool exists, the first process obtains a process identifier from the index pool management module, creates a state storage unit according to the process identifier, and obtains an index block from the index pool, wherein the state storage unit is configured in the shared memory and is used for storing online or offline state information of the first process for the second process to identify;

[0066] In the embodiment of the application, the first process or the second process is only used to distinguish between processes, and is not used to limit the prior or subsequent order of the processes; for example, the first process can be a prior process, and the second process can be a subsequent process; for example, the first process can also be a subsequent process, and the second process can be a prior process which is restored online after being offline; for example, the first process or the second process can also be a concurrent independent process.

[0067] After the first process is started, the first process obtains a process identifier from the index pool management module, comprising: the first process applies for a process identifier from the index pool management head; the index pool management head traverses a bitmap to find a bit marked as idle; if the index pool management head finds a bit marked as idle, the process identifier corresponding to the bit marked as idle is configured to the first process from the process management head, and the bit corresponding to the process identifier is marked from idle to occupied.

[0068] After the first process starts, it requests a process identifier (such as ID0, ID1, ..., ID7) from the index pool management head. The present invention describes using the index pool management head to traverse the bitmap and find bits marked as free. (See reference...) Figure 2 The diagram shows a reference illustration of the bitmap corresponding to the process identifier. When the bit of the bitmap corresponding to the process identifier is 0, the process identifier is marked as idle. At this time, the idle process identifier can be configured to the first process from the process management header. After the configuration is completed, the process management header is updated, that is, the bit corresponding to the process identifier is marked from idle to occupied, and the bit of the bitmap corresponding to the allocated process identifier is marked as 1. When the bit of the bitmap is 1, the corresponding process identifier is in the allocated state and is marked as occupied.

[0069] If all process identifiers are in an assigned state, it is necessary to further confirm whether the processes corresponding to the assigned process identifiers are online. If any process goes offline due to an anomaly, the resources it occupies need to be released. In this embodiment of the invention, the process identifiers and index blocks corresponding to the processes corresponding to all assigned process identifiers are online and the process identifiers and index blocks corresponding to the processes currently in an offline state are reclaimed.

[0070] Specifically, the embodiments of the present invention further include: if the index pool management head does not find any bits marked as free, then traverse the bits marked as occupied, and use the process identifier corresponding to the bit marked as occupied to identify the online or offline status information of the corresponding process from the state storage unit of the corresponding process; if the corresponding process is identified as being offline, then configure the process identifier corresponding to the bit marked as occupied to the first process from the process management head; if the corresponding process is identified as being online, then repeat the steps of traversing the bits marked as occupied and using the process identifier corresponding to the bit marked as occupied to identify the online or offline status information of the corresponding process from the state storage unit of the corresponding process, until all bits marked as occupied in the bitmap have been traversed.

[0071] In this embodiment of the invention, when any process successfully applies for and obtains a process identifier, a state storage unit is created based on the process identifier. The state storage unit is configured in shared memory to store the online or offline state information of the first process for identification by the second process. When the first process starts, it stores online state information in its state storage unit when creating the state storage unit based on the process identifier. When the first process exits, it stores offline state information in its state storage unit based on the process identifier of the first process.

[0072] According to the process identifier, a state storage unit is created, including: after any process obtains a process identifier, a process management handle is obtained according to the process identifier, a 1B-sized heartbeat detection shared memory is created according to the process identifier, and the process corresponding to the process identifier is linked to the heartbeat detection shared memory by using a shmat (Linux shared memory mapping) function; each state information shm_nattch (Linux shared memory attachment counter) corresponding to the process identifier is traversed by using a shmctl function, and whether the current process corresponding to the process identifier is online is determined based on the state information shm_nattch; if it is identified that the corresponding process is in an offline state, the process identifier corresponding to the bit marked as occupied is configured to the first process from the process management header; correspondingly, if it is identified that the corresponding process is in an online state, the steps of traversing the bit marked as occupied and identifying the online or offline state information of the corresponding process from the state storage unit of the corresponding process by using the process identifier corresponding to the bit marked as occupied are repeatedly performed until the bit marked as occupied in the bitmap is traversed.

[0073] After each process obtains a process identifier, a 1B-sized state storage unit (heartbeat detection shared memory) is created, and the process is linked to the 1B-sized micro memory segment by calling a shmat function; when the process is normally running, the link is maintained, and when the process exits (regardless of normal or crash), the operating system automatically releases the link; the administrator views shm_nattach (link number) by using a shmctl system call, and if it is found that the link number is 0, it is determined that the current process corresponding to the process identifier is in an offline state, and all resources of the process can be safely recycled.

[0074] S3, when the second process obtains an index block from the index pool, and there is no unallocated index block in the index pool, the second process identifies online or offline state information of the first process from the state storage unit of the first process;

[0075] In the embodiment of the application, when the second process applies for an index block to the index pool, the index pool preferentially allocates an unallocated index block to the second process, and if there is no unallocated index block, the index pool traverses the bit marked as occupied by using an index pool management header, and identifies online or offline state information of the first process from the state storage unit of the first process by using the process identifier of the first process corresponding to the bit marked as occupied; if it is identified that the corresponding first process is in an online state, the steps of traversing the bit marked as occupied and identifying online or offline state information of the first process from the state storage unit of the first process by using the process identifier of the first process corresponding to the bit marked as occupied are repeatedly performed until the bit marked as occupied in the bitmap is traversed.

[0076] Before allocating an index block to the second process, this embodiment of the invention initializes a Linux semaphore, uses the Linux semaphore, searches for an unallocated index block from the index pool, allocates the unallocated index block to the second process, and then releases the Linux semaphore.

[0077] The Linux semaphore is used to synchronize and mutually exclude index block requests among multiple processes. Specifically, the Linux semaphore is a counter used to control access to shared resources by multiple processes. The index pool management module initializes the Linux semaphore. Using the Linux semaphore can, for example, decrease its value. Assuming the total value of the Linux semaphore is 1 (or other values ​​in other implementations), after using the semaphore, the total value becomes 0, which can be considered process blocking. After allocating the unallocated index block to the second process, the Linux semaphore is released, i.e., its value is increased. At this point, the total value of the Linux semaphore is 1. When the total value of the Linux semaphore is not 0, subsequent processes can request index blocks. Thus, by using the Linux semaphore, it is ensured that only one process can operate the index pool management module at any given time, guaranteeing data consistency and integrity. Combined with the aforementioned state storage unit to identify its online or offline status information, an optimized strategy of simultaneous request and reclamation among multiple processes is implemented.

[0078] The index block includes an index block with an index and an empty index block. The index block with an index is an index block that stores an index, and the empty index block is an index block that does not store an index. When the process of this embodiment of the invention requests an index block, it can simultaneously request an index block with an index and an empty index block, so that after reading the index from the index block with an index, the corresponding index can be directly stored into the empty index block.

[0079] The free index block resources are determined based on the number of indexes read. If all indexes in the index block have been read and used, the entire index block is used as the free index block resources. If only some indexes in the index block have been read and used, the index entries corresponding to the indexes that have been read and used are used as the free index block resources. This method greatly improves the flexibility of index resource allocation.

[0080] S4. If the first process is offline, the second process retrieves the index block that has been allocated to the first process;

[0081] If it is confirmed that the first process is offline, then the process ID and index block corresponding to the first process are reclaimed for use by the second process.

[0082] For resource recycling of the first process, in addition to recycling the first process by identifying its online or offline state information according to the state storage unit before the first process is offline due to an exception, the embodiment of the application can also recycle the index block resource through the aging mechanism built in the DPU, specifically, after the second process is started, the index block configured by the first process is subjected to an aging test to determine whether the index entry reading out the index in the index block is hit by traffic within a preset interval threshold; when the index entry is not hit by traffic within the preset interval threshold, the index entry is released as the idle index block resource, and the index corresponding to the index entry is recycled and stored in the index block configured by the second process.

[0083] That is, the index used by the first process can be released after the second process is started based on the aging mechanism of the DPU by determining whether the index entry reading out the index in the index block is hit by traffic within a preset interval threshold, the index entry being hit by traffic means that the feature (five-tuple) of a data packet (i.e., the aforementioned traffic) is successfully matched with the matching key of an existing index entry in the DPU hardware session table; if the index entry is not hit by traffic within the preset interval threshold, the index entry can be considered as an object to be aged and deleted, and the index entry is directly released as the idle index block resource and is configured to the second process as the idle index block resource, so that the index used by the first process can also be released by the second process, and the flexibility of index resource allocation is improved.

[0084] The multi-process index allocation method of the embodiment of the application has the following advantages compared with the prior art:

[0085] 1. By initializing a shared memory index pool, a shared memory is created to store index resources, and multiple processes can obtain indexes in batches through the shared index pool, and the index block resource corresponding to the index used by any process can be released and used by other processes, so that efficient allocation of indexes among multiple processes is realized;

[0086] 2. By creating a state storage unit for each process to determine the current state of each process, when the current process corresponding to the process identifier is determined to be offline, the process identifier and the index block are recycled for use by other processes, so that the flexibility of index resource allocation is greatly improved;

[0087] 3. The index block resource is recycled through the aging mechanism built in the DPU, and if the index entry in the index block applied by any process is not hit by traffic within a preset interval threshold, the index entry is directly released for use by other processes, so that the flexibility of index resource allocation is further improved;

[0088] 4. In the case of multiple processes applying for index blocks, a Linux semaphore is introduced as a reference to control the synchronization and mutual exclusion of the application of index blocks among multiple processes, ensuring that only one process can operate the index pool management module at any time, guaranteeing data consistency and integrity, and cooperating with the aforementioned identification of online or offline state information according to the state storage unit to realize the optimization strategy of applying and recycling simultaneously among multiple processes.

[0089] On the basis of the above-mentioned embodiments, as an implementation of the method shown in the above-mentioned Figure 1 The present application provides an embodiment of a multi-process index allocation device, which corresponds to the method embodiment shown in the above-mentioned Figure 1 The device can be applied to various electronic devices, as shown in the above-mentioned Figure 3 The multi-process index allocation device includes:

[0090] The judgment module 100 is configured to judge whether the index pool exists after the first process is started, wherein the index pool is configured in the shared memory and includes an index pool management module and multiple index blocks.

[0091] The first acquisition module 200 is configured to acquire the process identifier from the index pool management module and create a state storage unit according to the process identifier if the index pool exists, and acquire the index block from the index pool, wherein the state storage unit is configured in the shared memory and is used to store the online or offline state information of the first process for the identification of the second process.

[0092] The identification module 300 is configured to identify the online or offline state information of the first process from the state storage unit of the first process when the second process acquires the index block from the index pool and there is no unallocated index block in the index pool.

[0093] The second acquisition module 400 is configured to acquire the index block allocated to the first process if the first process is in the offline state.

[0094] The above-mentioned modules in the multi-process index allocation device can be all or partially realized by software, hardware and their combinations. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to the above-mentioned modules.

[0095] The multi-process index allocation device provided by the embodiment of the present application can execute the multi-process index allocation method provided by the above-mentioned embodiment, has the corresponding functional steps and beneficial effects of the multi-process index allocation method provided by the above-mentioned embodiment, and specific details can be referred to the embodiment of the multi-process index allocation method. The embodiment of the present application will not be described here again.

[0096] In an exemplary embodiment, a computer device, which can be a terminal, has an internal structure diagram as shown in Figure 4 The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device, such as a network interface card, is configured to communicate with external terminals in a wired or wireless manner. The wireless manner can be achieved through WIFI, mobile cellular network, near field communication (NFC) or other technologies. The computer program is executed by the processor to implement a congestion control method. The display unit of the computer device is configured to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.

[0097] Those skilled in the art can understand that Figure 4 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0098] In an exemplary embodiment, a chip is provided, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the method in any one of the above-mentioned embodiments.

[0099] In one example embodiment, a network interface card is provided, comprising the chip in any one of the above embodiments and a plurality of interfaces, the chip communicates with the outside through the interfaces.

[0100] In one embodiment, a computer device is also provided, comprising a processor, the chip in any one of the above embodiments or the network interface card in any one of the above embodiments, the chip or the network interface card is configured to dispatch a packet to the processor or the chip or the network interface card itself to process, and the processor is configured to process the packet dispatched by the chip or the network interface card.

[0101] In one embodiment, a computer readable storage medium is provided, having stored thereon a computer program, which when executed by a processor, implements the steps in any one of the above method embodiments.

[0102] In one embodiment, a computer program product is provided, comprising a computer program, which when executed by a processor, implements the steps in any one of the above method embodiments.

[0103] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. In the embodiments provided in the present application, any reference to memory, database or other medium can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.

[0104] In the specification provided herein, a large number of specific details are described. However, it can be understood that the embodiments of the present application can be practiced without these specific details. In some examples, well-known methods, structures and techniques are not shown in detail in order not to obscure the understanding of the present specification.

[0105] Similarly, it is to be understood that the embodiments of the application can include hardwired and / or program modules and that the various embodiments of the application can be implemented by computer, electrical or hybrid circuits intended for use stand-alone, or can be implemented by a combination of these forms. In this case, at least one software program can be loaded into memory and, once it is executed by processor(s), it can cause the processing system to perform one or more of the methods described herein. Similarly, it is to be understood that, for brevity and clarity, the above description has focused on the various aspects of the application, and that the various features of the application have sometimes been grouped together in a single embodiment, figure, or description of related features. Other embodiments of the application will be readily apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the application can be practiced otherwise than as specifically described without departing from the spirit and scope of the application. The present application is intended to cover any and all adaptations or variations of various embodiments of the application and includes all features available from and combinations of elements found throughout the specification, appended claims, and accompanying drawings. It is to be understood that the above description is intended to be illustrative and not restrictive. Many other embodiments will be apparent to those of skill in the art upon reading the above description and the application is therefore intended to cover any variations that fall within the scope of the application.

Claims

1. A multi-process index allocation method, characterized in that, The method includes: After the first process starts, it checks whether the index pool exists. The index pool is configured in shared memory and includes: an index pool management module and multiple index blocks. If the index pool exists, the first process obtains the process identifier from the index pool management module, creates a state storage unit based on the process identifier, and obtains an index block from the index pool. The state storage unit is configured in shared memory to store the online or offline status information of the first process for the second process to identify. The index pool management module includes an index management header and a process management header. The index management header includes a bitmap, which contains multiple bits, each marked as free or occupied. The process management header includes multiple process identifiers, with each bit corresponding one-to-one with the process identifier. The first process obtains its process identifier from the index pool management module, including: The first process requests a process identifier from the index pool management head; The index pool management head traverses the bitmap to find bits marked as free; If the index pool management head finds a bit marked as free, the process identifier corresponding to the bit marked as free is configured to the first process from the process management head, and the bit corresponding to the process identifier is marked as occupied from free. When the second process retrieves an index block from the index pool, and there are no unallocated index blocks in the index pool, the second process identifies its online or offline status information from the state storage unit of the first process. The step of identifying the online or offline status information of the first process from its state storage unit when the second process retrieves an index block from the index pool and there are no unallocated index blocks in the index pool includes: When a second process requests an index block from the index pool, the index pool prioritizes allocating unallocated index blocks to the second process. If no unallocated index blocks are available, the index pool traverses the bits marked as occupied through the index pool management header and uses the process identifier of the first process corresponding to the marked bit to identify its online or offline status information from the state storage unit of the first process. The unallocated index blocks are the free index block resources, which include index blocks and empty index blocks. If all indexes in an index block have been read and used, the entire index block is used as the free index block resource. If only some indexes in an index block have been read and used, the index entries corresponding to the indexes that have been read and used are used as the free index block resource. If the first process corresponding to it is identified as being online, the steps of traversing the bits marked as occupied and using the process identifier of the first process corresponding to the bit marked as occupied to identify its online or offline status information from the state storage unit of the first process are repeated until all the bits marked as occupied in the bitmap are traversed. If the first process is offline, the second process retrieves the index block that has been allocated to the first process.

2. The multi-process index allocation method according to claim 1, characterized in that, The method further includes: The first process obtains the memory configuration file and determines whether the index pool exists based on the memory configuration file. The memory configuration file includes the identification information of the index pool.

3. The multi-process index allocation method according to claim 2, characterized in that, The step of determining whether the index pool exists based on the memory configuration file includes: Parse the obtained memory configuration file and extract the identification information of the index pool included in the memory configuration file; Verify the identification information of the index pool to determine whether the index pool configured in shared memory is included in memory.

4. The multi-process index allocation method according to claim 1, characterized in that, The method further includes: If the index pool does not exist, the first process creates and initializes the index pool in shared memory.

5. The multi-process index allocation method according to claim 1, characterized in that, The first process obtains the process identifier from the index pool management module, and also includes: If the index pool management head does not find any bits marked as free, it traverses the bits marked as occupied and uses the process identifier corresponding to the bit marked as occupied to identify the online or offline status information of the corresponding process from the status storage unit of the corresponding process. If the corresponding process is identified as being offline, the process identifier corresponding to the bit marked as occupied is configured to the first process from the process management header; If the corresponding process is identified as being online, the process of traversing the bits marked as occupied and using the process identifier corresponding to the bit marked as occupied to identify the online or offline status information of the corresponding process from the state storage unit of the corresponding process is repeated until all the bits marked as occupied in the bitmap are traversed.

6. The multi-process index allocation method according to claim 1, characterized in that, The method further includes: When the first process starts and creates the state storage unit according to the process identifier, it stores online status information in its state storage unit. When the first process exits, its offline status information is stored in its status storage unit according to the process identifier of the first process.

7. A multi-process index allocation device, characterized in that, include: The judgment module is configured to determine whether the index pool exists after the first process starts. The index pool is configured in shared memory and includes: an index pool management module and multiple index blocks. The first acquisition module is configured to, if the index pool exists, obtain a process identifier from the index pool management module, create a state storage unit based on the process identifier, and obtain an index block from the index pool. The state storage unit is configured in shared memory to store the online or offline status information of the first process for identification by the second process. The identification module is configured to identify the online or offline status information of the first process from its state storage unit when the second process obtains an index block from the index pool and there are no unallocated index blocks in the index pool. The second acquisition module is configured to acquire the index block that has been allocated to the first process if the first process is offline.

8. A chip comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A network interface card, characterized in that, It includes the chip and interface as described in claim 8, wherein the chip communicates externally through the interface.

10. A computing device, characterized in that, It includes a processor, the chip as described in claim 8, or the network interface card as described in claim 9, wherein the chip or the network interface card is used to schedule packets to the processor or the chip or the network interface card itself for processing, and the processor is used to process the packets scheduled by the chip or the network interface card.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that are loaded and executed by a processor to perform the operations described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Memory management method and device for multiprocess system

    CN103425592A

  • Memory pool implementation method based on shared memory

    CN116225738A

  • Memory allocation method and device, computer equipment and storage medium

    CN116450328A

  • Shared memory data processing method, shared memory, electronic equipment, storage medium and program product

    CN118819891A