CN111324447B - Thread adjusting method and device, application server and storage medium - Google Patents

Thread adjusting method and device, application server and storage medium Download PDF

Info

Publication number
CN111324447B
CN111324447B CN201910561103.8A CN201910561103A CN111324447B CN 111324447 B CN111324447 B CN 111324447B CN 201910561103 A CN201910561103 A CN 201910561103A CN 111324447 B CN111324447 B CN 111324447B
Authority
CN
China
Prior art keywords
thread
completion
preset
specified
load rate
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.)
Active
Application number
CN201910561103.8A
Other languages
Chinese (zh)
Other versions
CN111324447A (en
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.)
Hangzhou Hikvision System Technology Co Ltd
Original Assignee
Hangzhou Hikvision System Technology Co Ltd
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 Hangzhou Hikvision System Technology Co Ltd filed Critical Hangzhou Hikvision System Technology Co Ltd
Priority to CN201910561103.8A priority Critical patent/CN111324447B/en
Publication of CN111324447A publication Critical patent/CN111324447A/en
Application granted granted Critical
Publication of CN111324447B publication Critical patent/CN111324447B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application discloses a thread adjusting method, a thread adjusting device, an application server and a storage medium, and belongs to the field of thread management. According to the thread adjusting method provided by the embodiment of the application, in the current statistical period, the first completion number of a plurality of threads which have completed tasks and the running time of each thread are determined; determining the percentage of the running time of the plurality of threads according to the first completion number and the running time of each thread; and when the running time percentage reaches the preset confidence running time percentage, adjusting the thread number of the target subprogram according to the first completion number and the running time of each thread. The method avoids the influence of the running time of a few abnormal threads of the subprogram on the thread number of the subprogram, and improves the accuracy of thread number adjustment.

Description

