[go: up one dir, main page]

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 PDF

Info

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
fluctuation range
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
CN202110767231.5A
Other languages
Chinese (zh)
Other versions
CN113238854A (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.)
Suzhou Metabrain Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202110767231.5A priority Critical patent/CN113238854B/en
Publication of CN113238854A publication Critical patent/CN113238854A/en
Application granted granted Critical
Publication of CN113238854B publication Critical patent/CN113238854B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION 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/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; 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

本发明提供了一种线程数自动调节的方法、装置、设备及可读介质,该方法包括:设定线程调节波动范围,并获取当前最后一个线程和再增加一个线程的运行稳定后的性能;基于获取到的性能计算线程处理速度的第一变化率;将第一变化率的绝对值与波动范围进行比较;响应于第一变化率的绝对值小于波动范围,退出调节并将线程数保持在当前线程数。通过使用本发明的方案,能够找到最优线程数进而调节任务的处理速度,能够满足存储性能的更高需求,提高用户体验感。

Figure 202110767231

The present invention provides a method, device, device and readable medium for automatically adjusting the number of threads. The method includes: setting a thread adjustment fluctuation range, and obtaining the stable performance of the current last thread and an additional thread; Calculate the first rate of change of the thread processing speed based on the acquired performance; compare the absolute value of the first rate of change with the fluctuation range; in response to the absolute value of the first rate of change being less than the fluctuation range, exit the adjustment and keep the number of threads within The current number of threads. By using the solution of the present invention, the optimal number of threads can be found and then the processing speed of the task can be adjusted, which can meet the higher requirements of storage performance and improve the user experience.

Figure 202110767231

Description

