Multi-thread-oriented table item index efficient management method and system, terminal and medium

By initializing and managing global index pools and thread index caches in a multi-threaded environment, the application and release process of entry indexes is optimized, and the inefficiency and security problems in the existing technology are solved, and efficient entry index management is achieved.

CN120256086APending Publication Date: 2025-07-04CORE YUNSHENG (HANGZHOU) ELECTRONIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510178381.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-18
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

The existing multithreaded table entry index management method is inefficient and difficult to apply in large-capacity table entry requirements scenarios. The efficiency further decreases during concurrent operations, and it is difficult to ensure concurrency security between threads.

Method used

When the business software is started, the global index pool and thread index cache are initialized, and the thread index cache is preferred to the entry index index. If it is insufficient, the global index pool resources will be applied in batches; when it is released, it will be recycled to the thread index cache first, and after reaching the upper limit, it will be released in batches to the global index pool; when it is exited, all resources will be released.

Benefits of technology

In multi-threaded concurrency scenarios, improve table entry index management efficiency, ensure security, reduce lock time complexity, and improve system concurrency performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256086A_ABST
    Figure CN120256086A_ABST
Patent Text Reader

Abstract

The invention provides a multi-thread-oriented table item index efficient management method and system, a terminal and a medium. The method comprises the following steps: performing initialization operation on a global index pool and a thread index cache of each working thread when service software is started; when a working thread needs to apply for the table item index, firstly, the table item index is applied in the thread index cache corresponding to the working thread, and if an available table item index cannot be applied, table item index batch application operation is executed on the global index pool; when a working thread needs to release the table item index, firstly recovering the table item index to a corresponding thread index cache, and if the thread index cache reaches a recovery upper limit, executing table item index batch release operation on the global index pool; and when the business software exits, releasing the index cache of each thread and all memory resources in the global index pool. According to the method and the device, the table entry index management efficiency is further improved while the table entry index can be safely accessed in a multi-thread concurrent scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer network communication, and particularly to an efficient management method, system, terminal and medium for table item indexing for multi-threading. Background Art

[0002] During the design and development of network service software, there are usually operations of adding, deleting, modifying and querying table items, which requires the service software to maintain the index of table items, so as to find the corresponding table items for operations through the index. Typically, such as the forwarding table / routing table that needs to be maintained in traditional network switch / router software, and in the hardware acceleration application scenario based on DPU (Data Processing Unit), the offloading flow table that needs to be maintained in the driver software, etc.

[0003] There is a one-to-one correspondence between the index of table items and the table items, and it is also the "handle" for the "upper layer" software to operate on the corresponding table items. Therefore, the efficiency and security of its allocation and release are also key parts that need to be considered in the design of service software. Generally, the bitmap method can be used to manage the index of table items, that is, when allocating the table item index, traverse to find the free bit in the bitmap, and set the corresponding bit to 1 after allocation. When releasing the table item index, set the corresponding bit to 0. It is easy to see that the bitmap method needs to globally search for an available bit as the table item index allocation each time. Even with local bitmap search acceleration, it is impossible to avoid global search for free bits in extreme cases. Therefore, as the number of table items increases, the management efficiency of the bitmap method for table items will gradually decrease. It is not a method with a definite time complexity and will become a potential bottleneck in the operation of service software, and ultimately it is very difficult to be directly applied in scenarios with large-capacity table item requirements. In addition, if multi-threaded concurrent operations of the "upper layer" software are considered, locks need to be added to ensure the security of table item index concurrency between threads, and its execution efficiency will further decrease. Summary of the Invention

[0004] In view of the above-mentioned disadvantages of the prior art, the purpose of the present invention is to provide an efficient management method, system, terminal and medium for table item indexing for multi-threading, which is used to solve technical problems such as low management efficiency of existing table item indexing management methods for multi-threading.