Thread adjusting method and device, application server and storage medium
Technical Field
The present application relates to the field of thread management. In particular, to a method and an apparatus for adjusting a thread, an application server, and a storage medium.
Background
The application server comprises a plurality of subprograms and a thread pool, and the thread pool comprises a plurality of threads. The application server can provide services for the terminal or other servers, and when the services are provided, at least one task corresponding to the services is sent to at least one subprogram in the plurality of subprograms, and at least one thread is allocated to each subprogram. For each subroutine, the subroutine performs the task by at least one thread assigned to it. However, when the task amount of the task is large but the number of the allocated threads is small, the task completion efficiency is low; when the task amount of the task is small but the number of the allocated threads is large, resources are wasted. Thus, the application server needs to dynamically adjust the number of threads allocated to each subroutine.
At present, the thread number of each subprogram is periodically adjusted, that is, the thread number of the subprogram is adjusted according to the average value of the whole thread running time every other period. However, the running time of the potentially few exception threads of the subroutine in the cycle may affect the average of the overall thread running time, and thus the number of threads allocated to the subroutine. Therefore, when the adjustment is performed by the above method, the operating time of a few abnormal threads of the subroutine affects the thread count of the subroutine, resulting in poor accuracy of thread count adjustment.
Disclosure of Invention
The embodiment of the application provides a thread adjusting method, a thread adjusting device, an application server and a storage medium, and can solve the problem that the accuracy of thread number adjustment is poor due to the influence of the running time of a few abnormal threads of a subprogram on the thread number of the subprogram. The technical scheme is as follows:
in one aspect, a method for adjusting a thread is provided, where the method includes:
determining a first completion number of a plurality of threads which have completed tasks and the running time of each thread in a current statistical period;
determining the percentage of the running time of the plurality of threads according to the first completion number and the running time of each thread;
and when the running time percentage reaches a preset confidence running time percentage, adjusting the thread number of the target subprogram according to the first completion number and the running time of each thread.
In one possible implementation, the determining the percentage of the running time of the plurality of threads according to the first number of completions and the running time of each thread includes:
determining a plurality of second completion numbers in a plurality of first appointed operation time ranges according to the operation time of each thread, wherein the sum of the plurality of second completion numbers in the plurality of first appointed operation time ranges is the first completion number;
and determining the running time percentages of the plurality of threads according to a plurality of second completion numbers and the first completion numbers in the plurality of first appointed running time ranges.
In another possible implementation manner, the adjusting the thread number of the target subroutine according to the first completion number and the runtime of each thread includes:
determining the confidence degrees and the polymerization degrees of the running time of the plurality of threads according to the first completion number and the running time of each thread;
determining the thread load rate of the target subprogram according to the first completion number, the statistical duration in the current statistical period, the current first thread number of the target subprogram and the confidence coefficient;
determining a load rate adjustment factor of the target subprogram according to the thread load rate, and determining a polymerization degree adjustment factor of the target subprogram according to the polymerization degree;
determining a second thread number of threads required by the target subprogram according to the first thread number, the load rate adjustment factor and the polymerization degree adjustment factor;
and allocating the second thread number of threads to the target subprogram.
In another possible implementation manner, the determining the confidence and the aggregation degree of the running times of the plurality of threads according to the first completion number and the running time of each thread includes:
determining a plurality of third completion numbers in a plurality of second specified operation time ranges according to the operation time of each thread, wherein the sum of the plurality of third completion numbers in the plurality of second specified operation time ranges is the first completion number;
selecting a second specified operation time range with the specified number and the maximum third completion number according to a plurality of third completion numbers in the second specified operation time ranges;
determining the specified number of first weights and the specified number of target run times according to the specified number of second specified run time ranges;
carrying out weighted average on the first weights with the specified number and the target running times with the specified number to obtain the confidence coefficient;
and determining the polymerization degree through a polymerization degree algorithm according to the first completion number and the running time of each thread.
In another possible implementation manner, the determining, according to the first completion number, the statistical duration in the current statistical period, the current first thread number of the target subprogram, and the confidence, the thread load rate of the target subprogram includes:
determining a first thread completion rate of the plurality of threads in unit time according to the first completion number and the statistical duration;
determining a second thread completion rate of the thread of the target subprogram in unit time according to the first thread number and the confidence coefficient;
and determining the thread load rate according to the first thread completion rate and the second thread completion rate, wherein the thread load rate is in direct proportion to the first thread completion rate and in inverse proportion to the second thread completion rate.
In another possible implementation manner, the determining a load rate adjustment factor of the target subroutine according to the thread load rate includes:
when the thread load rate reaches a first preset thread load rate, setting the load rate adjustment factor as a first preset numerical value;
when the thread load rate does not reach a second preset thread load rate, setting the load rate adjustment factor as a second preset numerical value;
when the thread load rate reaches the second preset thread load rate but does not reach the first preset thread load rate, setting the load rate adjustment factor as a third preset numerical value;
the first preset thread load rate is greater than the second preset thread load rate, the first preset numerical value is greater than the third preset numerical value, and the third preset numerical value is greater than the second preset numerical value.
In another possible implementation manner, the determining, according to the degree of polymerization, a degree of polymerization adjustment factor of the target subroutine includes:
when the polymerization degree reaches a first preset polymerization degree, setting the polymerization degree adjustment factor as a fourth preset numerical value;
when the polymerization degree does not reach a second preset polymerization degree, setting the polymerization degree adjustment factor as a fifth preset numerical value;
when the polymerization degree reaches the second preset polymerization degree but does not reach the first preset polymerization degree, setting the polymerization degree adjustment factor as a sixth preset numerical value;
the first preset polymerization degree is larger than the preset second polymerization degree, the fourth preset numerical value is larger than the sixth preset numerical value, and the sixth preset numerical value is larger than the fifth preset numerical value.
In another possible implementation manner, the determining, according to the first thread number, the load factor adjustment factor, and the aggregation degree adjustment factor, a second thread number of threads required by the target subroutine, includes:
and taking the product of the first thread number, the load factor adjusting factor and the polymerization degree adjusting factor as the second thread number.
In another possible implementation manner, before the adjusting the number of threads of the target subroutine according to the first completion number and the runtime of each thread, the method further includes:
determining a specified number of third specified running time ranges in a last statistical period of the current statistical period;
when the specified number of third specified run-time ranges and the specified number of second specified run-time ranges are different, the step of determining the specified number of first weights and the specified number of target run-times from the specified number of second specified run-time ranges is performed.
In another aspect, an apparatus for adjusting a thread is provided, the apparatus including:
the first determining module is used for determining the first completion number of a plurality of threads which have completed tasks and the running time of each thread in the current counting period;
a second determining module, configured to determine run time percentages of the plurality of threads according to the first completion number and the run time of each thread;
and the adjusting module is used for adjusting the thread number of the target subprogram according to the first completion number and the running time of each thread when the running time percentage reaches a preset confidence running time percentage.
In a possible implementation manner, the second determining module is further configured to determine, according to the running time of each thread, a plurality of second completion numbers within a plurality of first specified running time ranges, where a sum of the plurality of second completion numbers within the plurality of first specified running time ranges is the first completion number;
the second determining module is further configured to determine the run time percentages of the plurality of threads according to a plurality of second completion numbers and the first completion number within the plurality of first specified run time ranges.
In another possible implementation manner, the adjusting module is further configured to determine confidence levels and polymerization degrees of the running times of the multiple threads according to the first completion number and the running time of each thread;
the adjusting module is further configured to determine a thread load rate of the target subprogram according to the first completion number, the statistical duration in the current statistical period, the current first thread number of the target subprogram, and the confidence;
the adjusting module is further configured to determine a load factor adjusting factor of the target subprogram according to the thread load rate, and determine a polymerization degree adjusting factor of the target subprogram according to the polymerization degree;
the adjusting module is further configured to determine a second thread number of the thread required by the target subprogram according to the first thread number, the load factor adjusting factor and the polymerization degree adjusting factor;
the adjusting module is further configured to allocate the second thread number to the target subprogram.
In another possible implementation manner, the adjusting module is further configured to determine, according to the running time of each thread, a plurality of third completion numbers within a plurality of second specified running time ranges, where a sum of the plurality of third completion numbers within the plurality of second specified running time ranges is the first completion number;
the adjusting module is further configured to select a second specified operation time range with a specified number, in which the third completion number is the largest, according to a plurality of third completion numbers in the second specified operation time ranges;
the adjusting module is further configured to determine the specified number of first weights and the specified number of target run times according to the specified number of second specified run time ranges;
the adjusting module is further configured to perform weighted average on the specified number of first weights and the specified number of target operation times to obtain the confidence level;
the adjusting module is further configured to determine the aggregation degree through an aggregation degree algorithm according to the first completion number and the running time of each thread.
In another possible implementation manner, the adjusting module is further configured to determine a first thread completion rate of the multiple threads in unit time according to the first completion number and the statistical duration;
the adjusting module is further configured to determine a second thread completion rate of the thread of the target subroutine in unit time according to the first thread number and the confidence level;
the adjusting module is further configured to determine the thread load rate according to the first thread completion rate and the second thread completion rate, where the thread load rate is directly proportional to the first thread completion rate and inversely proportional to the second thread completion rate.
In another possible implementation manner, the adjusting module is further configured to set the load factor adjusting factor to a first preset value when the thread load rate reaches a first preset thread load rate;
the adjusting module is further configured to set the load factor adjusting factor to a second preset value when the thread load rate does not reach a second preset thread load rate;
the adjusting module is further configured to set the load factor adjusting factor to a third preset value when the thread load rate reaches the second preset thread load rate but does not reach the first preset thread load rate;
the first preset thread load rate is greater than the second preset thread load rate, the first preset numerical value is greater than the third preset numerical value, and the third preset numerical value is greater than the second preset numerical value.
In another possible implementation manner, the adjusting module is further configured to set the polymerization degree adjusting factor to a fourth preset value when the polymerization degree reaches a first preset polymerization degree;
the adjusting module is further configured to set the polymerization degree adjusting factor to a fifth preset numerical value when the polymerization degree does not reach a second preset polymerization degree;
the adjusting module is further configured to set the polymerization degree adjusting factor to a sixth preset numerical value when the polymerization degree reaches the second preset polymerization degree but does not reach the first preset polymerization degree;
the first preset polymerization degree is larger than the preset second polymerization degree, the fourth preset numerical value is larger than the sixth preset numerical value, and the sixth preset numerical value is larger than the fifth preset numerical value.
In another possible implementation manner, the adjusting module is configured to use a product of the first thread number, the load factor adjustment factor, and the polymerization degree adjustment factor as the second thread number.
In another possible implementation manner, the adjusting module is further configured to determine a third specified running time range of a specified number in a last statistical period of the current statistical period;
the adjusting module is further configured to, when the specified number of third specified runtime ranges is different from the specified number of second specified runtime ranges, perform the step of determining the specified number of first weights and the specified number of target runtime ranges according to the specified number of second specified runtime ranges.
In another aspect, the present invention provides an application server, which includes a processor and a memory, where the memory stores at least one instruction, at least one program, a set of codes, or a set of instructions, and the instruction, the program, the set of codes, or the set of instructions is loaded and executed by the processor to implement the operations executed in the above-mentioned thread adjusting method.
In another aspect, the present invention provides a computer-readable storage medium having at least one instruction, at least one program, a set of codes, or a set of instructions stored therein, which is loaded and executed by a processor to implement the operations performed in the method for adjusting a thread described above.
The technical scheme provided by the embodiment of the application has the following beneficial effects:
according to the thread adjusting method provided by the embodiment of the application, the application server determines the first completion number of a plurality of threads which have completed tasks and the running time of each thread in the current statistical period; determining the percentage of the running time of the plurality of threads according to the first completion number and the running time of each thread; and when the running time percentage reaches the preset confidence running time percentage, adjusting the thread number of the target subprogram according to the first completion number and the running time of each thread. The method avoids the influence of the running time of a few abnormal threads of the subprogram on the thread number of the subprogram, and improves the accuracy of thread number adjustment.
Drawings
Fig. 1 is a schematic diagram of an application scenario of adjustment of a thread according to an embodiment of the present application;
fig. 2 is a flowchart of a thread adjustment method according to an embodiment of the present disclosure;
fig. 3 is a flowchart of a thread adjustment method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an adjusting apparatus for threads according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an application server according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions and advantages of the present application more clear, the following describes the embodiments of the present application in further detail.
An application scenario of thread adjustment is provided in the embodiment of the present application, and referring to fig. 1, the application scenario includes: the application server 110 and the terminal 120 are connected through a network, and the application server 110 provides services for the terminal 120. Among them, the application server 110 includes: the system comprises a thread pool and a plurality of subprograms, wherein the thread pool comprises a plurality of threads.
When the terminal 120 needs the application server 110 to provide a service for the terminal, the terminal 120 sends at least one task corresponding to the needed service to the application server 110, and the application server 110 receives the at least one task corresponding to the service. The application server 110 sends at least one task to at least one of the plurality of sub-programs and allocates at least one thread in the thread pool to the at least one sub-program that accepts the task, the at least one sub-program executing the at least one task through the at least one thread allocated thereto. However, when the running time of most threads in a subroutine changes, the number of threads allocated to the subroutine needs to be dynamically adjusted. When the thread having the subprogram completes the task sent by the application server 110, the application server 110 sends a task completion signal to the terminal 120, and the terminal 120 executes the service after receiving the task completion signal.
An embodiment of the present application provides a method for adjusting a thread, referring to fig. 2, where the method includes:
step 201: and determining the first completion number of a plurality of threads which have completed the task and the running time of each thread in the current statistical period.
Step 202: determining a percentage of run time for the plurality of threads based on the first number of completions and the run time for each thread.
Step 203: and when the running time percentage reaches the preset confidence running time percentage, adjusting the thread number of the target subprogram according to the first completion number and the running time of each thread.
In one possible implementation, determining the percentage of runtime of the plurality of threads based on the first number of completions and the runtime of each thread includes:
and determining a plurality of second completion numbers in a plurality of first appointed running time ranges according to the running time of each thread, wherein the sum of the plurality of second completion numbers in the plurality of first appointed running time ranges is the first completion number.
And determining the running time percentage of the plurality of threads according to a plurality of second completion numbers and the first completion numbers in the plurality of first appointed running time ranges.
In another possible implementation manner, adjusting the thread number of the target subroutine according to the first completion number and the runtime of each thread includes:
and determining the confidence degree and the polymerization degree of the running time of the plurality of threads according to the first completion number and the running time of each thread.
And determining the thread load rate of the target subprogram according to the first completion number, the statistical time length in the current statistical period, the current first thread number of the target subprogram and the confidence coefficient.
And determining a load rate adjustment factor of the target subprogram according to the thread load rate, and determining a polymerization degree adjustment factor of the target subprogram according to the polymerization degree.
And determining the second thread number of the threads required by the target subprogram according to the first thread number, the load rate adjustment factor and the polymerization degree adjustment factor.
The second number of threads is allocated to the target subroutine.
In another possible implementation manner, determining the confidence and the aggregation degree of the running times of the plurality of threads according to the first completion number and the running time of each thread includes:
determining a plurality of third completion numbers in a plurality of second specified running time ranges according to the running time of each thread, wherein the sum of the plurality of third completion numbers in the plurality of second specified running time ranges is the first completion number;
selecting a second specified operation time range with the specified number and the maximum third completion number according to a plurality of third completion numbers in the second specified operation time ranges;
determining a specified number of first weights and a specified number of target running times according to the specified number of second specified running time ranges;
carrying out weighted average on the first weights with the specified number and the target running time with the specified number to obtain the confidence coefficient;
and determining the polymerization degree through a polymerization degree algorithm according to the first completion number and the running time of each thread.
In another possible implementation manner, determining the thread load rate of the target subprogram according to the first completion number, the statistical duration in the current statistical period, the current first thread number of the target subprogram, and the confidence level includes:
determining a first thread completion rate of the plurality of threads in unit time according to the first completion number and the statistical time length;
determining the second thread completion rate of the thread of the target subprogram in unit time according to the first thread number and the confidence coefficient;
determining the thread load rate according to the first thread completion rate and the second thread completion rate, wherein the thread load rate is proportional to the first thread completion rate and inversely proportional to the second thread completion rate.
In another possible implementation manner, determining a load rate adjustment factor of the target subroutine according to the thread load rate includes:
when the thread load rate reaches a first preset thread load rate, setting the load rate adjustment factor as a first preset value;
when the thread load rate does not reach a second preset thread load rate, setting the load rate adjustment factor as a second preset value;
when the thread load rate reaches the second preset thread load rate but does not reach the first preset thread load rate, setting the load rate adjustment factor as a third preset numerical value;
the first preset thread load rate is greater than the second preset thread load rate, the first preset numerical value is greater than the third preset numerical value, and the third preset numerical value is greater than the second preset numerical value.
In another possible implementation manner, determining an aggregation level adjustment factor of the target subroutine according to the aggregation level includes:
when the polymerization degree reaches the first preset polymerization degree, setting the polymerization degree adjustment factor as a fourth preset numerical value;
when the polymerization degree does not reach a second preset polymerization degree, setting the polymerization degree adjustment factor as a fifth preset numerical value;
when the polymerization degree reaches the second preset polymerization degree but does not reach the first preset polymerization degree, setting the polymerization degree adjustment factor as a sixth preset numerical value;
the first preset polymerization degree is greater than the preset second polymerization degree, the fourth preset numerical value is greater than the sixth preset numerical value, and the sixth preset numerical value is greater than the fifth preset numerical value.
In another possible implementation manner, determining, according to the first thread number, the load factor adjustment factor, and the aggregation degree adjustment factor, a second thread number of threads required by the target subroutine, includes:
taking the product of the first thread number, the load factor and the polymerization degree factor as the second thread number.
In another possible implementation manner, before adjusting the number of threads of the target subroutine according to the first completion number and the runtime of each thread, the method further includes:
determining a specified number of third specified running time ranges in the last statistical period of the current statistical period;
when the specified number of third specified run-time ranges and the specified number of second specified run-time ranges are different, the step of determining the specified number of first weights and the specified number of target run-times based on the specified number of second specified run-time ranges is performed.
According to the thread adjusting method provided by the embodiment of the application, the application server determines the first completion number of a plurality of threads which have completed tasks and the running time of each thread in the current statistical period; determining the percentage of the running time of the plurality of threads according to the first completion number and the running time of each thread; and when the running time percentage reaches the preset confidence running time percentage, adjusting the thread number of the target subprogram according to the first completion number and the running time of each thread. The method avoids the influence of the running time of a few abnormal threads of the subprogram on the thread number of the subprogram, and improves the accuracy of thread number adjustment.
An embodiment of the present application provides a method for adjusting a thread, and referring to fig. 3, the method includes:
step 301: the application server determines a first completion number of a plurality of threads which have completed tasks and the running time of each thread in the current statistical period.
In this embodiment, the current statistical period is a time point at which all threads allocated to the subprogram start to execute the task as an initial time, a time point at which all threads finish the task as an end time, and a time duration between the end time and the initial time is the current statistical period.
For each thread, the application server determines the time interval between the start time when the thread starts executing the task and the end time when the thread completes the task as the running time of the thread. And the application server counts the number of finished threads added on the basis of the number of finished threads in the current counting period when each thread finishes a task, obtains the first finished number of the multiple threads, and records the running time of the thread in real time.
When the first completion number reaches the preset thread number threshold, the numerical value of the first completion number is not increased any more, and at this time, the first completion number is the preset thread number threshold. The application server also stores the completion time for each thread that has completed. And when the first completion number reaches a preset thread number threshold value, the application server deletes the thread with the earliest completion time from the completed threads according to the completion time of each completed thread when each thread completes the task, and deletes the running time corresponding to the thread with the earliest completion time. Meanwhile, the application server adds the number of the threads which just finish the task to the first finished number, and stores the running time of the threads. And when the first completion number reaches the preset thread number threshold value, the application server maintains the first completion number unchanged according to the mode.
The size of the preset thread count threshold may be set and changed as needed, and in the embodiment of the present application, the size of the preset thread count threshold is not specifically limited.
Step 302: the application server determines a percentage of run time for the plurality of threads based on the first completion number and the run time for each thread.
This step can be realized by the following steps (1) to (2), including:
(1): and the application server determines a plurality of second completion numbers in a plurality of first appointed operation time ranges according to the operation time of each thread, and the sum of the plurality of second completion numbers in the plurality of first appointed operation time ranges is the first completion number.
The application server divides the possible running time of each thread into a plurality of first specified running time ranges, and for each thread, the application server determines the first specified running time range to which the running time of the thread belongs according to the running time of the thread and the first specified running time ranges. And for each first specified running time range, the application server counts the number of threads in the first specified running time range, and takes the number of the threads as a second completion number. The application server counts the running time of each thread in the current counting period when the thread completes the task, and the running time of the thread belongs to one first appointed running time range in a plurality of first appointed running time ranges.
And after the application server determines the second completion number in each first specified operation time range, the application server stores the corresponding relation between each first specified operation time range and the second completion number. The application server may store the correspondence between each first specified run-time range and the second completion number by using a correspondence table or a statistical table. And when the application server stores the corresponding relation between each first appointed operation time range and the second completion number through the statistical table, the application server establishes the statistical table by taking the first appointed operation time range as an abscissa and the second completion number as an ordinate.
(2): the application server determines the run time percentage of the plurality of threads according to a plurality of second completion numbers and the first completion numbers within a plurality of first specified run time ranges.
The application server selects a first appointed number of second completion numbers with the maximum completion number from the plurality of second completion numbers according to the plurality of second completion numbers in the plurality of first appointed operation time ranges, sums the first appointed number of second completion numbers to obtain a first sum value, and determines the operation time percentages of the plurality of threads according to the first sum value and the first completion number.
The run time percentage is proportional to the first sum and inversely proportional to the first number of completions. The application server determines the run time percentage by a calculation algorithm in which any one of the run time percentages is proportional to the first sum value and inversely proportional to the first completion number, based on the first sum value and the first completion number. The calculation algorithm is not particularly limited in the present application; for example, the application server determines the run time percentage based on the first sum and the first completion count by equation one below.
The formula I is as follows: θ = N a /N last
Where θ is the percent of run time, N a Is a first sum value, N last Is the first completion number.
It should be noted that, when the application server selects the first specified number of second completion numbers, the application server may first sort the plurality of second completion numbers in a descending order according to the plurality of second completion numbers within the plurality of first specified operation time ranges, and select the first specified number of second completion numbers that are ranked at the top. The application server can also perform ascending arrangement on the plurality of second completion numbers according to the plurality of second completion numbers in the plurality of first specified operation time ranges, and select the first specified number of second completion numbers arranged at the lowest end. The first designated number can be set and changed as required, and in the embodiment of the application, the first designated number is not specifically limited; for example, the first specified number may be 8 or 10, etc.
Step 303: and the application server determines the confidence degree and the polymerization degree of the running time of the plurality of threads according to the first completion number and the running time of each thread.
This step can be realized by the following steps (1) to (6), including:
(1): and the application server determines a plurality of third completion numbers in a plurality of second specified running time ranges according to the running time of each thread, wherein the sum of the plurality of third completion numbers in the plurality of second specified running time ranges is the first completion number.
The application server counts the possible running time of each thread, divides the possible running time of each thread into a plurality of second specified running time ranges, and counts the running time of each thread which belongs to one of the second specified running time ranges.
And the application server counts a third completion number corresponding to each second specified running time range.
In the present embodiment, the second specified operating time ranges and the first specified operating time ranges are the same as each other, or different from each other.
Accordingly, the second and third completion numbers may be the same or different. The second number of completions and the third number of completions are the same when the plurality of second specified operating time ranges and the plurality of first specified operating time ranges are the same.
(2): the application server selects a second specified running time range with the maximum third completion number according to a plurality of third completion numbers in the second specified running time ranges.
The application server selects a third completion number with a third specified number with the largest completion number from the third completion numbers according to the third completion numbers in the second specified operation time ranges, and selects a second specified operation time range with the second specified number corresponding to the third completion number with the third specified number.
It should be noted that, when the application server selects the third completion numbers with the third designated number, the third completion numbers may be sorted in descending order according to the third completion numbers within the second designated operation time ranges, and the third completion number with the third designated number arranged at the top end is selected. The application server may further perform ascending order arrangement on the plurality of third completion numbers according to the plurality of third completion numbers within the plurality of second designated operation time ranges, and select a third completion number of a third designated number arranged at the lowermost end. The second designated number can be set and changed as required, and in the embodiment of the application, the second designated number is not specifically limited; for example, the second specified number may be 8 or 10, etc.
And when the application server determines that the running time percentage reaches the preset confidence running time percentage, a third specified number of second specified running time ranges corresponding to a third completion number are obtained.
It should be noted that the second specified number and the third specified number may be the same or different. When the second specified running time ranges corresponding to the running time of each thread are different, the second specified number is the same as the third specified number; when there are a plurality of threads whose running times belong to the same second specified running time range, the second specified number and the third specified number are different.
(3): the application server determines a second specified number of third specified operation time ranges in the last statistical period of the current statistical period; when the second specified number of third specified operating time ranges and the second specified number of second specified operating time ranges are different, the step of determining the second specified number of first weights and the second specified number of target operating times based on the second specified number of second specified operating time ranges is performed.
The application server determines a second specified number of third specified run-time ranges within a last statistical period of the current statistical period. And when the running time percentage reaches the preset confidence running time percentage, counting whether the second specified running time range of the second specified number is the same as the third specified running time range of the second specified number. If the first specified running time range is the same as the second specified running time range, waiting again until the second specified running time range is different from the second specified running time range; if the difference is not the same, the current counting period is ended, and the step of determining a second specified number of first weights and a second specified number of target operation time according to a second specified number of second specified operation time ranges is executed.
(4): the application server determines a second specified number of first weights and a second specified number of target runtime times based on the second specified number of second specified runtime ranges.
For each second specified runtime range, the application server determines a third completion number for the second specified runtime range as a first weight for the second specified runtime range. The application server selects a target runtime from the second specified runtime range. The application server may randomly select a target operation time from the second specified operation time range, may also select a maximum value of the second specified operation time range, and use the maximum value as the target operation time, may also select a minimum value of the second specified operation time range, and use the minimum value as the target operation time, and may also select a middle value of the second specified operation time range, and use the middle value as the target operation time.
For example, one of the second specified operation time ranges is [1s (sec) -2s (sec) ], and the target operation time of the one second specified operation time range may be 1, 1.5, or 2. In the embodiment of the present application, the value mode of the target running time is not specifically limited.
(5): and the application server carries out weighted average on the second specified number of first weights and the second specified number of target running times to obtain the confidence coefficient.
And the application server performs weighted average calculation on the second specified number of first weights and the target running time corresponding to each first weight to obtain the confidence coefficient. The confidence level is proportional to the sum of the products of each first weight and the target running time corresponding to the first weight and inversely proportional to the sum of a second specified number of first weights. The application server determines the confidence level according to the second designated number of first weights and the second designated number of target running times through any one calculation algorithm which is in direct proportion to the sum of the products of each first weight and the target running time corresponding to the first weight and in inverse proportion to the sum of the second designated number of first weights. The calculation algorithm is not particularly limited in the present application; for example, the application server determines the confidence level according to a second specified number of first weights and a second specified number of target run times by the following formula two.
The formula II is as follows: t is t 0 =(T 1 *N 1 +T 2 *N 2 +T 3 *N 3 +……T i *N i )/(N 1 +N 2 +N 3 +……N i )
Wherein, t 0 As confidence, T 1 、T 2 、T 3 ……T i For a target operating time, N 1 、N 2 、N 3 ……N i Is a first weight.
(6): and the application server determines the polymerization degree through a polymerization degree algorithm according to the first completion number and the running time of each thread.
The polymerization degree algorithm may be any algorithm for determining the polymerization degree, such as a gaussian function or a variance formula. In the embodiment of the present application, the kind of the algorithm using the degree of polymerization is not particularly limited.
Step 304: and the application server determines the thread load rate of the target subprogram according to the first completion number, the statistical duration in the current statistical period, the current first thread number and the confidence coefficient of the target subprogram.
This step can be achieved by the following (1) to (3), including:
(1): and the application server determines the first thread completion rate of the multiple threads in unit time according to the first completion number and the statistical duration.
And the application server determines the first thread completion rate of the multiple threads in unit time according to the first completion number and the statistical duration. The statistical time duration is from the current statistical cycle to the point that a second specified number of second specified operation time ranges are different from a second specified number of third specified operation time ranges. The first thread completion rate is proportional to the first number of completions and inversely proportional to the statistical duration.
The application server determines the first thread completion rate through a calculation algorithm that any one first thread completion rate is in direct proportion to the first completion number and in inverse proportion to the statistical duration. The calculation algorithm is not particularly limited in the present application; for example, the application server determines the first thread completion rate according to the first completion number and the statistical duration by the following formula three.
The formula III is as follows: r is 1 =N last /T last
Wherein r is 1 Is the first thread completion rate, N last Is the first completion number, T last The statistical time length is obtained.
(2): and the application server determines the second thread completion rate of the thread of the target subprogram in unit time according to the first thread number and the confidence coefficient.
And the application server determines the second thread completion rate of the thread of the target subprogram in unit time according to the first thread number and the confidence coefficient. The second thread completion rate is proportional to the first thread count and inversely proportional to the confidence level.
The application server determines the second thread completion rate through any calculation algorithm in which the second thread completion rate is in direct proportion to the number of the first threads and in inverse proportion to the confidence coefficient. The calculation algorithm is not particularly limited in the present application; for example, the application server determines the second thread completion rate according to the first thread number and the confidence level by the following formula four.
The formula four is as follows: r is 2 =L 0 /t 0
Wherein r is 2 Is the second thread completion rate, L 0 Is the first thread number, t 0 Is the confidence level.
(3): the application server determines a thread load rate according to the first thread completion rate and the second thread completion rate, wherein the thread load rate is in direct proportion to the first thread completion rate and in inverse proportion to the second thread completion rate.
The application server determines the thread load rate through a calculation algorithm that any one thread load rate is in direct proportion to the first thread completion rate and in inverse proportion to the second thread completion rate. The calculation algorithm is not particularly limited in the present application; for example, the application server determines the thread load rate according to the first thread completion rate and the second thread completion rate by the following formula five.
The formula is five: r is 0 =r 1 /r 2
Wherein r is 0 Is the thread load rate, r 1 Is the first thread completion rate, r 2 Is the second thread completion rate.
Step 305: and the application server determines a load rate adjustment factor of the target subprogram according to the thread load rate and determines a polymerization degree adjustment factor of the target subprogram according to the polymerization degree.
This step is realized by the following steps (1) to (2), including:
(1): and the application server determines a load rate adjustment factor of the target subprogram according to the thread load rate.
This step is realized by the following steps (1-1) to (1-3), including:
(1-1): and when the thread load rate reaches a first preset thread load rate, the application server sets the load rate adjustment factor as a first preset numerical value.
When the thread load rate is greater than or equal to, that is, not less than, a first preset thread load rate, the application server sets the load rate adjustment factor to a first preset value. For example, the application server determines the load rate adjustment factor according to equation six below.
Formula six: r is 0 ≥r a ,β=β 1
Wherein r is 0 Is the thread load rate, r a Is a first predetermined thread load rate, beta is a load rate adjustment factor, beta 1 Is a first predetermined value.
(1-2): and when the thread load rate does not reach a second preset thread load rate, the application server sets the load rate adjustment factor as a second preset numerical value.
And when the thread load rate is smaller than a second preset thread load rate, the application server sets the load rate adjustment factor to be a second preset value. For example, the application server determines the load rate adjustment factor according to equation seven below.
Formula six: r is 0 <r b ,β=β 2
Wherein r is 0 Is the thread load rate, r b Is the second preset thread load rate, beta is the load rate adjustment factor, beta 2 Is a second predetermined value.
(1-3): when the thread load rate reaches a second preset thread load rate but does not reach the first preset thread load rate, the application server sets the load rate adjustment factor to be a third preset numerical value; the first preset thread load rate is greater than the second preset thread load rate, the first preset numerical value is greater than the third preset numerical value, and the third preset numerical value is greater than the second preset numerical value.
And when the thread load rate is greater than or equal to a second preset thread load rate and smaller than the first preset thread load rate, the application server sets the load rate adjustment factor to be a third preset value. The first preset thread load rate is greater than the second preset thread load rate, the first preset numerical value is greater than the third preset numerical value, and the third preset numerical value is greater than the second preset numerical value. For example, the application server determines the load rate adjustment factor by equation eight below.
Formula six: r is b ≤r 0 <r a ,β=β 3
Wherein r is 0 Is the thread load rate, r a Is a first predetermined thread load rate, r b Is the second preset thread load rate, beta is the load rate adjustment factor, beta 3 Is a third predetermined value.
(2): and the application server determines a polymerization degree adjustment factor of the target subprogram according to the polymerization degree.
The step is realized by the following steps (2-1) to (2-3), and comprises the following steps:
(2-1): and when the polymerization degree reaches the first preset polymerization degree, the application server sets the polymerization degree adjustment factor to be a fourth preset numerical value.
And when the polymerization degree is greater than or equal to the first preset polymerization degree, namely the polymerization degree is not less than the first preset polymerization degree, the application server sets the polymerization degree adjustment factor to be a fourth preset numerical value. For example, the application server determines the degree of polymerization adjustment factor according to the following formula nine.
The formula six: u. of 0 ≥u a ,α=α 1
Wherein u is 0 Is the degree of polymerization, u a Is a first preset polymerization degree, alpha is a polymerization degree regulating factor, alpha 1 Is a fourth predetermined value.
(2-2): and when the polymerization degree does not reach the second preset polymerization degree, the application server sets the polymerization degree adjustment factor as a fifth preset numerical value.
And when the polymerization degree is smaller than the second preset polymerization degree, the application server sets the polymerization degree adjustment factor as a fifth preset numerical value. For example, the application server determines the degree of polymerization adjustment factor according to the following equation ten.
Formula six: u. of 0 <u b ,α=α 2
Wherein u is 0 Is the degree of polymerization, u b Is the second preset polymerization degree, alpha is a polymerization degree regulating factor, alpha 2 Is a fifth predetermined value.
(2-3): when the polymerization degree reaches the second preset polymerization degree but does not reach the first preset polymerization degree, the application server sets the polymerization degree adjustment factor as a sixth preset numerical value; the first preset polymerization degree is larger than the second preset polymerization degree, the fourth preset numerical value is larger than the sixth preset numerical value, and the sixth preset numerical value is larger than the fifth preset numerical value.
And when the polymerization degree is greater than or equal to the second preset polymerization degree and smaller than the first preset polymerization degree, the application server sets the polymerization degree adjustment factor as a sixth preset numerical value. The first preset polymerization degree is larger than the second preset polymerization degree, the fourth preset numerical value is larger than the sixth preset numerical value, and the sixth preset numerical value is larger than the fifth preset numerical value.
For example, the application server determines the degree of polymerization adjustment factor by the following formula eleven.
Formula six: u. of b ≤u 0 <u a ,α=α 3
Wherein u is 0 Is the degree of polymerization, u a Is a first predetermined degree of polymerization, u b Is the second preset polymerization degree, alpha is a polymerization degree regulating factor, alpha 3 Is a sixth preset value.
Step 306: and the application server determines the second thread number of the threads required by the target subprogram according to the first thread number, the load rate adjustment factor and the polymerization degree adjustment factor.
The step is realized by the following steps (1) and comprises the following steps:
(1): and the application server takes the product of the first thread number, the load rate adjusting factor and the polymerization degree adjusting factor as a second thread number.
And the application server takes the product of the first thread number, the load rate adjusting factor and the polymerization degree adjusting factor as a second thread number. For example, the application server determines the second thread number by the following equation twelve.
Equation twelve: l is 1 =L 0 *β*α
Wherein L is 1 Is the second thread number, L 0 Is the first thread number, beta is the load factor, alpha is the polymerization degree factor.
Step 307: the application server allocates a second number of threads to the target subroutine.
The application server adjusts the first thread number of the target subprogram into a second thread number of the target subprogram.
According to the thread adjusting method provided by the embodiment of the application, an application server determines the first completion number of a plurality of threads completing a task and the running time of each thread in a current statistical cycle; determining the running time percentage of the plurality of threads according to the first completion number and the running time of each thread; and when the running time percentage reaches the preset confidence running time percentage, adjusting the thread number of the target subprogram according to the first completion number and the running time of each thread. The method avoids the influence of the running time of a few abnormal threads of the subprogram on the thread number of the subprogram, and improves the accuracy of thread number adjustment.
The embodiment of the application provides a thread adjusting device, which is applied to an application server and used for executing steps executed by the application server in the thread adjusting method. Referring to fig. 4, the thread adjusting apparatus includes:
the first determining module 401 is configured to determine a first completion number of the plurality of threads that have completed the task and a running time of each thread in the current statistical cycle.
A second determining module 402, configured to determine a percentage of the running time of the plurality of threads according to the first number of completions and the running time of each thread.
And an adjusting module 403, configured to adjust the thread count of the target subroutine according to the first completion count and the running time of each thread when the running time percentage reaches the preset confidence running time percentage.
In a possible implementation manner, the second determining module 402 is further configured to determine, according to the running time of each thread, a plurality of second completion numbers within a plurality of first specified running time ranges, where a sum of the plurality of second completion numbers within the plurality of first specified running time ranges is the first completion number;
determining a run time percentage of the plurality of threads based on a plurality of second completion counts and the first completion counts within a plurality of first specified run time ranges.
In another possible implementation manner, the adjusting module 403 is further configured to determine confidence levels and aggregation degrees of the running times of the multiple threads according to the first completion number and the running time of each thread;
determining the thread load rate of the target subprogram according to the first completion number, the statistical duration in the current statistical period, the current first thread number and the confidence coefficient of the target subprogram;
determining a load rate adjustment factor of the target subprogram according to the thread load rate, and determining a polymerization degree adjustment factor of the target subprogram according to the polymerization degree;
determining a second thread number of threads required by the target subprogram according to the first thread number, the load rate adjustment factor and the polymerization degree adjustment factor;
the target subroutine is assigned a second number of threads.
In another possible implementation manner, the adjusting module 403 is further configured to determine, according to the running time of each thread, a plurality of third completion numbers within a plurality of second specified running time ranges, where a sum of the plurality of third completion numbers within the plurality of second specified running time ranges is the first completion number;
selecting a second specified operation time range with the specified number and the maximum third completion number according to a plurality of third completion numbers in the second specified operation time ranges;
determining a specified number of first weights and a specified number of target running times according to a specified number of second specified running time ranges;
carrying out weighted average on the first weights with the specified number and the target running times with the specified number to obtain confidence;
and determining the polymerization degree through a polymerization degree algorithm according to the first completion number and the running time of each thread.
In another possible implementation manner, the adjusting module 403 is further configured to determine a first thread completion rate of the multiple threads in unit time according to the first completion number and the statistical duration;
determining the second thread completion rate of the thread of the target subprogram in unit time according to the first thread number and the confidence coefficient;
and determining a thread load rate according to the first thread completion rate and the second thread completion rate, wherein the thread load rate is in direct proportion to the first thread completion rate and in inverse proportion to the second thread completion rate.
In another possible implementation manner, the adjusting module 403 is further configured to set the load factor adjustment factor to a first preset value when the thread load rate reaches a first preset thread load rate;
when the thread load rate does not reach a second preset thread load rate, setting the load rate adjustment factor as a second preset value;
when the thread load rate reaches the second preset thread load rate but does not reach the first preset thread load rate, setting the load rate adjustment factor as a third preset numerical value;
the first preset thread load rate is greater than the second preset thread load rate, the first preset value is greater than a third preset value, and the third preset value is greater than the second preset value.
In another possible implementation manner, the adjusting module 403 is further configured to set the polymerization degree adjusting factor to a fourth preset value when the polymerization degree reaches the first preset polymerization degree;
when the polymerization degree does not reach the second preset polymerization degree, setting the polymerization degree adjustment factor as a fifth preset numerical value;
when the polymerization degree reaches the second preset polymerization degree but does not reach the first preset polymerization degree, setting the polymerization degree adjustment factor as a sixth preset numerical value;
the first preset polymerization degree is larger than the second preset polymerization degree, the fourth preset numerical value is larger than the sixth preset numerical value, and the sixth preset numerical value is larger than the fifth preset numerical value.
In another possible implementation manner, the adjusting module 403 is configured to use a product of the first thread number, the load factor adjustment factor, and the polymerization degree adjustment factor as the second thread number.
In another possible implementation manner, the adjusting module 403 is further configured to determine a third specified running time range of a specified number in a last statistical period of the current statistical period;
when the specified number of third specified run-time ranges and the specified number of second specified run-time ranges are different, the step of determining the specified number of first weights and the specified number of target run-times according to the specified number of second specified run-time ranges is performed.
According to the thread adjusting device provided by the embodiment of the application, the application server determines the first completion number of a plurality of threads which have completed tasks and the running time of each thread in the current statistical period; determining the percentage of the running time of the plurality of threads according to the first completion number and the running time of each thread; and when the running time percentage reaches the preset confidence running time percentage, adjusting the thread number of the target subprogram according to the first completion number and the running time of each thread. The device avoids the influence of the running time of a few abnormal threads of the subprogram on the thread number of the subprogram, and improves the accuracy of thread number adjustment.
It should be noted that: in the thread adjusting apparatus provided in the above embodiments, only the division of the functional modules is illustrated when adjusting the thread, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the thread adjusting apparatus may be divided into different functional modules to complete all or part of the functions described above. In addition, the thread adjusting apparatus and the thread adjusting method provided in the foregoing embodiments belong to the same concept, and specific implementation processes thereof are described in detail in the method embodiments, and are not described herein again.
Fig. 5 is a schematic structural diagram of an application server according to an embodiment of the present invention, where the application server 500 may generate a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 501 and one or more memories 502, where the memory 502 stores at least one instruction, and the at least one instruction is loaded and executed by the processors 501 to implement the method provided by the foregoing method embodiment. Certainly, the application server may further have a wired or wireless network interface, a keyboard, an input/output interface, and other components to facilitate input and output, and the application server may further include other components for implementing functions of the device, which are not described herein again.
The above description is only for facilitating the understanding of the technical solutions of the present application by those skilled in the art, and is not intended to limit the present application. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (16)

