Task group execution method and device
By cyclically judging the time interval and dynamically updating the task order during task group execution, the problem of difficult execution time is solved, and the execution efficiency and adaptability of the task group are improved.
Patent Information
- Application Number
- CN202311404275.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-26
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art is difficult to effectively deal with task groups whose execution time is not easy to estimate. Especially under the influence of task entry and network factors, existing methods cannot dynamically adjust the task group, resulting in limited execution efficiency.
Through looping, determine whether the current system time and the last sorted time interval meet the preset conditions, dynamically update the task order in the task group, and adjust the task priority and order according to the actual execution time.
It realizes dynamic adaptive adjustment of the task group, improves execution efficiency, is suitable for task scenarios with uncertain execution time, and enhances the flexibility and adaptability of the system.
Smart Images

Figure CN119902862A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for executing a task group. Background Art
[0002] Using thread pools to execute parallel tasks in Java applications is a common method. In order to improve the execution efficiency of parallel tasks, each task is usually sorted into a task group according to the execution time of each task and then submitted to the thread pool.
[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems:
[0004] For tasks such as data query, remote call, and real-time computing, the execution time may be affected by other factors such as task parameters and network, and the execution time is difficult to estimate. In addition, the sorted task group is fixed. If new tasks are added, R&D personnel need to re-arrange the task group. Therefore, the existing method is more suitable for task groups with stable and clear task execution times. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for executing a task group, which realizes the execution of the task group by dynamically and adaptively adjusting the order of tasks in the task group, which not only weakens the impact of the accuracy of the estimated execution time on the execution efficiency of the task group, but also for new tasks with uncertain execution time, the order can be adaptively adjusted and optimized according to the actual execution time of the task, thereby improving the execution efficiency of the task group, thereby being suitable for more business scenarios.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for executing a task group is provided, comprising:
[0007] In response to receiving an execution request of a task group, sorting the tasks in the task group, and executing the task group according to the sorting result;
[0008] It is cyclically determined whether the time interval between the current system time and the sorting time of the last sorting satisfies a preset sorting update condition. If the time interval satisfies the preset sorting update condition, the sorting result is updated, and the task group is executed according to the updated sorting result.
[0009] Optionally, when the time interval satisfies a preset sorting update condition, the sorting result is updated, including: obtaining the execution duration of each task in the task group within a specified historical time period; and updating the order of each task in the sorting result according to the execution duration of each task and the preset sorting rules.
[0010] Optionally, based on the execution time of each task and according to a preset sorting rule, the order of each task in the sorting result is updated, including: for each task in the task group, using a sliding window algorithm to count the execution time of the task within a sliding window period to obtain the sliding window execution time of each task in the task group; based on the sliding window execution time of each task in the task group and according to a preset sorting rule, updating the order of each task in the sorting result.
[0011] Optionally, when the task is executed multiple times within the sliding window period, a sliding window algorithm is used to count the execution time of the task within the sliding window period, including: calculating the average execution time of the task within the sliding window period based on multiple execution times corresponding to the multiple executions of the task within the sliding window period and the total number of executions; and determining the execution time of the task within the sliding window period based on the average execution time.
[0012] Optionally, before calculating the average execution time of the task within the sliding window cycle based on multiple execution times and the total number of executions corresponding to multiple executions of the task within the sliding window cycle, the method also includes: obtaining the execution status of each task in the task group based on the execution time of each task in the task group within the sliding window cycle, combined with a preset execution time threshold of each task, and determining that the execution status of the task is a non-speeding state.
[0013] Optionally, in the case where there is a task in an overspeeding state in the task group, the sorting result is updated according to the sliding window execution time of each task in the task group and according to a preset sorting rule, including: placing the task in the overspeeding state after the task corresponding to the non-speeding state.
[0014] Optionally, the non-overspeeding state includes a normal state and a timeout state; when there is a task in a timeout state among the tasks corresponding to the non-overspeeding state, the method further includes: judging whether the execution time of the task in the timeout state exceeds a preset abandonment time, and if the execution time of the task in the timeout state exceeds the preset abandonment time, deleting the task in the timeout state from the task group.
[0015] According to a second aspect of an embodiment of the present invention, there is provided a task group execution device, including:
[0016] A task group initial execution module, configured to sort the tasks in the task group in response to receiving an execution request of the task group, and execute the task group according to the sorting result;
[0017] The task group update execution module is used to cyclically determine whether the time interval between the current system time and the sorting time of the last sorting satisfies the preset sorting update condition. If the time interval satisfies the preset sorting update condition, the sorting result is updated, and the task group is executed according to the updated sorting result.
[0018] According to a third aspect of an embodiment of the present invention, there is provided an electronic execution device of a task group, comprising:
[0019] one or more processors;
[0020] a storage device for storing one or more programs,
[0021] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0022] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0023] An embodiment of the invention has the following advantages or beneficial effects: by responding to receiving an execution request of a task group, sorting each task in the task group, and executing the task group according to the sorting result; cyclically judging whether the time interval between the current system time and the sorting time of the last sorting satisfies a preset sorting update condition, and updating the sorting result when the time interval satisfies the preset sorting update condition, and executing the task group according to the updated sorting result. The technical solution realizes executing the task group by dynamically and adaptively adjusting the order of tasks in the task group, which not only weakens the influence of the accuracy of the estimated execution time on the execution efficiency of the task group, but also for new tasks with uncertain execution time, the order can be adaptively adjusted and optimized according to the actual execution time of the task, thereby improving the execution efficiency of the task group, making it suitable for more business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0025] Figure 1 is a schematic diagram of the main process of the method for executing a task group according to an embodiment of the present invention;
[0026] Figure 2 is a schematic diagram of a process for determining a task execution time according to an embodiment of the present invention;
[0027] Figure 3 is a schematic diagram of a flow chart of recording execution time in an embodiment of the present invention;
[0028] Figure 4 is a complete flowchart of a method for executing a task group according to an embodiment of the present invention;
[0029] Figure 5 is a schematic diagram of main modules of an execution device of a task group according to an embodiment of the present invention;
[0030] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0031] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0032] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0033] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0034] In the existing task group execution method, for tasks such as data query, remote call, and real-time computing, the execution time may be affected by other factors such as task parameters and network, and the task execution time is not easy to estimate; in addition, the sorted task group is fixed. If new tasks are added, R&D personnel need to re-arrange the task group. Therefore, the existing method is more suitable for task groups with stable and clear task execution time, which cannot meet practical applications well.
[0035] In order to solve the above problems existing in the prior art, the present invention proposes a method for executing a task group. Based on the task group that has been sorted and is being executed, it is cyclically determined whether the time interval between the current system time and the sorting time of the last sorting satisfies the preset sorting update condition, and if it is satisfied, the sorting in the task group is updated to execute the task group in the updated order. The task group is executed by dynamically and adaptively adjusting the order of the tasks in the task group, which not only weakens the impact of the accuracy of the estimated execution time on the execution efficiency of the task group, but also for new tasks with uncertain execution time, the order can be adaptively adjusted and optimized according to the actual execution time of the task, thereby improving the execution efficiency of the task group, so that it is suitable for more business scenarios.
[0036] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows:
[0037] Greedy thinking: It is a method that always chooses the current optimal one in the hope of achieving the overall optimal one, and is generally used to solve optimization problems.
[0038] Figure 1 is a schematic diagram of the main process of the execution method of the task group according to an embodiment of the present invention, such as Figure 1 As shown, the execution method of the task group according to the embodiment of the present invention includes the following steps S101 to S102.
[0039] Step S101 : in response to receiving an execution request of a task group, sorting the tasks in the task group, and executing the task group according to the sorting result.
[0040] Specifically, during the execution of parallel tasks, researchers use thread pools to execute tasks, and the size of the thread pool generally depends on the number of cores of the server. In order to further improve the efficiency of parallel execution, multiple tasks are usually reasonably sorted into a task group. For example, based on the greedy idea, tasks are arranged in descending order according to their execution time to obtain a task group. The efficiency of parallel execution is improved by submitting each task in the task group to the thread pool in sequence.
[0041] The embodiment of the present invention uses a dynamic and adaptive method to sort the tasks in the task group. Before receiving the execution request of the task group, it is necessary to clarify the size of the thread pool and the tasks included in the task group. According to the received execution request, based on personal experience and / or relevant data records, the tasks in the task group are initially sorted and submitted to the instantiated task group executor. The task group executor allocates the tasks to the thread pools according to the order of the sorting results to execute the task group. In addition, in order to prevent a task from taking up resources for a long time due to other factors, the embodiment of the present invention can also pre-set a task group overall execution waiting time. If the task group has not been executed within the overall execution waiting time, the execution of the task group can be stopped immediately, and a prompt message is issued to prompt relevant personnel to check the cause of the timeout and handle it.
[0042] Step S102, cyclically determine whether the time interval between the current system time and the sorting time of the last sorting satisfies a preset sorting update condition; if the time interval satisfies the preset sorting update condition, update the sorting result, and execute the task group according to the updated sorting result.
[0043] Specifically, based on the task group that has been sorted and is being executed, an adaptive adjustment time is set, and the embodiment of the present invention uses the time interval between the current system time and the sorting time of the last sorting as the adaptive adjustment time. It is cyclically determined whether the time interval between the current time and the last sorting time meets the preset sorting time interval, that is, whether the time interval exceeds the preset sorting time interval. In the case that the current time interval exceeds the sorting time interval, the sorting of each task in the above task group is dynamically and adaptively updated according to the execution status of each task within the current time interval, so as to submit the updated task group to the thread pool and optimize the execution efficiency of the task group.
[0044] According to one embodiment of the present invention, when the time interval satisfies a preset sorting update condition, the sorting result is updated, including: obtaining the execution duration of each task in the task group within a specified historical time period; and updating the order of each task in the sorting result according to the execution duration of each task and the preset sorting rules.
[0045] Specifically, considering that based on the above, when the task group execution request is received, the task group is initially sorted and submitted to the thread pool for execution of the task group. During the execution of each task, the system can record the execution time of the task, use the execution of the task group in the thread pool as actual reference data, specify the historical time period within the sorting time interval, and obtain the execution time of each task within this time period. For example, the sorting time interval is 3 hours, the last sorting time is 9:00, the current time is 12:10, and it exceeds the sorting time interval by 3 hours. At this time, the historical execution time of each task in the task group between 9:00 and 10:00 can be obtained, and the historical execution time of each task between 9:30 and 11:00 can also be obtained. According to the execution time of each task, each task is arranged in descending order according to the execution time, and the sorting update of each task in the task group is realized. Of course, the available resources of the current system can also be obtained. When the available resources of the system are sufficient, the tasks with longer execution time are prioritized. When the available resources are tight, the tasks with shorter execution time are prioritized. The specific sorting rules are determined according to the actual business scenario and the situation of system resources, and are not specifically limited in the embodiment of the present invention.
[0046] According to another embodiment of the present invention, based on the execution time of each task and according to a preset sorting rule, the order of each task in the sorting result is updated, including: for each task in the task group, using a sliding window algorithm to count the execution time of the task within a sliding window period to obtain the sliding window execution time of each task in the task group; based on the sliding window execution time of each task in the task group and according to the preset sorting rule, updating the order of each task in the sorting result.
[0047] Specifically, in order to more scientifically count the execution time of each task, the embodiment of the present invention uses a sliding window algorithm to count the execution time of each task within a sliding window period. According to business experience, a reasonable sliding window size and statistical period are set. The embodiment of the present invention sets the sliding window size to 10 minutes, and the statistical period of the sliding window, that is, the sliding window period, is 1 hour, that is, the execution time of each task within one hour is counted. In this way, the sliding window execution time of each task is obtained, and then the order of each task in the sorting result of the above task group is updated according to the sliding window execution time of each task, combined with the sorting rules.
[0048] According to another embodiment of the present invention, when the task is executed multiple times within the sliding window period, a sliding window algorithm is used to count the execution time of the task within the sliding window period, including: calculating the average execution time of the task within the sliding window period based on multiple execution times corresponding to the multiple executions of the task within the sliding window period and the total number of executions; and determining the execution time of the task within the sliding window period based on the average execution time.
[0049] Specifically, considering that the tasks in the task group are executed multiple times within a time period, when the task is executed multiple times within the sliding window period, the average execution time is calculated based on the multiple execution times of the task executions counted within the sliding window period and the total number of executions. Subsequently, the average execution time can be directly used as the execution time of the task within the sliding window period, or the degree to which the execution time of multiple executions of the task deviates from the average execution time can be obtained based on the average execution time, and a weighting coefficient is determined based on this degree. The average execution time is fine-grainedly adjusted by the weighting coefficient, and the adjusted time is used as the execution time of the task within the sliding window period.
[0050] According to another embodiment of the present invention, before calculating the average execution time of the task within the sliding window period according to multiple execution times and the total number of executions corresponding to multiple executions of the task within the sliding window period, the method further includes: obtaining the execution status of each task in the task group according to the execution time of each task in the task group within the sliding window period, combined with a preset execution time threshold of each task, and determining that the execution status of the task is a non-speeding state.
[0051] Specifically, considering the business scenario of the embodiment of the present invention, the execution of the task group is cyclic and uninterrupted, or continues to execute after a short interruption, that is, there are usually dozens of times or more executions in a sliding window cycle. In the case of a large number of executions, if all are counted according to the execution time, it will affect the statistical efficiency. To this end, the embodiment of the present invention sets the execution time threshold of each task in advance, and determines the execution status of each task in the task group according to the execution time of each task in the sliding window cycle. For example, the execution time threshold of task A is set to [10, 100] milliseconds, that is, if the execution time of task A is within [10, 100] milliseconds, it belongs to the execution state that meets the requirements, and the execution time less than 10 milliseconds is an overspeed state. Similarly, when a task is executed multiple times in the sliding window cycle, the execution state corresponding to each execution time can be counted, and the execution state of the task is determined according to the proportion of various execution states in the sliding window cycle.
[0052] Furthermore, the embodiment of the present invention is mainly based on the greedy idea, and arranges each task in descending order according to the execution time of each task. Taking into account that the execution time of tasks in the overspeed state is relatively short, their specific execution time is generally of little guiding significance for sorting. The embodiment of the present invention can only calculate the average execution time of tasks in the non-overspeed state, which can further improve the update efficiency.
[0053] According to another embodiment of the present invention, in the case where there is a task in an overspeeding state in the task group, the sorting result is updated according to the sliding window execution time of each task in the task group and according to a preset sorting rule, including: placing the task in the overspeeding state after the task corresponding to the non-speeding state.
[0054] Specifically, according to the execution status of each task determined as above, when there is a task in the overspeeding state in the task group, considering that the execution time of the tasks in the overspeeding state is relatively short and the impact on the execution efficiency of the task group is not significant, the embodiment of the present invention can mark the tasks in the overspeeding state as 0, and then directly arrange the tasks marked with 0 after the tasks corresponding to the non-overspeeding state. Of course, if the tasks in the task group are sorted in the form of a queue, then the tasks marked with 0 are directly placed at the end of the queue, that is, as the last type of task to be executed.
[0055] According to another embodiment of the present invention, the non-overspeeding state includes a normal state and a timeout state; when there is a task in a timeout state among the tasks corresponding to the non-overspeeding state, the method further includes: judging whether the execution time of the task in the timeout state exceeds a preset abandonment time, and if the execution time of the task in the timeout state exceeds the preset abandonment time, deleting the task in the timeout state from the task group.
[0056] Specifically, for the above-mentioned determination of the execution status of each task according to the set execution time threshold, it is specifically divided into overspeeding state, normal state and timeout state according to the execution time. The overspeeding state means that the execution time is less than the lower limit of the threshold, the normal state means that the execution time is within the threshold range, and the timeout state means that the execution time exceeds the upper limit of the threshold. When there is a task in the timeout state among the tasks in the non-overspeeding state, it is possible to further measure whether the specific execution time of the task in the timeout state is within an acceptable range, that is, whether it exceeds the preset abandonment time. If the execution time of the task in the timeout state exceeds the preset abandonment time, considering the overall execution requirements of the task group, the task in the timeout state can be deleted from the task group, and a prompt message is issued to prompt relevant personnel such as R&D to determine whether there are other external influencing factors for the task in the timeout state, or to optimize the task in the timeout state so that it can be added to the task group when the execution time is less than the abandonment time.
[0057] Preferably, in order to further improve the efficiency of determining the task execution time, the embodiment of the present invention sets a reasonable execution time threshold, and can only count the average execution time of tasks in normal state, and use the counted average execution time as the execution time of the task; for tasks in overspeed state, directly mark them as 0; for tasks in timeout state, they can be discarded first, and can be re-added to the task group after optimization. In this way, the execution time of the task can be determined most efficiently.
[0058] Figure 21 is a flow chart of determining the execution time of a task according to an embodiment of the present invention. The embodiment of the present invention uses a preferred solution, first determining the execution status of each task according to the execution time, and then determining the execution time of the task for which the execution time needs to be determined according to the different execution statuses. Specifically, it is determined whether the time interval between the current system time and the sorting time of the last sorting exceeds the preset sorting time interval. If it does not meet the requirement, it is not necessary to determine the execution time of each task in the task group. If the time interval exceeds the preset sorting time interval, for each task in the task group: first, according to the execution time of multiple executions within the sliding window period, determine whether the execution state of each execution is a normal state, a timeout state or an overspeed state, and count the proportions of various states. If the proportion of the normal state is the largest, the task is determined to be in a normal state. At this time, the average execution time can be calculated according to the multiple execution times corresponding to the multiple executions of the task within the sliding window period and the total number of executions. It can also be more accurate to calculate the average execution time according to the sum of the execution times of the normal state of the task within the sliding window period and the total number of normal states, and use the average execution time as the execution time of the task; if the proportion of the timeout state is the largest, the task is determined to be in a timeout state, and the average execution time does not need to be calculated at this time. Use 1 to mark the task for subsequent sorting of the task group; if the proportion of the normal state is not the largest, and the proportion of the timeout state is not the largest, then the task is determined to be in an overspeed state, and the average execution time does not need to be calculated. Use 0 to mark the task for subsequent sorting of the task group.
[0059] Further, based on the execution time of each of the above tasks, the sorting result is updated, preferably, the tasks are sorted in descending order according to the execution time of each task. Figure 2 Determine the execution time, sort the normal tasks in descending order according to the average execution time of each task, then put the overspeed tasks marked with 0 after the normal tasks, and discard the timeout tasks marked with 1 to get the updated sorting result. Submit the sorted task group to the thread pool, and the thread pool will poll and execute each task according to the updated sorting result of the task group, and record the specific execution time when each task is executed in the new sorting order.
[0060] Figure 3It is a flowchart of recording execution time in an embodiment of the present invention. The start time and end time of each task are counted using a sliding window algorithm, and the execution time of the task is calculated based on the start time and end time. The embodiment of the present invention still uses the execution status to mark the execution time of the task, and determines whether the task is within the normal execution time based on the preset execution time threshold. If it is, the normal execution times are increased by 1, and the normal execution time is also recorded accordingly. If it exceeds the upper limit of the threshold, that is, the timeout state, the timeout times are increased by 1. Similarly, if it is not within the execution time threshold and is not timed out, then it is a task in the overspeed state, and the overspeed times are increased by 1.
[0061] Figure 4 It is a complete flow chart of the execution method of the task group of the embodiment of the present invention. All the preset parameters involved in the embodiment of the present invention are uniformly configured into the configuration file to determine the configuration file of the task group; read and parse the configuration file, generate a task group executor instance according to the configuration content, and sort the tasks in the task group to execute the tasks in the task group according to the sorting results; use the sliding window algorithm to obtain the execution time of each task in the task group; then update and sort the sorting results of the task group according to the obtained execution time; submit the updated sorting results to the thread pool; the thread pool executes the tasks of the task group in the order of the sorting results of the tasks of the task group received, and records the execution status of each task in this process (execution time, execution status, etc.).
[0062] The embodiment of the present invention utilizes a sliding window algorithm to record the execution status of each task, and arranges each task in the task group in descending order according to the execution time, which can effectively improve the execution efficiency of the parallel task group. Furthermore, in order to avoid the performance impact of the real-time sorting of the task group on the execution of the task group, by setting a reasonable sorting time interval, the sorting and the task group execution can be taken into account. At the same time, in order to avoid the serious impact of the abnormal timeout of a single task on the execution performance of the overall task group, and to save the performance consumption of the task group sorting, the embodiment of the present invention sets an execution time threshold for each task, and by determining the execution status of the task, optimizes the logic of sorting and updating according to the execution time of the task, which not only saves the calculation of the execution time of the tasks in the overspeed state and the timeout state, but also avoids the occupation of resources by the tasks in the timeout state.
[0063] Figure 5 Schematic diagram of the main modules of the execution device of the task group according to an embodiment of the present invention. Figure 5 As shown, the task group execution device 500 mainly includes a task group initial execution module 501 and a task group update execution module 502 .
[0064] The task group initial execution module 501 is used to sort the tasks in the task group in response to receiving an execution request of the task group, and execute the task group according to the sorting result;
[0065] The task group update execution module 502 is used to cyclically determine whether the time interval between the current system time and the sorting time of the last sorting satisfies the preset sorting update condition. If the time interval satisfies the preset sorting update condition, the sorting result is updated, and the task group is executed according to the updated sorting result.
[0066] According to one embodiment of the present invention, the task group update execution module 502 is also used to: obtain the execution time of each task in the task group within a specified historical time period; and update the order of each task in the sorting result according to the execution time of each task and a preset sorting rule.
[0067] According to another embodiment of the present invention, the task group update execution module 502 is also used to: for each task in the task group, use a sliding window algorithm to count the execution time of the task within the sliding window period to obtain the sliding window execution time of each task in the task group; and update the order of each task in the sorting result according to the sliding window execution time of each task in the task group and according to a preset sorting rule.
[0068] According to another embodiment of the present invention, when the task is executed multiple times within the sliding window period, the task group updates the execution module 502, and is also used to: calculate the average execution time of the task within the sliding window period according to multiple execution times and the total number of executions corresponding to the multiple executions of the task within the sliding window period; and determine the execution time of the task within the sliding window period based on the average execution time.
[0069] According to another embodiment of the present invention, the execution device 500 of the task group also includes a state determination module (not shown in the figure), which is used to: before calculating the average execution time of the task within the sliding window period according to multiple execution times and the total number of executions corresponding to multiple executions of the task within the sliding window period, obtain the execution state of each task in the task group according to the execution time of each task in the task group within the sliding window period, combined with the preset execution time threshold of each task, and determine that the execution state of the task is a non-speeding state.
[0070] According to another embodiment of the present invention, when there is a task in an overspeeding state in the task group, the task group update execution module 502 is further used to: arrange the task in the overspeeding state after the task corresponding to the non-overspeeding state.
[0071] According to another embodiment of the present invention, the non-overspeeding state includes a normal state and a timeout state; when there is a task in a timeout state among the tasks corresponding to the non-overspeeding state, the execution device 500 of the task group also includes a timeout state processing module (not shown in the figure), which is used to: determine whether the execution time of the task in the timeout state exceeds the preset abandonment time, and if the execution time of the task in the timeout state exceeds the preset abandonment time, delete the task in the timeout state from the task group.
[0072] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.
[0073] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0074] Users can use terminal devices 601, 602, 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications, such as task group execution applications, etc., can be installed on terminal devices 601, 602, 603 (only as an example).
[0075] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0076] The server 605 may be a server that provides various services, such as a background management server (only an example) that supports the task group performed by the user using the terminal devices 601, 602, and 603. In response to receiving the execution request of the task group, the background management server may sort the tasks in the task group and execute the task group according to the sorting result; cyclically determine whether the time interval between the current system time and the sorting time of the last sorting satisfies the preset sorting update condition, and if the time interval satisfies the preset sorting update condition, update the sorting result, execute the task group according to the updated sorting result, and feed back the processing result (such as the task group sorting result, etc. - only an example) to the terminal device.
[0077] It should be noted that the execution method of the task group provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the execution device of the task group is generally arranged in the server 605 .
[0078] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0079] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 7 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0080] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0081] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0082] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0083] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination thereof.
[0084] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0085] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be arranged in a processor, for example, it may be described as follows: a processor includes: a task group initial execution module and a task group update execution module.
[0086] Among them, the names of these modules do not constitute a limitation of the modules themselves in certain cases. For example, the task group initial execution module can also be described as "a module for sorting the tasks in the task group in response to receiving an execution request of the task group, and executing the task group according to the sorting result."
[0087] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiment; or may exist independently without being assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device includes: in response to receiving an execution request of a task group, sorting each task in the task group, and executing the task group according to the sorting result; cyclically determining whether the time interval between the current system time and the sorting time of the last sorting satisfies a preset sorting update condition, and if the time interval satisfies the preset sorting update condition, updating the sorting result, and executing the task group according to the updated sorting result.
[0088] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: by responding to the execution request received from the task group, sorting each task in the task group, and executing the task group according to the sorting result; cyclically judging whether the time interval between the current system time and the sorting time of the last sorting satisfies the preset sorting update condition, and updating the sorting result when the time interval satisfies the preset sorting update condition, and executing the task group according to the updated sorting result. The technical solution realizes the execution of the task group by dynamically and adaptively adjusting the order of tasks in the task group, which not only weakens the influence of the accuracy of the estimated execution time on the execution efficiency of the task group, but also for new tasks with uncertain execution time, the order can be adaptively adjusted and optimized according to the actual execution time of the task, thereby improving the execution efficiency of the task group, making it suitable for more business scenarios.
[0089] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A method for executing a task group, characterized in that: include: In response to receiving an execution request of a task group, sorting the tasks in the task group, and executing the task group according to the sorting result; It is cyclically determined whether the time interval between the current system time and the sorting time of the last sorting satisfies a preset sorting update condition. If the time interval satisfies the preset sorting update condition, the sorting result is updated, and the task group is executed according to the updated sorting result.
2. The method according to claim 1, characterized in that When the time interval satisfies a preset sorting update condition, updating the sorting result includes: Get the execution time of each task in the task group within the specified historical time period; According to the execution time of each task and the preset sorting rule, the order of each task in the sorting result is updated.
3. The method according to claim 2, characterized in that According to the execution time of each task and the preset sorting rule, the order of each task in the sorting result is updated, including: For each task in the task group, a sliding window algorithm is used to count the execution time of the task within the sliding window period to obtain the sliding window execution time of each task in the task group; According to the sliding window execution time of each task in the task group and according to a preset sorting rule, the order of each task in the sorting result is updated.
4. The method according to claim 3, characterized in that When the task is executed multiple times within the sliding window period, a sliding window algorithm is used to count the execution time of the task within the sliding window period, including: Calculate the average execution time of the task in the sliding window period according to the multiple execution times and the total number of executions corresponding to the multiple executions of the task in the sliding window period; The execution duration of the task within the sliding window period is determined according to the average execution duration.
5. The method according to claim 4, characterized in that Before calculating the average execution time of the task in the sliding window period according to the multiple execution times and the total number of executions corresponding to the multiple executions of the task in the sliding window period, the method further includes: According to the execution time of each task in the task group within the sliding window period, combined with the preset execution time threshold of each task, the execution status of each task in the task group is obtained, and the execution status of the task is determined to be a non-speeding state.
6. The method according to claim 5, characterized in that In the case where there is a task in the overspeed state in the task group, the sorting result is updated according to the sliding window execution time of each task in the task group and the preset sorting rule, including: The task in the overspeed state is arranged after the task corresponding to the non-overspeed state.
7. The method according to claim 5, characterized in that The non-overspeed state includes a normal state and a timeout state; when the tasks corresponding to the non-overspeed state include tasks in a timeout state, the method further includes: It is determined whether the execution time of the task in the timeout state exceeds the preset abandonment time. If the execution time of the task in the timeout state exceeds the preset abandonment time, the task in the timeout state is deleted from the task group.
8. An execution device of a task group, characterized in that: include: A task group initial execution module, configured to sort the tasks in the task group in response to receiving an execution request of the task group, and execute the task group according to the sorting result; The task group update execution module is used to cyclically determine whether the time interval between the current system time and the sorting time of the last sorting satisfies the preset sorting update condition. If the time interval satisfies the preset sorting update condition, the sorting result is updated, and the task group is executed according to the updated sorting result.
9. A mobile electronic device terminal, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.