CN112162901A - Method, system, storage medium and electronic device for determining CPU utilization rate - Google Patents

Method, system, storage medium and electronic device for determining CPU utilization rate Download PDF

Info

Publication number
CN112162901A
CN112162901A CN202010997284.1A CN202010997284A CN112162901A CN 112162901 A CN112162901 A CN 112162901A CN 202010997284 A CN202010997284 A CN 202010997284A CN 112162901 A CN112162901 A CN 112162901A
Authority
CN
China
Prior art keywords
core
target time
cpu utilization
forwarding
forwarding core
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010997284.1A
Other languages
Chinese (zh)
Inventor
刘健男
党丽娜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Neusoft Corp
Original Assignee
Neusoft Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Neusoft Corp filed Critical Neusoft Corp
Priority to CN202010997284.1A priority Critical patent/CN112162901A/en
Publication of CN112162901A publication Critical patent/CN112162901A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3024Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • G06F11/3419Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment by assessing time
    • G06F11/3423Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment by assessing time where the assessed time is active or idle time
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3452Performance evaluation by statistical analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present disclosure relates to a method, a system, a storage medium, and an electronic device for determining a CPU utilization, the method including: the forwarding core counts the number of messages received in a target time period and the number of overtime timers in the target time period; after the target time interval is finished, the configuration core acquires the message quantity and the timer quantity of the forwarding core; and the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity. Through the technical scheme, the forwarding core only needs to count the number of the processed messages and the number of the overtime timers in the target time period, so that the occupation and the expense of the CPU utilization rate on the processing resources of the forwarding core can be effectively reduced, and the forwarding performance of the forwarding core is ensured. And moreover, the stability of the message forwarding system can be effectively ensured, and the high performance of the multi-core concurrent processing CPU utilization rate is further improved.

Description