[0005] To achieve the above and other related objectives, the present invention provides an efficient management method for table entry indexing for multi-threading. The method includes: when the business software starts, initializing the global index pool and the thread index caches of each working thread; wherein, each thread index cache is a fast access channel between each working thread and the global index pool; when a working thread needs to apply for a table entry index, applying for the table entry index in the thread index cache corresponding to the working thread, and when no available table entry index can be applied for in the corresponding thread index cache, performing a batch application operation for table entry indexes on the global index pool; when a working thread needs to release a table entry index, recycling the table entry index to be released to the thread index cache corresponding to the working thread, and when the corresponding thread index cache has reached the recycling limit, performing a batch release operation for table entry indexes on the global index pool; when the business software exits, releasing all the memory resources in each thread index cache and the global index pool.

[0006] In an embodiment of the present invention, the global index pool is divided into an index lock, an unallocated area, and an allocated area.

[0007] In an embodiment of the present invention, the initialization operation of the global index pool and the thread index caches of each working thread includes: creating a global index pool table entry index management object based on configuration information, and respectively initializing the index lock, the unallocated area, and the allocated area in the global index pool; initializing the corresponding thread index cache in each working thread.

[0008] In an embodiment of the present invention, the batch application operation for table entry indexes in the global index pool includes: locking the batch application operation for table entry indexes by setting the index lock to a locked state; preferentially batch applying for available table entry indexes from the unallocated area, and if no available table entry indexes can be provided in the unallocated area, continuing to apply for the table entry index values that the working thread has not applied for in the allocated area.

[0009] In an embodiment of the present invention, while batch applying for table entry indexes, the working thread records the number of all table entry indexes applied for in this batch application operation for table entry indexes in the corresponding thread index cache.

[0010] In an embodiment of the present invention, the batch release operation for table entry indexes includes: recycling all the table entry indexes in the thread index cache corresponding to the working thread that needs to release the table entry index to the allocated area in the global index pool for continuing to recycle the table entry indexes that the working thread has not released to the corresponding thread index cache.

[0011] In an embodiment of the present invention, the unallocated area and the allocated area perform the batch application operation and the batch release operation of the entry index under the condition of O(1) time complexity, so as to reduce the performance loss of the index lock itself.

[0012] To achieve the above object and other related objects, the present invention provides a high-efficiency management system for entry index for multi-threading, and the system includes: an initialization module, configured to perform initialization operations on the global index pool and the thread index cache of each working thread when the business software is started; an entry index application module, configured to, when a working thread needs to apply for an entry index, apply for an entry index in the thread index cache corresponding to the working thread, and when no available entry index can be applied for in the corresponding thread index cache, perform a batch application operation of the entry index on the global index pool; an entry index release module, configured to, when a working thread needs to release an entry index, recycle the entry index to be released to the thread index cache corresponding to the working thread, and when the corresponding thread index cache has reached the recycling limit, perform a batch release operation of the entry index on the global index pool; a resource release module, configured to release all memory resources in each thread index cache and the global index pool when the business software exits.

[0013] To achieve the above object and other related objects, the present invention provides an electronic terminal, including: one or more memories and one or more processors; the one or more memories are configured to store computer programs; the one or more processors are connected to the memories and are configured to run the computer programs to execute the high-efficiency management method for entry index for multi-threading.

[0014] To achieve the above object and other related objects, the present invention provides a computer-readable storage medium storing a computer program, and the computer program executes the method when being run by one or more processors.

[0015] As described above, the present invention is a high-efficiency management method, system, terminal and medium for entry index for multi-threading, and has the following beneficial effects: the present invention performs initialization operations on the global index pool and the thread index cache of each working thread when the business software is started; when a working thread needs to apply for an entry index, first apply for an entry index in the thread index cache corresponding to the working thread, and if no available entry index can be applied for, perform a batch application operation of the entry index on the global index pool; when a working thread needs to release an entry index, first recycle the entry index to the corresponding thread index cache, and if the thread index cache has reached the recycling limit, perform a batch release operation of the entry index on the global index pool; when the business software exits, release all memory resources in each thread index cache and the global index pool. The present invention further improves the management efficiency of the entry index while ensuring safe access to the entry index in a multi-threaded concurrent scenario. Brief Description of the Drawings