1. A method for adjusting a thread, the method comprising:
determining a first completion number of a plurality of threads which have completed tasks and the running time of each thread in a current statistical period;
determining a plurality of second completion numbers in a plurality of first appointed operation time ranges according to the operation time of each thread, wherein the sum of the plurality of second completion numbers in the plurality of first appointed operation time ranges is the first completion number;
determining the running time percentage of the plurality of threads according to a plurality of second completion numbers and the first completion number in the plurality of first appointed running time ranges;
when the running time percentage reaches a preset confidence running time percentage, determining the confidence degrees and the polymerization degrees of the running times of the multiple threads according to the first completion number and the running time of each thread;
determining the thread load rate of the target subprogram according to the first completion number, the statistical duration in the current statistical period, the current first thread number of the target subprogram and the confidence coefficient;
determining a load rate adjustment factor of the target subprogram according to the thread load rate, and determining a polymerization degree adjustment factor of the target subprogram according to the polymerization degree;
determining a second thread number of threads required by the target subprogram according to the first thread number, the load rate adjustment factor and the polymerization degree adjustment factor;
and allocating the second thread number of threads to the target subprogram.
2. The method of claim 1, wherein determining the confidence level and the degree of polymerization of the runtime of the plurality of threads based on the first number of completions and the runtime of each thread comprises:
determining a plurality of third completion numbers in a plurality of second specified running time ranges according to the running time of each thread, wherein the sum of the plurality of third completion numbers in the plurality of second specified running time ranges is the first completion number;
selecting a second specified operation time range with the specified number and the maximum third completion number according to a plurality of third completion numbers in the second specified operation time ranges;
determining the specified number of first weights and the specified number of target run times according to the specified number of second specified run time ranges;
carrying out weighted average on the first weights with the specified number and the target running times with the specified number to obtain the confidence;
and determining the polymerization degree through a polymerization degree algorithm according to the first completion number and the running time of each thread.
3. The method of claim 1, wherein determining the thread load rate of the target subroutine according to the first completion number, the statistical duration in the current statistical period, the current first thread number of the target subroutine, and the confidence level comprises:
determining a first thread completion rate of the plurality of threads in unit time according to the first completion number and the statistical duration;
determining a second thread completion rate of the thread of the target subprogram in unit time according to the first thread number and the confidence coefficient;
and determining the thread load rate according to the first thread completion rate and the second thread completion rate, wherein the thread load rate is in direct proportion to the first thread completion rate and in inverse proportion to the second thread completion rate.
4. The method of claim 1, wherein determining a load rate adjustment factor for the target subroutine based on the thread load rate comprises:
when the thread load rate reaches a first preset thread load rate, setting the load rate adjustment factor as a first preset numerical value;
when the thread load rate does not reach a second preset thread load rate, setting the load rate adjustment factor as a second preset numerical value;
when the thread load rate reaches the second preset thread load rate but does not reach the first preset thread load rate, setting the load rate adjustment factor as a third preset numerical value;
the first preset thread load rate is greater than the second preset thread load rate, the first preset numerical value is greater than the third preset numerical value, and the third preset numerical value is greater than the second preset numerical value.
5. The method of claim 1, wherein determining an aggregation level adjustment factor for the target subroutine based on the aggregation level comprises:
when the polymerization degree reaches a first preset polymerization degree, setting the polymerization degree adjustment factor as a fourth preset numerical value;
when the polymerization degree does not reach a second preset polymerization degree, setting the polymerization degree adjustment factor as a fifth preset numerical value;
when the polymerization degree reaches the second preset polymerization degree but does not reach the first preset polymerization degree, setting the polymerization degree adjustment factor as a sixth preset numerical value;
the first preset polymerization degree is larger than the second preset polymerization degree, the fourth preset numerical value is larger than the sixth preset numerical value, and the sixth preset numerical value is larger than the fifth preset numerical value.
6. The method of claim 1, wherein determining the second number of threads of the threads required by the target subroutine according to the first number of threads, the load factor adjustment factor and the aggregation level adjustment factor comprises:
and taking the product of the first thread number, the load factor adjusting factor and the polymerization degree adjusting factor as the second thread number.
7. The method of claim 2, further comprising:
determining a specified number of third specified run-time ranges within a last statistical period of the current statistical period;
when the specified number of third specified operating time ranges and the specified number of second specified operating time ranges are different, the step of determining the specified number of first weights and the specified number of target operating times according to the specified number of second specified operating time ranges is performed.
8. An apparatus for thread tuning, the apparatus comprising:
the first determining module is used for determining the first completion number of a plurality of threads which have completed the task and the running time of each thread in the current statistical period;
a second determining module, configured to determine, according to the running time of each thread, a plurality of second completion numbers within a plurality of first specified running time ranges, where a sum of the plurality of second completion numbers within the plurality of first specified running time ranges is the first completion number; determining the running time percentages of the plurality of threads according to a plurality of second completion numbers and the first completion numbers in the plurality of first specified running time ranges;
the adjusting module is used for determining the confidence degrees and the polymerization degrees of the running time of the plurality of threads according to the first completion number and the running time of each thread when the running time percentage reaches a preset confidence running time percentage; determining the thread load rate of the target subprogram according to the first completion number, the statistical duration in the current statistical period, the current first thread number of the target subprogram and the confidence coefficient; determining a load rate adjustment factor of the target subprogram according to the thread load rate, and determining a polymerization degree adjustment factor of the target subprogram according to the polymerization degree; determining a second thread number of threads required by the target subprogram according to the first thread number, the load rate adjustment factor and the polymerization degree adjustment factor; and allocating the second thread number of threads to the target subprogram.
9. The apparatus of claim 8, wherein the adjustment module is further configured to determine a plurality of third completion numbers within a plurality of second specified running time ranges according to the running time of each thread, and a sum of the plurality of third completion numbers within the plurality of second specified running time ranges is the first completion number;
the adjusting module is further configured to select a second specified operation time range with a specified number, in which the third completion number is the largest, according to a plurality of third completion numbers in the second specified operation time ranges;
the adjusting module is further configured to determine the first weight of the specified number and the target operation time of the specified number according to the second specified operation time range of the specified number;
the adjusting module is further configured to perform weighted average on the specified number of first weights and the specified number of target operation times to obtain the confidence level;
the adjusting module is further configured to determine the aggregation degree through an aggregation degree algorithm according to the first completion number and the running time of each thread.
10. The apparatus of claim 8, wherein the adjusting module is further configured to determine a first thread completion rate of the plurality of threads in a unit time according to the first completion number and the statistical duration;
the adjusting module is further configured to determine a second thread completion rate of the thread of the target subroutine in unit time according to the first thread number and the confidence level;
the adjusting module is further configured to determine the thread load rate according to the first thread completion rate and the second thread completion rate, where the thread load rate is proportional to the first thread completion rate and inversely proportional to the second thread completion rate.
11. The apparatus of claim 8, wherein the adjusting module is further configured to set the load factor adjustment factor to a first preset value when the thread load rate reaches a first preset thread load rate;
the adjusting module is further configured to set the load factor adjusting factor to a second preset value when the thread load rate does not reach a second preset thread load rate;
the adjusting module is further configured to set the load factor adjusting factor to a third preset value when the thread load rate reaches the second preset thread load rate but does not reach the first preset thread load rate;
the first preset thread load rate is greater than the second preset thread load rate, the first preset value is greater than the third preset value, and the third preset value is greater than the second preset value.
12. The apparatus according to claim 8, wherein the adjusting module is further configured to set the degree of polymerization adjusting factor to a fourth preset value when the degree of polymerization reaches a first preset degree of polymerization;
the adjusting module is further configured to set the polymerization degree adjusting factor to a fifth preset numerical value when the polymerization degree does not reach a second preset polymerization degree;
the adjusting module is further configured to set the polymerization degree adjusting factor to a sixth preset numerical value when the polymerization degree reaches the second preset polymerization degree but does not reach the first preset polymerization degree;
the first preset polymerization degree is larger than the second preset polymerization degree, the fourth preset numerical value is larger than the sixth preset numerical value, and the sixth preset numerical value is larger than the fifth preset numerical value.
13. The apparatus of claim 8, wherein the adjusting module is further configured to take a product of the first thread number, the load factor adjustment factor, and the degree of polymerization adjustment factor as the second thread number.
14. The apparatus of claim 9, wherein the adjustment module is further configured to determine a third specified number of runtime ranges within a last statistical period of the current statistical period;
the adjusting module is further configured to determine the first weight of the specified number and the target operation time of the specified number according to the second specified operation time range of the specified number when the third specified operation time range of the specified number and the second specified operation time range of the specified number are different.
15. An application server, characterized in that the application server comprises:
a processor and a memory, the memory having stored therein at least one instruction that is loaded and executed by the processor to implement the operations performed in the method of tuning a thread of any of claims 1-7.
16. A computer-readable storage medium having stored therein at least one instruction which is loaded and executed by a processor to perform operations performed in a method of tuning a thread of any of claims 1-7.
CN201910561103.8A 2019-06-26 2019-06-26 Thread adjusting method and device, application server and storage medium Active CN111324447B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910561103.8A CN111324447B (en) 2019-06-26 2019-06-26 Thread adjusting method and device, application server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910561103.8A CN111324447B (en) 2019-06-26 2019-06-26 Thread adjusting method and device, application server and storage medium