Method, system, storage medium and electronic device for determining CPU utilization rate
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and a system for determining a CPU utilization, a storage medium, and an electronic device.
Background
A packet forwarding system developed based on a DPDK (Data Plane Development Kit) platform is based on a dead-cycle mode to receive and transmit packets from a network card, and the process requires monopolizing a CPU, in which case the CPU utilization is generally determined to be 100%.
However, in an actual usage scenario, the CPU utilization rate represents whether the CPU has spare capacity to process other tasks, and in the scheduling manner based on the DPDK dead loop, the CPU utilization rate cannot be determined by using the general process utilization rate, and is usually determined based on the time corresponding to the CPU idle processing and the packet processing. In the above manner, the corresponding time stamp TSC needs to be obtained before and after processing of each message, so as to obtain the time corresponding to message processing, and the frequent obtaining of the TSC occupies a large overhead of the message forwarding system, which affects the performance of the message forwarding system.
Disclosure of Invention
An object of the present disclosure is to provide a simple, high-performance CPU utilization determination method, system, storage medium, and electronic device.
In order to achieve the above object, according to a first aspect of the present disclosure, there is provided a method of determining a CPU utilization, the method including:
the forwarding core counts the number of messages received in a target time period and the number of overtime timers in the target time period;
after the target time interval is finished, the configuration core acquires the message quantity and the timer quantity of the forwarding core;
and the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity.
Optionally, the method further comprises:
the forwarding core counts the calling times of while circulation in the target time period;
the configuration core acquires the calling times;
the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity, and the method comprises the following steps:
and the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the calling times.
Optionally, the determining, by the configuration core, the CPU utilization of the forwarding core in the target time period according to the packet number, the timer number, and the call times includes:
determining a first influence parameter corresponding to the forwarding core according to the calling times, wherein the first influence parameter is used for representing the influence of the message quantity on the CPU utilization rate;
and determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the first influence parameter.
Optionally, the first impact parameter corresponding to the forwarding core is determined according to the number of calls by the following formula:
Figure BDA0002693037250000021
determining the CPU utilization rate of the forwarding core in the target time interval according to the number of the messages, the number of the timers and the first influence parameter by the following formula:
Figure BDA0002693037250000022
wherein Q represents the CPU utilization;
cur _ pkt _ sum represents the number of messages;
cur _ timer _ sum represents the timer number;
cur _ while _ sum represents the number of calls;
omega is used for representing a first influence parameter of the message quantity on the CPU utilization rate;
p1 represents the limit number of messages that can be received by the forwarding core in the target time period;
p2 represents the limit number of timeout timers that can be processed in the case of the forwarding core new session performance limit in the target time period;
p3 represents the number of while loops that can be invoked at throughput line speed within the target time period;
alpha is used to characterize the second impact parameter of the timer on CPU utilization.
Optionally, after the step of determining the first impact parameter corresponding to the forwarding core according to the number of calls, the method further includes:
updating the first impact parameter to a first threshold when the first impact parameter is less than the first threshold;
updating the first impact parameter to a second threshold when the first impact parameter is greater than the second threshold, wherein the first threshold is less than the second threshold;
determining the CPU utilization of the forwarding core in the target time period according to the packet number, the timer number, and the first impact parameter includes:
and determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the updated first influence parameter.
Optionally, the method further comprises:
the forwarding core determines whether a message receiving queue corresponding to the forwarding core loses a message in the target time period;
under the condition that the message receiving queue is determined not to lose the message, the step that the forwarding core counts the number of the received messages in a target time period and the number of overtime timers is executed;
and under the condition that the message receiving queue is determined to have message loss, determining that the CPU utilization rate of the forwarding core is 100%.
According to a second aspect of the present disclosure, there is provided a CPU utilization determination system, the system comprising a forwarding core and a configuration core,
the forwarding core is used for counting the number of messages received in a target time period and the number of overtime timers in the target time period;
the configuration core is used for acquiring the message quantity and the timer quantity of the forwarding core after the target time interval is ended;
and the configuration core is used for determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity.
Optionally, the forwarding core is further configured to count the number of calls of while loop in the target time period;
the configuration core is further used for acquiring the calling times;
the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity, and the method comprises the following steps:
and the configuration core is further used for determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the calling times.
Optionally, the determining, by the configuration core, the CPU utilization of the forwarding core in the target time period according to the packet number, the timer number, and the call times includes:
the configuration core is further configured to determine a first influence parameter corresponding to the forwarding core according to the number of calls, where the first influence parameter is used to represent an influence of the number of packets on a CPU utilization rate;
and the configuration core is further configured to determine the CPU utilization rate of the forwarding core in the target time period according to the packet number, the timer number, and the first impact parameter.
Optionally, the configuration core is further configured to determine, according to the number of calls, a first impact parameter corresponding to the forwarding core by using the following formula:
Figure BDA0002693037250000041
the configuration core is further configured to determine, according to the number of packets, the number of timers, and the first impact parameter, a CPU utilization rate of the forwarding core in the target time period by the following formula:
Figure BDA0002693037250000051
wherein Q represents the CPU utilization;
cur _ pkt _ sum represents the number of messages;
cur _ timer _ sum represents the timer number;
cur _ while _ sum represents the number of calls;
omega is used for representing a first influence parameter of the message quantity on the CPU utilization rate;
p1 represents the limit number of messages that can be received by the forwarding core in the target time period;
p2 represents the limit number of timeout timers that can be processed in the case of the forwarding core new session performance limit in the target time period;
p3 represents the number of while loops that can be invoked at throughput line speed within the target time period;
alpha is used to characterize the second impact parameter of the timer on CPU utilization.
Optionally, after the step of determining the first impact parameter corresponding to the forwarding core according to the number of calls, the configuration core is further configured to:
updating the first impact parameter to a first threshold when the first impact parameter is less than the first threshold;
updating the first impact parameter to a second threshold when the first impact parameter is greater than the second threshold, wherein the first threshold is less than the second threshold;
the configuration core is further to:
and determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the updated first influence parameter.
Optionally, the forwarding core is further configured to:
determining whether a message receiving queue corresponding to the forwarding core loses a message in the target time period;
under the condition that the message receiving queue is determined not to lose the message, the step that the forwarding core counts the number of the received messages in a target time period and the number of overtime timers is executed;
and under the condition that the message receiving queue is determined to have message loss, determining that the CPU utilization rate of the forwarding core is 100%.
According to a third aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of any of the methods of the first aspect described above.
According to a fourth aspect of the present disclosure, there is provided an electronic device comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of any of the first aspects.
In the technical scheme, the forwarding core counts the number of messages received in a target time period and the number of overtime timers in the target time period; and after the target time interval is finished, the configuration core acquires the message quantity and the timer quantity of the forwarding core, and determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity. Therefore, by the technical scheme, the forwarding core only needs to count the number of the processed messages and the number of the overtime timers in the target time period, and does not need to acquire the timestamps twice for each message, so that the occupation and the expenditure of the CPU utilization rate on the processing resources of the forwarding core can be effectively reduced, and the forwarding performance of the forwarding core is ensured. And the CPU utilization rate is calculated by the configuration core, so that the influence of the CPU utilization rate calculated by the forwarding core on the forwarding performance can be reduced, the accuracy of the CPU utilization rate calculation is ensured, and the stability of the message forwarding system can be effectively ensured. In addition, the counted message quantity and the overtime timer quantity are used as variables of each forwarding core, multi-core sharing does not need locking access, the messages can be periodically read by a configuration core, reading and writing are not mutually exclusive, and therefore high performance of the multi-core concurrent processing CPU utilization rate can be further improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow chart of a method of determining CPU utilization provided in accordance with one embodiment of the present disclosure;
fig. 2 is a schematic diagram of a message forwarding system provided in the embodiment of the present disclosure;
fig. 3 is a flowchart of an exemplary implementation manner, provided by the configuration core according to an embodiment of the present disclosure, that determines, according to the number of packets, the number of timers, and the number of times of calls, a CPU utilization rate of the forwarding core in the target time period;
FIG. 4 is a block diagram illustrating an electronic device in accordance with an exemplary embodiment;
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
As described in the background art, the packet forwarding system based on the DPDK platform mainly traverses the receive queue of each network card in a dead loop in the user-mode CPU, receives a packet from the network card, and forwards the packet. In the prior art, the CPU utilization CPU _ OPPUCY is usually calculated as follows:
OPPUCY _ TSC _ COST is the sum of the processing time of each message and the processing time of a timer;
TOTAL _ TSC _ COST is the processing time for the CPU to perform all operations;
CPU_OPPUCY=OPPUCY_TSC_COST/TOTAL_TSC_COST;
therefore, it can be seen that if the number of processed packets in this period is small, the utilization rate of the CPU is low, and otherwise, the utilization rate is high. In the scheme, corresponding time stamps TSC are required to be acquired before and after each message is processed, so that the processing time cost _ csc of the message can be acquired:
cost_csc=after_tsc–before_tsc;
wherein, after _ tsc is the timestamp obtained after the message processing, and before _ tsc is the timestamp obtained before the message processing.
Therefore, in the above technical scheme, the timestamp needs to be frequently acquired, and the overhead of resource occupation of the message forwarding system is large, which may cause the overall stability of the message forwarding system to be reduced.
The applicant finds that the firewall system is relatively complex, and besides the message needs to be received from the network card (gigabit network port + tera network port), the firewall system still needs to receive and process the message from other forwarding cores and configuration cores, and needs to process the operation of the timer. For the firewall, after the forwarding core receives the message, the session table can be inquired, and the message is correspondingly forwarded based on the inquired session table; if the session table is not queried, the session table needs to be constructed according to the policy, so the forwarding core also needs to pay attention to the timeout mechanism of the session table.
In summary, each forwarding core may always call a while loop to execute a corresponding operation, where the operations to be executed in each while loop include:
1. receiving a message from each network card (kilomega network port + giga network port) and processing the message;
2. receiving messages from other forwarding cores and processing the messages;
3. receiving a message from each configuration core and processing the message;
4. sending out the accumulated messages at regular time;
5. processing overtime timers corresponding to elements such as a session table and the like;
as described above, in the DPDK platform-based packet forwarding system, the forwarding core basically performs operations of processing packets and processing timers, that is, the CPU utilization rate is related to the number of packet processes. Therefore, in the embodiments of the present disclosure, the CPU utilization may be determined approximately based on the number of processed messages. Based on this, the present disclosure provides the following embodiments to facilitate determining CPU utilization.
Fig. 1 is a flowchart illustrating a method for determining CPU utilization according to an embodiment of the present disclosure, where as shown in fig. 1, the method includes:
in step 11, the forwarding core counts the number of messages received in the target time period and the number of overtime timers in the target time period.
For example, as shown in fig. 2, a schematic diagram of a message forwarding system provided in the embodiment of the present disclosure is shown, where the system may include multiple forwarding cores (CPU0-CPU3) and multiple configuration cores (CPU4-CPU 7). Before the target time interval begins, the number of messages and the number of timers in each forwarding core are initialized to 0, one operation is added to the number of messages when one message is received, and if the timer is overtime in the target time interval, the number of timers is added, so that the number of messages and the number of overtime timers in the target time interval can be counted conveniently and accurately, and the accuracy of statistical information is ensured.
In step 12, after the target time interval is over, the configuration core obtains the number of messages and the number of timers of the forwarding core.
For example, as shown in fig. 2, one or more configuration cores may be selected from the plurality of configuration cores to obtain the packet number and the timer number of the forwarding core. For example, the CPU4 is selected as the configuration core, and the forwarding core may correspondingly store the counted packet number and the counted timer number in the statistics file of the forwarding core. The configuration core CPU4 has readable access to the statistics file in any forwarding core, so that the information in the statistics file can be obtained without affecting the forwarding performance of the forwarding core.
In step 13, the configuration core determines the CPU utilization of the forwarding core in the target time period according to the number of the messages and the number of the timers.
For example, the number of packets and the number of timers that can be acquired by the configuration core for each forwarding core determine the CPU utilization of the forwarding core in the target time period.
In the technical scheme, the forwarding core counts the number of messages received in a target time period and the number of overtime timers in the target time period; and after the target time interval is finished, the configuration core acquires the message quantity and the timer quantity of the forwarding core, and determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity. Therefore, by the technical scheme, the forwarding core only needs to count the number of the processed messages and the number of the overtime timers in the target time period, and does not need to acquire the timestamps twice for each message, so that the occupation and the expenditure of the CPU utilization rate on the processing resources of the forwarding core can be effectively reduced, and the forwarding performance of the forwarding core is ensured. And the CPU utilization rate is calculated by the configuration core, so that the influence of the CPU utilization rate calculated by the forwarding core on the forwarding performance can be reduced, the accuracy of the CPU utilization rate calculation is ensured, and the stability of the message forwarding system can be effectively ensured. In addition, the counted message quantity and the overtime timer quantity are used as variables of each forwarding core, multi-core sharing does not need locking access, the messages can be periodically read by a configuration core, reading and writing are not mutually exclusive, and therefore high performance of the multi-core concurrent processing CPU utilization rate can be further improved.
In order to make those skilled in the art understand the technical solutions provided by the embodiments of the present invention, the following detailed descriptions are provided for the above steps.
Optionally, in step 13, the CPU utilization of the forwarding core in the target time period may be determined according to the number of packets and the number of timers by using the following formula:
Figure BDA0002693037250000101
wherein Q represents the CPU utilization;
cur _ pkt _ sum represents the number of messages;
cur _ timer _ sum represents the timer number;
p1 represents the limit number of messages that can be received by the forwarding core in the target time period;
p2 represents the limit number of timeout timers that can be processed in the case of the forwarding core new session performance limit in the target time period;
alpha is used to characterize the second impact parameter of the timer on CPU utilization.
The P1 and P2 can be obtained by performing preliminary experiments on CPU processors of different specifications and types, and the disclosure does not limit the method. The applicant researches and discovers that the forwarding core mainly executes the processing and forwarding operation on the message, and if the overtime processing of the timer is limited in the number of operations that the forwarding core needs to execute, the overtime processing has limited influence on the determination of the CPU utilization rate of the whole forwarding core. Therefore, the second influence parameter α is increased in the present disclosure to avoid an excessive influence of the timer on the CPU utilization. The value of α may be 0.1 as an example, that is, the influence of the timer on the CPU utilization does not exceed 10%, which may be set according to an actual usage scenario, which is not limited by the present disclosure.
Therefore, the CPU utilization rate can be calculated through the technical scheme, so that the real-time CPU utilization rate can be obtained. Meanwhile, the configuration core can write the determined CPU utilization rate into a file for storage, and compared with the forwarding core in the prior art that the CPU utilization rate is calculated and the file is written into the forwarding core for output and display to a user, the configuration core can further reduce the influence of the CPU utilization rate determination on the performance of the forwarding core, is convenient for the user to know the CPU performance of the message forwarding system in time, and improves the user experience.
In an actual usage scenario, processing times of different messages may be different, and processing times of each timer may also be different, so that durations of processing messages in while loops each time may be different.
Optionally, the method further comprises:
the forwarding core counts the calling times of while circulation in the target time period;
and the configuration core acquires the calling times.
As can be seen from the above description, the smaller the number of times of calling the while loop in the target time period is, the longer the time for processing the packet in the while loop is, that is, the higher the utilization rate of the CPU. Similarly, the forwarding core may initialize the number of calls in each target time period, where the initial value is 0, and the number of calls performs an add operation every time a while loop call is performed. The configuration core can realize lock-free reading on the calling times, so that the calling times are obtained.
In step 13, an exemplary implementation manner in which the configuration core determines the CPU utilization of the forwarding core in the target time period according to the number of the messages and the number of the timers is as follows:
and the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the calling times.
Therefore, by the technical scheme, the number of the processed messages and the number of overtime timers in the target time interval are considered, meanwhile, the influence of different messages which can be processed in each while cycle is fully considered, the comprehensiveness of the reference parameters for determining the CPU utilization rate can be improved, the accuracy of the determined CPU utilization rate is ensured, the determination of the CPU utilization rate is matched with an actual use scene, and the application range of the determination method for the CPU utilization rate is widened.
Optionally, an exemplary implementation manner of determining, by the configuration core, the CPU utilization of the forwarding core in the target time period according to the packet number, the timer number, and the call times is as follows, as shown in fig. 3, this step may include:
in step 31, determining a first impact parameter corresponding to the forwarding core according to the number of calls, wherein the first impact parameter is used for representing the impact of the number of messages on the utilization rate of the CPU;
as can be seen from the above description, the smaller the number of calls of the while loop in the target period, the longer the time for processing the packet in the while loop is represented, i.e., the higher the utilization rate of the CPU is represented, so that the number of packets is weighted and calculated based on the number of calls to ensure the accurate influence of the number of packets when determining the utilization rate of the CPU.
Exemplarily, the first impact parameter corresponding to the forwarding core is determined according to the number of calls by the following formula:
Figure BDA0002693037250000121
wherein cur _ while _ sum represents the number of calls;
omega is used for representing a first influence parameter of the message quantity on the CPU utilization rate;
p3 represents the number of times that while the wire speed is swallowed and spitted in the target time period, while the wire speed is being handled, while P3 may be obtained by performing preliminary experiments according to the specification, type, etc. of the CPU in the message forwarding system, which is not limited in this disclosure.
In step 32, the CPU utilization of the forwarding core in the target time period is determined according to the number of the packets, the number of the timers, and the first impact parameter.
Optionally, determining, by the following formula, a CPU utilization of the forwarding core in the target time period according to the number of packets, the number of timers, and the first impact parameter:
Figure BDA0002693037250000131
wherein Q represents the CPU utilization;
cur _ pkt _ sum represents the number of messages;
cur _ timer _ sum represents the timer number;
p1 represents the limit number of messages that can be received by the forwarding core in the target time period;
p2 represents the limit number of timeout timers that can be processed in the case of the forwarding core new session performance limit in the target time period;
α is used to represent a second influence parameter of the timer on the CPU utilization, and the setting of the second influence parameter is described in detail above and is not described herein again.
Therefore, according to the technical scheme, when the corresponding CPU utilization rate is determined according to the number of the messages processed in the target time period and the number of the overtime timers, the first influence parameter is determined according to the calling times of while circulation, and the calculated value of the number of the messages is weighted, so that when the CPU utilization rate is calculated, the time for processing the messages in the target time period can be accurately represented, the accuracy of the determined CPU utilization rate can be improved, and accurate data support is provided for the follow-up processing of the message forwarding system based on the CPU utilization rate.
Optionally, after the step of determining the first impact parameter corresponding to the forwarding core according to the number of calls, the method further includes:
updating the first impact parameter to a first threshold when the first impact parameter is less than the first threshold;
updating the first impact parameter to a second threshold when the first impact parameter is greater than the second threshold, wherein the first threshold is less than the second threshold.
The applicant researches and finds that, in a forwarding core, the difference between the longest time and the shortest time of each packet processing is not too much, and therefore, the influence of the longest time and the shortest time on the CPU utilization rate is not too much, and therefore, in the present disclosure, a parameter range of a first influence parameter may be set, where a first threshold is a lower limit value of the parameter range, and a second threshold is an upper limit value of the parameter range, and for example, the first threshold may be set to 0.8, and the second threshold may be set to 1.2. In this embodiment, if the first impact parameter determined based on the number of calls is less than 0.8, the first impact parameter may be updated to 0.8, if the first impact parameter determined based on the number of calls is greater than 1.2, the first impact parameter may be updated to 1.2, and if the first impact parameter determined based on the number of calls is 0.9, the first impact parameter remains 0.9.
Accordingly, in step 32, an exemplary implementation manner of determining the CPU utilization of the forwarding core in the target time period according to the number of packets, the number of timers, and the first impact parameter is as follows:
and determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the updated first influence parameter.
That is, if the first influence parameter determined in step 31 is 0.7, it can be updated to 0.8 through the above steps, and if the CPU utilization is determined by equation (2), the first influence parameter is calculated by using 0.8.
Therefore, according to the technical scheme, the influence of the calling times of the while loop on the CPU utilization rate is considered, and meanwhile, the influence range of the calling times of the while loop on the CPU utilization rate is also considered fully, so that data support is provided for accurately determining the CPU utilization rate, and the accuracy of the determined CPU utilization rate is further improved.
Optionally, the method further comprises:
and the forwarding core determines whether the message receiving queue corresponding to the forwarding core loses the message in 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.
Under the condition that the message receiving queue is determined not to lose the message, the step that the forwarding core counts the number of the received messages in a target time period and the number of overtime timers is executed;
and under the condition that the message receiving queue is determined to have message loss, determining that the CPU utilization rate of the forwarding core is 100%.
When any message receiving queue has a message loss, the processing performance of the message of the current forwarding core reaches the limit, the CPU utilization rate of the forwarding core can be directly determined to be 100%, and when the message receiving queue does not have the message loss, the CPU of the current forwarding core is idle, the steps 11 to 13 can be executed to further determine the CPU utilization rate of the forwarding core in the target time period. Therefore, by the technical scheme, the process for determining the CPU utilization rate can be further simplified, the data calculation amount and statistic amount required in the determination process are reduced, the efficiency for determining the CPU utilization rate can be improved, and the real-time performance and the accuracy of the CPU utilization rate are guaranteed.
Optionally, the CPU utilization may be approximately calculated in the above manner, and the method further includes: when the determined CPU utilization rate is more than 100%, the CPU utilization rate can be updated to 100%, so that the reasonability and the accuracy of the determined CPU utilization rate are ensured.
The present disclosure also provides a system for determining CPU utilization, the system comprising a forwarding core and a configuration core,
the forwarding core is used for counting the number of messages received in a target time period and the number of overtime timers in the target time period;
the configuration core is used for acquiring the message quantity and the timer quantity of the forwarding core after the target time interval is ended;
and the configuration core is used for determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity.
Optionally, the forwarding core is further configured to count the number of calls of while loop in the target time period;
the configuration core is further used for acquiring the calling times;
the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity, and the method comprises the following steps:
and the configuration core is further used for determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the calling times.
Optionally, the determining, by the configuration core, the CPU utilization of the forwarding core in the target time period according to the packet number, the timer number, and the call times includes:
the configuration core is further configured to determine a first influence parameter corresponding to the forwarding core according to the number of calls, where the first influence parameter is used to represent an influence of the number of packets on a CPU utilization rate;
and the configuration core is further configured to determine the CPU utilization rate of the forwarding core in the target time period according to the packet number, the timer number, and the first impact parameter.
Optionally, the configuration core is further configured to determine, according to the number of calls, a first impact parameter corresponding to the forwarding core by using the following formula:
Figure BDA0002693037250000161
the configuration core is further configured to determine, according to the number of packets, the number of timers, and the first impact parameter, a CPU utilization rate of the forwarding core in the target time period by the following formula:
Figure BDA0002693037250000162
wherein Q represents the CPU utilization;
cur _ pkt _ sum represents the number of messages;
cur _ timer _ sum represents the timer number;
cur _ while _ sum represents the number of calls;
omega is used for representing a first influence parameter of the message quantity on the CPU utilization rate;
p1 represents the limit number of messages that can be received by the forwarding core in the target time period;
p2 represents the limit number of timeout timers that can be processed in the case of the forwarding core new session performance limit in the target time period;
p3 represents the number of while loops that can be invoked at throughput line speed within the target time period;
alpha is used to characterize the second impact parameter of the timer on CPU utilization.
Optionally, after the step of determining the first impact parameter corresponding to the forwarding core according to the number of calls, the configuration core is further configured to:
updating the first impact parameter to a first threshold when the first impact parameter is less than the first threshold;
updating the first impact parameter to a second threshold when the first impact parameter is greater than the second threshold, wherein the first threshold is less than the second threshold;
the configuration core is further to:
and determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the updated first influence parameter.
Optionally, the forwarding core is further configured to:
determining whether a message receiving queue corresponding to the forwarding core loses a message in the target time period;
under the condition that the message receiving queue is determined not to lose the message, the step that the forwarding core counts the number of the received messages in a target time period and the number of overtime timers is executed;
and under the condition that the message receiving queue is determined to have message loss, determining that the CPU utilization rate of the forwarding core is 100%.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 4 is a block diagram illustrating an electronic device 700 according to an example embodiment. As shown in fig. 4, 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.
The processor 701 is configured to control the overall operation of the electronic device 700, so as to complete all or part of the steps in the method for determining the CPU utilization. The memory 702 is used to store various types of data to support operation at the electronic device 700, such as instructions for any application or method operating on the electronic device 700 and application-related data, such as contact data, transmitted and received messages, pictures, audio, video, and the like. The Memory 702 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk, or optical disk. The multimedia components 703 may include screen and audio components. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 702 or transmitted through the communication component 705. The audio assembly 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, such as a keyboard, mouse, 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, which is not limited herein. The corresponding communication component 705 may thus include: Wi-Fi module, Bluetooth module, NFC module, etc.
In an exemplary embodiment, the electronic Device 700 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described CPU utilization determination method.
In another exemplary embodiment, there is also provided a computer-readable storage medium including program instructions which, when executed by a processor, implement the steps of the above-described method of determining CPU utilization. For example, the computer readable storage medium may be the memory 702 comprising program instructions executable by the processor 701 of the electronic device 700 to perform the method of determining CPU utilization described above.
Fig. 5 is a block diagram illustrating an electronic device 1900 according to an example embodiment. For example, the electronic device 1900 may be provided as a server. Referring to fig. 5, an electronic device 1900 includes a processor 1922, which may be one or more in number, and a memory 1932 for storing computer programs executable by the processor 1922. The computer program stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processor 1922 may be configured to execute the computer program to perform the above-described method of determining the CPU utilization.
Additionally, electronic device 1900 may also include a power component 1926 and a communication component 1950, the power component 1926 may be configured to perform power management of the electronic device 1900, and the communication component 1950 may be configured to enable communication, e.g., wired or wireless communication, of the electronic device 1900. In addition, the electronic device 1900 may also include input/output (I/O) interfaces 1958. The electronic device 1900 may operate based on an operating system, such as Windows Server, stored in memory 1932TM,Mac OS XTM,UnixTM,LinuxTMAnd so on.
In another exemplary embodiment, there is also provided a computer-readable storage medium including program instructions which, when executed by a processor, implement the steps of the above-described method of determining CPU utilization. For example, the computer readable storage medium may be the memory 1932 that includes program instructions executable by the processor 1922 of the electronic device 1900 to perform the method of determining CPU utilization described above.
In another exemplary embodiment, a computer program product is also provided, which comprises a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-mentioned method of determining CPU utilization when executed by the programmable apparatus.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, various possible combinations will not be separately described in this disclosure.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