[0016] Figure 1 It is a schematic flowchart showing the method for efficiently managing table item indexes for multi-threading in an embodiment of the present invention.

[0017] Figure 2 It is a schematic diagram showing the scenario of efficiently managing table item indexes for multi-threading in an embodiment of the present invention.

[0018] Figure 3 It is a schematic structural diagram showing the system for efficiently managing table item indexes for multi-threading in an embodiment of the present invention.

[0019] Figure 4 It is a schematic structural diagram showing an electronic terminal in an embodiment of the present invention. Detailed Embodiments

[0020] The following describes the embodiments of the present invention through specific specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, without conflict, the following embodiments and the features in the embodiments can be combined with each other.

[0021] It should be noted that in the following description, reference is made to the accompanying drawings, which describe several embodiments of the present invention. It should be understood that other embodiments can also be used, and mechanical composition, structure, electrical, and operational changes can be made without departing from the spirit and scope of the present invention. The following detailed description should not be considered restrictive, and the scope of the embodiments of the present invention is only defined by the claims of the published patent. The terms used here are only for describing specific embodiments and are not intended to limit the present invention. Spatially related terms, such as "upper", "lower", "left", "right", "below", "beneath", "lower part", "above", "upper part", etc., can be used in the text to facilitate the description of the relationship between one element or feature shown in the drawings and another element or feature.

[0022] Throughout the specification, when it is said that a part is "connected" to another part, this includes not only the case of "direct connection", but also the case of "indirect connection" with other elements placed therebetween. Additionally, when it is said that a certain part "includes" a certain component, unless there is a particularly contrary record, it does not exclude other components, but means that other components can also be included.

[0023] The first, second, third, etc. terms mentioned herein are used to illustrate various parts, components, regions, layers, and / or segments, but are not limited thereto. These terms are only used to distinguish a part, component, region, layer, or segment from other parts, components, regions, layers, or segments. Therefore, the first part, component, region, layer, or segment described below can refer to the second part, component, region, layer, or segment without exceeding the scope of the present invention.

[0024] Furthermore, as used herein, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context indicates otherwise. It should be further understood that the terms "comprising", "including" indicate the presence of the stated features, operations, elements, components, items, kinds, and / or groups, but do not exclude the presence, occurrence, or addition of one or more other features, operations, elements, components, items, kinds, and / or groups. The terms "or" and "and / or" used herein are interpreted as inclusive, or meaning any one or any combination. Thus, "A, B, or C" or "A, B, and / or C" means "any one of the following: A; B; C; A and B; A and C; B and C; A, B, and C". An exception to this definition occurs only when the combination of elements, functions, or operations is inherently mutually exclusive in some way.

[0025] The present invention provides an efficient management method for table entry indexing for multi-threading, which performs initialization operations on the global index pool and the thread index caches of each working thread when the business software is started; when a working thread needs to apply for a table entry index, it first applies for a table entry index in the thread index cache corresponding to the working thread, and if an available table entry index cannot be applied for, it performs a batch application operation for table entry indexes on the global index pool; when a working thread needs to release a table entry index, it first reclaims the table entry index to the corresponding thread index cache, and if the thread index cache reaches the recycling upper limit, it performs a batch release operation for table entry indexes on the global index pool; when the business software exits, it releases all the memory resources in each thread index cache and the global index pool. The present invention further improves the efficiency of table entry index management while ensuring safe access to table entry indexes in a multi-threaded concurrent scenario.

[0026] The following will be described in detail with reference to the accompanying drawings for the embodiments of the present invention, so that those skilled in the technical field of the present invention can easily implement it. The present invention can be embodied in many different forms and is not limited to the embodiments described herein.