Method, device and equipment for automatically adjusting thread number and readable medium
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.一种线程数自动调节的方法,其特征在于,包括以下步骤:1. a method for automatic adjustment of thread number, is characterized in that, comprises the following steps: 设定线程调节波动范围,并获取当前最后一个线程和再增加一个线程的运行稳定后的性能;Set the thread adjustment fluctuation range, and obtain the stable performance of the current last thread and an additional thread; 基于获取到的性能计算线程处理速度的第一变化率;Calculate the first rate of change of the thread processing speed based on the acquired performance; 将第一变化率的绝对值与所述波动范围进行比较;comparing the absolute value of the first rate of change with the fluctuation range; 响应于第一变化率的绝对值小于所述波动范围,退出调节并将线程数保持在当前线程数;In response to the absolute value of the first rate of change being less than the fluctuation range, exit the adjustment and keep the number of threads at the current number of threads; 响应于第一变化率的绝对值大于所述波动范围,基于所述第一变化率计算待调节到的线程数并将当前线程数调节到所述待调节到的线程数;其中,响应于第一变化率的绝对值大于所述波动范围,基于所述第一变化率计算待调节到的线程数包括:使用第一变化率与正比例系数的乘积加上当前线程数得到待调节到的线程数;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; wherein, in response to the first rate of change The absolute value of a rate of change is greater than the fluctuation range, and calculating the number of threads to be adjusted based on the first rate of change includes: using the product of the first rate of change and a proportional coefficient plus the current number of threads to obtain the number of threads to be adjusted ; 所述波动范围为当相邻两次调节得到的处理速度差值在一个范围内时,认定继续做线程调节带来的速度调节的优势低于性能波动的劣势,此时需要停止线程调节所设定的范围。The fluctuation range is that when the difference in processing speed obtained by two adjacent adjustments is within a range, it is determined that the advantage of speed adjustment brought by continuing to do thread adjustment is lower than the disadvantage of performance fluctuation. At this time, it is necessary to stop thread adjustment. determined range. 2.根据权利要求1所述的方法,其特征在于,还包括:2. The method of claim 1, further comprising: 获取所述待调节到的线程数的最后一个线程和所述最后一个线程的下一个线程的运行稳定后的性能;Obtain the stable performance of the last thread of the number of threads to be adjusted and the next thread of the last thread; 基于获取到的性能计算线程处理速度的第二变化率;Calculate the second rate of change of the thread processing speed based on the acquired performance; 将第二变化率的绝对值与所述波动范围进行比较;comparing the absolute value of the second rate of change with the fluctuation range; 响应于第二变化率的绝对值小于所述波动范围,退出调节并将线程数保持在当前线程数。In response to the absolute value of the second rate of change being less than the fluctuation range, the adjustment is exited and the number of threads is maintained at the current number of threads. 3.根据权利要求1所述的方法,其特征在于,还包括:3. The method of claim 1, further comprising: 响应于抖动造成当前线程的处理速度下降,获取当前最后一个线程和再增加一个线程的运行稳定后的性能;In response to the jitter causing the processing speed of the current thread to decrease, obtain the stable performance of the current last thread and adding another thread; 基于获取到的性能计算线程处理速度的第三变化率;Calculate the third rate of change of thread processing speed based on the acquired performance; 将第三变化率的绝对值与所述波动范围进行比较;comparing the absolute value of the third rate of change with the fluctuation range; 响应于第三变化率的绝对值小于所述波动范围,退出调节并将线程数保持在当前线程数。In response to the absolute value of the third rate of change being less than the fluctuation range, the adjustment is exited and the number of threads is maintained at the current number of threads. 4.根据权利要求3所述的方法,其特征在于,还包括:4. The method of claim 3, 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; 获取所述待调节到的线程数的最后一个线程和所述最后一个线程的下一个线程的运行稳定后的性能;Obtain the stable performance of the last thread of the number of threads to be adjusted and the next thread of the last thread; 基于获取到的性能计算线程处理速度的第四变化率;Calculate the fourth rate of change of the thread processing speed based on the acquired performance; 将第四变化率的绝对值与所述波动范围进行比较;comparing the absolute value of the fourth rate of change with the fluctuation range; 响应于第四变化率的绝对值小于所述波动范围,退出调节并将线程数保持在当前线程数。In response to the absolute value of the fourth rate of change being less than the fluctuation range, the adjustment is exited and the number of threads is maintained at the current number of threads. 5.根据权利要求1所述的方法,其特征在于,基于获取到的性能计算线程处理速度的第一变化率包括:5. The method according to claim 1, wherein calculating the first rate of change of the thread processing speed based on the acquired performance comprises: 使用再增加一个线程运行稳定后的性能减去最后一个线程运行稳定后的性能得到第一变化率。The first rate of change is obtained by subtracting the stabilized performance of the last thread from the stabilized performance of one more thread. 6.根据权利要求1所述的方法,其特征在于,所述线程调节波动范围为第一个线程运行稳定后的性能的10%。6 . The method according to claim 1 , wherein the fluctuation range of the thread adjustment is 10% of the performance after the first thread runs stably. 7 . 7.一种线程数自动调节的装置,其特征在于,所述装置包括:7. A device for automatically adjusting the number of threads, wherein the device comprises: 获取模块,所述获取模块配置为设定线程调节波动范围,并获取当前最后一个线程和再增加一个线程的运行稳定后的性能;an acquisition module, the acquisition module is configured to set the thread adjustment fluctuation range, and acquire the performance after the running of the current last thread and an additional thread after stable operation; 计算模块,所述计算模块配置为基于获取到的性能计算线程处理速度的第一变化率;a calculation module, the calculation module is configured to calculate the first rate of change of the thread processing speed based on the acquired performance; 比较模块,所述比较模块配置为将第一变化率的绝对值与所述波动范围进行比较;a comparison module configured to compare the absolute value of the first rate of change with the fluctuation range; 调节模块,所述调节模块配置为响应于第一变化率的绝对值小于所述波动范围,退出调节并将线程数保持在当前线程数;以及an adjustment module configured to, in response to the absolute value of the first rate of change being less than the fluctuation range, exit the adjustment and maintain the number of threads at the current number of threads; and 响应于第一变化率的绝对值大于所述波动范围,基于所述第一变化率计算待调节到的线程数并将当前线程数调节到所述待调节到的线程数;其中,响应于第一变化率的绝对值大于所述波动范围,基于所述第一变化率计算待调节到的线程数包括:使用第一变化率与正比例系数的乘积加上当前线程数得到待调节到的线程数;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; wherein, in response to the first rate of change The absolute value of a rate of change is greater than the fluctuation range, and calculating the number of threads to be adjusted based on the first rate of change includes: using the product of the first rate of change and a proportional coefficient plus the current number of threads to obtain the number of threads to be adjusted ; 所述波动范围为当相邻两次调节得到的处理速度差值在一个范围内时,认定继续做线程调节带来的速度调节的优势低于性能波动的劣势,此时需要停止线程调节所设定的范围。The fluctuation range is that when the difference in processing speed obtained by two adjacent adjustments is within a range, it is determined that the advantage of speed adjustment brought by continuing to do thread adjustment is lower than the disadvantage of performance fluctuation. At this time, it is necessary to stop thread adjustment. determined range. 8.一种计算机设备,其特征在于,包括:8. A computer equipment, characterized in that, comprising: 至少一个处理器;以及at least one processor; and 存储器,所述存储器存储有可在所述处理器上运行的计算机指令,所述指令由所述处理器执行时实现权利要求1-6任意一项所述方法的步骤。a memory storing computer instructions executable on the processor, the instructions implementing the steps of the method of any one of claims 1-6 when executed by the processor. 9.一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1-6任意一项所述方法的步骤。9. A computer-readable storage medium storing a computer program, characterized in that, when the computer program is executed by a processor, the steps of the method according to any one of claims 1-6 are implemented.
CN202110767231.5A 2021-07-07 2021-07-07 Method, device and equipment for automatically adjusting thread number and readable medium Active CN113238854B (en)

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)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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 郑州云海信息技术有限公司 Work thread dynamic adjustment method, device, device 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)