Claims (10)

1. A method for determining CPU utilization, the method comprising:
the forwarding core counts the number of messages received in a target time period and the number of overtime timers in the target time period;
after the target time interval is finished, the configuration core acquires the message quantity and the timer quantity of the forwarding core;
and the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity.
2. The method of claim 1, further comprising:
the forwarding core counts the calling times of while circulation in the target time period;
the configuration core acquires the calling times;
the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity, and the method comprises the following steps:
and the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the calling times.
3. The method of claim 2, wherein the determining, by the configuration core, the CPU utilization of the forwarding core in the target time period according to the packet number, the timer number, and the call times comprises:
determining a first influence parameter corresponding to the forwarding core according to the calling times, wherein the first influence parameter is used for representing the influence of the message quantity on the CPU utilization rate;
and determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the first influence parameter.
4. The method according to claim 3, wherein the first impact parameter corresponding to the forwarding core is determined according to the number of calls by the following formula:
Figure FDA0002693037240000021
determining the CPU utilization rate of the forwarding core in the target time interval according to the number of the messages, the number of the timers and the first influence parameter by the following formula:
Figure FDA0002693037240000022
wherein Q represents the CPU utilization;
cur _ pkt _ sum represents the number of messages;
cur _ timer _ sum represents the timer number;
cur _ while _ sum represents the number of calls;
omega is used for representing a first influence parameter of the message quantity on the CPU utilization rate;
p1 represents the limit number of messages that can be received by the forwarding core in the target time period;
p2 represents the limit number of timeout timers that can be processed in the case of the forwarding core new session performance limit in the target time period;
p3 represents the number of while loops that can be invoked at throughput line speed within the target time period;
alpha is used to characterize the second impact parameter of the timer on CPU utilization.
5. The method according to claim 3 or 4, wherein after the step of determining the first impact parameter corresponding to the forwarding core according to the number of calls, the method further comprises:
updating the first impact parameter to a first threshold when the first impact parameter is less than the first threshold;
updating the first impact parameter to a second threshold when the first impact parameter is greater than the second threshold, wherein the first threshold is less than the second threshold;
determining the CPU utilization of the forwarding core in the target time period according to the packet number, the timer number, and the first impact parameter includes:
and determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the updated first influence parameter.
6. The method of claim 1, further comprising:
the forwarding core determines whether a message receiving queue corresponding to the forwarding core loses a message in the target time period;
under the condition that the message receiving queue is determined not to lose the message, the step that the forwarding core counts the number of the received messages in a target time period and the number of overtime timers is executed;
and under the condition that the message receiving queue is determined to have message loss, determining that the CPU utilization rate of the forwarding core is 100%.
7. A CPU utilization determination system, comprising a forwarding core and a configuration core,
the forwarding core is used for counting the number of messages received in a target time period and the number of overtime timers in the target time period;
the configuration core is used for acquiring the message quantity and the timer quantity of the forwarding core after the target time interval is ended;
and the configuration core is used for determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity.
8. The system of claim 7,
the forwarding core is further used for counting the calling times of while loops in the target time period;
the configuration core is further used for acquiring the calling times;
the configuration core determines the CPU utilization rate of the forwarding core in the target time interval according to the message quantity and the timer quantity, and the method comprises the following steps:
and the configuration core is further used for determining the CPU utilization rate of the forwarding core in the target time interval according to the message quantity, the timer quantity and the calling times.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
10. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 6.
CN202010997284.1A 2020-09-21 2020-09-21 Method, system, storage medium and electronic device for determining CPU utilization rate Pending CN112162901A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010997284.1A CN112162901A (en) 2020-09-21 2020-09-21 Method, system, storage medium and electronic device for determining CPU utilization rate

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010997284.1A CN112162901A (en) 2020-09-21 2020-09-21 Method, system, storage medium and electronic device for determining CPU utilization rate