[0027] As Figure 1 shows a schematic flowchart of an efficient management method for table entry indexing for multi-threading in an embodiment of the present invention.

[0028] The method includes:

[0029] Step S1: When the business software starts, initialize the global index pool and the thread index caches of each working thread.

[0030] Specifically, the present invention involves multiple working threads, and each working thread is correspondingly provided with a thread index cache (index cache); the thread index cache records the set of table item indexes that the corresponding working thread has recently accessed frequently. Each thread index cache serves as a fast access channel between each working thread and the global index pool, which is used to increase the hit rate of CPU table item index access, effectively reduce the occurrence of the situation where the required data is not in the CPU cache, and improve the access efficiency of table item indexes.

[0031] In one embodiment, as Figure 2 , the global index pool (Index pool) is divided into an index lock (indexlock), an unallocated zone (unalloced zone), and an allocated zone (alloced zone).

[0032] The unalloced zone is used for the first allocation application of table item indexes and is also the area where table item indexes are preferentially allocated for application; when a working thread needs to apply for a table item index, it will first check whether there are available table item indexes in the unalloced zone. As long as there are available table item indexes in the unalloced zone, they will be allocated from this area. This reflects a principle of preferential allocation, preferentially using new and unallocated table item index resources until all the table item indexes in this area are allocated, that is, exhausted.

[0033] The alloced zone is a supplement to the unalloced zone. The table item indexes it stores come from the table item indexes that have been applied and used. These indexes are released and recycled after use and re-enter the alloced zone for re-allocation. When the table item indexes in the unalloced zone are allocated and exhausted and cannot meet the new application requirements, the system will turn to the alloced zone for the allocation application of table item indexes. The system will allocate available table item indexes from the alloced zone until the table item indexes in the alloced zone are also allocated. This mechanism ensures the full utilization of table item index resources.

[0034] The index lock is a thread-safe lock at the Index pool level and is a key guarantee in a multi-threaded concurrent environment. When multiple threads access the resources in the global index pool simultaneously, the index lock ensures that only one thread can access or modify the index resources at the same time, avoiding data inconsistency or conflict issues that may be caused by multiple threads operating simultaneously and guaranteeing the security of multi-threaded concurrent access to index resources.

[0035] In one embodiment, the initialization operation of the global index pool and the thread index caches of each working thread includes:

[0036] Create a global index pool entry index management object based on the configuration information, and initialize the index lock, unallocated area, and allocated area in the global index pool respectively;

[0037] Specifically, first create a global index pool entry index management object according to the configuration information. When the business software starts, the main process will attempt to read and parse the configuration file to obtain relevant information from the configuration file. If the configuration file does not exist or the reading fails, the default initial configuration information will be adopted.

[0038] Then, initialize the important components in the global index pool, including the index lock, unallocated area, and allocated area. The specific methods include: creating and initializing the index lock, which serves as a thread-safe lock at the global index pool level and plays a guarantee role in a multi-threaded concurrent environment to prevent data inconsistency when multiple threads operate on the global index pool simultaneously. Initialize the unallocated area to prepare for storing new, unallocated table entry indexes, which is the main area for the first allocation of table entry indexes. Initialize the allocated area as a supplement after the resources in the unallocated area are exhausted and to prepare for storing the resources recovered from the released used table entry indexes.

[0039] Initialize the corresponding thread index cache in each working thread. Specifically, during the startup process of the business software, the main process is responsible for initiating each working thread and initializing the corresponding thread index cache in each working thread; the main purpose of initializing the thread index cache is to create a local data storage structure for the working thread to store the set of table entry indexes that the thread has recently accessed frequently to achieve fast access to the table entry indexes.

[0040] Step S2: When a working thread needs to apply for a table entry index, apply for the table entry index in the thread index cache corresponding to the working thread, and in the case where no available table entry index can be applied for in the corresponding thread index cache, perform a batch application operation for the table entry index on the global index pool.