* Cited by examiner, † Cited by third party
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

Patent Citations (6)

* Cited by examiner, † Cited by third party
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 郑州云海信息技术有限公司 Work thread dynamic adjustment method, device, device 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)

* Cited by examiner, † Cited by third party
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
US11709534B2 (en) Method and apparatus for managing global chip power on a multicore system on chip
CN110096647B (en) Method and device for optimizing quantization model, electronic equipment and computer storage medium
CN108845882B (en) Method and device for realizing CPU load balancing based on transcoding task scheduling
CN103929366B (en) Flow control methods, device and equipment
CN111245732B (en) Flow control method, device and equipment
CN113238854B (en) Method, device and equipment for automatically adjusting thread number and readable medium
WO2016172848A1 (en) Method and device for adjusting virtual resources in cloud computing
WO2015153643A1 (en) Method and system for optimizing performance of a pcd while mitigating thermal generation
WO2023029680A1 (en) Method and apparatus for determining usable duration of magnetic disk
CN114936133A (en) Method, device, equipment and readable medium for improving system availability
CN110380982B (en) A flow control method and related device
CN110385344B (en) Method and device for controlling self-adaptive loop amount of loop of hot continuous rolling mill
CN112187870B (en) A kind of bandwidth smoothing method and device
CN113625949A (en) Method, system, equipment and medium for optimizing performance consistency of solid state disk
JP6513704B2 (en) Communication apparatus and data processing method
CN111966918A (en) Current limiting method, device and system for concurrent access requests
US20250013277A1 (en) Chip frequency control method and apparatus, blockchain server, and storage medium
CN114443283B (en) Method and device for stretching application instance
CN110838982A (en) Method and device for adjusting network flow table parameters
CN114167963A (en) Fan control management method, device, equipment and machine readable storage medium
CN111756850A (en) Automatic proxy IP request frequency adjusting method serving for Internet data acquisition
CN119415268B (en) Cache management method and device for metadata management component
CN115297361B (en) Transcoding task processing method and device, transcoding system, electronic equipment and medium
CN119629127A (en) Current limiting method, device, electronic device and medium for distributed cluster
JP4788422B2 (en) Noise shaping type quantizer

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
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 215000 Building 9, No.1 guanpu Road, Guoxiang street, Wuzhong Economic Development Zone, Suzhou City, Jiangsu Province

Patentee after: Suzhou Yuannao Intelligent Technology Co.,Ltd.

Country or region after: China

Address before: 215000 Building 9, No.1 guanpu Road, Guoxiang street, Wuzhong Economic Development Zone, Suzhou City, Jiangsu Province

Patentee before: SUZHOU LANGCHAO INTELLIGENT TECHNOLOGY Co.,Ltd.

Country or region before: China