A message processing method and device, a storage medium and a computer device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-08
- Publication Date
- 2026-08-11
AI Technical Summary
但是,这种基于静态映射关系的转发方式,容易造成各个控制核之间负载不均衡的情况,例如造成某个控制核被转发大量报文,而其他控制核处于空闲状态的情况,降低了网络设备的整体吞吐量和资源利用率
[0009]本公开实施例提供的报文处理方法、装置、存储介质和计算机设备,通过设置负载反馈条件并控制各个控制核向目标调度器反馈实时负载信息,可以使得目标调度器能够及时存储各个控制核的最新负载信息。然后,在数据核接收到待转发报文的情况下,通过控制数据核向目标调度器发送调度请求信息,并利用目标调度器根据存储的最新负载信息,生成与最新负载信息匹配的调度指示信息,再利用数核根据调度指示信息进行目标控制核的选取,可以实现在对控制核的动态负载进行实时感知的基础上,基于各个控制核的实时负载进行目标控制核的合理选取,降低了各个控制核被分发的报文量不均衡的概率,从而为提高各个控制核之间的负载均衡性、提升网络设备的整体吞吐量和资源利用率提供实现基础。
Smart Images

Figure CN122554553A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and more specifically, to a message processing method, apparatus, storage medium, and computer equipment. Background Technology
[0002] With the continuous growth of network bandwidth, the packet processing pressure on network devices is increasing. To improve packet processing throughput and reduce packet processing latency, high-performance network devices employing multi-core Central Processing Unit (CPU) architectures are becoming increasingly common. In high-performance network devices, a data plane and control plane separation architecture is used, dividing multiple CPUs into data cores and control cores. The data core is primarily responsible for receiving packets and forwarding them to the control core, while the control core is mainly responsible for packet processing and forwarding to other communication devices.
[0003] To achieve packet forwarding between data cores and control cores, a common approach is to pre-establish a static mapping relationship between them. After receiving a packet, the data core determines the control core to forward it to based on the packet's hash value and the static mapping relationship. However, this forwarding method based on static mapping relationships can easily lead to an unbalanced load among the control cores. For example, one control core might be forwarded with a large number of packets while other control cores remain idle, reducing the overall throughput and resource utilization of the network device. Summary of the Invention
[0004] In view of this, this application provides a message processing method, apparatus, storage medium, and computer device to improve the load balancing among various control cores in a network device and ensure the overall throughput and resource utilization of the network device.
[0005] Specifically, this application is implemented through the following technical solution: In a first aspect, embodiments of this disclosure provide a message processing method applied to a network device, the network device comprising a first number of data cores, a second number of control cores, and a third number of schedulers, wherein each data core and each control core are pre-configured with a lock-free queue; the method includes: In response to any data core receiving a message to be forwarded, a control core scheduling request is generated using the data core and sent to the target scheduler associated with the data core; Using the target scheduler, scheduling instruction information is generated and fed back to the data core based on the control core's retrieval request and the latest load information fed back by each control core under the condition of satisfying the load feedback. Using the data core and the scheduling instruction information, the target control core is determined from multiple control cores, and the message to be forwarded is distributed to the target lock-free queue between the target control core and the data core; The target control kernel is used to retrieve packets to be forwarded from the target lock-free queue and process the packets.
[0006] Secondly, embodiments of this disclosure also provide a message processing apparatus applied to a network device, the network device including a first number of data cores, a second number of control cores, and a third number of schedulers, wherein each data core and each control core are pre-configured with a lock-free queue; the apparatus includes: The first generation module is used to respond to any data core receiving a message to be forwarded, using the data core to generate a control core scheduling request, and send it to the target scheduler associated with the data core; The second generation module is used to generate scheduling instruction information and feed it back to the data core based on the control core retrieval request and the latest load information fed back by each control core under the condition of satisfying the load feedback condition, using the target scheduler. The distribution module is used to determine the target control core from multiple control cores according to the scheduling instruction information using the data core, and distribute the message to be forwarded to the target lock-free queue between the target control core and the data core; The processing module is used to obtain the message to be forwarded from the target lock-free queue using the target control core and to process the message.
[0007] Thirdly, an optional implementation of this disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps in the first aspect described above.
[0008] Fourthly, an optional implementation of this disclosure also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps in the first aspect described above.
[0009] The message processing method, apparatus, storage medium, and computer device provided in this disclosure, by setting load feedback conditions and controlling each control core to feed back real-time load information to the target scheduler, enable the target scheduler to store the latest load information of each control core in a timely manner. Then, when a data core receives a message to be forwarded, it sends a scheduling request message to the target scheduler by controlling the data core. The target scheduler then generates scheduling instruction information matching the latest load information based on the stored latest load information. The data core then selects the target control core based on the scheduling instruction information. This enables the rational selection of the target control core based on the real-time load of each control core, based on the dynamic load of the control cores in real time. This reduces the probability of uneven message distribution to each control core, thereby providing a foundation for improving the load balance among control cores and enhancing the overall throughput and resource utilization of network devices.
[0010] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0011] Figure 1 This is a schematic diagram illustrating a static mapping relationship between an existing data core, control core, and lockless queue, as shown in an exemplary embodiment of this application. Figure 2 This is a flowchart illustrating a message processing method according to an exemplary embodiment of this application; Figure 3 This is a schematic diagram illustrating a two-dimensional queue matrix structure according to an exemplary embodiment of this application; Figure 4 This is an exemplary embodiment of the present application illustrating the architecture of a network device; Figure 5 This is a schematic diagram illustrating a load information synchronization according to an exemplary embodiment of this application; Figure 6 This is a flowchart illustrating a message processing method according to an exemplary embodiment of this application; Figure 7 This is a schematic diagram of a message processing apparatus shown in an exemplary embodiment of this application; Figure 8 This is a schematic diagram of the structure of a computer device shown in an exemplary embodiment of this application. Detailed Implementation
[0012] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0013] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0014] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0015] Research has found that in multi-core network devices, lock-free queues are typically used as communication middleware between data cores and control cores to reduce communication overhead. Based on the configuration of lock-free queues, current traffic forwarding schemes often employ a pre-established static mapping relationship between data cores, control cores, and lock-free queues. Specifically, in these schemes, each lock-free queue is pre-defined using the formula "Number of lock-free queues = Number of data cores × Number of control cores," and the mapping relationship between data cores, control cores, and lock-free queues is bound. After receiving a message, the data core determines the message hash value using the message's 5-tuple information. Based on the hash value, it selects the target control core from multiple control cores and sends the message to the target control core's lock-free queue for reading and processing. However, while these methods are applicable to different data core and control core ratios within a network device, they still have the following drawbacks: 1. Uneven load: Static binding of control cores based on message hash values fails to detect real-time load on control cores. This can easily lead to situations where some control cores have already received a large number of messages while others are idle, causing high-load control cores to continue receiving messages, becoming a bottleneck for data core message processing. 2. Lack of dynamic adaptability: The mapping relationship is fixed after initialization, making it impossible to dynamically select lock-free queues based on the real-time load status of each control core. 3. Low resource utilization: When the load on different control cores is uneven, some lock-free queues can become idle, resulting in wasted memory resources.
[0016] For example, a traditional method of packet distribution using static mapping relationships is as follows: Taking an M+N core CPU network device as an example, assuming the network device has M data cores and N control cores, M×N lock-free queues are created, with each data core associated with N lock-free queues and each control core managing M lock-free queues. Figure 1 The diagram shown illustrates a static mapping relationship between a conventional data core, control core, and lock-free queue, as provided in an embodiment of this application. Figure 1In this scheme, M and N are both 3, and the number of lock-free queues is M×N. When any data core receives a message, it calculates the message hash value based on the message's 5-tuple, then takes the modulo of the number of control cores, and determines the target control core based on the modulo result. The data core can then determine the target lock-free queue managed by the target control core from the associated N lock-free queues based on a static mapping relationship, and send the message to the target lock-free queue. The target control core can read messages from its own M lock-free queues through round-robin, process, and forward them. However, this scheme, because the hash mapping process is based on a static mapping relationship, cannot dynamically adapt to the load of each control core (especially the load of each control core's lock-free queue). This results in the data core still sending new messages to a control core even when the load of a certain control core or lock-free queue is too high, failing to achieve message reallocation based on the real-time load of the control core. Furthermore, when a control core corresponding to a certain hash value already has a large number of packets, that control core will become a performance bottleneck for the network device, but the solution based on static mapping cannot adjust the load pressure on that control core. In addition, in non-uniform traffic scenarios, the solution based on static mapping may cause some control cores' lock-free queues to be idle for a long time while other lock-free queues overflow, which not only reduces the resource utilization of the network device, but also causes packet loss problems.
[0017] Therefore, how to solve the problem of uneven control kernel load caused by the existing message distribution scheme based on static mapping relationship has become a key focus.
[0018] Based on the above research, this disclosure provides a message processing method, apparatus, storage medium, and computer device. By setting load feedback conditions and controlling each control core to feed back real-time load information to the target scheduler, the target scheduler can store the latest load information of each control core in a timely manner. Then, when the data core receives a message to be forwarded, it sends a scheduling request message to the target scheduler. The target scheduler then generates scheduling instruction information matching the latest load information based on the stored latest load information. Finally, the data core selects the target control core based on the scheduling instruction information. This enables real-time perception of the dynamic load of the control cores and reasonable selection of the target control core based on the real-time load of each control core, reducing the probability of uneven message distribution to each control core. This provides a foundation for improving load balance among control cores and enhancing the overall throughput and resource utilization of network devices.
[0019] The shortcomings of the above solutions are the result of the inventor's practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed in this disclosure below should be considered as the inventor's contribution to this disclosure.
[0020] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0021] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0022] To facilitate understanding of this embodiment, a message processing method disclosed in this disclosure will first be described in detail. The message processing method provided in this disclosure is generally executed by a terminal device or other processing device with certain computing capabilities. The terminal device may be a user equipment (UE), a mobile device, a terminal, a personal digital assistant (PDA), a handheld device, a computer device, a network device, etc. In some possible implementations, the message processing method can be implemented by a processor calling computer-readable instructions stored in the memory.
[0023] The following describes the message processing method provided in this embodiment, taking a network device as the executing entity as an example.
[0024] like Figure 2 The flowchart shown is a message processing method provided in an embodiment of this disclosure, which may include the following steps: S201: In response to any data core receiving a message to be forwarded, use the data core to generate a control core scheduling request and send it to the target scheduler associated with the data core.
[0025] First, it should be noted that the message processing method provided in this application embodiment can be applied to any high-performance network device, which has the ability to receive, process, and forward messages. Specifically, the network device may include a first number of data cores, a second number of control cores, and a third number of schedulers, and each data core and each control core is pre-configured with a lock-free queue.
[0026] Specifically, the network device may include K CPUs and adopt an architecture that separates the data plane and control plane. Each CPU can be referred to as a processing core, and the number of K is greater than 1. This application does not limit the value of K and can set it according to actual processing requirements. For example, K can be 16, 32, 64, 128, etc. The K CPUs can be further divided into a first number of data cores, a second number of control cores, and a third number of schedulers. The sum of the first, second, and third numbers can be less than or equal to K. This application does not limit the specific values of the first, second, and third numbers; all three numbers can be set according to actual traffic processing requirements. Data cores are used to handle packet reception, and control cores are used to handle packet processing and transmission logic, enabling packets to be sent to the target device via Transmission Control Protocol (TCP) connections or other methods. The scheduler has the ability to communicate with the data cores and control cores, and can be used to receive load information sent by the control cores and to assist the data cores in selecting the control core for packet processing.
[0027] Taking a first quantity of M, a second quantity of N, and a third quantity of P as an example, the number of lock-free queues can be M×N. Each of the M data cores can have a lock-free queue pre-set between it and each control core. Each of the N control cores can manage a lock-free queue associated with it. Each lock-free queue can be a Single Producer Single Consumer (SPSC) queue. That is, when writing to each lock-free queue, only one data core's write thread is allowed to write as a producer, and when reading from each lock-free queue, only one control core's read thread is allowed to read as a consumer. In this way, using SPSC queues for packet enqueueing and dequeueing can improve packet read and write performance while avoiding read and write contention between different cores.
[0028] The relationship between lock-free queues among M data cores and N control cores can be expressed as described in this application. Figure 3 The two-dimensional queue matrix structure shown is as follows, where, Figure 3 In this context, M data cores are referred to as data cores 0 to M-1, and N control cores are referred to as control cores 0 to N-1. The N×N queue matrix between the M data cores and N control cores can include Q[0][0] to Q[M-1][N-1] lock-free queues, where Q[i][j] represents the lock-free queue between data core i and control core j, i∈[0,M-1], j∈[0,N-1]. Figure 3In this structure, a data core is associated with each lock-free queue under a row in an N×N queue matrix. This data core can write messages to each lock-free queue in that row. For example, data core 0 can be used to write messages to each lock-free queue (Q[0][0]~Q[0][N-1]) in the first row. A control core is used to manage each lock-free queue under a column in an N×N queue matrix. This control core is used to read messages from each lock-free queue in that column. For example, control core N-1 is used to read messages from each lock-free queue (Q[0][N-1]~Q[M-1][N-1]) in the last column.
[0029] Specifically, for any network device, the first number of data cores, the second number of control cores, and the third number of schedulers can be determined based on packet processing requirements. Then, a lock-free SPSC queue is created by multiplying the first number by the second number, forming a structure like this: Figure 3 The two-dimensional matrix structure shown.
[0030] In S201 above, the message to be forwarded can be a data message that needs to be forwarded from the data core to the control core. The control core scheduling request is used to request the target scheduler to schedule the control core. The target scheduler can be a third number of schedulers, a scheduler associated with a data core. For example, if the third number is 1, this one scheduler is associated with each data core, so this scheduler is the target scheduler associated with each data core.
[0031] In practical implementation, when any data core receives a packet to be forwarded from an external network device, the network device can determine a target scheduler associated with that data core from a third number of schedulers. Simultaneously, it can use the data core to generate a control core retrieval request indicating a current need for control core selection, and send this request to the target scheduler. For example, if only one scheduler is configured, that scheduler serves as the target scheduler. After receiving the packet to be forwarded, the data core can generate a control core scheduling request such as "determine target control core" and send it to the target scheduler.
[0032] Understandably, each data core can synchronously receive packets to be forwarded, and the network device can synchronously respond when each data core receives a packet to be forwarded, and then synchronously control each data core to generate a control core scheduling request and send it to the target scheduler associated with each data core.
[0033] S202: Using the target scheduler, based on the control core's retrieval request and the latest load information fed back by each control core under the condition of satisfying the load feedback, generate scheduling instruction information and feed it back to the data core.
[0034] Here, the load feedback condition is the trigger condition that instructs the control core to send the latest load information. The target scheduler can store the latest load information sent to itself by each control core when the feedback condition is triggered. The scheduling indication information is used to indicate the control core to which the current packet should be forwarded; for example, the scheduling indication information can be a unique core identifier of the control core to which forwarding is required.
[0035] Network devices can control each control core to monitor its own load information. This load information may include, but is not limited to, the queue depth of each lock-free queue managed by the control core, the resource utilization of the control core, and the packet transmission and reception rate of the control core itself. Then, the control core can determine whether it meets the load feedback conditions based on its real-time load information. If the real-time load information of any control core meets the load feedback conditions, the network device can simultaneously control each control core to send its latest load information to each scheduler. After receiving the latest load information from each control core, each scheduler can store the latest load information of each control core in its local global load table. Alternatively, each scheduler can also calculate the latest load score corresponding to the latest load information of each control core using a preset scoring algorithm, and store the latest load score and / or latest load information of each controller in its local global load table.
[0036] Optionally, each lockless queue can use other processing cores in the network device besides the data core, control core, and scheduler to monitor queue information. For ease of description, this application defines the processing core used for monitoring lockless queues as the queue management core. In this case, each control core can obtain the queue load information of each lockless queue it manages through communication with the queue management core. The queue load information may include real-time queue depth information, queue utilization, etc. Then, each control core can determine its own real-time load information and judge whether it meets the load feedback conditions based on the obtained real-time queue load information, its own real-time resource utilization, and packet transmission and reception rate. If any control core detects that the real-time load information meets the load feedback conditions, the network device can control each control core to feed back its own real-time load information to the scheduler, and can also control the queue management core to feed back the real-time queue depth information of each lockless queue to the scheduler. After receiving the latest load information from each control core and the queue load information from the queue management core, the scheduler, for each control core, can utilize the weights set for the control core's feedback information and the queue management core's feedback information to integrate the relevant queue load information from both sources. This integration yields the final latest load information for that control core, which is then stored. Alternatively, the scheduler can determine the latest load score for each control core based on the final latest load information and store the latest load score and / or latest load information for each controller. By establishing a queue management core to monitor the queue load information of each lock-free queue, and by having the queue management core send the real-time queue load information of each lock-free queue to the scheduler when any control core triggers a load feedback condition, the scheduler can simultaneously combine the load information from both the control cores and the queue management core to determine a more accurate latest load information for each control core, providing a foundation for load balancing among the control cores.
[0037] In the specific implementation of S202, after the network device uses the data core to send the control core scheduling request to the target scheduler, it can use the target scheduler to receive the control core scheduling request sent by the data core. Then, in response to the control core scheduling request, the target scheduler uses the latest load information of each control core stored in its own storage to make a scheduling decision, determine the control core with the lightest load (for example, select the control core with the highest score), and feed back the unique core identifier of the control core as scheduling instruction information to the data core.
[0038] S203: Using the data core, determine the target control core from multiple control cores according to the scheduling instruction information, and distribute the message to be forwarded to the target lockless queue between the target control core and the data core.
[0039] Here, the target control core is a control core used to process packets to be forwarded received by the current data core. The target lock-free queue is a lock-free queue associated between the current data core and the target control core. For example, when the data core is data core i and the target control core is control core j, the target lock-free queue is queue Q[i][j].
[0040] For example, after receiving the scheduling instruction information from the target scheduler, the network device can control the data core to parse the scheduling instruction information, determine the core identifier carried in the scheduling instruction information, and then select the control core with the core identifier from among multiple control cores as the target control core. At the same time, the target lock-free queue between the data core and the target control core can be determined, and the packet to be forwarded can be written to the target lock-free queue, thereby realizing the packet distribution between the data core and the control core.
[0041] S204: Use the target control kernel to retrieve the message to be forwarded from the target lock-free queue and process the message.
[0042] In practical implementation, for each control core, the network device can control that control core to sequentially read packets from the various lock-free queues it manages through polling, and then process and forward the read packets. The processing required by each control core for the read packets can be determined according to actual business processing needs, and this embodiment does not impose specific limitations. For example, the control core can parse and convert the format of the read packets, determine the external network device to receive the packets, and send the converted packets to the external network device.
[0043] Understandably, network devices can control various control cores to read packets, thereby enabling the control core to read packets to be forwarded from the target lock-free queue and process and forward them.
[0044] In this way, by creating a dedicated SPSC lock-free queue between each data core and each control core, and designing a two-dimensional queue matrix structure, this application ensures that packets in each queue are single-in, single-out, avoiding the overhead of multi-producer contention in traditional methods and maintaining the high-performance advantage of lock-free queues. By collecting control core load information in real time through the scheduler and guiding data cores to select target control cores for packet forwarding based on this load information, dynamic scheduling of packets to the least busy control core can be achieved, improving the dynamic load balancing among control cores, effectively avoiding hot core issues, and improving the overall throughput and resource utilization of the network device. Furthermore, by scheduling control cores based on their load information, it is ensured that all lock-free queues are active queues with no idle lock-free queues, improving the memory utilization of the network device.
[0045] like Figure 4 The diagram shown is an architecture diagram of a network device provided in an embodiment of this application, in which external traffic can be transmitted to M data cores. The external traffic refers to the packets to be forwarded from various external network devices. After receiving a packet to be forwarded, any data core can generate a control core scheduling request and send it to the target scheduler. Figure 4 Taking the example of setting up a central scheduler as the target scheduler for each data core, the central scheduler can receive real-time load information from each control core and real-time queue load information from each lock-free queue from the queue management core. Based on this feedback, it determines and stores the latest load information for each control core. Upon receiving a scheduling request from a control core, the target scheduler can determine the lightest-loaded target control core based on the latest load information stored locally and feeds back the target control core's identifier as scheduling instruction information to the data cores. Then, the data cores can determine the target control core based on the identifier in the scheduling instruction information and write the packets to be forwarded to the target lock-free queue between themselves and the target control core. Each control core can then read the packets to be forwarded from its own lock-free queue, process and forward them, thereby enabling traffic transmission. Figure 4 In the diagram, solid arrows indicate the flow of data, that is, the flow of packets to be forwarded in network devices; dashed arrows indicate the flow of control flow, that is, the flow of control information used to achieve load balancing scheduling between control cores.
[0046] In one embodiment, the step of "generating a control core scheduling request using the data core" in S201 above can be implemented according to the following steps A1 to A3: A1: Determine whether the data core has enabled the local cache space used to cache the load information of each control core.
[0047] Here, the local cache space can be a segment of memory within the data core itself. This space is used to cache the load information of each control core sent by the target scheduler. The local cache space can be dynamically opened and closed based on information such as the packet processing pressure of the data core.
[0048] In practical implementation, for a data core, after receiving a packet to be forwarded, it can first determine whether it has enabled a local cache space for caching the load information of each control core. For example, it can obtain status indication information indicating whether the local cache space is enabled, and determine whether the local cache space is enabled based on the status indication information. If not, the data core can directly generate a control core scheduling request and send it to the target scheduler. If yes, it means that the local cache space may cache the load information of each control core, so it can proceed to execute A2 below.
[0049] A2: If so, then determine whether the first load information is available based on the cached duration of the first load information of each control core currently cached in the local cache space; the first load information is periodically fed back to the data core by the target scheduler based on the load information fed back by each control core stored in the local cache space.
[0050] Here, a load synchronization period can be set for the scheduler, allowing it to periodically synchronize the latest locally stored load information of each control core to the local cache space of each data core according to the set load synchronization period. Optionally, the first preset feedback period can be dynamically adjusted according to the scheduler's resource usage. For example, the first preset feedback period can be increased when the scheduler's resource usage is too high, and decreased when the scheduler's resource usage is too low.
[0051] The first load information can be the load information of each control core currently stored in the local cache space of the data core. If the load information of each control core stored in the scheduler is detailed load content (such as queue depth, resource utilization, message transmission / reception rate, etc.), the first load information can also be the detailed load content of each control core, or it can be the load score determined by the data core for each control core based on the detailed load content. If the load information of each control core stored in the scheduler is a load score, the first load information can also be the load score of each control core. The cached duration indicates the total duration that the first load information has been stored in the local cache space.
[0052] In practical implementation, with the data core having its local cache space enabled, for any target scheduler associated with the data core, the target scheduler can send the latest locally stored second load information of each control core to the data core each time a load synchronization cycle arrives. After receiving the second load information from the target scheduler, the data core can overwrite this second load information and store it as new first load information in its local cache space. For example, the second load information can be stored as new first load information in the local load table within the local cache space, and the caching duration for the first load information can be started from the current time. Then, after receiving a packet to be forwarded, and confirming that the local cache space is enabled, the data core can retrieve the first load information of each control core currently cached in its local cache space. Then, based on the cached duration of each first load information and a preset cache duration, it determines whether the first load information of each control core is available. For example, if the cached duration is less than or equal to the preset cache duration, the first load information is determined to be available; otherwise, it is determined to be unavailable. The preset cache duration can be dynamically adjusted according to the packet processing pressure of the data core.
[0053] If at least one of the first load information of each control core is unavailable, it indicates that the load information in the local cache has expired, and A3 below can then be executed.
[0054] If the first load information of each control core is available, the target control core can be determined using the data core based on the first load information without initiating a control core scheduling request to the target scheduler, thereby reducing the query overhead of the target scheduler. Specifically, if the first load information is available, the target control core is determined from multiple pre-set control cores based on the first load information, and the packets to be forwarded are distributed to the target lock-free queue.
[0055] For example, if the first load information is available and it consists of detailed load information for each control core, the control core with the lightest load can be identified as the target control core based on its detailed load information. Then, the packets to be forwarded are distributed to the target lock-free queue between the target control core and the target control core. Alternatively, if the first load information is available and it consists of load scores for each control core, the control core with the lightest load can be identified as the target control core based on its load score. Then, the packets to be forwarded are distributed to the target lock-free queue between the target control core and the target control core. Here, the load score characterizes the load intensity of the control core. For example, the load score and load intensity can be negatively or positively correlated, and can be flexibly set according to requirements.
[0056] A3: If not, generate a control core scheduling request related to the message to be forwarded and send it to the target scheduler related to the data core.
[0057] For example, if the first load information cached locally by the data core is unavailable, in order to ensure that the scheduling of the control core is more in line with the real-time load of the control core, the data core can be used to generate a control core scheduling request related to the message to be forwarded and send it to the target scheduler associated with the data core.
[0058] In one embodiment, the opening and closing of the local cache space of each data core can be dynamically set according to the following steps: For any data core, based on the data core's message receiving rate and the first state of the data core's local buffer space, determine whether to adjust the first state to the second state; wherein the first state is an on state or a off state.
[0059] Here, the message reception rate indicates the amount of messages the data core needs to receive and the amount of messages it needs to send, reflecting the message processing pressure during data verification. The first state can be either an on or off state, and the second state can be either an on or off state. For example, if the first state is on, the second state is off; conversely, if the first state is off, the second state is on.
[0060] In practice, for any given data core, the network device can determine the current state of its local cache space based on status indication information. Simultaneously, based on the relationship between the data core's packet reception rate and the preset packet transmission / reception rate, it can determine whether the data core is experiencing high traffic. If so, the device determines the current first state of the local cache space. If this state is active, it can be determined that it needs to be switched to a closed state; if the state is closed, it can be determined that it does not need to be switched to a closed state.
[0061] If the data core is not in a period of high traffic, it can be determined that there is no need to change it to the off state if the first state is on; conversely, if the first state is off, it can be determined that it needs to be changed to the on state.
[0062] Optionally, if it is determined that the local cache space needs to be adjusted from the first state to the second state, the local cache space can be cleared synchronously when the state adjustment is performed.
[0063] Optionally, this application can independently adjust the open / closed state of the local cache space of each data core, or when it is determined that the open / closed state of the local cache space of any data core needs to be adjusted, the state of the local cache space of each data core can be adjusted simultaneously.
[0064] like Figure 5 The diagram illustrates a load information synchronization method provided in this embodiment of the application. Each of the N control cores can determine whether a load feedback condition has been triggered. If at least one control core triggers the load feedback condition, the real-time load information of each control core is fed back to the central scheduler and stored in the global load table of the central scheduler. If none of the control cores trigger the load feedback condition, the system continues to wait until any control core meets the load feedback condition. The central scheduler can periodically feed back the latest load information of each control core stored in the global load table to each of the M data cores according to the load synchronization cycle, and store it in the local load table in the local cache space of each data core.
[0065] In this way, by caching a local load table in each data core's local cache space and updating it periodically from the scheduler, data cores can utilize locally cached information for control core scheduling, reducing the query overhead on the scheduler. Each control core only actively reports real-time load information to the scheduler when a load feedback condition is triggered (e.g., load changes exceeding a threshold), ensuring that the scheduler can obtain the latest load information from each control core in a timely manner, providing a foundation for load balancing scheduling. Furthermore, the scheduler and each core can exchange load information via shared memory, thereby reducing communication latency.
[0066] In one embodiment, for the step of "generating a control core scheduling request" in S201, different methods can be used to generate requests containing different information according to different scheduling requirements. The two request generation methods will be described below: Method 1: Using the data core, determine the scheduling strategy that matches the message to be forwarded based on the message characteristics; generate a control core scheduling request based on the message characteristics and the scheduling strategy and send it to the target scheduler associated with the data core.
[0067] Here, message characteristic information may include, but is not limited to, the total number of bytes in the message to be forwarded, packets per second (PPS), packet transmission rate, payload characteristics, etc. The scheduling policy is used to indicate the information dimensions and scheduling requirements that the control kernel needs to focus on during scheduling.
[0068] In practical implementation, for any data core, when generating a control core scheduling request, if the scheduling requirement is for the control scheduler to schedule according to a strategy that conforms to message characteristics, the data core can be used to extract features from the message to be forwarded to obtain message feature information. Then, based on the message feature information, the message type of the message to be forwarded is determined. The message type can include, but is not limited to, packet-sensitive, byte-sensitive, and transmit / receive rate-sensitive types. Then, a scheduling strategy is generated based on the message type and the data core's traffic changes. For example, if the message type is packet-sensitive, the scheduling strategy can be to prioritize control cores whose packet processing rate can meet the PPS (Packet Per Second). If the message type is byte-sensitive, the scheduling strategy can be to prioritize control cores whose byte processing capacity meets the total number of bytes. If the message type is transmit / receive rate-sensitive, the scheduling strategy can be to prioritize control cores whose transmit / receive rate meets the packet sending rate.
[0069] After obtaining the scheduling policy, the scheduling policy and message characteristic information can be encapsulated together into a control core scheduling request and sent to the target scheduler associated with the data core.
[0070] Optionally, after determining the scheduling strategy, the data core can generate a control core scheduling request that only carries the scheduling strategy and send it to the target scheduler, thereby reducing the amount of request information and saving request overhead.
[0071] Optionally, after extracting message feature information, the data core can also generate a control core scheduling request carrying only the message feature information and send it to the target scheduler. The target scheduler can then determine the scheduling strategy based on the message feature information in the control core scheduling request and select a control core accordingly. In this way, by delegating the scheduling strategy determination process to the target scheduler, the overhead of the data core determining the scheduling strategy can be saved.
[0072] Furthermore, if the control kernel scheduling request includes message characteristic information and scheduling policy, the above S202 can be implemented according to the following steps B1 to B4: B1: Using the target scheduler, based on the latest load information of each control core, determine the processing capacity of each control core under the message characteristic information carried in the control core retrieval request.
[0073] Here, processing capability can include processing capabilities under various types of information included in the message characteristic information. For example, processing capability can control the core's byte processing capability under the total byte count characteristic, packet processing rate under PPS, message sending and receiving rate under the packet sending rate, and message analysis capability under the payload characteristic, etc.
[0074] In practice, the target scheduler can be used to parse the received control core scheduling requests to determine the message characteristics and scheduling policy. Then, based on the message characteristics and the latest load information fed back by each control core under the condition of meeting the load feedback conditions (that is, the latest load information of each control core currently stored in the global load table in the target scheduler), the processing capacity of the target scheduler under each message characteristic can be determined.
[0075] B2: Based on processing capacity, select initial control cores from among the various control cores that meet the scheduling strategy carried in the control core retrieval request.
[0076] In practice, the initial control cores whose processing capabilities meet the scheduling strategy can be selected from among the control cores according to the scheduling strategy and the processing capabilities of each control core under various message characteristic information. For example, if the scheduling strategy prioritizes the selection of control cores whose byte processing capabilities meet the total number of bytes, the initial control cores whose byte processing capabilities are greater than or equal to the total number of bytes in the message characteristic information can be selected from among the control cores.
[0077] Understandably, the number of initial control cores selected can be greater than or equal to 1.
[0078] B3: Based on the latest load information of each initial control core, select the target control core with the lightest load from among the initial control cores; In practice, if there is only one initial control core, it can be used as the target control core. If there are multiple initial control cores, the target control core with the lightest load can be determined from among the initial control cores based on the latest load information of each initial control core stored in the global load table (e.g., the latest load score or the latest detailed load content).
[0079] In one embodiment, regarding B3 above, when screening target control cores, the selection can also be based on the predicted load of each initial control core. Specifically, B3 above can also be implemented according to the following steps: B3-1: Based on the historical load information of each initial control core, determine the load change trend of each initial control core in the future preset time period.
[0080] Here, the length of the preset time period can be set based on experience, and this embodiment does not impose a specific limitation. For example, it could be the next hour, the next two hours, etc. The load change trend is used to indicate the overall load change of the initial control core during the preset time period.
[0081] In practice, for each initial control core, the target scheduler can use a preset load prediction algorithm and historical load information of the initial control core at the same historical time period to predict the load change of the initial control core over a preset future time period, thus obtaining the load change trend of the initial control core. For example, the load change trend can be an upward trend, a downward trend, or a stable trend over the preset future time period.
[0082] B3-2: Select candidate control cores from each initial control core based on the load change trend of each initial control core and the number of pending messages of each initial control core.
[0083] Here, the number of pending messages is used to indicate the number of messages currently waiting to be processed by the initial control kernel.
[0084] In practice, candidate control cores with a future decreasing load and a number of pending messages can be selected from each initial control core based on the load change trend and the number of pending messages.
[0085] Alternatively, the packet processing pressure of each initial control core can be determined based on the number of packets to be processed and the maximum number of packets that each initial control core can process. Then, initial control cores with packet processing pressure less than the preset pressure and whose future load shows a decreasing trend or remains stable are selected as candidate control cores.
[0086] B3-3: Based on the latest load information of each candidate control core, select the target control core with the lightest load from among the candidate control cores.
[0087] In practice, the target control core with the lightest load can be selected from among the candidate control cores based on the latest load information of each candidate control core.
[0088] By combining the future load trends of the control core with the current real-time load when selecting the control core, potential congestion in the future can be avoided in advance. For example, if the load of a control core shows an upward trend recently, even if the current load is not high, it may be allocated fewer packets, thus avoiding impending congestion.
[0089] B4: Generate scheduling instruction information based on the target core identifier of the target control core and feed it back to the data core.
[0090] In practice, the target scheduler can be used to use the unique core identifier of the target control core as the target core identifier, and then feed the target core identifier back to the data core as scheduling instruction information.
[0091] Furthermore, regarding the step in S203 of "using the data core to determine the target control core from multiple control cores based on the scheduling instruction information", the data core can be directly used to select the control core with the target core identifier from among the multiple control cores as the target control core based on the target core identifier carried in the scheduling instruction information.
[0092] For example, after the data core receives the scheduling instruction information, it can parse out the target core identifier carried in the information, and then select a control core with the target core identifier from among the various control cores as the target control core.
[0093] In one embodiment, a control core scheduling request can be used to instruct the acquisition of load information corresponding to each control core, wherein the load information may include the load score or load information of the control core. That is, the control core scheduling request can be a load information acquisition request, and the target scheduler uses this request to feed back the load information to the data core without performing a control core selection decision. In this case, the control core scheduling request can be generated according to method 2 below.
[0094] Method 2: Utilize the data core to generate a control core scheduling request that indicates the load status of each control core and send it to the target scheduler.
[0095] In practice, for any data core, when generating a control core scheduling request, if the scheduling requirement is a control core that the data core needs to schedule autonomously, then the data core can be used to directly generate a load status acquisition request and send it to the target scheduler.
[0096] Furthermore, the above-mentioned S202 can be implemented according to the following steps C1~C2: C1: Using the target scheduler, based on the control core's retrieval request, the latest load information of each control core is used as the load status, or based on the latest load information of each control core, the latest load score of each control core is determined, and the latest load score is used as the load status; the level of the latest load score is used to indicate the severity of the load.
[0097] In practical implementation, when the control core scheduling request is a load status retrieval request, the target scheduler can be used to respond to the control core retrieval request by retrieving the latest load information of each control core stored in the global load table as the load status. Alternatively, the target scheduler can also be used to respond to the control core retrieval request by calculating the latest load score corresponding to the latest load information of each control core based on the latest load information of each control core stored in the global load table, and then using the latest load score of each control core as the load status of each control core.
[0098] Optionally, if the global load table stores the load scores of each control core, the target scheduler can be used to directly retrieve the currently stored load scores of each control core in the global load table in response to the control core retrieval request, and use the load scores as the load status of the control core.
[0099] C2: Generates scheduling instructions based on load conditions and feeds them back to the data core.
[0100] In practice, a target scheduler can be used to encapsulate the load status of each control core into scheduling instruction information and feed it back to the data core.
[0101] Furthermore, regarding the step in S203 of "using the data core to determine the target control core from multiple control cores based on the scheduling instruction information", the data core can be used directly to determine the load of each control core based on the load status of each control core carried by the scheduling instruction information, and the control core with the lightest load can be selected as the target control core.
[0102] For example, after receiving scheduling instruction information, the data core can parse the load status of each control core carried in the information. Then, by analyzing and processing the load status of each control core, the target control core with the lightest load can be determined. Alternatively, the data core can be used to determine a scheduling strategy matching the message to be forwarded based on the message characteristics. Then, according to the scheduling strategy and the load status of each control core, the target control core with the lightest load that meets the scheduling strategy can be selected from among the control cores.
[0103] In one embodiment, the load feedback condition may specifically include reaching a preset feedback period and / or the load change level of any control core exceeding a preset threshold. The preset feedback period can be set empirically, and this embodiment does not impose specific limitations. For example, the preset feedback period can be per minute, per second, etc. Optionally, the preset feedback period can also be dynamically adjusted according to the real-time load of each control core. For example, when the controller load increases, the duration of the feedback period is reduced; when the controller load decreases, the duration of the feedback period is increased. The load change level is used to indicate the load change situation during control verification.
[0104] For the control core, real-time load information can be fed back to the scheduler in the following steps: Upon reaching the preset feedback period, the system synchronously controls each control core, using the queue message depth, resource utilization, and message transmission and reception rate of each associated lockless queue as real-time load information, and sends it to the third set of schedulers.
[0105] In practice, network devices can detect in real time whether a preset feedback period has been established. If so, they synchronously control each control core to obtain information such as queue packet depth, resource utilization, and packet transmission / reception rate of each associated lock-free queue. This information is used as their own real-time load information and synchronously fed back to each scheduler. In this way, by setting a preset feedback period, the real-time load information of each control core can be periodically synchronized to the scheduler for storage.
[0106] And / or, for each control core, determine the load change level of the control core based on the queue message depth, resource utilization, and message transmission / reception rate of each lock-free queue associated with the control core; if the load change level of any control core exceeds a preset threshold, synchronously control each control core to send the queue message depth, resource utilization, and message transmission / reception rate of each associated lock-free queue as real-time load information to a third number of schedulers.
[0107] Here, the degree of load change can be used to provide feedback on the overall load change of the control core, or to reflect the changes in various load information of the control core.
[0108] For example, for each control core, the current load level of the control core can be determined based on the queue message depth, resource utilization, and message transmission / reception rate of each lock-free queue associated with that control core, according to a preset weighted average. For instance, the proportion of queues with depths exceeding a preset depth can be determined based on the queue message depth of each lock-free queue. The current load level of the control core can then be determined using a first weight for the queue proportion, a second weight for resource utilization, and a third weight for message transmission / reception rate. Then, the load change rate of the control core can be determined by comparing the previously determined load level with the current load level. Next, it is determined whether the load change rate of any control core exceeds a preset threshold. If so, each control core can be synchronously controlled to use the queue message depth, resource utilization, and message transmission / reception rate of each lock-free queue associated with it as its real-time load information and synchronously feed it back to each scheduler.
[0109] For example, for each control core, the queue load level of the control core can be determined based on the queue message depth of each lock-free queue associated with that control core, the proportion of queues exceeding a preset depth, and the queue load level of that control core. The resource utilization level of the control core can be determined based on its resource utilization rate, and the send / receive load level can be determined based on its message transmission / reception rate. Then, the queue load level, resource utilization level, and send / receive load level are combined to form the current load level of the control core. Next, the load change level is determined by combining the queue load level, resource utilization level, and send / receive load level from the previous load level, as well as the queue load level, resource utilization level, and send / receive load level from the current load level. For example, the queue load change level can be determined first based on the queue load level from the previous load level and the queue load level from the current load level; similarly, the resource utilization change level and the send / receive load change level can be determined. Then, the maximum / average / weighted change level among the three change levels can be used as the load change level of the control core; or, all three change levels can be used together as the load change level.
[0110] Furthermore, it can be determined whether the load variation of any control core exceeds a preset threshold. Specifically, when the load variation is one of three variations (maximum, average, or weighted), the load variation can be directly compared to a preset threshold to determine if it exceeds the threshold. When the load variation includes queue load variation, resource usage variation, and transmit / receive load variation, for each control core, each variation can be compared to its corresponding preset threshold (where the preset thresholds for each variation can be different). If at least one variation exceeds its corresponding threshold, it is determined that the load variation of that control core exceeds the preset threshold.
[0111] If the load change of any control core exceeds a preset threshold, each control core can be controlled synchronously to use the queue message depth, resource utilization, message transmission and reception rate, and other information of each lock-free queue associated with itself as its real-time load information and synchronously feed it back to each scheduler.
[0112] For example, if the load change of any control core exceeds a preset threshold, each control core can be controlled synchronously to feed back its real-time load information to each scheduler through the shared memory corresponding to the third set of schedulers.
[0113] In one embodiment, to avoid a single point of performance bottleneck due to a single central scheduler, a distributed scheduler framework can be used. In this case, the number of schedulers can be determined based on the number of groups obtained by grouping data cores. The number of data cores in each group can be preset based on experience; for example, the number of data cores in each group can be 4, 8, etc. One scheduler is used to associate the various data cores in a group.
[0114] For example, with 32 data cores, 4 data cores can be grouped together to get 8 groups, so that 8 schedulers can be set up, with one scheduler used to associate 4 data cores in a group.
[0115] Furthermore, regarding the step of "sending the real-time load information of each control core to each scheduler," the real-time load information of each control core can be synchronously sent to each shared memory location by pre-setting shared memory between each control core and each scheduler. Then, each scheduler can obtain the real-time load information of each control core based on the shared memory between itself and each control core.
[0116] Alternatively, to reduce the communication overhead between the control core and the scheduler, load information synchronization between the control core and the scheduler can be achieved through the following steps D1~D3: D1: Determine a first scheduler from among the schedulers based on the scheduler load of each scheduler in the third number of schedulers.
[0117] Here, the scheduler load may include, but is not limited to, the load of the scheduler processing the scheduling requests of each data core, the communication load between the scheduler and each control core, etc.
[0118] In practice, if it is determined that the real-time load information of the control core needs to be synchronized to the scheduler, the real-time scheduler load of each of the third number of schedulers can be determined, and then the scheduler with the smallest load can be used as the first scheduler, and all other schedulers except the first scheduler can be used as the second scheduler.
[0119] D2: Synchronously control each control core, and send the queue message depth, resource utilization, and message transmission and reception rate of each associated lock-free queue as the real-time load information of the control core to the first scheduler.
[0120] For example, the network device can synchronously control each control core, using the queue message depth, resource utilization, and message transmission and reception rate of each associated lockless queue as the real-time load information of the control core, and transmit the real-time load information to the first scheduler through shared memory with the first scheduler.
[0121] D3: Using the first scheduler, the received real-time load information is synchronized to each of the second schedulers (excluding the first scheduler) through a heartbeat mechanism.
[0122] For example, after the first scheduler receives the real-time load information of each control core, it can store the real-time load information in the first scheduler and synchronize the real-time load information to each second scheduler for storage through the heartbeat mechanism between the first scheduler and each second scheduler and through the shared memory between the first scheduler and each second scheduler.
[0123] Then, after receiving a message to be forwarded, any data core can determine its associated scheduler from among the various schedulers and send the control core scheduling request to that scheduler. The scheduler then generates scheduling instructions based on the latest load information of each control core currently stored within it.
[0124] In this way, by setting up multiple schedulers and associating each scheduler with different data cores, it is possible to use different schedulers to independently manage the scheduling of control cores under a portion of the data cores, thereby reducing the scheduling pressure on each scheduler.
[0125] Optionally, after any data core sends a control core scheduling request to the associated scheduler, if the scheduler finds that the load information stored by itself has expired, it can also obtain the latest load information of each control core by requesting the latest load information of each control core from other schedulers, and generate scheduling indication information based on the latest load information. Among them, the expiration time of the load information can be dynamically adjusted according to the real-time traffic size of the data core. For example, when the real-time traffic of the data core is large, the expiration time can be shortened; when the real-time traffic of the data core is small,the expiration time can be increased.
[0126] In this way, by combining the local cache of the data core and the method of the control core reporting load information according to the load feedback condition, this application can reduce the communication overhead of the scheduler and improve the real-time performance of message processing of network devices.
[0127] To facilitate the understanding of the embodiments of this application, a specific message processing process will be used as an example below to illustrate the message processing method provided by this application: Determine the number M of data cores, the number N of control cores, and the number P of schedulers.
[0128] Create M×N SPSC lock-free queues to form a two-dimensional matrix structure, and establish the association relationship between the data core and the scheduler.
[0129] Each queue Q[i][j] (0≤i<M-1, 0≤j<N-1) is exclusively used by data core i and control core j.
[0130] Data core i can only write the messages to be forwarded into the N SPSC queues from Q[i][0] to Q[i][N-1]; control core j can only read messages from the M SPSC queues from Q[0][j] to Q[M-1][j].
[0131] Start each scheduler, which is responsible for collecting the real-time load information of each control core and generating scheduling decisions (i.e., scheduling indication information) for the data core when receiving the control core scheduling request of the data core.
[0132] Each scheduler obtains the real-time load information fed back by each control core, and can calculate a comprehensive load score for each control core according to the real-time load information of each control core. Among them, the lower the score, the more idle the control core is.
[0133] Execute the message processing process, where the message processing process can be as described in this application Figure 6As shown, the specific process includes: Data core i receives the packet to be forwarded and sends a control core scheduling request to the associated scheduler. The scheduler selects the control core j with the lightest load based on the stored load information of each control core (such as load score) and feeds back the identifier of control core j to data core i. Data core i writes the packet to be forwarded into the Q[i][j] queue. Control core j periodically polls its dedicated M SPSC queues (i.e., Q[0][j] to Q[M-1][j]), retrieves the packet to be forwarded from each SPSC queue, processes the packet, and sends the packet to be forwarded to the external network device after processing. Furthermore, each control core can synchronize its real-time load information to each scheduler when the load feedback condition is triggered.
[0134] Taking a network device with a 16-core CPU as an example, CPU8-15 are used as data cores (M=8), CPU0-3 are used as control cores (N=4), and CPU7 runs the central scheduler. 32 lock-free SPSC queues (8×4) are created. After receiving a message, the central scheduler finds that control core 2 (CPU2) is the least busy by querying the load table. Data core 10 can put the message into queue Q[3][2]. Control core 2 can read and process messages from queues Q[0][2] to Q[7][2].
[0135] In this way, this application can achieve high performance while maintaining a single producer-single consumer (SPSC) mode for each queue, and simultaneously achieve load balancing through a dynamic scheduling mechanism, thereby improving the overall system throughput and resource utilization. Furthermore, this application can adapt to different core configurations of different network devices and can dynamically adjust scheduling strategies based on traffic changes, improving the flexibility of control core scheduling. In addition, by setting up SPSC queues, this application reduces debugging and maintenance costs compared to the use of complex multi-producer-multi-consumer (MPMC) queues in existing technologies.
[0136] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0137] Based on the same inventive concept, this disclosure also provides a message processing device corresponding to the message processing method. Since the principle of the device in this disclosure for solving the problem is similar to the message processing method described above in this disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0138] like Figure 7The diagram illustrates a message processing apparatus provided in an embodiment of this disclosure, applied to a network device. The network device includes a first number of data cores, a second number of control cores, and a third number of schedulers. Each data core and each control core are pre-configured with a lock-free queue. The apparatus includes: The first generation module 701 is used to respond to any data core receiving a message to be forwarded, using the data core to generate a control core scheduling request, and send it to the target scheduler associated with the data core; The second generation module 702 is used to generate scheduling instruction information and feed it back to the data core based on the control core retrieval request and the latest load information fed back by each control core under the condition of satisfying the load feedback condition using the target scheduler. The distribution module 703 is used to use the data core to determine the target control core from multiple control cores according to the scheduling instruction information, and distribute the message to be forwarded to the target lock-free queue between the target control core and the data core; The processing module 704 is used to obtain the message to be forwarded from the target lock-free queue using the target control core and to process the message.
[0139] In one possible implementation, the first generation module 701, when generating the control core scheduling request using the data core, is configured to: Determine whether the data core has enabled a local cache space for caching the load information of each control core; If so, the availability of the first load information is determined based on the cache duration of the first load information of each control core currently cached in the local cache space; the first load information is periodically fed back to the data core by the target scheduler based on the load information fed back by each control core in the latest storage. If not, a control core scheduling request related to the message to be forwarded is generated and sent to the target scheduler related to the data core.
[0140] In one possible implementation, the distribution module 703 is further configured to: If the first load information is available, the target control core is determined from multiple pre-set control cores based on the first load information, and the message to be forwarded is distributed to the target lock-free queue.
[0141] In one possible implementation, the device further includes an adjustment module 705 for: For any data core, based on the message receiving rate of the data core and the first state of the local buffer space of the data core, it is determined whether to adjust the first state to the second state; wherein the first state is an on state or a off state.
[0142] In one possible implementation, the first generation module 701, when generating the control core scheduling request using the data core, is configured to: Using the data core, a scheduling strategy matching the message to be forwarded is determined based on the message characteristic information of the message to be forwarded; Based on the message characteristic information and the scheduling policy, the control core scheduling request is generated and sent to the target scheduler associated with the data core.
[0143] In one possible implementation, the second generation module 702, when generating scheduling indication information and feeding it back to the data core using the target scheduler based on the control core retrieval request and the latest load information fed back by each of the control cores under the condition of satisfying load feedback, is configured to: Using the target scheduler, the processing capacity of each control core is determined based on the latest load information of each control core under the message feature information carried in the control core retrieval request; Based on the processing capacity, select initial control cores from among the control cores that conform to the scheduling strategy carried in the control core retrieval request; Based on the latest load information of each initial control core, select the target control core with the lightest load from among the initial control cores; Scheduling instruction information is generated based on the target core identifier of the target control core and fed back to the data core; The distribution module 703, when determining the target control core from multiple control cores using the data core according to the scheduling instruction information, is configured to: Using the data core, and based on the target core identifier carried in the scheduling instruction information, the control core with the target core identifier among multiple control cores is selected as the target control core.
[0144] In one possible implementation, the second generation module 702, when selecting the target control core with the lightest load from the initial control cores based on the latest load information of each initial control core, is configured to: Based on the historical load information of each initial control core, determine the load change trend of each initial control core in the future preset time period; Based on the load change trend of each initial control core and the number of pending messages of each initial control core, candidate control cores are selected from each initial control core. Based on the latest load information of each candidate control core, the target control core with the lightest load is selected from among the candidate control cores.
[0145] In one possible implementation, the control core scheduling request is used to instruct the acquisition of the load status corresponding to each control core; The second generation module 702, when generating scheduling instruction information and feeding it back to the data core using the target scheduler based on the control core retrieval request and the latest load information fed back by each control core under the condition of satisfying the load feedback condition, is used to: Using the target scheduler, based on the control core retrieval request, the latest load information of each control core is used as the load status, or based on the latest load information of each control core, the latest load score of each control core is determined, and the latest load score is used as the load status; the level of the latest load score is used to indicate the severity of the load; Based on the load conditions, a scheduling instruction is generated and fed back to the data core; The distribution module 703, when determining the target control core from multiple control cores using the data core according to the scheduling instruction information, is configured to: Using the data core, and based on the load information carried by the scheduling instruction information, a target control core with the lightest load is selected from each control core.
[0146] In one possible implementation, the load feedback condition includes reaching a preset feedback period and / or the load change of any control core exceeding a preset threshold. The device further includes a feedback module 706, used for: When the preset feedback period is reached, each of the control cores is synchronously controlled to send the queue message depth, resource utilization, and message transmission and reception rate of each associated lockless queue as real-time load information to the third number of schedulers. And / or, for each of the control cores, the load variation of the control core is determined based on the queue message depth, resource utilization, and message transmission / reception rate of each lock-free queue associated with the control core; If the load change of any of the control cores exceeds a preset threshold, the control cores are synchronously controlled to send the queue message depth, resource utilization, and message transmission and reception rate of each associated lockless queue as real-time load information to the third number of schedulers.
[0147] In one possible implementation, the third quantity is determined based on the number of groups obtained by grouping the data cores, and a scheduler is used to associate the data cores in a group; The feedback module 706, when synchronously controlling each control core, sends the queue message depth, resource utilization, and message transmission / reception rate of each associated lock-free queue as real-time load information to the third number of schedulers, is used for: Based on the scheduler load of each scheduler in the third number of schedulers, a first scheduler is determined from each caller; Synchronously control each control core and send the queue message depth, resource utilization, and message transmission and reception rate of each associated lock-free queue to the first scheduler as the real-time load information of the control core. Using the first scheduler, the received real-time load information is synchronized to each of the second schedulers other than the first scheduler through a heartbeat mechanism.
[0148] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0149] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0150] Based on the same technical concept, embodiments of this application also provide a computer device. (Refer to...) Figure 8 The diagram shown is a structural schematic of a computer device provided in an embodiment of this application, comprising: The system includes a processor 801, a memory 802, and a bus 803. The memory 802 stores machine-readable instructions that can be executed by the processor 801. The processor 801 executes the machine-readable instructions stored in the memory 802. When the machine-readable instructions are executed by the processor 801, the processor 801 executes the above-described S201~S204.
[0151] The aforementioned memory 802 includes a main memory 8021 and an external memory 8022. The main memory 8021, also known as internal memory, is used to temporarily store the computational data in the processor 801, as well as the data exchanged with external memory such as a hard disk 8022. The processor 801 exchanges data with the external memory 8022 through the main memory 8021. When the computer device is running, the processor 801 and the memory 802 communicate through the bus 803, so that the processor 801 executes the execution instructions mentioned in the above method embodiments.
[0152] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the message processing method described in the above-described method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0153] This disclosure also provides a computer program product carrying program code. The program code includes instructions that can be used to execute the steps of the message processing method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0154] The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0155] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0156] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0157] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0158] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0159] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the user through pop-up information or by asking the user to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.
[0160] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method of processing a packet, the method comprising: Applied to a network device, the network device comprising a first number of data cores, a second number of control cores, and a third number of schedulers, wherein a lock-free queue is pre-configured between each data core and each of the control cores; the method includes: In response to any data core receiving a message to be forwarded, a control core scheduling request is generated using the data core and sent to the target scheduler associated with the data core; Using the target scheduler, scheduling instruction information is generated and fed back to the data core based on the control core's retrieval request and the latest load information fed back by each control core under the condition of satisfying the load feedback. Using the data core and the scheduling instruction information, the target control core is determined from multiple control cores, and the message to be forwarded is distributed to the target lock-free queue between the target control core and the data core; The target control kernel is used to retrieve packets to be forwarded from the target lock-free queue and process the packets.
2. The method of claim 1, wherein, The step of generating a control core scheduling request using the data core includes: Determine whether the data core has enabled a local cache space for caching the load information of each control core; If so, the availability of the first load information is determined based on the cache duration of the first load information of each control core currently cached in the local cache space; the first load information is periodically fed back to the data core by the target scheduler based on the load information fed back by each control core in the latest storage. If not, a control core scheduling request related to the message to be forwarded is generated and sent to the target scheduler related to the data core.
3. The method of claim 2, wherein, The method further includes: If the first load information is available, the target control core is determined from multiple pre-set control cores based on the first load information, and the message to be forwarded is distributed to the target lock-free queue.
4. The method of claim 2, wherein, The method further includes: For any data core, based on the message receiving rate of the data core and the first state of the local buffer space of the data core, it is determined whether to adjust the first state to the second state; wherein the first state is an on state or a off state.
5. The method of claim 1, wherein, The step of generating a control core scheduling request using the data core includes: Using the data core, a scheduling strategy matching the message to be forwarded is determined based on the message characteristic information of the message to be forwarded; Based on the message characteristic information and the scheduling policy, the control core scheduling request is generated and sent to the target scheduler associated with the data core.
6. The method of claim 5, wherein, The step of using the target scheduler to generate scheduling instruction information and feed it back to the data core based on the control core's retrieval request and the latest load information fed back by each control core under the condition of satisfying load feedback includes: Using the target scheduler, the processing capacity of each control core is determined based on the latest load information of each control core under the message feature information carried in the control core retrieval request; Based on the processing capacity, select initial control cores from among the control cores that conform to the scheduling strategy carried in the control core retrieval request; Based on the latest load information of each initial control core, select the target control core with the lightest load from among the initial control cores; Scheduling instruction information is generated based on the target core identifier of the target control core and fed back to the data core; The step of using the data core to determine the target control core from multiple control cores according to the scheduling instruction information includes: Using the data core, and based on the target core identifier carried in the scheduling instruction information, the control core with the target core identifier among multiple control cores is selected as the target control core.
7. The method of claim 6, wherein, The step of selecting the target control core with the lightest load from among the initial control cores based on the latest load information of each initial control core includes: Based on the historical load information of each initial control core, determine the load change trend of each initial control core in the future preset time period; Based on the load change trend of each initial control core and the number of pending messages of each initial control core, candidate control cores are selected from each initial control core. Based on the latest load information of each candidate control core, the target control core with the lightest load is selected from among the candidate control cores.
8. The method of claim 1, wherein, The control core scheduling request is used to instruct the acquisition of the load status corresponding to each control core; The step of using the target scheduler to generate scheduling instruction information and feed it back to the data core based on the control core's retrieval request and the latest load information fed back by each control core under the condition of satisfying load feedback includes: Using the target scheduler, based on the control core retrieval request, the latest load information of each control core is used as the load status, or based on the latest load information of each control core, the latest load score of each control core is determined, and the latest load score is used as the load status; the level of the latest load score is used to indicate the severity of the load; Based on the load conditions, a scheduling instruction is generated and fed back to the data core; The step of using the data core to determine the target control core from multiple control cores according to the scheduling instruction information includes: Using the data core, and based on the load information carried by the scheduling instruction information, a target control core with the lightest load is selected from each control core.
9. The method of claim 1, wherein, The load feedback conditions include reaching a preset feedback period and / or the load change of any control core exceeding a preset threshold. The method further includes: When the preset feedback period is reached, each of the control cores is synchronously controlled to send the queue message depth, resource utilization, and message transmission and reception rate of each associated lockless queue as real-time load information to the third number of schedulers. And / or, for each of the control cores, the load variation of the control core is determined based on the queue message depth, resource utilization, and message transmission / reception rate of each lock-free queue associated with the control core; If the load change of any of the control cores exceeds a preset threshold, the control cores are synchronously controlled to send the queue message depth, resource utilization, and message transmission and reception rate of each associated lockless queue as real-time load information to the third number of schedulers.
10. The method of claim 9, wherein, The third quantity is determined based on the number of groups obtained by grouping the data cores, and a scheduler is used to associate the data cores in a group. The synchronization control of each control core includes sending the queue message depth, resource utilization, and message transmission / reception rate of each associated lock-free queue as real-time load information to the third number of schedulers, including: Based on the scheduler load of each scheduler in the third number of schedulers, a first scheduler is determined from each caller; Synchronously control each control core and send the queue message depth, resource utilization, and message transmission and reception rate of each associated lock-free queue to the first scheduler as the real-time load information of the control core. Using the first scheduler, the received real-time load information is synchronized to each of the second schedulers other than the first scheduler through a heartbeat mechanism.
11. A packet processing device, characterized by Applied to network devices, the network devices include a first number of data cores, a second number of control cores, and a third number of schedulers, wherein each data core and each control core are pre-configured with a lock-free queue; the device includes: The first generation module is used to respond to any data core receiving a message to be forwarded, using the data core to generate a control core scheduling request, and send it to the target scheduler associated with the data core; The second generation module is used to generate scheduling instruction information and feed it back to the data core based on the control core retrieval request and the latest load information fed back by each control core under the condition of satisfying the load feedback condition, using the target scheduler. The distribution module is used to determine the target control core from multiple control cores according to the scheduling instruction information using the data core, and distribute the message to be forwarded to the target lock-free queue between the target control core and the data core; The processing module is used to obtain the message to be forwarded from the target lock-free queue using the target control core and to process the message.
12. A computer readable storage medium having stored thereon a computer program, characterized in that, When the program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 10.
13. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method as described in any one of claims 1 to 10.