Method and device for calculating optimal number of threads
A thread count and thread count technology, applied in the field of optimal thread count calculation methods and devices, can solve problems such as process blockage and unreasonable use of resources, and achieve the effects of improving efficiency, reducing time-consuming conversion, and reducing running time
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Publication Date
- 2020-08-28
Smart Images

Figure 1 
Figure 2 
Figure 3
Abstract
Description
technical field
[0001] The present invention relates to the technical field of data processing, in particular to a method and device for calculating an optimal number of threads. Background technique
[0002] Existing technologies include multiple conversion processes during data processing. Each conversion process includes multiple steps. The steps are generally executed sequentially through certain logic. Each step will enable a separate thread by default, and each step runs simultaneously. , if a part of the data is processed in the first step, it will be directly passed to the next step for processing. When processing the conversion, you can perform single-threaded processing for each step or manually add the number of threads, but the complexity of the steps will lead to unreasonable resource usage, and complex steps will block the entire process. Contents of the invention
[0003] In view of this, the purpose of the embodiments of the present invention is to provide...
Examples
no. 1 example
[0038] This embodiment provides a method for calculating the optimal number of threads, through the thread loss c of each step i , a single thread takes time t i In relation to the total time-consuming T of the steps, the optimal number of threads for each step is calculated to minimize the total time-consuming T of each step, thereby reducing the time-consuming conversion.
[0039] see figure 2 , figure 2 A flow chart of the method for obtaining the optimal number of threads provided by this embodiment is shown. The method for obtaining the optimal number of threads includes steps S10-S30.
[0040] Step S10: Obtain the time-consuming step t of the single-threaded operation of each step i .
[0041] Run each step single-threaded, run each step of the entire transformation, set each step to run in single-threaded mode. Record the start time of each step and the end time of each step, and obtain the step time t of each step according to the start time and end time of eac...
no. 2 example
[0070] This embodiment provides an apparatus 200 for obtaining the optimal number of threads, which is applied to the electronic device and used to implement the method for obtaining the optimal number of threads described in the first embodiment.
[0071] It should be noted that the basic principle of the device 200 for obtaining the optimal number of threads provided in this embodiment is roughly the same as the method for obtaining the optimal number of threads provided in the first embodiment. Please refer to the relevant content in the first embodiment for detailed description.
[0072] see Figure 4 , Figure 4 A schematic diagram of functional modules of the apparatus 200 for calculating the optimal number of threads provided by this embodiment is shown.
[0073] The device 200 for obtaining the optimal number of threads includes an obtaining module 210 and a obtaining module 220 .
[0074] Wherein, the obtaining module 210 is used to obtain the thread switching loss...