[0041] Specifically, when a worker thread needs a table entry index, it first tries to find and apply for the required single table entry index from its corresponding thread index cache. If there are multiple table entry index application requirements, after obtaining one, it will then find and apply for the next single table entry index from its corresponding thread index cache until all table entry index applications are completed or the corresponding thread index cache cannot provide the required table entry index. This is because the thread index cache stores the set of table entry indexes that the worker thread has recently accessed frequently. This way of applying from the thread index cache is based on performance optimization considerations. When a worker thread executes a task, it often has a higher access frequency to certain table entry indexes. Storing these frequently used table entry indexes in its own index cache enables subsequent lookups to be performed quickly, avoiding direct interaction with the more complex global index pool and improving access efficiency. If no available table entry index can be found in the index cache corresponding to the worker thread, the worker thread will initiate a bulk application operation for the global index pool (index pool) object.

[0042] In one embodiment, the performing a bulk application operation for table entry indexes in the global index pool includes:

[0043] Locking the current bulk application operation for table entry indexes by setting the index lock to the locked state; specifically, when a bulk application operation for table entry indexes needs to be performed in the global index pool, the index lock will first be set to the locked state to lock this bulk application operation. The purpose of this is to ensure thread safety in a multi-threaded environment and prevent data inconsistency or resource contention problems caused by multiple threads operating on the global index pool simultaneously. Only the thread that has acquired the lock can execute the subsequent table entry index application operation, and other threads need to wait for the lock to be released.

[0044] Prioritizing bulk application for available table entry indexes from the unallocated area, and if no available table entry indexes can be provided in the unallocated area, continuing to apply for the table entry indexes that the worker thread has not applied for in the allocated area; specifically, after successfully locking, it will prioritize bulk application for other table entry indexes that the worker thread has not applied for in the thread index cache from the unallocated area (unalloced zone). The unallocated area is specifically used to store new, unallocated table entry indexes, so resource acquisition will be prioritized from here during application. If the unallocated area cannot provide enough available table entry indexes, the system will turn to the allocated area (alloced zone) to bulk apply for other table entry indexes that the worker thread has not applied for in the unallocated area, and this process will continue until the available indexes in the alloced zone are exhausted.

[0045] In one embodiment, while batch-applying for item indexes, the worker thread records the number of all item indexes applied for in the current batch item index application operation in the corresponding thread index cache. Specifically, the number of indexes actually allocated for the current application operation is returned to the worker thread, so that the worker thread knows how many item indexes it has successfully applied for, for subsequent use.

[0046] Step S3: When a worker thread needs to release item indexes, the item indexes to be released are recycled to the thread index cache corresponding to the worker thread, and when the corresponding thread index cache has reached the recycling upper limit, a batch item index release operation is performed on the global index pool.

[0047] Specifically, when a worker thread needs to release item indexes, first, these item indexes to be released are sequentially recycled to the thread index cache corresponding to the worker thread. The purpose of doing this is to utilize the characteristics of the thread index cache to temporarily store the item indexes most recently used by the worker thread, because these indexes may be frequently used by the worker thread again in subsequent operations. Storing them in the index cache can improve subsequent access efficiency, which conforms to the principle of locality of the program. When the index cache of the worker thread has reached the recycling upper limit, it means that no more item indexes can be stored. At this time, it is necessary to perform a release operation on the item indexes stored in the index cache to avoid memory overflow or other performance problems. Therefore, the worker thread initiates a batch index release operation on the index pool object, releases all the item indexes in the index cache back to the global index pool, and then sequentially recycles the unreleased item indexes to the thread index cache corresponding to the worker thread until all item indexes are recycled. This can return the resources to the global index pool so that other worker threads can re-apply for use when needed, and it also helps with the reasonable management and recycling of system resources.

[0048] In one embodiment, the batch item index release operation includes: recycling all the item indexes in the thread index cache corresponding to the worker thread that needs to release item indexes to the allocated area in the global index pool, for continuing to recycle the unreleased item indexes of the worker thread to the corresponding thread index cache.

