CN113238854B - Method, device and equipment for automatically adjusting thread number and readable medium - Google Patents
Method, device and equipment for automatically adjusting thread number and readable medium Download PDFInfo
- Publication number
- CN113238854B CN113238854B CN202110767231.5A CN202110767231A CN113238854B CN 113238854 B CN113238854 B CN 113238854B CN 202110767231 A CN202110767231 A CN 202110767231A CN 113238854 B CN113238854 B CN 113238854B
- Authority
- CN
- China
- Prior art keywords
- thread
- change
- rate
- threads
- performance
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 48
- 230000008859 change Effects 0.000 claims abstract description 130
- 238000012545 processing Methods 0.000 claims abstract description 69
- 230000004044 response Effects 0.000 claims abstract description 41
- 238000003860 storage Methods 0.000 claims abstract description 25
- 230000033228 biological regulation Effects 0.000 claims abstract description 7
- 238000004590 computer program Methods 0.000 claims description 11
- 238000004364 calculation method Methods 0.000 claims description 7
- 230000008901 benefit Effects 0.000 claims description 5
- 238000010586 diagram Methods 0.000 description 7
- 230000000694 effects Effects 0.000 description 6
- 230000006870 function Effects 0.000 description 6
- 230000008569 process Effects 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 4
- 238000013461 design Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 238000004519 manufacturing process Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Business, Economics & Management (AREA)
- Finance (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Accounting & Taxation (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- General Business, Economics & Management (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention provides a method, a device, equipment and a readable medium for automatically adjusting thread number, wherein the method comprises the following steps: setting a thread regulation fluctuation range, and acquiring the performance of the current last thread and the performance of the added thread after stable operation; calculating a first rate of change of thread processing speed based on the obtained performance; comparing the absolute value of the first rate of change to the fluctuation range; in response to the absolute value of the first rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads. By using the scheme of the invention, the optimal thread number can be found so as to adjust the processing speed of the task, the higher requirement of the storage performance can be met, and the user experience is improved.
Description
Technical Field
The field relates to the field of computers, and more particularly to a method, a device, equipment and a readable medium for automatically adjusting thread number.
Background
With the increasing of the application scale of big data, the processing requirement of mass data puts higher demands on the storage performance of the computer system. Users prefer to have an efficient use environment, the I/0 request response time delay is increased when the number of processing threads is too small, the processing resources of other tasks are occupied when the number of threads is too large, user experience is also affected, especially, the completion time of user requests is affected when thread allocation is applied to real-time transaction, and the user experience is reduced.
Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide a method, an apparatus, a device, and a readable medium for automatically adjusting a thread count, which can find an optimal thread count to adjust a processing speed of a task, meet a higher requirement of storage performance, and improve a user experience.
In view of the above object, an aspect of the embodiments of the present invention provides a method for automatically adjusting a thread count, including the steps of:
setting a thread regulation fluctuation range, and acquiring the performance of the current last thread and the performance of the added thread after stable operation;
calculating a first rate of change of thread processing speed based on the obtained performance;
comparing the absolute value of the first rate of change to the fluctuation range;
in response to the absolute value of the first rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
According to an embodiment of the present invention, further comprising:
in response to the absolute value of the first rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the first rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the operation is stable;
calculating a second rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the second rate of change to the fluctuation range;
in response to the absolute value of the second rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
According to an embodiment of the present invention, further comprising:
responding to the decrease of the processing speed of the current thread caused by jitter, and acquiring the performance of the current last thread and increasing the running stability of one thread;
calculating a third rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the third rate of change to the fluctuation range;
in response to the absolute value of the third rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
According to an embodiment of the present invention, further comprising:
in response to the absolute value of the third rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the third rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the operation is stable;
calculating a fourth rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the fourth rate of change to the fluctuation range;
in response to the absolute value of the fourth rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
According to an embodiment of the present invention, in response to the absolute value of the first rate of change being greater than the fluctuation range, calculating the number of threads to adjust to based on the first rate of change includes:
and adding the current thread number to the product of the first change rate and the direct proportion coefficient to obtain the thread number to be adjusted.
According to one embodiment of the present invention, calculating the first rate of change of the thread processing speed based on the obtained performance includes:
and subtracting the performance of the last thread after the last thread runs stably from the performance of the other thread after the last thread runs stably to obtain a first change rate.
According to one embodiment of the invention, the thread tuning ripple ranges to 10% of the performance of the first thread after running stably.
In another aspect of the embodiments of the present invention, there is also provided an apparatus for automatically adjusting a thread count, the apparatus including:
the acquisition module is configured to set a thread regulation fluctuation range and acquire the performance of the current last thread and the performance of the added thread after stable operation;
a calculation module configured to calculate a first rate of change of the thread processing speed based on the obtained performance;
a comparison module configured to compare an absolute value of the first rate of change with the fluctuation range;
an adjustment module configured to exit the adjustment and maintain the number of threads at the current number of threads in response to the absolute value of the first rate of change being less than the fluctuation range.
In another aspect of an embodiment of the present invention, there is also provided a computer apparatus including:
at least one processor; and
a memory storing computer instructions executable on the processor, the instructions when executed by the processor implementing the steps of any of the methods described above.
In another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium storing a computer program, which when executed by a processor implements the steps of any one of the above-mentioned methods.
The invention has the following beneficial technical effects: according to the method for automatically adjusting the thread number, which is provided by the embodiment of the invention, the performance of the current last thread and the performance of the thread added with the last thread after stable operation are obtained by setting the thread adjustment fluctuation range; calculating a first rate of change of thread processing speed based on the obtained performance; comparing the absolute value of the first rate of change to the fluctuation range; and in response to the fact that the absolute value of the first change rate is smaller than the fluctuation range, exiting from the adjustment and keeping the thread number at the current thread number, the optimal thread number can be found so as to adjust the processing speed of the task, the higher requirement on the storage performance can be met, and the user experience is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
FIG. 1 is a schematic flow chart diagram of a method of thread count auto-adjustment according to one embodiment of the present invention;
FIG. 2 is a schematic diagram of an apparatus for automatic thread count adjustment according to one embodiment of the present invention;
FIG. 3 is a schematic diagram of a computer device according to one embodiment of the present invention;
fig. 4 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
In view of the above objects, a first aspect of embodiments of the present invention proposes an embodiment of a method for automatically adjusting a thread count. Fig. 1 shows a schematic flow diagram of the method.
As shown in fig. 1, the method may include the steps of:
s1, setting the fluctuation range of thread adjustment, and obtaining the performance of the current last thread and the thread added with the last thread after the operation is stable.
The thread number adjustment can optimize the processing speed of the tasks, which is expressed by the number of tasks processed per second, but since the thread adjustment process may cause fluctuation of the processing speed, we need to first determine a balance point of the processing speed and the stability. When the difference value of the processing speeds obtained by two adjacent times of adjustment is within a range, the advantage of speed adjustment brought by continuously performing thread adjustment is considered to be lower than the disadvantage of performance fluctuation, the thread adjustment needs to be stopped at the moment, the set range is called as a fluctuation range delta, generally about 10 percent of the current processing speed is taken, in actual production and development, a plurality of tasks often share a plurality of threads, the maximum number of threads that can be occupied by the task is n, the number of threads initially set in the program is a _0 (a _0< n), generally speaking, the initial number of threads a _0 is all 1, after the operation is stable for a period of time, the stability can be reached within 5 minutes generally, the number of tasks processed per second after the stable operation of the thread number a _0 is recorded as the initial performance P _0, the thread number at the time t is represented by a _ t, and the corresponding performance value at the time t is P _ t. For example, if there are 8 threads in the current system, the performance of the 8 th thread and the 9 th thread needs to be obtained, that is, the performance of the 8 th thread at time t is P _ t, and the performance of the 9 th thread at time t +1 is P _ t + 1.
S2 calculates a first rate of change of the thread processing speed based on the acquired performance.
After the performance P _ t +1 of the 9 threads and the performance P _ t of the 8 th thread are acquired, the slope K (i.e. the change rate) of the change of the running speed is calculated, the slope represents the trend of the change of the task processing speed, and the performance of the previous thread is subtracted from the performance of the following thread, namely, K = (P _ t + 1) -P _ t.
S3 compares the absolute value of the first rate of change with the fluctuation range.
Since the trend of change in the task processing speed may be either an increase or a decrease, the calculated K value may be a positive value or a negative value, and the value of the fluctuation range is a set positive value, and therefore, it is necessary to compare the absolute value of the change rate with the fluctuation range.
S4 exits the adjusting and maintains the number of threads at the current number of threads in response to the absolute value of the first rate of change being less than the fluctuation range.
When K is less than δ, that is, the variation of the processing speed is within the set fluctuation range, at this time, according to the balance between the processing speed and the speed fluctuation, it is considered that the thread adjustment effect reaches the acceptable range, if the speed fluctuation is continuously caused by continuous adjustment, and the range within which the speed can be continuously increased is limited, and the continuous adjustment may obtain an unreliable effect, so that the optimization process is ended, the adjustment is exited, and the current thread number is maintained as the current state, as in the above example, the current thread number is maintained as 8 threads.
According to the technical scheme, the thread number of the system can be automatically adjusted, the optimal thread number is automatically found, the processing speed of the task is further adjusted, the higher requirement on the storage performance can be met, and the user experience is improved.
In a preferred embodiment of the present invention, the method further comprises:
in response to the absolute value of the first rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the first rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the operation is stable;
calculating a second rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the second rate of change to the fluctuation range;
in response to the absolute value of the second rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
When K > δ, that is, the variation of the processing speed is outside the set fluctuation range, the number of threads needs to be adjusted to reach the optimal number of threads, at this time, the number of threads to be adjusted may be calculated according to a formula, where the number of threads to be adjusted = the current number of threads + m × K, where m may be a set direct scaling factor, K is the rate of change of adding one thread to the last thread and the last thread before the adjustment is not performed, for example, δ is 50, the current number of threads is 8, the direct scaling factor is 0.02, the performance of the 8 th thread is 300/s, if one thread is added as the 9 th thread, the performance of the 9 th thread is 200/s, then K is-100, | -100| =100>50, if the number of threads to be adjusted is 8+0.02 = -100), then the current number of threads needs to be adjusted to 6, and then whether the requirements are met when the 6 threads are continuously calculated according to the method, the adjustment is stopped until the absolute value of the calculated K value is less than the set delta.
In a preferred embodiment of the present invention, the method further comprises:
responding to the decrease of the processing speed of the current thread caused by jitter, and acquiring the performance of the current last thread and increasing the running stability of one thread;
calculating a third rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the third rate of change to the fluctuation range;
in response to the absolute value of the third rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
In a preferred embodiment of the present invention, the method further comprises:
in response to the absolute value of the third rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the third rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the operation is stable;
calculating a fourth rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the fourth rate of change to the fluctuation range;
in response to the absolute value of the fourth rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
When a code running platform fault or other tasks are started and the like possibly interfere with the current task, the processing speed of the current task is suddenly reduced, and the system needs to find the optimal thread again. After the above-mentioned condition suddenly occurs, the adjustment is performed according to the above-mentioned method, which is not described herein again.
In a preferred embodiment of the present invention, calculating the number of threads to adjust to based on the first rate of change in response to the absolute value of the first rate of change being greater than the fluctuation range includes:
and adding the current thread number to the product of the first change rate and the direct proportion coefficient to obtain the thread number to be adjusted.
In a preferred embodiment of the present invention, calculating the first rate of change of the thread processing speed based on the obtained performance includes:
and subtracting the performance of the last thread after the last thread runs stably from the performance of the other thread after the last thread runs stably to obtain a first change rate.
In a preferred embodiment of the present invention, the range of the thread tuning fluctuation is 10% of the performance of the first thread after running stably.
Examples
According to the steps, the method is applied to the automatic adjustment requirement of the number of the threads for data flash in the storage product, the number of the total threads is 10, delta =50, the direct proportionality coefficient is 0.02, the initial number of the threads is 1, the number of the processing tasks after the first thread stably runs is 500/s, when the number of the threads is 2, namely the number of the processing tasks after the second thread stably runs is 800/s, when K =800 plus 500=300, and 300>50, the number of the threads needs to be adjusted, the number of the threads to be adjusted is 1+300 plus 0.02=7 through calculation according to a formula, namely the number of the threads is adjusted to 7;
at this time, the number of lower brushes is caused to be insufficient, the number of processing tasks of the seventh thread is 300/s, when the number of threads is 8, that is, the number of processing tasks of the eighth thread is 200/s, at this time, K = 200-;
the fifth thread processing task number is 870/s, when the thread number is 6, that is, the sixth thread processing task number is 900/s, at this time, K = 900-.
By the technical scheme, the optimal thread number can be found, the processing speed of the task can be further adjusted, the higher requirement on the storage performance can be met, and the user experience is improved.
It should be noted that, as will be understood by those skilled in the art, all or part of the processes in the methods of the above embodiments may be implemented by instructing relevant hardware through a computer program, and the above programs may be stored in a computer-readable storage medium, and when executed, the programs may include the processes of the embodiments of the methods as described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like. The embodiments of the computer program may achieve the same or similar effects as any of the above-described method embodiments.
Furthermore, the method disclosed according to an embodiment of the present invention may also be implemented as a computer program executed by a CPU, and the computer program may be stored in a computer-readable storage medium. The computer program, when executed by the CPU, performs the above-described functions defined in the method disclosed in the embodiments of the present invention.
In view of the above object, according to a second aspect of the embodiments of the present invention, there is provided an apparatus for automatically adjusting a thread count, as shown in fig. 2, the apparatus 200 includes:
and the obtaining module 201, wherein the obtaining module 201 is configured to set a thread regulation fluctuation range, and obtain the performance of the current last thread and the performance of the current last thread after the operation of the thread is stabilized.
The thread number adjustment can optimize the processing speed of the tasks, which is expressed by the number of tasks processed per second, but since the thread adjustment process may cause fluctuation of the processing speed, we need to first determine a balance point of the processing speed and the stability. When the difference value of the processing speeds obtained by two adjacent times of adjustment is within a range, the advantage of speed adjustment brought by continuously performing thread adjustment is considered to be lower than the disadvantage of performance fluctuation, the thread adjustment needs to be stopped at the moment, the set range is called as a fluctuation range delta, generally about 10 percent of the current processing speed is taken, in actual production and development, a plurality of tasks often share a plurality of threads, the maximum number of threads that can be occupied by the task is n, the number of threads initially set in the program is a _0 (a _0< n), generally speaking, the initial number of threads a _0 is all 1, after the operation is stable for a period of time, the stability can be reached within 5 minutes generally, the number of tasks processed per second after the stable operation of the thread number a _0 is recorded as the initial performance P _0, the thread number at the time t is represented by a _ t, and the corresponding performance value at the time t is P _ t. For example, if there are 8 threads in the current system, the performance of the 8 th thread and the 9 th thread needs to be obtained by the obtaining module, that is, the performance of the 8 th thread at time t is P _ t, and the performance of the 9 th thread at time t +1 is P _ t + 1.
A calculation module 202, the calculation module 202 configured to calculate a first rate of change of the thread processing speed based on the obtained performance.
After the performance P _ t +1 of the 9 threads and the performance P _ t of the 8 th thread are obtained, the calculation module calculates the slope K (namely the change rate) of the change of the running speed, the slope represents the trend of the change of the task processing speed, and the performance of the previous thread is subtracted from the performance of the next thread, namely K = (P _ t + 1) -P _ t.
A comparison module 203, the comparison module 203 configured to compare an absolute value of the first rate of change with the fluctuation range.
Since the trend of the change of the task processing speed may be increased or decreased, the calculated K value may be a positive value or a negative value, and the value of the fluctuation range is a set positive value, so that the absolute value of the change rate needs to be compared with the fluctuation range by the comparison module.
An adjustment module 204, the adjustment module 204 configured to exit the adjustment and maintain the number of threads at the current number of threads in response to the absolute value of the first rate of change being less than the fluctuation range.
When K is less than δ, that is, the variation of the processing speed is within the set fluctuation range, at this time, according to the balance between the processing speed and the speed fluctuation, it is considered that the thread adjustment effect reaches the acceptable range, if the speed fluctuation is continuously caused by continuous adjustment, and the range within which the speed can be continuously increased is limited, and the continuous adjustment may obtain an unreliable effect, so that the optimization process is ended, the adjustment is exited, and the current thread number is maintained as the current state, as in the above example, the current thread number is maintained as 8 threads.
In a preferred embodiment of the invention, the adjustment module is further configured to:
in response to the absolute value of the first rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the first rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the operation is stable;
calculating a second rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the second rate of change to the fluctuation range;
in response to the absolute value of the second rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
In a preferred embodiment of the invention, the adjustment module is further configured to:
responding to the decrease of the processing speed of the current thread caused by jitter, and acquiring the performance of the current last thread and increasing the running stability of one thread;
calculating a third rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the third rate of change to the fluctuation range;
in response to the absolute value of the third rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
In a preferred embodiment of the invention, the adjustment module is further configured to:
in response to the absolute value of the third rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the third rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the operation is stable;
calculating a fourth rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the fourth rate of change to the fluctuation range;
in response to the absolute value of the fourth rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
In a preferred embodiment of the invention, the adjustment module is further configured to:
and adding the current thread number to the product of the first change rate and the direct proportion coefficient to obtain the thread number to be adjusted.
In a preferred embodiment of the invention, the calculation module is further configured to:
and subtracting the performance of the last thread after the last thread runs stably from the performance of the other thread after the last thread runs stably to obtain a first change rate.
In a preferred embodiment of the present invention, the range of the thread tuning fluctuation is 10% of the performance of the first thread after running stably.
In view of the above object, a third aspect of the embodiments of the present invention provides a computer device. Fig. 3 is a schematic diagram of an embodiment of a computer device provided by the present invention. As shown in fig. 3, an embodiment of the present invention includes the following means: at least one processor S21; and a memory S22, the memory S22 storing computer instructions S23 executable on the processor, the instructions when executed by the processor implementing the method of:
setting a thread regulation fluctuation range, and acquiring the performance of the current last thread and the performance of the added thread after stable operation;
calculating a first rate of change of thread processing speed based on the obtained performance;
comparing the absolute value of the first rate of change to the fluctuation range;
in response to the absolute value of the first rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
In a preferred embodiment of the present invention, the method further comprises:
in response to the absolute value of the first rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the first rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the operation is stable;
calculating a second rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the second rate of change to the fluctuation range;
in response to the absolute value of the second rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
In a preferred embodiment of the present invention, the method further comprises:
responding to the decrease of the processing speed of the current thread caused by jitter, and acquiring the performance of the current last thread and increasing the running stability of one thread;
calculating a third rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the third rate of change to the fluctuation range;
in response to the absolute value of the third rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
In a preferred embodiment of the present invention, the method further comprises:
in response to the absolute value of the third rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the third rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the operation is stable;
calculating a fourth rate of change of the thread processing speed based on the obtained performance;
comparing the absolute value of the fourth rate of change to the fluctuation range;
in response to the absolute value of the fourth rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
In a preferred embodiment of the present invention, calculating the number of threads to adjust to based on the first rate of change in response to the absolute value of the first rate of change being greater than the fluctuation range includes:
and adding the current thread number to the product of the first change rate and the direct proportion coefficient to obtain the thread number to be adjusted.
In a preferred embodiment of the present invention, calculating the first rate of change of the thread processing speed based on the obtained performance includes:
and subtracting the performance of the last thread after the last thread runs stably from the performance of the other thread after the last thread runs stably to obtain a first change rate.
In a preferred embodiment of the present invention, the range of the thread tuning fluctuation is 10% of the performance of the first thread after running stably.
In view of the above object, a fourth aspect of the embodiments of the present invention proposes a computer-readable storage medium. FIG. 4 is a schematic diagram illustrating an embodiment of a computer-readable storage medium provided by the present invention. As shown in fig. 4, the computer readable storage medium S31 stores a computer program S32 which, when executed by a processor, performs the method as described above.
Furthermore, the methods disclosed according to embodiments of the present invention may also be implemented as a computer program executed by a processor, which may be stored in a computer-readable storage medium. Which when executed by a processor performs the above-described functions defined in the methods disclosed in embodiments of the invention.
Further, the above method steps and system elements may also be implemented using a controller and a computer readable storage medium for storing a computer program for causing the controller to implement the functions of the above steps or elements.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.
In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, Digital Versatile Disc (DVD), floppy disk, blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.
Claims (9)
1. A method for automatically adjusting thread number is characterized by comprising the following steps:
setting a thread regulation fluctuation range, and acquiring the performance of the current last thread and the performance of the added thread after stable operation;
calculating a first rate of change of thread processing speed based on the obtained performance;
comparing an absolute value of the first rate of change to the fluctuation range;
in response to the absolute value of the first rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads;
in response to the absolute value of a first rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the first rate of change and adjusting the current number of threads to the number of threads to be adjusted; wherein, in response to the absolute value of the first rate of change being greater than the fluctuation range, calculating the number of threads to adjust to based on the first rate of change comprises: adding the product of the first change rate and the direct proportion coefficient to the current thread number to obtain the thread number to be adjusted;
the fluctuation range is a range set by stopping thread adjustment when the advantage of speed adjustment brought by continuously performing thread adjustment is considered to be lower than the disadvantage of performance fluctuation when the processing speed difference obtained by two adjacent adjustments is within a range.
2. The method of claim 1, further comprising:
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the running is stable;
calculating a second rate of change of the thread processing speed based on the obtained performance;
comparing an absolute value of the second rate of change to the fluctuation range;
in response to the absolute value of the second rate of change being less than the fluctuation range, exiting the adjustment and maintaining the number of threads at the current number of threads.
3. The method of claim 1, further comprising:
responding to the decrease of the processing speed of the current thread caused by jitter, and acquiring the performance of the current last thread and increasing the running stability of one thread;
calculating a third rate of change of the thread processing speed based on the obtained performance;
comparing an absolute value of the third rate of change to the fluctuation range;
in response to the absolute value of the third rate of change being less than the fluctuation range, exiting the adjusting and maintaining the number of threads at the current number of threads.
4. The method of claim 3, further comprising:
in response to the absolute value of a third rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the third rate of change and adjusting the current number of threads to the number of threads to be adjusted;
obtaining the performance of the last thread of the thread number to be adjusted and the next thread of the last thread after the running is stable;
calculating a fourth rate of change of the thread processing speed based on the obtained performance;
comparing an absolute value of a fourth rate of change to the fluctuation range;
in response to the absolute value of the fourth rate of change being less than the fluctuation range, exiting the adjusting and maintaining the number of threads at the current number of threads.
5. The method of claim 1, wherein calculating the first rate of change of the thread processing speed based on the obtained performance comprises:
and subtracting the performance of the last thread after the last thread runs stably from the performance of the other thread after the last thread runs stably to obtain a first change rate.
6. The method of claim 1, wherein the thread tuning ripple is 10% of the performance of the first thread after running stably.
7. An apparatus for automatically adjusting a thread count, the apparatus comprising:
the acquisition module is configured to set a thread regulation fluctuation range and acquire the performance of the current last thread and the performance of the added thread after stable operation;
a calculation module configured to calculate a first rate of change of thread processing speed based on the obtained performance;
a comparison module configured to compare an absolute value of a first rate of change to the fluctuation range;
an adjustment module configured to exit the adjustment and maintain the number of threads at a current number of threads in response to an absolute value of the first rate of change being less than the fluctuation range; and
in response to the absolute value of a first rate of change being greater than the fluctuation range, calculating the number of threads to be adjusted based on the first rate of change and adjusting the current number of threads to the number of threads to be adjusted; wherein, in response to the absolute value of the first rate of change being greater than the fluctuation range, calculating the number of threads to adjust to based on the first rate of change comprises: adding the product of the first change rate and the direct proportion coefficient to the current thread number to obtain the thread number to be adjusted;
the fluctuation range is a range set by stopping thread adjustment when the advantage of speed adjustment brought by continuously performing thread adjustment is considered to be lower than the disadvantage of performance fluctuation when the processing speed difference obtained by two adjacent adjustments is within a range.
8. A computer device, comprising:
at least one processor; and
a memory storing computer instructions executable on the processor, the instructions when executed by the processor implementing the steps of the method of any one of claims 1 to 6.
9. A computer-readable storage medium, in 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.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110767231.5A CN113238854B (en) | 2021-07-07 | 2021-07-07 | Method, device and equipment for automatically adjusting thread number and readable medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110767231.5A CN113238854B (en) | 2021-07-07 | 2021-07-07 | Method, device and equipment for automatically adjusting thread number and readable medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113238854A CN113238854A (en) | 2021-08-10 |
CN113238854B true CN113238854B (en) | 2021-11-19 |
Family
ID=77141256
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110767231.5A Active CN113238854B (en) | 2021-07-07 | 2021-07-07 | Method, device and equipment for automatically adjusting thread number and readable medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113238854B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116700999B (en) * | 2023-08-07 | 2023-10-03 | 上海观安信息技术股份有限公司 | Data processing method, device, computer equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102360310A (en) * | 2011-09-28 | 2012-02-22 | 中国电子科技集团公司第二十八研究所 | Multitask process monitoring method and system in distributed system environment |
CN104717236A (en) * | 2013-12-11 | 2015-06-17 | 中国移动通信集团公司 | Equipment performance test method and device |
CN105260165A (en) * | 2015-10-10 | 2016-01-20 | 西安交通大学 | Method for dynamically controlling speculative thread number in thread-level speculation system based on SMT |
CN109766058A (en) * | 2019-01-08 | 2019-05-17 | 郑州云海信息技术有限公司 | Worker thread dynamic adjusting method, device, equipment and storage medium |
CN109885470A (en) * | 2019-03-04 | 2019-06-14 | 上海拉扎斯信息科技有限公司 | Method of adjustment, device, storage medium and the electronic equipment of thread pool |
CN110245019A (en) * | 2019-06-17 | 2019-09-17 | 广东金赋科技股份有限公司 | A kind of the thread concurrent method and device of Adaptable System resource |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8793515B2 (en) * | 2011-06-27 | 2014-07-29 | Intel Corporation | Increasing power efficiency of turbo mode operation in a processor |
CN103810048B (en) * | 2014-03-11 | 2017-01-18 | 国家电网公司 | Automatic adjusting method and device for thread number aiming to realizing optimization of resource utilization |
US10073718B2 (en) * | 2016-01-15 | 2018-09-11 | Intel Corporation | Systems, methods and devices for determining work placement on processor cores |
-
2021
- 2021-07-07 CN CN202110767231.5A patent/CN113238854B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102360310A (en) * | 2011-09-28 | 2012-02-22 | 中国电子科技集团公司第二十八研究所 | Multitask process monitoring method and system in distributed system environment |
CN104717236A (en) * | 2013-12-11 | 2015-06-17 | 中国移动通信集团公司 | Equipment performance test method and device |
CN105260165A (en) * | 2015-10-10 | 2016-01-20 | 西安交通大学 | Method for dynamically controlling speculative thread number in thread-level speculation system based on SMT |
CN109766058A (en) * | 2019-01-08 | 2019-05-17 | 郑州云海信息技术有限公司 | Worker thread dynamic adjusting method, device, equipment and storage medium |
CN109885470A (en) * | 2019-03-04 | 2019-06-14 | 上海拉扎斯信息科技有限公司 | Method of adjustment, device, storage medium and the electronic equipment of thread pool |
CN110245019A (en) * | 2019-06-17 | 2019-09-17 | 广东金赋科技股份有限公司 | A kind of the thread concurrent method and device of Adaptable System resource |
Non-Patent Citations (2)
Title |
---|
OpenMP多线程负载均衡调度策略研究与实现;任小西,唐玲等;《计算机科学》;20101130;第37卷(第11期);全文 * |
通用图形处理器线程调度优化方法研究综述;何炎祥,张军等;《计算机学报》;20160930;第39卷(第9期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN113238854A (en) | 2021-08-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20200301491A1 (en) | Method and Apparatus for Managing Global Chip Power on a Multicore System on Chip | |
CN107357405B (en) | Power consumption control method and related equipment | |
US9755935B2 (en) | Method, system and computer storage medium for bandwidth optimization of network application | |
CN108845882B (en) | Method and device for realizing CPU load balance based on transcoding task scheduling | |
CN111245732B (en) | Flow control method, device and equipment | |
CN113238854B (en) | Method, device and equipment for automatically adjusting thread number and readable medium | |
CN105024933B (en) | The control method and device of request packet transmission frequency | |
CN107436835B (en) | Access control method and device | |
EP3524810A1 (en) | Method and apparatus for controlling variable pitch of wind-driven generator set under extreme turbulent wind conditions | |
CN105100800A (en) | Video coder coding code rate adjustment method and device | |
CN111324533B (en) | A/B test method and device and electronic equipment | |
WO2016172848A1 (en) | Method and device for adjusting virtual resources in cloud computing | |
US20130254386A1 (en) | Scheduling apparatus and method for load balancing when performing multiple transcoding operations | |
CN109819172B (en) | Automatic exposure method and system | |
CN110874314A (en) | Pressure measurement method, apparatus, device and medium | |
CN111966918B (en) | Current limiting method, device and system for concurrent access request | |
CN110385344B (en) | Method and device for controlling self-adaptive loop amount of loop of hot continuous rolling mill | |
CN110418068B (en) | Focusing method, device, electronic equipment and storage medium | |
JP7214287B1 (en) | Resource allocation determination method, device, computing device and computer program | |
CN113835626A (en) | Method and device for determining usable time of disk | |
CN111176814B (en) | Task execution method and related device | |
CN111787268A (en) | Audio signal processing method and device, electronic equipment and storage medium | |
CN110838982A (en) | Method and device for adjusting network flow table parameters | |
CN114640675B (en) | Unloading strategy determining method and device, electronic equipment and storage medium | |
CN116432011A (en) | Deep learning model training method and device and related equipment |
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 |