Publications (2)

Publication Number Publication Date
CN111324447A CN111324447A (en) 2020-06-23
CN111324447B true CN111324447B (en) 2023-03-28

Family

ID=71169149

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910561103.8A Active CN111324447B (en) 2019-06-26 2019-06-26 Thread adjusting method and device, application server and storage medium

Country Status (1)

Country Link
CN (1) CN111324447B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114237505A (en) * 2021-12-14 2022-03-25 中国建设银行股份有限公司 Batch processing method and device of business data and computer equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103428272A (en) * 2013-07-16 2013-12-04 无限极(中国)有限公司 System and method for monitoring and scheduling of middleware threads
CN107832126A (en) * 2017-10-20 2018-03-23 平安科技(深圳)有限公司 The method of adjustment and its terminal of a kind of thread
CN108874550A (en) * 2018-07-18 2018-11-23 郑州云海信息技术有限公司 A kind of method, apparatus, storage medium and computer equipment adjusting thread pool
CN109271252A (en) * 2018-08-29 2019-01-25 华为技术有限公司 A kind of method and device adjusting Thread Count

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8108863B2 (en) * 2005-12-30 2012-01-31 Intel Corporation Load balancing for multi-threaded applications via asymmetric power throttling

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103428272A (en) * 2013-07-16 2013-12-04 无限极(中国)有限公司 System and method for monitoring and scheduling of middleware threads
CN107832126A (en) * 2017-10-20 2018-03-23 平安科技(深圳)有限公司 The method of adjustment and its terminal of a kind of thread
CN108874550A (en) * 2018-07-18 2018-11-23 郑州云海信息技术有限公司 A kind of method, apparatus, storage medium and computer equipment adjusting thread pool
CN109271252A (en) * 2018-08-29 2019-01-25 华为技术有限公司 A kind of method and device adjusting Thread Count

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Basireddy Karunakar Reddy et al..Inter-Cluster Thread-to-Core Mapping and DVFS on Heterogeneous Multi-Cores.《IEEE TRANSACTIONS ON MULTI-SCALE COMPUTING SYSTEMS》.2018,第369-382页. *
王庆等.基于线程负载的嵌入式多核低功耗优化方法研究.《高技术通讯》.2013,第901-907页. *