[0049] Specifically, these entry indexes are recycled to the allocated zone in the global index pool. The allocated zone is a place where entry indexes that have been previously applied for but then released and recycled are stored. As a resource storage area, it provides reusable resources for subsequent entry index applications. When performing a batch release operation of entry indexes, releasing the entry indexes in the thread index cache of the working thread to here can make these entry indexes become allocable resources again for other working threads to use in subsequent application operations.

[0050] In one embodiment, in a multi-threaded environment, to ensure the security of operations, an index lock is usually used. When performing an application or release operation of an entry index, the index lock needs to be set to the locked state first, and the lock is released after the operation is completed. If the time complexity of the operation is relatively high, the thread will hold the lock for a longer time, resulting in a longer waiting time for other threads for the lock, thereby affecting the concurrency performance of the system.

[0051] In this solution, the unallocated zone and the allocated zone perform batch application operations and batch release operations of entry indexes under the condition of O(1) time complexity. This means that regardless of the number of entry indexes stored in these zones, when a working thread initiates a batch application, the system can complete the application operation within a constant time. Similarly, when performing a batch release operation of entry indexes, it can also be completed under O(1) time complexity. This indicates that when releasing multiple entry indexes back to the unallocated zone or the allocated zone, the required time will not increase significantly with the increase in the number of released entry indexes. The thread can quickly complete the operation in the locked state, reducing the locking time, thereby reducing the performance loss of the index lock itself. This is very important for improving the concurrency performance of the system because it allows multiple threads to complete operations on index resources faster, reduces the performance overhead caused by waiting for the lock, enables the system to process multi-threaded concurrent operations more efficiently, and ensures the efficient operation of the system in a multi-threaded concurrent scenario.

[0052] Similar to the principle of the above embodiment, the present invention provides an efficient management system for entry indexes oriented to multi-threads.

[0053] The following provides specific embodiments in conjunction with the accompanying drawings:

[0054] As Figure 3 shows a schematic structural diagram of an efficient management system for entry indexes oriented to multi-threads in an embodiment of the present invention.

[0055] The system includes:

[0056] An initialization module 1, used to perform initialization operations on the global index pool and the thread index cache of each working thread when the business software is started;

[0057] The entry index application module 2 is used to apply for an entry index in the thread index cache corresponding to the working thread when a working thread needs to apply for an entry index, and perform a batch application operation of the entry index on the global index pool when no available entry index can be applied in the corresponding thread index cache;

[0058] The entry index release module 3 is used to recycle the entry index to be released to the thread index cache corresponding to the working thread when a working thread needs to release an entry index, and perform a batch release operation of the entry index on the global index pool when the corresponding thread index cache has reached the recycling limit;

[0059] The resource release module 4 releases all memory resources in each thread index cache and the global index pool when the business software exits.

[0060] Since the implementation principle of the efficient management system for entry indexes for multi-threads has been described in the foregoing embodiments, it will not be repeated here.

[0061] The efficient management method for entry indexes for multi-threads provided by the embodiments of the present invention can be implemented on the terminal side or the server side. As for the hardware structure of the electronic terminal, please refer to Figure 4 , which is an optional schematic diagram of the hardware structure of the electronic terminal 1000 provided by the embodiments of the present invention. The terminal 1000 may be a mobile phone, a computer device, a tablet device, a personal digital processing device, a factory background processing device, etc. The terminal 1000 includes: at least one processor 1001, a memory 1002, at least one network interface 10010, and a user interface 1009. Each component in the device is coupled together through a bus system 1005. It can be understood that the bus system 1005 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 1005 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, in Figure 4 all kinds of buses are labeled as the bus system.

[0062] Among them, the user interface 1009 may include a display, a keyboard, a mouse, a trackball, a click gun, a key, a button, a touchpad, or a touch screen, etc.