Publications (1)

Publication Number Publication Date
CN112162901A true CN112162901A (en) 2021-01-01

Family

ID=73863197

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010997284.1A Pending CN112162901A (en) 2020-09-21 2020-09-21 Method, system, storage medium and electronic device for determining CPU utilization rate

Country Status (1)

Country Link
CN (1) CN112162901A (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106201441A (en) * 2016-07-08 2016-12-07 汉柏科技有限公司 The acquisition methods of cpu busy percentage and device in a kind of network equipment
CN106713185A (en) * 2016-12-06 2017-05-24 瑞斯康达科技发展股份有限公司 Load balancing method and apparatus of multi-core CPU
WO2018094743A1 (en) * 2016-11-28 2018-05-31 华为技术有限公司 Method for processing packet, and computer device
CN108363621A (en) * 2018-01-18 2018-08-03 东软集团股份有限公司 Message forwarding method, device, storage medium under numa frameworks and electronic equipment
CN108512727A (en) * 2018-04-02 2018-09-07 北京天融信网络安全技术有限公司 A kind of determination method and device of central processing unit utilization rate
CN108667730A (en) * 2018-04-17 2018-10-16 东软集团股份有限公司 Message forwarding method, device, storage medium based on load balancing and equipment
CN109614305A (en) * 2018-12-11 2019-04-12 广东省新代通信与网络创新研究院 Occupancy acquisition methods, device and the computer readable storage medium of processor
US10332235B1 (en) * 2018-05-01 2019-06-25 At&T Intellectual Property I, L.P. Direct memory access for graphics processing unit packet processing
CN110061924A (en) * 2019-04-18 2019-07-26 东软集团股份有限公司 A kind of message forwarding method, device and Related product
CN110704211A (en) * 2019-09-29 2020-01-17 烽火通信科技股份有限公司 Method and system for receiving packets across CPUs (central processing units) in multi-core system

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106201441A (en) * 2016-07-08 2016-12-07 汉柏科技有限公司 The acquisition methods of cpu busy percentage and device in a kind of network equipment
WO2018094743A1 (en) * 2016-11-28 2018-05-31 华为技术有限公司 Method for processing packet, and computer device
CN106713185A (en) * 2016-12-06 2017-05-24 瑞斯康达科技发展股份有限公司 Load balancing method and apparatus of multi-core CPU
CN108363621A (en) * 2018-01-18 2018-08-03 东软集团股份有限公司 Message forwarding method, device, storage medium under numa frameworks and electronic equipment
CN108512727A (en) * 2018-04-02 2018-09-07 北京天融信网络安全技术有限公司 A kind of determination method and device of central processing unit utilization rate
CN108667730A (en) * 2018-04-17 2018-10-16 东软集团股份有限公司 Message forwarding method, device, storage medium based on load balancing and equipment
US10332235B1 (en) * 2018-05-01 2019-06-25 At&T Intellectual Property I, L.P. Direct memory access for graphics processing unit packet processing
CN109614305A (en) * 2018-12-11 2019-04-12 广东省新代通信与网络创新研究院 Occupancy acquisition methods, device and the computer readable storage medium of processor
CN110061924A (en) * 2019-04-18 2019-07-26 东软集团股份有限公司 A kind of message forwarding method, device and Related product
CN110704211A (en) * 2019-09-29 2020-01-17 烽火通信科技股份有限公司 Method and system for receiving packets across CPUs (central processing units) in multi-core system

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
JUNJUNG等: "Real time synchronization for a small group of wireless sensor network system implemented with a DSP", SERSC: ASTL PROCEEDINGS, 31 December 2014 (2014-12-31) *
别体伟;华蓓;: "用户空间协议栈的并行化与性能优化", 电子技术, no. 08, 25 August 2016 (2016-08-25) *
姚崎;刘吉强;韩臻;沈昌祥;: "面向多核处理器的Linux网络报文缓冲区重用机制研究", 通信学报, no. 09, 25 September 2009 (2009-09-25) *

Similar Documents

Publication Publication Date Title
CN108776934B (en) Distributed data calculation method and device, computer equipment and readable storage medium
CN109845303B (en) Management method and management unit for network slices
CN109617829B (en) Method, device and system for processing service request data
CN111163018B (en) Network equipment and method for reducing transmission delay thereof
WO2019042169A1 (en) Resource allocation method and related products
CN108023829B (en) Message processing method and device, storage medium and electronic equipment
US10848366B2 (en) Network function management method, management unit, and system
CN107807852B (en) Application program performance control method, device and computer readable storage medium
US20170185454A1 (en) Method and Electronic Device for Determining Resource Consumption of Task
CN107832142B (en) Resource allocation method and equipment for application program
CN107832141A (en) Application program progress control method and equipment
US20180167326A1 (en) Method and system for limiting data traffic
WO2023174037A1 (en) Resource scheduling method, apparatus and system, device, medium, and program product
CN108037898A (en) A kind of method, system and device of the dpdk communications based on Ceph
CN113138801A (en) Command distribution device, method, chip, computer equipment and storage medium
CN113138802A (en) Command distribution device, method, chip, computer equipment and storage medium
US20150304227A1 (en) Queue Management Method and Apparatus
CN112860387A (en) Distributed task scheduling method and device, computer equipment and storage medium
WO2021208682A1 (en) Data sampling method, apparatus and device for network device, and medium
WO2019109902A1 (en) Queue scheduling method and apparatus, communication device, and storage medium
CN113746763B (en) Data processing method, device and equipment
CN112162901A (en) Method, system, storage medium and electronic device for determining CPU utilization rate
CN108418730B (en) Network flow testing method, device, equipment and computer readable storage medium
US20190108060A1 (en) Mobile resource scheduler
CN109062706B (en) Electronic device, method for limiting inter-process communication thereof and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination