CN113127057A - Method and device for parallel execution of multiple tasks - Google Patents

Method and device for parallel execution of multiple tasks Download PDF

Info

Publication number
CN113127057A
CN113127057A CN202010048351.5A CN202010048351A CN113127057A CN 113127057 A CN113127057 A CN 113127057A CN 202010048351 A CN202010048351 A CN 202010048351A CN 113127057 A CN113127057 A CN 113127057A
Authority
CN
China
Prior art keywords
execution
task
execution time
tasks
combination
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.)
Granted
Application number
CN202010048351.5A
Other languages
Chinese (zh)
Other versions
CN113127057B (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.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information 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 Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202010048351.5A priority Critical patent/CN113127057B/en
Publication of CN113127057A publication Critical patent/CN113127057A/en
Application granted granted Critical
Publication of CN113127057B publication Critical patent/CN113127057B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a device for parallel execution of multiple tasks, and relates to the technical field of computers. One embodiment of the method comprises: acquiring the execution time of each task, and splitting and merging the multiple tasks according to the execution time to obtain a task combination; executing the multiple tasks in parallel according to the task combination, and recording the execution time of the multiple tasks; and if the execution time of the multitask is less than the execution time of the previous task combination, taking the task combination as the execution mode of the multitask, and executing the multitask in parallel according to the execution mode. According to the implementation method, codes and the existing services can be not required to be adjusted, the execution efficiency of the tasks is monitored through the execution and track recording of the tasks, and the execution of the tasks is rearranged, combined and split according to the execution time efficiency, so that the execution efficiency is optimized, the execution efficiency of the system is improved, the execution combination of the tasks is adjusted at any time according to the service change, and the execution speed of the whole task is greatly improved.

Description

Method and device for parallel execution of multiple tasks
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for multi-task parallel execution.
Background
In the process of executing the service system code, method calls are often required to be performed, and if a plurality of method joint operations are involved and the processing time of some methods is long, the overall execution time of the service code is prolonged, so that the execution efficiency of the service code is seriously affected. At this time, a plurality of methods in the service code need to be combined and asynchronously optimized to optimize the performance of the whole service code.
At present, a processing scheme generally adopted is multithreading or an asynchronous execution framework or the like is adopted to process a service code so as to reduce the execution time of the service code.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
1. the service codes are processed in a multithreading mode of the thread pool, the coupling of the codes is high, the original service codes need to be reconstructed, and development, online testing and the like of multi-thread developers with rich experience are needed, so that the influence on an original service system is large;
2. the method for processing the service code by adopting the asynchronous execution framework (such as the spring asynchronous task framework) has the advantages of higher code coupling and relatively single returned object, and if the old service system needs to carry out multi-task asynchronous processing, the original code needs to be changed for reconstruction, so that the development time is wasted, the test is carried out again, and the access, the maintenance and the modification are relatively complex.
In summary, the two existing schemes have poor flexibility, and cannot be flexibly adjusted and automatically optimized in time according to the performance of the method.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for parallel multi-task execution, which can perform rearrangement, combination, and splitting on the execution of tasks according to execution time efficiency through the execution of tasks and track recording and monitoring the execution efficiency of the tasks without adjusting codes and existing services, thereby optimizing the execution efficiency, increasing the execution efficiency of a system, adjusting the execution combination of the tasks at any time according to service changes, and greatly improving the execution speed of the overall task.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of multitask parallel execution.
A method of multitask parallel execution, comprising: acquiring the execution time of each task, and splitting and merging the multiple tasks according to the execution time to obtain a task combination; executing the multiple tasks in parallel according to the task combination, and recording the execution time of the multiple tasks; and if the execution time of the multiple tasks is less than that of the previous task combination, taking the task combination as an execution mode of the multiple tasks, and executing the multiple tasks in parallel according to the execution mode.
Optionally, splitting and merging the multiple tasks according to the execution time to obtain a task combination includes: and splitting and merging the multiple tasks by taking the maximum value in the execution time as a base number to obtain a task combination.
Optionally, splitting and merging the multitask includes: sequencing the tasks according to the execution time of each task from large to small to obtain a task queue; sequentially taking out two tasks at the front end and the rear end except the task with the largest execution time from the task queue; and comparing the sum of the execution times of the two tasks with the maximum value of the execution times, and splitting and merging the two tasks if the ratio of the maximum value to the sum meets a preset first threshold value.
Optionally, after obtaining the task combination, the method further includes: and recording the task execution sequence which is inconsistent with the previous task combination in the task combination.
Optionally, the task combination includes a plurality of steps executed in parallel, and a ratio of a maximum value to a minimum value in execution time of the steps satisfies a preset second threshold.
Optionally, the multitask parallel execution is realized by performing annotation configuration or extensible markup language configuration on the code.
Optionally, the execution time of each task is obtained by performing a reflective proxy on the code corresponding to each task.
According to another aspect of the embodiments of the present invention, an apparatus for parallel execution of multiple tasks is provided.
An apparatus for multitask parallel execution, comprising: the task combination module is used for acquiring the execution time of each task and splitting and combining the multiple tasks according to the execution time to obtain a task combination; the time recording module is used for executing the multiple tasks in parallel according to the task combination and recording the execution time of the multiple tasks; and the mode determining module is used for taking the task combination as an execution mode of the multitask and executing the multitask in parallel according to the execution mode if the execution time of the multitask is less than the execution time of the previous task combination.
Optionally, the task combination module is further configured to: and splitting and merging the multiple tasks by taking the maximum value in the execution time as a base number to obtain a task combination.
Optionally, the task combination module is further configured to: sequencing the tasks according to the execution time of each task from large to small to obtain a task queue; sequentially taking out two tasks at the front end and the rear end except the task with the largest execution time from the task queue; and comparing the sum of the execution times of the two tasks with the maximum value of the execution times, and splitting and merging the two tasks if the ratio of the maximum value to the sum meets a preset first threshold value.
Optionally, the system further comprises an execution recording module, configured to: and after the task combination is obtained, recording the task execution sequence which is inconsistent with the previous task combination in the task combination.
Optionally, the task combination includes a plurality of steps executed in parallel, and a ratio of a maximum value to a minimum value in execution time of the steps satisfies a preset second threshold.
Optionally, the multitask parallel execution is realized by performing annotation configuration or extensible markup language configuration on the code.
Optionally, the execution time of each task is obtained by performing a reflective proxy on the code corresponding to each task.
According to still another aspect of the embodiments of the present invention, there is provided an electronic device for multitask parallel execution.
An electronic device for multitask parallel execution, comprising: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method for executing the multiple tasks in parallel provided by the embodiment of the invention.
According to yet another aspect of embodiments of the present invention, a computer-readable medium is provided.
A computer readable medium, on which a computer program is stored, which when executed by a processor implements a method of multitask parallel execution provided by embodiments of the present invention.
One embodiment of the above invention has the following advantages or benefits: acquiring the execution time of each task, and splitting and combining the multiple tasks according to the execution time to obtain a task combination; then, the multiple tasks are executed in parallel according to the task combination, and the execution time of the multiple tasks is recorded; and finally, if the execution time of the multitask is less than that of the previous task combination, taking the task combination as an execution mode of the multitask, executing the multitask in parallel according to the execution mode, without adjusting codes and the existing services, performing rearrangement, combination and splitting on the execution of the tasks according to the execution time efficiency through the execution of the tasks and track recording and monitoring the execution efficiency of the tasks, thereby optimizing the execution efficiency, accelerating the execution efficiency of the system, adjusting the execution combination of the tasks at any time according to service change and greatly improving the execution speed of the whole task.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method for multitask parallel execution according to an embodiment of the present invention;
FIG. 2 is a core architecture flow diagram of an embodiment of the present invention;
FIG. 3 is a task recording flow diagram of an embodiment of the present invention;
FIG. 4 is a flow diagram of task execution trajectory analysis according to an embodiment of the present invention;
FIG. 5 is a task orchestration flow diagram according to an embodiment of the invention;
FIG. 6 is a task execution flow diagram of an embodiment of the present invention;
FIG. 7 is a schematic diagram of the main blocks of an apparatus for multitask parallel execution according to an embodiment of the present invention;
FIG. 8 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 9 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of the main steps of a method for multitask parallel execution according to the embodiment of the present invention. As shown in fig. 1, the method for parallel execution of multiple tasks according to the embodiment of the present invention mainly includes the following steps S101 to S103.
Step S101: acquiring the execution time of each task, and splitting and merging the multiple tasks according to the execution time to obtain a task combination;
step S102: executing the multiple tasks in parallel according to the task combination, and recording the execution time of the multiple tasks;
step S103: and if the execution time of the multitask is less than the execution time of the previous task combination, taking the task combination as the execution mode of the multitask, and executing the multitask in parallel according to the execution mode.
According to an embodiment of the present invention, when splitting and merging the multitask according to the execution time to obtain the task combination, the multitask may be split and merged with a maximum value in the execution time as a base number to obtain the task combination.
According to the embodiment of the present invention, when splitting and merging multiple tasks, the method may specifically be performed according to the following steps:
sequencing the tasks according to the execution time of each task from large to small to obtain a task queue;
sequentially taking out two tasks at the front end and the rear end except the task with the largest execution time from the task queue;
and comparing the sum of the execution times of the two tasks with the maximum value of the execution times, and splitting and merging the two tasks if the ratio of the maximum value to the sum meets a preset first threshold value.
According to another embodiment of the present invention, after the task combination is obtained, the task execution sequence in the task combination that is inconsistent with the previous task combination may also be recorded.
According to a further embodiment of the invention, the task combination comprises a plurality of steps executed in parallel, and the ratio of the maximum value to the minimum value in the execution time of the steps satisfies a preset second threshold value.
According to the technical scheme of the invention, the multitask parallel execution is realized by performing annotation configuration or expandable markup language configuration on the code.
According to the technical scheme of the embodiment of the invention, the execution time of each task is obtained by carrying out reflection proxy on the code corresponding to each task.
The following describes the specific implementation process of the present invention with reference to specific embodiments. The invention mainly solves the problem of no invasion to codes completely and can realize multi-task processing without changing any original logic and codes. The processing mode of changing the task can be adjusted at any time according to the service requirement and the performance of the system, the flexible automatic switching can be carried out on the on-line task, and different execution strategies of the system are adjusted to dynamically optimize the execution efficiency of the system.
FIG. 2 is a core architecture flow diagram of an embodiment of the present invention. As shown in fig. 2, in the embodiment of the present invention, a plurality of tasks are executed on a line, and task arrangement is performed by combining the plurality of tasks into a plurality of operation steps, so that multitask parallel processing is realized. The processing time of each step may vary greatly, and the operation efficiency of each step seriously affects the overall efficiency of the whole task.
And recording the operation time of each step and the related information of the task, and performing execution analysis by performing execution record on the task. Judging the execution time of each step, comparing the execution time of each task to arrange the tasks, and adjusting a reasonable asynchronous multi-task processing sequence according to a maximum principle.
The execution aspect uses non-intrusive configuration adjustment of the code. And adopting modes such as a reflection agent and the like to perform multi-task parallel processing on the arranged task agents. The final efficiency (execution time) of each orchestration task and the efficiency (execution time) of each detailed step are recorded. And performing tuning judgment through the recorded data, calculating the final time and the maximum time ratio of the multitask execution, and performing performance alarm if the ratio is too large.
The invention can carry out task arrangement by recording the running tracks and the execution information of different tasks as reference bases. Recalculating in an efficiency sequencing and integrating mode, calculating the execution time of the original multi-task combination and the execution time after the recombination to adjust, and adjusting the execution time to be the most reasonable time to execute the multi-tasks in parallel.
According to the technical scheme of the embodiment of the invention, the system mainly comprises the following modules: non-invasive code setting, task recording, execution track analysis, intelligent arrangement, task execution and performance monitoring alarm. The implementation process of each module is described below.
1) Non-intrusive code setup
The existing system needs to be modified and upgraded in the running process of the system, the codes need to be seamlessly accessed or a small amount of configuration to complete the execution optimization of tasks, the codes need to be configured in a non-invasive manner to reduce the change of the existing service, and the multitask intelligent processing can be carried out without any redundant change of the existing service. The existing service is preferably modified by annotation configuration or xml configuration. The order and asynchronous processing of the execution of the tasks on the line can be controlled by dynamically configuring the effective operation.
The function of the code non-intrusive setting is mainly to perform relevant collection on tasks, control which tasks need to perform dynamic execution operation, and perform the sequence and the combination relation. Proxy operation is carried out on the objects, methods, return information and the like of the original tasks through the reflection proxy.
2) Task recording
FIG. 3 is a task recording flow diagram of an embodiment of the present invention. As shown in fig. 3, when a task is executed, some references and references need to be made to subsequent task combination arrangement and execution, so some information of the task needs to be recorded, including acquiring parameter data of the relevant task when the task is executed, recording the execution sequence and combination steps of the task, recording the number of queues and the number of task arrangements to be executed, and finally recording the execution time of the task.
3) Performing trajectory analysis
FIG. 4 is a flow chart of task execution trajectory analysis according to an embodiment of the present invention. The execution track analysis is to analyze the split task track of the asynchronous task execution, and analyze the difference and change situation before and after the combination of the tasks, so as to facilitate the understanding of the execution situation of the tasks.
And after the task recording data is obtained, sequencing according to execution time efficiency and recording the maximum and minimum values. And splitting and merging the tasks according to the maximum value as a base number, adding two tasks at the front end and the rear end except the maximum value, and comparing the two tasks with the maximum value, wherein if the maximum value/sum value is between 0.8 and 1.5 (which can be adjusted according to actual conditions), the splitting and merging can be performed by reasonably executing the tasks.
And after splitting and merging the tasks, if the execution sequence is inconsistent with the original execution sequence, recording inconsistent information. And scanning the task data in a worker polling mode, carrying out recalculation on the task and carrying out recalculation on the original task. And comparing the two different operation results, recording the new task record if the execution efficiency of the new combination is better, and directly switching the online task to a new task execution mode after the task record reaches a certain number.
4) Intelligent arrangement
FIG. 5 is a flow diagram of task orchestration according to an embodiment of the invention. And obtaining different execution tracks of different tasks according to the task records and the track analysis, and calculating the execution time comparison corresponding to the different execution tracks. If the difference is larger, the difference values are recombined. The difference match value closest to the maximum value is obtained. The scheduling combination can obtain the optimal execution task plan according to the business needs.
And inquiring related task records, including task operation records, execution tracks and the like. Classifying different task steps, comparing the execution time of each step, recording the maximum and minimum values, and calculating the ratio of the maximum and minimum values.
If the ratio is larger than 2 (can be adjusted according to the actual situation), which indicates that the task execution efficiency is poor, the difference value, the execution time and the detailed execution track information of the task are recorded. If less than 2, the task is temporarily not processed within a reasonable range.
And then obtaining the execution time of the multitask, comparing the ratio of the execution time of the multitask to the maximum time, judging whether the ratio is normal or not, if so, recording a log, if not, combining and splitting the multitask by taking the maximum time as a base point according to the sequence of the execution time of the tasks, and recording the result of the rearrangement of the multitask.
5) Task execution
FIG. 6 is a task execution flow diagram of an embodiment of the present invention. The initialization operation before execution mainly processes that one layer of proxy packaging is carried out on the annotation and the class of the configuration file when the program is started, the initialization work of the thread pool is carried out at the same time, and the proxy packaging is carried out on the method and the return value through a reflection mechanism.
Creating and setting a task thread pool, after the setting is completed, performing APE (Asynchronous parallel execution, an annotation agent framework realized by java) annotation analysis on related services, and then generating an agent object corresponding to an annotation class (class). And intercepting the method and the result object and caching the related proxy object.
The method comprises the steps of firstly judging whether APE proxy is performed or not during execution, if not, performing normally, if so, acquiring the proxy of the method for asynchronous execution, encapsulating and returning a final result proxy object through a Future mechanism, and obtaining a final execution result through operating the proxy object. Future is a tool class of java, and when A and B methods are executed, operation B can be executed without waiting for A to be executed completely.
6) Performance monitoring alarm
The performance monitoring alarm mainly monitors the recording condition of tasks, including execution change, execution time and execution sequence of the tasks. And periodically monitoring in a polling mode, if the performance difference is large and task change exists, informing related personnel by mail or short message, wherein the content comprises related information of task execution, including execution time, execution sequence steps and the like, and recording a piece of alarm information for being displayed and checked in the system.
Fig. 7 is a schematic diagram of main blocks of an apparatus for multitask parallel execution according to an embodiment of the present invention. As shown in fig. 7, an apparatus 700 for parallel multi-task execution according to an embodiment of the present invention mainly includes a task combination module 701, a time recording module 702, and a mode determination module 703.
The task combination module 701 is used for acquiring the execution time of each task, and splitting and combining the multiple tasks according to the execution time to obtain a task combination;
a time recording module 702, configured to execute the multiple tasks in parallel according to the task combination, and record the execution time of the multiple tasks;
a mode determining module 703, configured to, if the execution time of the multitask is less than the execution time of a previous task combination, use the task combination as an execution mode of the multitask, and execute the multitask in parallel according to the execution mode.
According to an embodiment of the present invention, the task combination module 701 may further be configured to:
and splitting and merging the multiple tasks by taking the maximum value in the execution time as a base number to obtain a task combination.
According to another embodiment of the present invention, the task combination module 701 may further be configured to:
sequencing the tasks according to the execution time of each task from large to small to obtain a task queue;
sequentially taking out two tasks at the front end and the rear end except the task with the largest execution time from the task queue;
and comparing the sum of the execution times of the two tasks with the maximum value of the execution times, and splitting and merging the two tasks if the ratio of the maximum value to the sum meets a preset first threshold value.
According to another embodiment of the present invention, the apparatus 700 for multitask parallel execution may further include an execution recording module (not shown in the figure) for:
and after the task combination is obtained, recording the task execution sequence which is inconsistent with the previous task combination in the task combination.
According to an embodiment of the present invention, the task combination includes a plurality of steps executed in parallel, and a ratio of a maximum value to a minimum value in execution times of the steps satisfies a preset second threshold.
According to the embodiment of the invention, the multitask parallel execution is realized by performing annotation configuration or extensible markup language configuration on the code.
According to the technical scheme of the invention, the execution time of each task is obtained by carrying out reflection proxy on the code corresponding to each task.
According to the technical scheme of the embodiment of the invention, the task combination is obtained by obtaining the execution time of each task and splitting and combining the multiple tasks according to the execution time; then, the multiple tasks are executed in parallel according to the task combination, and the execution time of the multiple tasks is recorded; and finally, if the execution time of the multitask is less than that of the previous task combination, taking the task combination as an execution mode of the multitask, executing the multitask in parallel according to the execution mode, without adjusting codes and the existing services, performing rearrangement, combination and splitting on the execution of the tasks according to the execution time efficiency through the execution of the tasks and track recording and monitoring the execution efficiency of the tasks, thereby optimizing the execution efficiency, accelerating the execution efficiency of the system, adjusting the execution combination of the tasks at any time according to service change and greatly improving the execution speed of the whole task.
Fig. 8 illustrates an exemplary system architecture 800 of a method of multitask parallel execution or a device of multitask parallel execution to which embodiments of the present invention may be applied.
As shown in fig. 8, the system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. The network 804 serves to provide a medium for communication links between the terminal devices 801, 802, 803 and the server 805. Network 804 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 801, 802, 803 to interact with a server 805 over a network 804 to receive or send messages or the like. The terminal devices 801, 802, 803 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 801, 802, 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 805 may be a server that provides various services, such as a back-office management server (for example only) that supports shopping-like websites browsed by users using the terminal devices 801, 802, 803. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for parallel multi-task execution provided by the embodiment of the present invention is generally executed by the server 805, and accordingly, a device for parallel multi-task execution is generally disposed in the server 805.
It should be understood that the number of terminal devices, networks, and servers in fig. 8 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 9, a block diagram of a computer system 900 suitable for use with a terminal device or server implementing an embodiment of the invention is shown. The terminal device or the server shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU)901 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
The following components are connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The above-described functions defined in the system of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 901.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present invention may be implemented by software, or may be implemented by hardware. The described units or modules may also be provided in a processor, and may be described as: a processor includes a task combining module, a time recording module, and a mode determination module. The names of these units or modules do not in some cases form a limitation on the units or modules themselves, for example, a task combination module may also be described as a "module that obtains the execution time of each task and splits and combines the multiple tasks according to the execution time to obtain a task combination".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: acquiring the execution time of each task, and splitting and merging the multiple tasks according to the execution time to obtain a task combination; executing the multiple tasks in parallel according to the task combination, and recording the execution time of the multiple tasks; and if the execution time of the multiple tasks is less than that of the previous task combination, taking the task combination as an execution mode of the multiple tasks, and executing the multiple tasks in parallel according to the execution mode.
According to the technical scheme of the embodiment of the invention, the task combination is obtained by obtaining the execution time of each task and splitting and combining the multiple tasks according to the execution time; then, the multiple tasks are executed in parallel according to the task combination, and the execution time of the multiple tasks is recorded; and finally, if the execution time of the multitask is less than that of the previous task combination, taking the task combination as an execution mode of the multitask, executing the multitask in parallel according to the execution mode, without adjusting codes and the existing services, performing rearrangement, combination and splitting on the execution of the tasks according to the execution time efficiency through the execution of the tasks and track recording and monitoring the execution efficiency of the tasks, thereby optimizing the execution efficiency, accelerating the execution efficiency of the system, adjusting the execution combination of the tasks at any time according to service change and greatly improving the execution speed of the whole task.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for multitask parallel execution, comprising:
acquiring the execution time of each task, and splitting and merging the multiple tasks according to the execution time to obtain a task combination;
executing the multiple tasks in parallel according to the task combination, and recording the execution time of the multiple tasks;
and if the execution time of the multiple tasks is less than that of the previous task combination, taking the task combination as an execution mode of the multiple tasks, and executing the multiple tasks in parallel according to the execution mode.
2. The method of claim 1, wherein splitting and merging the multiple tasks according to execution time to obtain a task combination comprises:
and splitting and merging the multiple tasks by taking the maximum value in the execution time as a base number to obtain a task combination.
3. The method of claim 1 or 2, wherein splitting and merging the multiple tasks comprises:
sequencing the tasks according to the execution time of each task from large to small to obtain a task queue;
sequentially taking out two tasks at the front end and the rear end except the task with the largest execution time from the task queue;
and comparing the sum of the execution times of the two tasks with the maximum value of the execution times, and splitting and merging the two tasks if the ratio of the maximum value to the sum meets a preset first threshold value.
4. The method of claim 1, wherein after obtaining the task combination, further comprising:
and recording the task execution sequence which is inconsistent with the previous task combination in the task combination.
5. The method according to claim 1, wherein the task combination comprises a plurality of steps executed in parallel, and a ratio of a maximum value to a minimum value in execution time of the steps satisfies a preset second threshold.
6. The method of claim 1, wherein the multitask parallel execution is realized by performing annotation configuration or extensible markup language configuration on the code.
7. The method of claim 1, wherein the execution time of each task is obtained by performing a reflective proxy on code corresponding to each task.
8. An apparatus for multitask parallel execution, comprising:
the task combination module is used for acquiring the execution time of each task and splitting and combining the multiple tasks according to the execution time to obtain a task combination;
the time recording module is used for executing the multiple tasks in parallel according to the task combination and recording the execution time of the multiple tasks;
and the mode determining module is used for taking the task combination as an execution mode of the multitask and executing the multitask in parallel according to the execution mode if the execution time of the multitask is less than the execution time of the previous task combination.
9. An electronic device for multitask parallel execution, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202010048351.5A 2020-01-16 2020-01-16 Method and device for parallel execution of multiple tasks Active CN113127057B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010048351.5A CN113127057B (en) 2020-01-16 2020-01-16 Method and device for parallel execution of multiple tasks

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010048351.5A CN113127057B (en) 2020-01-16 2020-01-16 Method and device for parallel execution of multiple tasks

Publications (2)

Publication Number Publication Date
CN113127057A true CN113127057A (en) 2021-07-16
CN113127057B CN113127057B (en) 2024-07-16

Family

ID=76771947

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010048351.5A Active CN113127057B (en) 2020-01-16 2020-01-16 Method and device for parallel execution of multiple tasks

Country Status (1)

Country Link
CN (1) CN113127057B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112379998A (en) * 2020-10-20 2021-02-19 广东工业大学 Switching time delay optimization method based on task fusion and task scheduling
CN113961328A (en) * 2021-10-26 2022-01-21 深圳大学 Task processing method and device, storage medium and electronic equipment
CN115756788A (en) * 2022-11-18 2023-03-07 北京华如科技股份有限公司 Method and device for setting multitask parallel execution relation

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103984594A (en) * 2014-05-14 2014-08-13 上海上讯信息技术股份有限公司 Task scheduling method and system based on distributed configurable weighting algorithm
US20160170811A1 (en) * 2014-12-16 2016-06-16 Microsoft Technology Licensing, Llc Job scheduling and monitoring
CN106685853A (en) * 2016-11-23 2017-05-17 泰康保险集团股份有限公司 Data processing method and apparatus
US20180307528A1 (en) * 2017-04-19 2018-10-25 International Business Machines Corporation Leveraging directed acyclic graph (dag) information to group tasks for execution
CN110084507A (en) * 2019-04-24 2019-08-02 信雅达系统工程股份有限公司 The scientific workflow method for optimizing scheduling of perception is classified under cloud computing environment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103984594A (en) * 2014-05-14 2014-08-13 上海上讯信息技术股份有限公司 Task scheduling method and system based on distributed configurable weighting algorithm
US20160170811A1 (en) * 2014-12-16 2016-06-16 Microsoft Technology Licensing, Llc Job scheduling and monitoring
CN106685853A (en) * 2016-11-23 2017-05-17 泰康保险集团股份有限公司 Data processing method and apparatus
US20180307528A1 (en) * 2017-04-19 2018-10-25 International Business Machines Corporation Leveraging directed acyclic graph (dag) information to group tasks for execution
CN110084507A (en) * 2019-04-24 2019-08-02 信雅达系统工程股份有限公司 The scientific workflow method for optimizing scheduling of perception is classified under cloud computing environment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112379998A (en) * 2020-10-20 2021-02-19 广东工业大学 Switching time delay optimization method based on task fusion and task scheduling
CN113961328A (en) * 2021-10-26 2022-01-21 深圳大学 Task processing method and device, storage medium and electronic equipment
CN115756788A (en) * 2022-11-18 2023-03-07 北京华如科技股份有限公司 Method and device for setting multitask parallel execution relation

Also Published As

Publication number Publication date
CN113127057B (en) 2024-07-16

Similar Documents

Publication Publication Date Title
CN110262807B (en) Cluster creation progress log acquisition system, method and device
CN113127057B (en) Method and device for parallel execution of multiple tasks
CN109245908B (en) Method and device for switching master cluster and slave cluster
CN109873863B (en) Asynchronous calling method and device of service
CN112783874A (en) Data analysis method, device and system
CN113076251A (en) Test method and device
CN115525411A (en) Method, device, electronic equipment and computer readable medium for processing service request
CN116627333A (en) Log caching method and device, electronic equipment and computer readable storage medium
CN111831503B (en) Monitoring method based on monitoring agent and monitoring agent device
CN112398669A (en) Hadoop deployment method and device
CN113127225A (en) Method, device and system for scheduling data processing tasks
CN112667368A (en) Task data processing method and device
CN112445860A (en) Method and device for processing distributed transaction
CN112084042A (en) Message processing method and device
CN117950850A (en) Data transmission method, device, electronic equipment and computer readable medium
CN113672671A (en) Method and device for realizing data processing
CN110807058B (en) Method and system for exporting data
CN111767126A (en) System and method for distributed batch processing
CN113535371A (en) Method and device for multithreading asynchronous loading of resources
US20230093004A1 (en) System and method for asynchronous backend processing of expensive command line interface commands
CN113378346A (en) Method and device for model simulation
CN116521639A (en) Log data processing method, electronic equipment and computer readable medium
CN114816477A (en) Server upgrading method, device, equipment, medium and program product
CN112860447B (en) Interaction method and system between different applications
CN114064803A (en) Data synchronization method and device

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