[0063] It can be understood that the memory 1002 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM, Read Only Memory), a programmable read-only memory (PROM, Programmable Read-Only Memory), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM, Static Random Access Memory), synchronous static random access memory (SSRAM, Synchronous Static Random Access Memory). The memory described in the embodiments of the present invention is intended to include but not limited to these and any other suitable categories of memories.

[0064] The memory 1002 in the embodiments of the present invention is used to store various categories of data to support the operation of the terminal 1000. Examples of such data include: any executable program for operating on the terminal 1000, such as the operating system 10021 and the application program 10022; the operating system 10021 contains various system programs, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks. The application program 10022 can include various application programs, such as a media player (Media Player), a browser (Browser), etc., for implementing various application services. Implementing the efficient management method for table entry indexing oriented to multiple threads provided by the embodiments of the present invention can be included in the application program 10022.

[0065] The method disclosed in the embodiments of the present invention described above can be applied to or implemented by the processor 1001. The processor 1001 may be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the above method can be completed by the integrated logic circuit in the hardware of the processor 1001 or instructions in the form of software. The above-mentioned processor 1001 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 1001 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The processor 1001 may be a microprocessor or any conventional processor, etc. Combining the steps of the accessory optimization method provided in the embodiments of the present invention can be directly embodied as being completed by the execution of the hardware decoding processor, or by the combination of the hardware and software modules in the decoding processor. The software module may be located in the storage medium, which is located in the memory. The processor reads the information in the memory and combines its hardware to complete the steps of the foregoing method.

[0066] In an exemplary embodiment, the terminal 1000 may be an application-specific integrated circuit (ASIC), a DSP, a programmable logic device (PLD), or a complex programmable logic device (CPLD) for executing the foregoing method.

[0067] Those of ordinary skill in the art can understand that all or part of the steps for implementing the above method embodiments can be completed by hardware related to a computer program. The foregoing computer program may be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above method embodiments; and the foregoing storage medium includes various media such as ROM, RAM, magnetic disks, or optical discs that can store program codes.

