CPU utilization determination method, system, storage medium and electronic device
By forwarding the kernel in the message forwarding system of the DPDK platform, the forwarding kernel counts the number of messages and timers, and the kernel configures the kernel to calculate the CPU utilization rate, solving the resource usage and performance impact caused by frequent acquisition of timestamps, and achieving more efficient CPU utilization rate Computational and system stability.
Patent Information
- Application Number
- CN202010997284.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-21
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2040-09-21
AI Technical Summary
In the message forwarding system based on the DPDK platform, the timestamp is frequently obtained to calculate the CPU utilization, resulting in large resource usage and overhead, affecting system performance.
By counting the number of messages and timeout timers within the target period, the forwarding core calculates the CPU utilization rate after the period ends, avoiding the acquisition of timestamps per message, and reducing resource usage and calculation impact.
It effectively reduces the use of forwarding core processing resources by CPU utilization calculation, ensures the performance and stability of the message forwarding system, and improves the high performance of multi-core concurrent processing.
Smart Images

Figure CN112162901B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a method, system, storage medium and electronic device for determining CPU utilization. Background Art
[0002] The message forwarding system developed based on the DPDK (Data Plane Development Kit) platform sends and receives messages from the network card based on an infinite loop, and the process requires exclusive use of the CPU. In this case, the CPU utilization rate is usually determined to be 100%.
[0003] However, in actual usage scenarios, CPU utilization represents whether the CPU has idle capacity to process other tasks. In the scheduling method based on DPDK infinite loop, the CPU utilization cannot be determined by using the general process utilization. Usually, the CPU utilization is determined based on the time corresponding to CPU idle processing and message processing. In the above method, it is necessary to obtain the corresponding timestamp TSC before and after the processing of each message, so as to obtain the corresponding time of message processing. Frequent acquisition of TSC occupies a large overhead of the message forwarding system, affecting the performance of the message forwarding system. Summary of the invention
[0004] The purpose of the present disclosure is to provide a simple and high-performance method, system, storage medium and electronic device for determining CPU utilization.
[0005] In order to achieve the above object, according to a first aspect of the present disclosure, a method for determining CPU utilization is provided, the method comprising:
[0006] The forwarding core counts the number of messages received within a target time period and the number of timers that time out within the target time period;
[0007] After the target time period ends, the configuration core obtains the number of messages and the number of timers of the forwarding core;
[0008] The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers.
[0009] Optionally, the method further comprises:
[0010] The forwarding core counts the number of calls of the while loop within the target time period;
[0011] The configuration core obtains the calling number;
[0012] The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers, including:
[0013] The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the number of calls.
[0014] Optionally, the configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the number of calls, including:
[0015] Determine, according to the number of calls, a first impact parameter corresponding to the forwarding core, wherein the first impact parameter is used to characterize the impact of the number of messages on CPU utilization;
[0016] The CPU utilization rate of the forwarding core within the target time period is determined according to the number of messages, the number of timers, and the first influencing parameter.
[0017] Optionally, the first impact parameter corresponding to the forwarding core is determined according to the number of calls by the following formula:
[0018]
[0019] The CPU utilization of the forwarding core in the target time period is determined according to the number of messages, the number of timers, and the first influencing parameter by the following formula:
[0020]
[0021] Wherein, Q represents the CPU utilization;
[0022] cur_pkt_sum represents the number of packets;
[0023] cur_timer_sum represents the number of timers;
[0024] cur_while_sum represents the number of calls;
[0025] ω is used to characterize the first influencing parameter of the number of packets on CPU utilization;
[0026] P1 represents the maximum number of messages that the forwarding core can receive within the target period;
[0027] P2 represents the maximum number of timeout timers that can be processed within the target period when the forwarding core has a new session performance limit;
[0028] P3 represents the number of times the while loop can be called at the throughput line rate within the target period;
[0029] α is used to characterize the second influencing parameter of the timer on the CPU utilization.
[0030] Optionally, after the step of determining, according to the number of calls, a first influencing parameter corresponding to the forwarding core, the method further includes:
[0031] When the first influencing parameter is less than a first threshold, updating the first influencing parameter to the first threshold;
[0032] When the first influencing parameter is greater than a second threshold, updating the first influencing parameter to the second threshold, wherein the first threshold is less than the second threshold;
[0033] The determining, according to the number of messages, the number of timers, and the first influencing parameter, the CPU utilization of the forwarding core within the target time period includes:
[0034] The CPU utilization rate of the forwarding core within the target time period is determined according to the number of messages, the number of timers and the updated first impact parameter.
[0035] Optionally, the method further comprises:
[0036] The forwarding core determines whether a message receiving queue corresponding to the forwarding core loses a message within the target time period;
[0037] When it is determined that the message receiving queue has not lost any message, the forwarding core performs a step of counting the number of messages received within the target time period and the number of timers that have timed out;
[0038] When it is determined that there is message loss in the message receiving queue, it is determined that the CPU utilization rate of the forwarding core is 100%.
[0039] According to a second aspect of the present disclosure, a system for determining CPU utilization is provided, the system comprising a forwarding core and a configuration core.
[0040] The forwarding core is used to count the number of messages received within a target time period and the number of timers that time out within the target time period;
[0041] The configuration core is used to obtain the number of messages and the number of timers of the forwarding core after the target time period ends;
[0042] The configuration core is used to determine the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers.
[0043] Optionally, the forwarding core is further used to count the number of calls of the while loop within the target time period;
[0044] The configuration core is also used to obtain the number of calls;
[0045] The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers, including:
[0046] The configuration core is further used to determine the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers and the number of calls.
[0047] Optionally, the configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the number of calls, including:
[0048] The configuration core is further used to determine a first impact parameter corresponding to the forwarding core according to the number of calls, wherein the first impact parameter is used to characterize the impact of the number of messages on CPU utilization;
[0049] The configuration core is further configured to determine the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers and the first influencing parameter.
[0050] Optionally, the configuration core is further used to determine a first impact parameter corresponding to the forwarding core according to the number of calls by using the following formula:
[0051]
[0052] The configuration core is further configured to determine the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the first influencing parameter by using the following formula:
[0053]
[0054] Wherein, Q represents the CPU utilization;
[0055] cur_pkt_sum represents the number of packets;
[0056] cur_timer_sum represents the number of timers;
[0057] cur_while_sum represents the number of calls;
[0058] ω is used to characterize the first influencing parameter of the number of packets on CPU utilization;
[0059] P1 represents the maximum number of messages that the forwarding core can receive within the target period;
[0060] P2 represents the maximum number of timeout timers that can be processed within the target period when the forwarding core has a new session performance limit;
[0061] P3 represents the number of times the while loop can be called at the throughput line rate within the target period;
[0062] α is used to characterize the second influencing parameter of the timer on the CPU utilization.
[0063] Optionally, the configuration core is further configured to, after the step of determining, according to the number of calls, a first influencing parameter corresponding to the forwarding core:
[0064] When the first influencing parameter is less than a first threshold, updating the first influencing parameter to the first threshold;
[0065] When the first influencing parameter is greater than a second threshold, updating the first influencing parameter to the second threshold, wherein the first threshold is less than the second threshold;
[0066] The configuration core is also used to:
[0067] The CPU utilization rate of the forwarding core within the target time period is determined according to the number of messages, the number of timers and the updated first influencing parameter.
[0068] Optionally, the forwarding core is further used for:
[0069] Determining whether a message receiving queue corresponding to the forwarding core loses a message within the target time period;
[0070] When it is determined that the message receiving queue has not lost any message, the forwarding core performs a step of counting the number of messages received within the target time period and the number of timers that have timed out;
[0071] When it is determined that there is message loss in the message receiving queue, it is determined that the CPU utilization rate of the forwarding core is 100%.
[0072] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of any method described in the first aspect are implemented.
[0073] According to a fourth aspect of the present disclosure, there is provided an electronic device, including:
[0074] a memory having a computer program stored thereon;
[0075] A processor is used to execute the computer program in the memory to implement the steps of any method described in the first aspect.
[0076] In the above technical solution, the forwarding core counts the number of messages received within the target time period and the number of timers that have timed out within the target time period; after the target time period ends, the configuration core obtains the number of messages and the number of timers of the forwarding core, and determines the CPU utilization of the forwarding core within the target time period based on the number of messages and the number of timers. Thus, through the above technical solution, the forwarding core only needs to count the number of messages processed and the number of timers that have timed out within the target time period, and does not need to obtain two timestamps for each message, which can effectively reduce the occupancy and overhead of the forwarding core processing resources for calculating the CPU utilization, and ensure the forwarding performance of the forwarding core. In addition, the calculation of the CPU utilization is calculated by the configuration core, so as to reduce the impact of the forwarding core calculating the CPU utilization on the forwarding performance, and ensure the accuracy of the CPU utilization calculation, while effectively ensuring the stability of the message forwarding system. In addition, the number of messages and the number of timers that have timed out are counted as variables of each forwarding core, and multi-core sharing does not require locked access, and can be read regularly by the configuration core, and reading and writing are not mutually exclusive, so as to further improve the high performance of multi-core concurrent processing of CPU utilization.
[0077] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0079] Figure 1 is a flowchart of a method for determining CPU utilization provided according to an embodiment of the present disclosure;
[0080] Figure 2 is a schematic diagram of a message forwarding system provided by an embodiment of the present disclosure;
[0081] Figure 3 is a flowchart of an exemplary implementation method of the configuration core determining the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers and the number of calls provided according to an embodiment of the present disclosure;
[0082] Figure 4 is a block diagram of an electronic device according to an exemplary embodiment;
[0083] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0084] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0085] As described in the background technology, the message forwarding system based on the DPDK platform mainly traverses the receiving queue of each network card in an infinite loop in the user-mode CPU, receives messages from the network card and forwards the messages. In the prior art, the CPU utilization CPU_OPPUCY is usually calculated in the following way:
[0086] OPPUCY_TSC_COST = the sum of the processing time of each message + the timer processing time;
[0087] TOTAL_TSC_COST = CPU processing time for all operations;
[0088] CPU_OPPUCY=OPPUCY_TSC_COST / TOTAL_TSC_COST;
[0089] It can be clearly seen that if the number of messages processed during this period is small, the CPU utilization is low, otherwise the utilization is high. In this solution, the corresponding timestamp TSC needs to be obtained before and after each message is processed, so that the processing time cost_csc of the message can be obtained:
[0090] cost_csc=after_tsc–before_tsc;
[0091] Among them, after_tsc is the timestamp obtained after the message is processed, and before_tsc is the timestamp obtained before the message is processed.
[0092] Therefore, in the above technical solution, it is necessary to frequently obtain timestamps, which incurs a large overhead on the resources of the message forwarding system and causes a decrease in the overall stability of the message forwarding system.
[0093] The applicant found that the firewall system is relatively complex. In addition to receiving messages from the network card (Gigabit network port + 10G network port), it still needs to receive and process messages from other forwarding cores and configuration cores, and needs to process timer operations. For the firewall, the forwarding core can query the session table after receiving the message, and forward it accordingly based on the queried session table; if the session table is not queried, it is necessary to build a session table according to the policy, so the forwarding core also needs to pay attention to the timeout mechanism of the session table.
[0094] In summary, each forwarding core can perform corresponding operations by continuously calling the while loop. The operations that need to be performed in each while loop include:
[0095] 1. Receive messages from each network card (Gigabit Ethernet port + 10 Gigabit Ethernet port) and process the messages;
[0096] 2. Receive messages from other forwarding cores and process them;
[0097] 3. Receive messages from each configuration core and process the messages;
[0098] 4. Send out the accumulated messages regularly;
[0099] 5. Process the timeout timer corresponding to elements such as the session table;
[0100] As described above, in a message forwarding system based on the DPDK platform, the operations performed by the forwarding core are basically processing messages and processing timers, that is, the CPU utilization is related to the number of message processing. Therefore, in an embodiment of the present disclosure, the CPU utilization can be approximately determined based on the number of messages processed. Based on this, the present disclosure provides the following embodiments to easily determine the CPU utilization.
[0101] Figure 1 As shown, it is a flowchart of a method for determining CPU utilization according to an embodiment of the present disclosure, such as Figure 1 As shown, the method includes:
[0102] In step 11, the forwarding core counts the number of packets received within the target time period and the number of timers that time out within the target time period.
[0103] For example, Figure 2 The schematic diagram of the message forwarding system provided by the embodiment of the present disclosure is shown, wherein the system may include multiple forwarding cores (CPU0-CPU3) and multiple configuration cores (CPU4-CPU7). Before the start of the target period, the number of messages and the number of timers in each forwarding core are initialized to 0, and the number of messages is increased by one for each message received, and if a timer times out during the target period, the number of timers is increased by one, so that the number of messages and the number of timers that have timed out during the target period can be conveniently and accurately counted, thereby ensuring the accuracy of the statistical information.
[0104] In step 12, after the target period ends, the configuration core obtains the number of messages and the number of timers of the forwarding core.
[0105] For example, Figure 2As shown, one or more configuration cores can be selected from multiple configuration cores to obtain the number of messages and the number of timers of the forwarding core. For example, CPU4 is selected as the configuration core, and the forwarding core can store the number of messages and the number of timers counted by it in the statistical file of the forwarding core. The configuration core CPU4 can perform readable access to the statistical file in any forwarding core, so as to obtain the information in the statistical file, and will not affect the forwarding performance of the forwarding core.
[0106] In step 13, the configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers.
[0107] For example, the number of messages and the number of timers of each forwarding core that can be acquired by the configuration core determine the CPU utilization rate of the forwarding core in the target time period.
[0108] In the above technical solution, the forwarding core counts the number of messages received within the target time period and the number of timers that have timed out within the target time period; after the target time period ends, the configuration core obtains the number of messages and the number of timers of the forwarding core, and determines the CPU utilization of the forwarding core within the target time period based on the number of messages and the number of timers. Thus, through the above technical solution, the forwarding core only needs to count the number of messages processed and the number of timers that have timed out within the target time period, and does not need to obtain two timestamps for each message, which can effectively reduce the occupancy and overhead of the forwarding core processing resources for calculating the CPU utilization, and ensure the forwarding performance of the forwarding core. In addition, the calculation of the CPU utilization is calculated by the configuration core, so as to reduce the impact of the forwarding core calculating the CPU utilization on the forwarding performance, and ensure the accuracy of the CPU utilization calculation, while effectively ensuring the stability of the message forwarding system. In addition, the number of messages and the number of timers that have timed out are counted as variables of each forwarding core, and multi-core sharing does not require locked access, and can be read regularly by the configuration core, and reading and writing are not mutually exclusive, so as to further improve the high performance of multi-core concurrent processing of CPU utilization.
[0109] In order to enable those skilled in the art to better understand the technical solution provided by the embodiment of the present invention, the above steps are described in detail below.
[0110] Optionally, in step 13, the CPU utilization of the forwarding core in the target time period may be determined by the configuration core according to the number of messages and the number of timers using the following formula:
[0111]
[0112] Wherein, Q represents the CPU utilization;
[0113] cur_pkt_sum represents the number of packets;
[0114] cur_timer_sum represents the number of timers;
[0115] P1 represents the maximum number of messages that the forwarding core can receive within the target period;
[0116] P2 represents the maximum number of timeout timers that can be processed within the target period when the forwarding core has a new session performance limit;
[0117] α is used to characterize the second influencing parameter of the timer on the CPU utilization.
[0118] Among them, P1 and P2 can be obtained by conducting preliminary tests on CPU processors of different specifications and types, and the present disclosure does not limit this. The applicant has found that the forwarding core mainly performs the processing and forwarding operations of the message, and the timer timeout processing corresponds to a limited number of operations that the forwarding core needs to perform, so its influence on the CPU utilization of the entire forwarding core is limited. Therefore, the present disclosure increases the second influencing parameter α to avoid excessive influence of the timer on the CPU utilization. For example, the value of α can be 0.1, that is, the influence of the timer on the CPU utilization does not exceed 10%, which can be set according to the actual usage scenario, and the present disclosure does not limit this.
[0119] Therefore, the CPU utilization can be calculated through the above technical solution, so that the real-time CPU utilization can be obtained. At the same time, the configuration core can write the determined CPU utilization into a file for storage. Compared with the prior art in which the forwarding core calculates the CPU utilization and writes the file to output and display it to the user, it can further reduce the impact of the CPU utilization determination on the forwarding core performance, and facilitate users to timely understand the CPU performance of the message forwarding system, thereby improving the user experience.
[0120] In actual usage scenarios, the processing time of different messages may be different, and the processing time of each timer may also be different, so that the duration of processing the message in each while loop may be different. Therefore, the present disclosure also provides the following embodiments to further improve the accuracy of the determined CPU utilization.
[0121] Optionally, the method further comprises:
[0122] The forwarding core counts the number of calls of the while loop within the target time period;
[0123] The configuration core obtains the calling number.
[0124] Among them, as described above, it can be known that the fewer the number of calls of the while loop in the target period, the longer the time for processing the message in the while loop, that is, the higher the CPU utilization rate. Similarly, the forwarding core can initialize the number of calls in each target period, with an initial value of 0, and the number of calls is increased by one each time the while loop call is executed. The configuration core can implement lock-free reading of the number of calls to obtain the number of calls.
[0125] In step 13, an exemplary implementation of the configuration core determining the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers is as follows, including:
[0126] The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the number of calls.
[0127] Therefore, through the above technical scheme, not only the number of messages processed and the number of timers that time out within the target time period are taken into consideration, but also the impact of different messages that may be processed in each while loop is fully considered, which can improve the comprehensiveness of the reference parameters for determining the CPU utilization, thereby ensuring the accuracy of the determined CPU utilization, making the determination of the CPU utilization match the actual usage scenario, and broadening the scope of application of the method for determining the CPU utilization.
[0128] Optionally, an exemplary implementation manner in which the configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the number of calls is as follows: Figure 3 As shown, this step may include:
[0129] In step 31, according to the number of calls, a first impact parameter corresponding to the forwarding core is determined, wherein the first impact parameter is used to characterize the impact of the number of packets on the CPU utilization;
[0130] As described above, the fewer the number of calls to the while loop within the target period, the longer the time it takes to process the message in the while loop, which means that the CPU utilization is higher. Therefore, the number of messages is weighted based on the number of calls to ensure the accurate impact of the number of messages when determining the CPU utilization.
[0131] For example, the first impact parameter corresponding to the forwarding core is determined according to the number of calls by the following formula:
[0132]
[0133] Wherein, cur_while_sum represents the number of calls;
[0134] ω is used to characterize the first influencing parameter of the number of packets on CPU utilization;
[0135] P3 represents the number of times the while loop can be called to process messages at the throughput line speed within the target time period, wherein P3 can be obtained through preliminary tests based on the specifications and types of the CPU in the message forwarding system, and the present disclosure does not limit this.
[0136] In step 32, the CPU utilization of the forwarding core in the target time period is determined according to the number of messages, the number of timers and the first influencing parameter.
[0137] Optionally, the CPU utilization of the forwarding core in the target time period is determined according to the number of messages, the number of timers, and the first influencing parameter by the following formula:
[0138]
[0139] Wherein, Q represents the CPU utilization;
[0140] cur_pkt_sum represents the number of packets;
[0141] cur_timer_sum represents the number of timers;
[0142] P1 represents the maximum number of messages that the forwarding core can receive within the target period;
[0143] P2 represents the maximum number of timeout timers that can be processed within the target period when the forwarding core has a new session performance limit;
[0144] α is used to characterize the second influencing parameter of the timer on the CPU utilization. The setting of the second influencing parameter has been described in detail above and will not be repeated here.
[0145] Therefore, through the above technical solution, when determining the corresponding CPU utilization by the number of messages processed within the target time period and the number of timers that have timed out, the first influencing parameter is determined by the number of calls of the while loop, and the calculated value of the number of messages is weighted, so that when calculating the CPU utilization, the time used to process messages within the target time period can be accurately characterized, thereby improving the accuracy of the determined CPU utilization and providing accurate data support for subsequent processing of the message forwarding system based on CPU utilization.
[0146] Optionally, after the step of determining, according to the number of calls, a first influencing parameter corresponding to the forwarding core, the method further includes:
[0147] When the first influencing parameter is less than a first threshold, updating the first influencing parameter to the first threshold;
[0148] When the first influencing parameter is greater than a second threshold, the first influencing parameter is updated to the second threshold, wherein the first threshold is less than the second threshold.
[0149] Among them, the applicant has found that in the forwarding core, the maximum time and the shortest time for processing each message will not differ too much, so its impact on CPU utilization will not differ too much. Therefore, the parameter range of the first influencing parameter can be set in the present disclosure, the first threshold is the lower limit of the parameter range, and the second threshold is the upper limit of the parameter range. For example, the first threshold can be set to 0.8, and the second threshold can be set to 1.2. In this embodiment, if the first influencing parameter determined based on the number of calls is less than 0.8, the first influencing parameter can be updated to 0.8, if the first influencing parameter determined based on the number of calls is greater than 1.2, the first influencing parameter can be updated to 1.2, and if the first influencing parameter determined based on the number of calls is 0.9, the first influencing parameter remains unchanged at 0.9.
[0150] Accordingly, in step 32, an exemplary implementation of determining the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the first influencing parameter is as follows, including:
[0151] The CPU utilization rate of the forwarding core within the target time period is determined according to the number of messages, the number of timers and the updated first impact parameter.
[0152] That is, when the first influencing parameter determined in step 31 is 0.7, it can be updated to 0.8 through the above steps. Then, when the CPU utilization is determined by formula (2), the first influencing parameter is calculated as 0.8.
[0153] Therefore, through the above technical scheme, not only the impact of the number of calls of the while loop on the CPU utilization is taken into account, but also the range of impact that the number of calls of the while loop can have on the CPU utilization is fully considered, thereby providing data support for accurately determining the CPU utilization and further improving the accuracy of the determined CPU utilization.
[0154] Optionally, the method further comprises:
[0155] The forwarding core determines whether a message receiving queue corresponding to the forwarding core loses a message within the target time period. The message receiving queue may be one or more of a network card message receiving queue, an inter-core message receiving queue, a heterogeneous platform message receiving queue, and the like.
[0156] When it is determined that the message receiving queue has not lost any message, the forwarding core performs a step of counting the number of messages received within the target time period and the number of timers that have timed out;
[0157] When it is determined that there is message loss in the message receiving queue, it is determined that the CPU utilization rate of the forwarding core is 100%.
[0158] Among them, when there is message loss in any message receiving queue, it means that the processing performance of the current forwarding core for messages has reached the limit, and the CPU utilization of the forwarding core can be directly determined to be 100%. When it is determined that the message receiving queue has not lost messages, it means that the CPU of the current forwarding core is still idle, and steps 11-13 can be performed to further determine the CPU utilization of the forwarding core in the target time period. Therefore, through the above technical solution, the process of determining the CPU utilization can be further simplified, the amount of data calculation and statistics required in the determination process can be reduced, and the efficiency of determining the CPU utilization can also be improved, and the real-time and accuracy of the CPU utilization can be ensured.
[0159] Optionally, the CPU utilization can be approximately calculated in the above manner, and the method further includes: when the determined CPU utilization is greater than 100%, the CPU utilization can be updated to 100%, thereby ensuring the rationality and accuracy of the determined CPU utilization.
[0160] The present disclosure also provides a system for determining CPU utilization, the system comprising a forwarding core and a configuration core.
[0161] The forwarding core is used to count the number of messages received within a target time period and the number of timers that time out within the target time period;
[0162] The configuration core is used to obtain the number of messages and the number of timers of the forwarding core after the target time period ends;
[0163] The configuration core is used to determine the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers.
[0164] Optionally, the forwarding core is further used to count the number of calls of the while loop within the target time period;
[0165] The configuration core is also used to obtain the number of calls;
[0166] The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers, including:
[0167] The configuration core is further used to determine the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers and the number of calls.
[0168] Optionally, the configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the number of calls, including:
[0169] The configuration core is further used to determine a first impact parameter corresponding to the forwarding core according to the number of calls, wherein the first impact parameter is used to characterize the impact of the number of messages on CPU utilization;
[0170] The configuration core is further configured to determine the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers and the first influencing parameter.
[0171] Optionally, the configuration core is further used to determine a first impact parameter corresponding to the forwarding core according to the number of calls by using the following formula:
[0172]
[0173] The configuration core is further configured to determine the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the first influencing parameter by using the following formula:
[0174]
[0175] Wherein, Q represents the CPU utilization;
[0176] cur_pkt_sum represents the number of packets;
[0177] cur_timer_sum represents the number of timers;
[0178] cur_while_sum represents the number of calls;
[0179] ω is used to characterize the first influencing parameter of the number of packets on CPU utilization;
[0180] P1 represents the maximum number of messages that the forwarding core can receive within the target period;
[0181] P2 represents the maximum number of timeout timers that can be processed within the target period when the forwarding core has a new session performance limit;
[0182] P3 represents the number of times the while loop can be called at the throughput line rate within the target period;
[0183] α is used to characterize the second influencing parameter of the timer on the CPU utilization.
[0184] Optionally, the configuration core is further configured to, after the step of determining, according to the number of calls, a first influencing parameter corresponding to the forwarding core:
[0185] When the first influencing parameter is less than a first threshold, updating the first influencing parameter to the first threshold;
[0186] When the first influencing parameter is greater than a second threshold, updating the first influencing parameter to the second threshold, wherein the first threshold is less than the second threshold;
[0187] The configuration core is also used to:
[0188] The CPU utilization rate of the forwarding core within the target time period is determined according to the number of messages, the number of timers and the updated first influencing parameter.
[0189] Optionally, the forwarding core is further used for:
[0190] Determining whether a message receiving queue corresponding to the forwarding core loses a message within the target time period;
[0191] When it is determined that the message receiving queue has not lost any message, the forwarding core performs a step of counting the number of messages received within the target time period and the number of timers that have timed out;
[0192] When it is determined that there is message loss in the message receiving queue, it is determined that the CPU utilization rate of the forwarding core is 100%.
[0193] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0194] Figure 4 FIG. 7 is a block diagram of an electronic device 700 according to an exemplary embodiment. Figure 4 As shown, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.
[0195] The processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned method for determining the CPU utilization. The memory 702 is used to store various types of data to support the operation of the electronic device 700, and these data may include, for example, instructions for any application or method used to operate on the electronic device 700, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent through the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0196] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned method for determining CPU utilization.
[0197] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned method for determining CPU utilization are implemented. For example, the computer-readable storage medium may be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions may be executed by the processor 701 of the electronic device 700 to complete the above-mentioned method for determining CPU utilization.
[0198] Figure 5 1 is a block diagram of an electronic device 1900 according to an exemplary embodiment. For example, the electronic device 1900 may be provided as a server. Figure 5 The electronic device 1900 includes a processor 1922, which may be one or more, and a memory 1932 for storing a computer program executable by the processor 1922. The computer program stored in the memory 1932 may include one or more modules each corresponding to a set of instructions. In addition, the processor 1922 may be configured to execute the computer program to perform the above-mentioned method for determining CPU utilization.
[0199] In addition, the electronic device 1900 may further include a power supply component 1926 and a communication component 1950. The power supply component 1926 may be configured to perform power management of the electronic device 1900, and the communication component 1950 may be configured to implement communication of the electronic device 1900, for example, wired or wireless communication. In addition, the electronic device 1900 may further include an input / output (I / O) interface 1958. The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2003. TM , Mac OS X TM , Unix TM , Linux TMetc.
[0200] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned method for determining CPU utilization are implemented. For example, the computer-readable storage medium may be the above-mentioned memory 1932 including program instructions, and the above-mentioned program instructions may be executed by the processor 1922 of the electronic device 1900 to complete the above-mentioned method for determining CPU utilization.
[0201] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program executable by a programmable device, and the computer program has a code portion for executing the above-mentioned method for determining CPU utilization when executed by the programmable device.
[0202] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.
[0203] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0204] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A method for determining CPU utilization, characterized in that: The method comprises: The forwarding core counts the number of messages received within a target time period and the number of timers that time out within the target time period; After the target time period ends, the configuration core obtains the number of messages and the number of timers of the forwarding core; The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers; The method further comprises: The forwarding core counts the number of calls of the while loop within the target time period; The configuration core obtains the calling number; The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers, including: The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers and the number of calls; The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the number of calls, including: Determine, according to the number of calls, a first impact parameter corresponding to the forwarding core, wherein the first impact parameter is used to characterize the impact of the number of messages on CPU utilization; The CPU utilization rate of the forwarding core within the target time period is determined according to the number of messages, the number of timers, and the first influencing parameter.
2. The method according to claim 1, characterized in that The first impact parameter corresponding to the forwarding core is determined according to the number of calls by the following formula: ; The CPU utilization of the forwarding core in the target time period is determined according to the number of messages, the number of timers, and the first influencing parameter by the following formula: Wherein, Q represents the CPU utilization; cur_pkt_sum represents the number of packets; cur_timer_sum represents the number of timers; cur_while_sum represents the number of calls; ω is used to characterize the first influencing parameter of the number of packets on CPU utilization; P1 represents the maximum number of messages that the forwarding core can receive within the target period; P2 represents the maximum number of timeout timers that can be processed within the target period when the forwarding core has a new session performance limit; P3 represents the number of times the while loop can be called at the throughput line rate within the target period; α is used to characterize the second influencing parameter of the timer on the CPU utilization.
3. The method according to claim 1 or 2, characterized in that: After the step of determining the first influencing parameter corresponding to the forwarding core according to the number of calls, the method further includes: When the first influencing parameter is less than a first threshold, updating the first influencing parameter to the first threshold; When the first influencing parameter is greater than a second threshold, updating the first influencing parameter to the second threshold, wherein the first threshold is less than the second threshold; The determining, according to the number of messages, the number of timers, and the first influencing parameter, the CPU utilization of the forwarding core within the target time period includes: The CPU utilization rate of the forwarding core within the target time period is determined according to the number of messages, the number of timers and the updated first impact parameter.
4. The method according to claim 1, characterized in that The method further comprises: The forwarding core determines whether a message receiving queue corresponding to the forwarding core loses a message within the target time period; When it is determined that the message receiving queue has not lost any message, the forwarding core performs a step of counting the number of messages received within the target time period and the number of timers that have timed out; When it is determined that there is message loss in the message receiving queue, it is determined that the CPU utilization rate of the forwarding core is 100%.
5. A system for determining CPU utilization, characterized in that: The system includes a forwarding core and a configuration core. The forwarding core is used to count the number of messages received within a target time period and the number of timers that time out within the target time period; The configuration core is used to obtain the number of messages and the number of timers of the forwarding core after the target time period ends; The configuration core is used to determine the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers; The forwarding core is also used to count the number of calls of the while loop within the target time period; The configuration core is also used to obtain the number of calls; The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages and the number of timers, including: The configuration core is further used to determine the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers and the number of calls; The configuration core determines the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers, and the number of calls, including: The configuration core is further used to determine a first impact parameter corresponding to the forwarding core according to the number of calls, wherein the first impact parameter is used to characterize the impact of the number of messages on CPU utilization; The configuration core is further configured to determine the CPU utilization of the forwarding core within the target time period according to the number of messages, the number of timers and the first influencing parameter.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 4 are implemented.
7. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 4.