Also Published As

Publication number Publication date
CN111324447A (en) 2020-06-23

Similar Documents

Publication Publication Date Title
US10558498B2 (en) Method for scheduling data flow task and apparatus
US7996846B2 (en) Allocation of system resources among applications using predefined entitlement values and weight associated with each of the applications
CN110365765B (en) Bandwidth scheduling method and device of cache server
CN108268317B (en) Resource allocation method and device
CN111225050B (en) Cloud computing resource allocation method and device
CN109981744B (en) Data distribution method and device, storage medium and electronic equipment
WO2008092733A2 (en) Processor thread allocation using delay-costs
CN111324447B (en) Thread adjusting method and device, application server and storage medium
CN111045808A (en) Distributed network task scheduling method and device
CN112685298A (en) Code coverage testing method and device for application program and electronic equipment
Langhnoja et al. Multi-objective based integrated task scheduling in cloud computing
CN112416520B (en) Intelligent resource scheduling method based on vSphere
CN113867953A (en) Resource allocation method, device, storage medium and electronic equipment
CN115640113A (en) Multi-plane flexible scheduling method
Beaumont et al. Minimizing weighted mean completion time for malleable tasks scheduling
CN116302404B (en) Resource decoupling data center-oriented server non-perception calculation scheduling method
US8108871B2 (en) Controlling computer resource utilization
CN114995974A (en) Task scheduling method and device, storage medium and computer equipment
CN115904724A (en) Thread allocation method, thread allocation device, storage medium and computer equipment
CN112667392A (en) Cloud computing resource allocation method and device, computer equipment and storage medium
CN114489463A (en) Method and device for dynamically adjusting QOS (quality of service) of storage volume and computing equipment
JPS62210546A (en) Job schedule processing system
CN112181498A (en) Concurrency control method, device and equipment
CN111796934A (en) Task issuing method and device, storage medium and electronic equipment
CN111628943A (en) Intelligent Internet of things method based on communication and perception technology

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
GR01 Patent grant
GR01 Patent grant