[0068] In the embodiments provided by the present application, the computer-readable and writable storage medium may include a read-only memory, a random access memory, an EEPROM, a CD-ROM or other optical disc storage devices, a magnetic disk storage device or other magnetic storage devices, a flash memory, a USB flash drive, a portable hard drive, or any other medium that can be used to store the desired program code in the form of instructions or data structures and can be accessed by a computer. Additionally, any connection may be appropriately referred to as a computer-readable medium. For example, if the instructions are sent from a website, a server, or other remote sources using coaxial cables, fiber optic cables, twisted pairs, digital subscriber lines (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cables, fiber optic cables, twisted pairs, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of the medium. However, it should be understood that computer-readable and writable storage media and data storage media do not include connections, carrier waves, signals, or other transient media, but are intended to refer to non-transient, tangible storage media. As used in the application, magnetic disks and optical discs include compact discs (CDs), laser discs, optical discs, digital versatile discs (DVDs), floppy disks, and Blu-ray discs, where magnetic disks typically replicate data magnetically, while optical discs optically replicate data using lasers.

[0069] In summary, for the method, system, terminal, and medium for efficient management of table entry indexes oriented to multiple threads of the present invention, initialization operations of the global index pool and the thread index caches of each working thread are performed when the business software is started; when a working thread needs to apply for a table entry index, first apply for the table entry index in the thread index cache corresponding to the working thread. If an available table entry index cannot be applied for, a batch application operation for table entry indexes is performed on the global index pool; when a working thread needs to release a table entry index, first recycle the table entry index to the corresponding thread index cache. If the thread index cache reaches the recycle upper limit, a batch release operation for table entry indexes is performed on the global index pool; when the business software exits, all memory resources in each thread index cache and the global index pool are released. The present invention can safely access table entry indexes in a multi-threaded concurrent scenario while further improving the efficiency of table entry index management. Therefore, the present invention effectively overcomes various disadvantages in the prior art and has high industrial utilization value.

[0070] The above embodiments only exemplarily illustrate the principles and effects of the present invention and are not used to limit the present invention. Any person familiar with this technology can modify or change the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or changes completed by those with ordinary knowledge in the technical field without departing from the spirit and technical idea disclosed by the present invention should still be covered by the claims of the present invention.

Claims

1. An efficient management method for table entry indexing oriented to multi-threading, characterized in that The method includes: When the business software starts, perform initialization operations on the global index pool and the thread index caches of each working thread; wherein, each thread index cache is a fast access channel between each working thread and the global index pool; When a working thread needs to apply for a table entry index, apply for the table entry index in the thread index cache corresponding to the working thread, and when the corresponding thread index cache cannot apply for an available table entry index, perform a batch application operation for the table entry index on the global index pool; When a working thread needs to release a table entry index, recycle the table entry index to be released into the thread index cache corresponding to the working thread, and when the corresponding thread index cache has reached the recycle limit, perform a batch release operation for the table entry index on the global index pool; When the business software exits, release all the memory resources in each thread index cache and the global index pool.

2. The efficient management method for table entry indexing oriented to multi-threading according to claim 1, characterized in that The global index pool is divided into an index lock, an unallocated area, and an allocated area.

3. The method for efficiently managing table entry indexes oriented to multi-threading according to claim 2, wherein The initialization operations on the global index pool and the thread index caches of each working thread include: Create a global index pool table entry index management object based on the configuration information, and initialize the index lock, the unallocated area, and the allocated area in the global index pool respectively; Initialize the corresponding thread index cache in each working thread.

4. The method for efficiently managing table entry indexes for multi-threading according to claim 2, characterized in that The batch application operation for the table entry index in the global index pool includes: Lock the batch application operation for the table entry index by setting the index lock to the locked state; Give priority to batch applying for available table entry indexes from the unallocated area. If no available table entry indexes can be provided in the unallocated area, continue to apply for the table entry indexes that the working thread has not applied for in the allocated area.

5. The method for efficiently managing table entry indexes for multi-threading according to claim 4, wherein While batch applying for the table entry index, the working thread records the number of all table entry indexes applied for in this batch application operation for the table entry index in the corresponding thread index cache.

6. The method for efficiently managing table entry indexes for multi-threading according to claim 2, characterized in that The batch release operation for the table entry index includes: recycling all the table entry indexes in the thread index cache corresponding to the working thread that needs to release the table entry index into the allocated area in the global index pool for continuing to recycle the table entry indexes that the working thread has not released into the corresponding thread index cache.

7. The method for efficiently managing table entry indexes for multi-threading according to claim 2, characterized in that, The unallocated area and the allocated area perform the batch application operation and the batch release operation for the table entry index under the condition of O(1) time complexity to reduce the performance loss of the index lock itself.

8. An efficient management system for table entry indexing oriented to multi-threading, characterized in that, The system includes: An initialization module, used to perform initialization operations on the global index pool and the thread index caches of each working thread when the business software starts; A table entry index application module, used to apply for a table entry index in the thread index cache corresponding to the working thread when a working thread needs to apply for a table entry index, and perform a batch application operation for the table entry index on the global index pool when the corresponding thread index cache cannot apply for an available table entry index; A table entry index release module, used to recycle the table entry index to be released into the thread index cache corresponding to the working thread when a working thread needs to release a table entry index, and perform a batch release operation for the table entry index on the global index pool when the corresponding thread index cache has reached the recycle limit; A resource release module that, when the business software exits, releases all memory resources in each thread index cache and the global index pool.

9. An electronic terminal, characterized in that, Including: One or more memories and one or more processors; The one or more memories are used to store computer programs; The one or more processors are connected to the memory and are used to run the computer program to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A computer program is stored, and when the computer program is run by one or more processors, it executes the method according to any one of claims 1 to 7.