CN113126968B - Task execution method, device, electronic equipment and storage medium - Google Patents

Task execution method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113126968B
CN113126968B CN202110548546.0A CN202110548546A CN113126968B CN 113126968 B CN113126968 B CN 113126968B CN 202110548546 A CN202110548546 A CN 202110548546A CN 113126968 B CN113126968 B CN 113126968B
Authority
CN
China
Prior art keywords
task
resource
tasks
execution
executed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110548546.0A
Other languages
Chinese (zh)
Other versions
CN113126968A (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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202110548546.0A priority Critical patent/CN113126968B/en
Publication of CN113126968A publication Critical patent/CN113126968A/en
Application granted granted Critical
Publication of CN113126968B publication Critical patent/CN113126968B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • 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
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

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 embodiment of the invention provides a task execution method, a device, electronic equipment and a storage medium. In the embodiment of the invention, a plurality of working threads can play the calculation advantages of a computer multi-core, for the parallel processing of tasks with dense unordered requirements, different types of tasks are distributed to different working threads, the parallelization of work is realized, the task processing speed is accelerated, the execution order of task groups is determined according to the dependency relationship among the task groups, the tasks with complex ordered requirements can be rapidly solved, the task execution time is optimized, the loading waiting time is shortened, the game fluency is improved, and excellent game experience is given to clients.

Description

Task execution method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a task execution method, a task execution device, an electronic device, and a storage medium.
Background
For software development projects, for example, in the development of games, the picture quality of the game and the development mode are dominated by the game engine (e.g., units). However, for games developed by some versions of the game engine, there is no direct multi-threaded interface (IJob) due to the nature of the game engine itself, single thread Cheng Kuangjia is always used; for some iterative version game engines after the above version, although a multithreading interface is added, the existing developed games cannot be directly utilized, and a large amount of reconstruction is needed for the code to exert the multithreading advantage, but the large amount of reconstruction is not only high in cost, but also brings a large amount of uncertainty risk to the online or mature games, so that the games developed by the game engines on the market still adopt a single-threaded architecture so far.
However, the engine processed by the single-thread framework cannot exert the computing advantages of the computer multi-core, and when meeting the tasks with dense unordered requirements and the tasks with complex ordered requirements, the computing time greatly exceeds the expectations, so that the problems of long loading waiting time, clamping in the game fluency and the like are caused, and the user experience is greatly influenced.
Disclosure of Invention
In view of the foregoing, embodiments of the present invention have been made to provide a task execution method and a corresponding task execution device, electronic apparatus, storage medium that overcome or at least partially solve the foregoing problems.
In order to solve the above problems, an embodiment of the present invention discloses a task execution method, which includes:
confirming task categories of tasks in the task pool;
determining a working thread corresponding to the task according to the task category of the task;
the task groups which belong to different working threads and can be executed in parallel are formed into task groups;
confirming a first dependency relationship between the task groups;
And executing the task group according to the first dependency relationship, wherein the tasks in the task group are tasks executed in parallel by calling the corresponding working threads.
Optionally, the executing the task group according to the first dependency relationship includes:
determining the execution sequence of the task group according to the first dependency relationship;
And sequentially executing the task groups according to the execution sequence of the task groups.
Optionally, the sequentially executing the task group includes:
When the task of the task group is executed, loading a resource package corresponding to the task of the task group;
And releasing the resource package after the task execution is completed.
Optionally, the releasing the resource package after the task execution is completed includes:
returning a result of the task execution after the task execution is completed;
and after returning the result of the task execution, releasing the resource package.
Optionally, before the loading of the resource package corresponding to the task of the task group, the method further includes:
Carrying out logic processing on a resource packet to be loaded corresponding to the task of the task group; wherein the logic process includes at least one of: file name checking, resource path checking, resource version checking, and error handling.
Optionally, before the loading of the corresponding resource package of the task group, the method further includes:
Acquiring a second dependency relationship between the resource package and other resource packages;
and loading the other resource packages on which the resource packages depend according to the second dependency relationship.
Optionally, after the task execution is completed, the releasing the resource package includes:
Determining whether the resource package or the other resource packages are depended by other resource packages to be loaded;
if yes, after loading is finished, caching the resource package or the other resource packages;
and if not, releasing the resource package or the other resource packages.
The embodiment of the invention discloses a task execution device, which comprises:
The category confirming module is used for confirming task categories of tasks in the task pool;
The thread determining module is used for determining a working thread corresponding to the task according to the task category of the task;
the task composition module is used for composing the tasks which belong to different working threads and can be executed in parallel into task groups;
the relation determining module is used for confirming a first dependency relation among the task groups;
And the task execution module is used for executing the task group according to the first dependency relationship, wherein the tasks in the task group are tasks executed in parallel by calling the corresponding working threads.
Optionally, the task execution module includes:
The order determining submodule is used for determining the execution order of the task group according to the first dependency relationship;
and the execution sub-module is used for sequentially executing the task groups according to the execution sequence of the task groups.
Optionally, the execution sub-module includes:
The resource loading unit is used for loading a resource packet corresponding to the task of the task group when the task of the task group is executed;
and the resource releasing unit is used for releasing the resource package after the task execution is completed.
Optionally, the resource release unit includes:
The result returning subunit is used for returning the result of the task execution after the task execution is completed;
And the first resource release subunit is used for releasing the resource package after returning the result of the task execution.
Optionally, before the resource loading unit, the method further includes:
The resource processing unit is used for logically processing the resource packet to be loaded corresponding to the task of the task group; wherein the logic process includes at least one of: file name checking, resource path checking, resource version checking, and error handling.
Optionally, before the resource loading unit, the apparatus further includes:
the relation determining unit is used for acquiring a second dependency relation between the resource package and other resource packages;
and the resource confirmation unit is used for loading the other resource packages on which the resource packages depend according to the second dependency relationship.
Optionally, the resource release unit includes:
A dependency determination subunit, configured to determine whether the resource packet or the other resource packet is dependent on another resource packet to be loaded; if yes, the resource cache subunit is called, and if not, the second resource release subunit is called;
The resource caching subunit is configured to cache the resource packet or the other resource packets after loading is completed;
The second resource releasing subunit is configured to release the resource packet or the other resource packet.
The embodiment of the invention discloses an electronic device, which comprises a processor, a memory and a computer program stored on the memory and capable of running on the processor, wherein the computer program realizes the steps of the task execution method when being executed by the processor.
The embodiment of the invention discloses a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and the computer program realizes the steps of the task execution method when being executed by a processor.
The embodiment of the invention has the following advantages:
In the embodiment of the invention, corresponding working threads are determined according to the types of the tasks in the task pool through the multithreading framework, meanwhile, the tasks which belong to different working threads and can be executed in parallel are formed into task groups, the execution sequence of the task groups is determined according to the dependency relationship among the task groups, and then the tasks in the task groups are respectively executed through a plurality of working threads in the multithreading framework. In the embodiment of the invention, a plurality of working threads can play the calculation advantages of a computer multi-core, for the parallel processing of tasks with dense unordered requirements, different types of tasks are distributed to different working threads, the parallelization of work is realized, the task processing speed is accelerated, the execution order of task groups is determined according to the dependency relationship among the task groups, the tasks with complex ordered requirements can be rapidly solved, the task execution time is optimized, the loading waiting time is shortened, the game fluency is improved, and excellent game experience is given to clients.
The method is suitable for games developed by various versions of game engines, solves the problem that the single-thread framework cannot exert the computational advantage of multiple cores through multiple threads for games developed by using certain versions of game engines on the premise of not spending high cost to reconstruct a large amount of codes, enables iterative versions after the versions to directly utilize the existing developed games, and does not bring uncertainty risks to the online or mature games.
Drawings
FIG. 1 is a flow chart of steps of an embodiment of a task execution method of the present invention;
FIG. 2 is a schematic diagram of the overall architecture of a multithreaded framework of the present invention;
FIG. 3 is a schematic diagram of a task system of the present invention;
FIG. 4 is a flowchart illustrating steps of another embodiment of a task execution method of the present invention;
FIG. 5 is a schematic diagram of a resource management framework of the present invention;
Fig. 6 is a block diagram showing the construction of an embodiment of a task execution apparatus according to the present invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
Currently, for games developed by some versions of the game engine (e.g., the previous version of Unity 2018), the single-threaded framework is still used because of the nature of the game engine itself, without a direct multi-threaded interface (IJob). For iterative versions after this version, although a multi-threaded interface is added, for games that are already in-formation or in the process of being developed, if a previous version is to be migrated, the game item needs to be reconstructed, which is not only costly, but also presents a significant risk of uncertainty for the already in-line or mature game. Therefore, for the games developed by the single-thread game engine, a good thread framework is lacking, so that the problems that the computing advantages of multiple cores cannot be exerted in the computer multi-core era, the waiting time in loading experience is long, the time spent in the logic computing is very long and the like are solved when the single thread Cheng Kuangjia is used.
In terms of resource loading of a game engine, the reference relation of resources is needed to be analyzed according to an interface provided by a resource package, then the resource is processed according to resource information in sequence, then a resource path is constructed for linear loading, and after the resource path is used up, the resource path is synchronously released in game logic. The above resource loading method will cause huge logic operation amount for the middle process of calculating storage position and the like with complex reference relation, and secondly, for the condition that the memory exceeds the system memory threshold value easily occurs when simultaneously loading the resources with huge resource amount, the following defects are brought to the game: and calculating stability caused by the fact that the waiting time exceeds the expected or acceptable range of a user and the memory exceeds the system threshold value.
In order to solve the above problems, the present invention provides a task execution method, which has high efficiency: the multi-core bonus in the hardware is applied, different types of tasks are distributed to different independent working threads, the parallelization of the work is realized, the linear execution of a single thread is not needed any more, the throughput of the game is greatly improved, and therefore the improvement of performance, loading and experience is obtained. Easy reconfiguration: in products that have been developed or have developed partial functionality, existing structures may be retained with little code added to accomplish multithreading. Stability: in the mechanism of increasing the pool cache, the peak value of the memory is effectively controlled, the number of threads and the like are controlled, and in a computer unit, the flash back problem caused by the memory threshold value and the number of threads is prevented.
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a task execution method according to the present invention may specifically include the following steps:
Step 101, confirming task category of the task in the task pool.
The embodiment of the invention provides a multithreading framework which can call a plurality of working threads to jointly execute tasks, wherein the multithreading framework comprises a task pool, and the task pool comprises a plurality of tasks of different categories, such as MAIN type tasks and SUB type tasks. In the embodiment of the invention, the tasks of the game are processed through the multithreading framework, various requests for loading game resources are generated according to the operation of a user in a game scene, various tasks are submitted according to the various requests for loading the game resources, and the submitted various tasks are collected into a task pool of the multithreading framework.
Specifically, before executing a task, it is necessary to determine task categories of all tasks in the task pool, for example, a task including a game engine native Application Program Interface (API) is determined as a MAIN type task, and other tasks are determined as SUB type tasks.
Step 102, determining a working thread corresponding to the task according to the task category of the task.
The multithreading framework comprises a plurality of working threads, different types of tasks are executed by the corresponding different working threads, for example, the working threads comprise a Main working thread and other working threads, and then the task type is Main type tasks corresponding to the Main working threads and Sub type tasks corresponding to other working threads.
Specifically, after task categories of all tasks in the task pool are determined, working threads corresponding to tasks of different categories are determined according to the task categories of the tasks.
Referring to fig. 2, an overall structure diagram of a multithreading framework of the present invention is shown, as can be seen from the figure, a task pool (Works) in the figure includes a plurality of tasks (Works 1, works 2 … …), the type of the task in the task pool is determined by the multithreading framework of the present invention, and a main working Thread (MAIN THREAD) or other working threads (Worker threads) corresponding to the task are confirmed, when the task is executed, the task is allocated to a specific corresponding working Thread according to the task type for execution, and in addition, the completion status of the task in the working Thread can be monitored by the multithreading framework.
And 103, combining tasks which belong to different working threads and can be executed in parallel into task groups.
Specifically, after the worker threads corresponding to the tasks of different types are processed, the tasks which belong to different types are formed into task groups, so that a plurality of task groups are obtained, and each task group contains tasks of different types and can be executed in parallel.
In an example of the present invention, the step 103 includes: and acquiring the reference relation between the tasks, and determining the tasks which can be executed in parallel according to the reference relation between the tasks.
The task and the task have a reference relationship, the task a references the task b, so that when the task a is executed, a resource package generated after the task b is executed needs to be loaded, and the execution sequence among the tasks can be determined usually according to the reference relationship among the tasks.
Specifically, the reference relationship between tasks in the task pool is obtained, and the task that can be executed in parallel can be determined by the reference relationship between tasks (the resource package that needs to be loaded when the task is executed), for example: there are three worker threads, a worker thread a, B worker thread B, and C worker thread C, respectively, which need to execute tasks a1, a2, a3, B1, B2, B3, C1, C2, C3 during loading of a small scenario. Wherein, the a1, a2 and a3 tasks can only be executed on the A working thread, the B1, B2 and B3 tasks can only be executed on the B working thread, and the C1, C2 and C3 tasks can only be executed on the C working thread. In the task execution process, other tasks (namely, the resource package generated after the execution of other tasks is not needed to be loaded when the tasks are executed) are not needed to be referenced for the tasks a1, b1 and c1, and the existing resource package is directly loaded when the tasks are executed, so that the tasks a1, b1 and c1 are determined to be tasks which can be executed in parallel, and the tasks a1, b1 and c1 are formed into a first task group which belongs to different working threads and can be executed in parallel; when the a2 task refers to the a1 task, or refers to the a1 task, the b1 task and the c1 task at the same time (namely, when the a2 task is executed, a resource package generated after the a1 task and the b1 task are executed, or a resource package generated after the a1 task, the b1 task and the c1 task are executed), the a2 task can only be executed after the a1 task or the a1 task and the b1 task are executed, namely, after the first task group is executed, and similarly, when the b2 task and the c2 task also refer to at least one of the c1 task, the c2 task and the c3 task, the a2 task, the b2 task and the c2 task form a second task group which belongs to different working threads and can be executed in parallel, and similarly, all the tasks which can be executed in parallel can be determined.
Step 104, confirming the first dependency relationship between the task groups.
Where there is a dependency relationship between task groups, e.g., the second task group depends on the first task group, then all tasks in the first task group must be executed to execute the tasks in the second task group.
Specifically, after the tasks which are different in working thread and can be executed in parallel are formed into task groups, according to the reference relation between the tasks in the task groups and the tasks in other task groups, determining a first dependency relation between the task groups, for example, three working threads are respectively an A working thread, a B working thread and a C working thread, wherein the first task group comprises a1 task, a B1 task and a C1 task, the second task group comprises a2 task, a2 task and a C2 task, and the third task group comprises a3 task, a3 task and a C3 task, wherein the a1 task, the a2 task, the a3 task, the B1 task, the B2 task, the B3 task and the C1 task, the C2 task and the C3 task are executed in the A working thread, the B working thread and the C working thread respectively; when the tasks a2, b2 and c2 in the second task group refer to at least one of the tasks a1, b1 and c1 in the first task group (i.e. when the tasks a2, b2 and c2 in the second task group are executed, at least one of the resource packages generated after the tasks a1, b1 and c1 are executed is needed to be loaded), the second task group is determined to depend on the first task group, and the tasks in the second task group can be executed only when the tasks in the first task group are all executed.
When each of the tasks a2, b2 and c2 in the second task group refers to at least one of the tasks a1, b1 and c1 in the first task group, and each of the tasks a3, b3 and c3 in the third task group refers to at least one of the tasks a1, b1 and c1 in the first task group, it is determined that the third task group and the second task group both depend on the first task group.
When a2, b2 and c2 tasks in the second task group at least refer to one of a1, b1 and c1 tasks in the first task group, a3, b3 and c3 tasks in the third task group at least refer to one of a2, b2 and c2 tasks in the second task group, and the third task group is determined to depend on the second task group, and the second task group depends on the first task group.
Referring to fig. 3, a schematic structural diagram of a task System of the present invention is shown, as can be seen, in the task System (Tasks (job) System), corresponding working threads of different types of Tasks (Tasks) are determined, tasks (GameObject, loadAssetAsyn, rectTransform … …) are Main classes (Main-UnityEngine), and are executed in Main threads (Unity Render UI Engine etc.); tasks (Data computer, data Combine, data Process, logic … …) are Sub-classes (Sub-Logic Data), executed in other threads (Data Process etc.), and the Tasks (Tasks) belonging to different work threads (different classes) and capable of parallel execution are grouped into task groups (Group 1, group 2 … …), such as task Group 1 (Group 1: game object, data computer, logic … …), task Group 2 (Group 2: loadAssyn, data Combine, logic … …), etc., and then the dependency relationship between the task groups is determined.
And 105, executing the task group according to the first dependency relationship, wherein the tasks in the task group are tasks executed in parallel by calling the corresponding working threads.
Specifically, according to the first dependency relationship between task groups, the task groups are sequentially executed, for example, the task group A depends on the task group B, then the task group A is executed after the task group B is executed, and when the task group A, B is executed, tasks of different types in the task groups are executed in parallel by calling the working threads in the multithreading framework.
When the second task group and the third task group depend on the first task group at the same time, after the first task group is executed, a prior execution is randomly selected from the second task group and the third task group.
When the single-threaded frame is used for a computer with multi-core (multiple CPUs), linear processing tasks can meet the use condition of the single-threaded frame by only adopting a single core (single CPU), so that the rest multi-core (multiple CPUs) cannot exert performance.
In one example of the present invention, parallel execution processes of tasks in a task group may be monitored to manage the executed tasks through the multi-threaded framework of the present invention.
In the embodiment of the invention, the tasks in the task pool are determined to be the given working threads according to the categories through the multithreading framework, meanwhile, the tasks which belong to different working threads and can be executed in parallel are formed into task groups, the execution sequence of the task groups is determined according to the dependency relationship among the task groups, and then the tasks in the task groups are respectively executed through a plurality of working threads in the multithreading framework. In the embodiment of the invention, a plurality of working threads can play the calculation advantages of a computer multi-core, for the parallel processing of tasks with dense unordered requirements, different types of tasks are distributed to different working threads, the parallelization of work is realized, the task processing speed is accelerated, the execution order of task groups is determined according to the dependency relationship among the task groups, the tasks with complex ordered requirements can be rapidly solved, the task execution time is optimized, the loading waiting time is shortened, the game fluency is improved, and excellent game experience is given to clients.
The multithreading framework and the task execution method in the embodiment are also suitable for games developed by all versions of the game engine, solve the problem that the multi-core computing advantage cannot be exerted by using only the single-threaded framework for games developed by using some versions of the game engine on the premise of not spending high cost to reconstruct a large amount of codes, enable the iteration version to directly utilize the existing developed games, and avoid the risk of uncertainty for the online or mature games.
Referring to fig. 4, a flowchart illustrating steps of another task execution method embodiment of the present invention may specifically include the following steps:
step 401, confirming task category of task in task pool.
Step 402, determining a working thread corresponding to the task according to the task category of the task.
And step 403, grouping tasks which belong to different working threads and can be executed in parallel into task groups.
Step 404, confirming a first dependency relationship between the task groups.
Step 405, determining an execution order of the task group according to the first dependency relationship.
Specifically, according to the first dependency relationship between the task groups, determining the execution order of the task groups, and sequentially executing the task groups according to the execution order of the task groups, for example, the task group A depends on the task group B, then determining that the task group B is executed first and then the task group A is executed.
And step 406, executing the task groups in sequence according to the execution sequence of the task groups, wherein the tasks in the task groups are tasks executed in parallel by calling the corresponding working threads.
In one embodiment of the present invention, the step 406 includes: and when the task of the task group is executed, loading a resource package corresponding to the task of the task group.
In the game developed by the game engine, the dynamic resource management uses the resource package (AssetBundle) provided by the dynamic resource management to manage, and the number of the loaded resource packages in the embodiment of the invention is determined by the equipment memory.
Specifically, when different types of tasks in the task group are executed in parallel by calling the working threads in the multithreading framework, resource packages corresponding to the tasks are required to be called for loading, the task management system adopts asynchronous IO for management, and other operation operations can be performed while the resource packages are loaded, so that a plurality of resource packages can be loaded simultaneously, and the tasks in the task group are executed in parallel by the working threads.
In the embodiment of the invention, when the working threads execute the tasks in the task group in parallel, the number of the resource packages is determined by the equipment memory, the resource packages are managed through the asynchronous IO, and some other operation operations can be carried out while the resource packages are loaded, so that a mode of loading a plurality of resource packages simultaneously is realized, the mode of linear loading the resource packages is avoided, the number of the simultaneously loaded resource packages is enabled to be optimal, the memory peak value of the system during loading is controlled simultaneously, the number of threads and the like are controlled, and the flash back problem caused by the memory threshold value and the number of the threads is prevented.
In an embodiment of the present invention, before the loading of the corresponding resource package of the task group, the method further includes: acquiring a second dependency relationship between the resource package and other resource packages; and loading the other resource packages on which the resource packages depend according to the second dependency relationship.
Before loading the resource package to be loaded, the resource on which the resource package to be loaded depends needs to be loaded.
Specifically, before loading the resource package corresponding to the task of the task group, a second dependency relationship between the resource package and the resource package is obtained through a game engine native dereferencing mechanism, other resource packages on which the resource package to be loaded depends are determined according to the second dependency relationship, and other resource packages on which the resource package to be loaded depends are loaded.
In addition, the second dependency relationship between the resource package and other resource packages corresponds to the reference relationship between the tasks, for example, when the task a is executed, the first resource package needs to be loaded, and the first resource package depends on the second resource package, so when the task a is executed, the second resource package needs to be loaded first and then the first resource package is loaded, at this time, if the first resource package exists, and the second resource package needs to be generated after the task b is executed, the task a refers to the task b, the task b needs to be executed first before the task a is executed, the task a is in the first task group, the task b needs to be executed after the task b is in the second task group, and if the task in the second task group does not exist between the first task group and the second task group and other task groups, the first task group depends on the second task group, namely, the first dependency relationship between the first task group and the second task group is determined.
In an embodiment of the present invention, before the loading of the resource package corresponding to the task of the task group, the method further includes: carrying out logic processing on a resource packet to be loaded corresponding to the task of the task group; wherein the logic process includes at least one of: file name checking, resource path checking, resource version checking, and error handling.
Specifically, before loading the resource package corresponding to the task of the task group, it is further required to determine that the resource package is confirmed through a system interface provided by the game engine, and after confirmation. And carrying out logic processing on the resource package, wherein the logic processing at least comprises file name checking, resource path checking, resource version checking, resource local checking, resource position filling (network or local), error processing and the like, and submitting a loading request to a resource request pool after the logic processing is finished so as to carry out the next resource package loading operation.
In one embodiment of the present invention, the step 406 includes: and releasing the resource package after the task execution is completed.
In an embodiment of the present invention, the releasing the resource packet includes: determining whether the resource package or the other resource packages are depended by other resource packages to be loaded; if yes, after loading is finished, caching the resource package or the other resource packages; and if not, releasing the resource package or the other resource packages.
The multithreading framework further comprises a resource pool for caching loading and resource packages to be loaded.
Specifically, after the resource package or other resource packages are loaded, judging whether the resource package or other resource packages are depended by other resource packages to be loaded, if so, indicating that the resource package or other resource packages still need to be loaded again, and caching the resource package in a resource pool through a caching mechanism so as to quickly access the resource package or other resource packages when the resource package or other resource packages are loaded next time.
In the embodiment of the invention, after the resource package or other resource packages are loaded, the resource package or other resource packages which are depended by other resource packages to be loaded are determined, and the resource package or other resource packages are cached in the resource pool through the caching mechanism, so that the resource package or other resource packages can be quickly accessed when being loaded next time, the task execution time is shortened, and the calculation waiting time is prevented from exceeding the expected or exceeding the acceptable range of a user.
In an embodiment of the present invention, the releasing the resource package after the task execution is completed includes: returning a result of the task execution after the task execution is completed; and after returning the result of the task execution, releasing the resource package.
In the related art, after the resource package is loaded, the loaded resource package is released through an interface for providing asynchronous release by the system, after the resource package is released, task execution is completed, and then a task execution result is returned to a user, so that in the process of releasing the resource package, the loading waiting time is overlong, the time of the user is wasted, and bad experience is brought to the user.
Specifically, after the resource package is loaded, the embodiment of the invention carries out asynchronous release processing on the resource package, namely, after the task execution is completed, the task execution result is immediately returned to the user, and the resource package is released after the resource package is delayed.
In the embodiment of the invention, the resource package is subjected to asynchronous release processing, the task execution result is returned to the user, and the resource package is released after being delayed, so that the release of the resource package does not consume the time of the user, and the game experience of the user is improved.
Referring to fig. 5, a flowchart illustrating steps of an embodiment of a task execution method according to the present invention is shown, where, as can be seen from the figure, when tasks in a task group are executed in parallel by multiple task threads, a resource management system (ASSET MANAGE SYSTEM) loads a resource packet corresponding to the task through asynchronous IO management:
when the tasks in the task group are executed in parallel, the multithread Cheng Kuangjia (Multi-THREAD SYSTEM) receives an asynchronous loading instruction (Alync Opration) returned by the resource management system, then the multithread framework starts to Load a resource package (Load Asset) through a resource package loading interface, inputs a resource package name (ASSET NAME) corresponding to the task to the resource management system, determines a dependency relationship (reference relationship) between the resource packages according to the resource package name, thereby determining resources to be Loaded, performs logic processing (such as 0-file name correct mapping, 1-resource local check, 2-resource location filling (network or local), 3-resource reading request, 4-error processing and the like) on the resource package to be Loaded through the multithread Cheng Kuangjia, then calls a loading request (Load Asset) to a resource request pool (RequestAssetPool) in a request pool (RequestPool) when the loading request (Requests) is added, and performs resource loading (Load Asset) through a resource loading handler (Load ASSET HANDER).
After the resource package is loaded, the multithreading framework starts unloading (Unload) the resource package, inputs a resource package name (ASSET NAME) corresponding to the resource package to be unloaded into the resource management system, confirms the resource package (Unload ()) to be unloaded, increases a resource package release request, carries out logic processing (such as 0-acquisition of the resource to be released, 1-resource reference counting processing, 2-delay release technology, 3-error processing and the like) on the resource package to be released through the multithreading framework, and then releases the resource package through a resource unloading processing program.
In the embodiment of the invention, when the working threads execute the tasks in the task group in parallel, the number of the resource packages is determined by the equipment memory, the resource packages are managed through the asynchronous IO, and other operation operations can be carried out while the resource packages are loaded, so that a mode of loading a plurality of resource packages at the same time is realized, the mode of loading the resource packages linearly is avoided, the number of the simultaneously loaded resource packages is enabled to be optimal, the memory peak value of the system during loading is controlled at the same time, the number of threads and the like are controlled, and the flash back problem caused by the memory threshold value and the number of the threads is prevented.
After the resource package or other resource packages are loaded, the resource package or other resource packages which are depended by other resource packages to be loaded are determined, and the resource package or other resource packages are cached in a resource pool through a caching mechanism, so that the resource package or other resource packages can be quickly accessed when being loaded next time, the task execution time is shortened, and the calculation waiting time is prevented from exceeding the expected or exceeding the acceptable range of a user.
And carrying out asynchronous release processing on the resource package, returning a task execution result to a user, and carrying out release processing after the resource package is delayed, so that the release of the resource package does not consume the time of the user, and the game experience of the user is improved.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the invention.
Referring to fig. 6, a block diagram of an embodiment of a task execution device according to the present invention is shown, where the embodiment of the present invention may specifically include the following modules:
a category confirmation module 601, configured to confirm a task category of a task in the task pool;
the thread determining module 602 is configured to determine a working thread corresponding to the task according to a task category of the task;
a task composition module 603, configured to compose tasks that belong to different work threads and can be executed in parallel into task groups;
A relationship determination module 604, configured to confirm a first dependency relationship between the task groups;
And a task execution module 605, configured to execute the task group according to the first dependency relationship, where the tasks in the task group are tasks executed in parallel by calling the corresponding worker threads.
In one embodiment of the present invention, the task execution module 605 includes:
The order determining submodule is used for determining the execution order of the task group according to the first dependency relationship;
and the execution sub-module is used for sequentially executing the task groups according to the execution sequence of the task groups.
In an embodiment of the present invention, the execution submodule includes:
The resource loading unit is used for loading a resource packet corresponding to the task of the task group when the task of the task group is executed;
and the resource releasing unit is used for releasing the resource package after the task execution is completed.
In an embodiment of the present invention, the resource release unit includes:
The result returning subunit is used for returning the result of the task execution after the task execution is completed;
And the first resource release subunit is used for releasing the resource package after returning the result of the task execution.
In an embodiment of the present invention, before the resource loading unit, the method further includes:
The resource processing unit is used for logically processing the resource packet to be loaded corresponding to the task of the task group; wherein the logic process includes at least one of: file name checking, resource path checking, resource version checking, and error handling.
In an embodiment of the present invention, before the resource loading unit, the method further includes:
the relation determining unit is used for acquiring a second dependency relation between the resource package and other resource packages;
and the resource confirmation unit is used for loading the other resource packages on which the resource packages depend according to the second dependency relationship.
In an embodiment of the present invention, the resource release unit includes:
A dependency determination subunit, configured to determine whether the resource packet or the other resource packet is dependent on another resource packet to be loaded; if yes, the resource cache subunit is called, and if not, the second resource release subunit is called;
The resource caching subunit is configured to cache the resource packet or the other resource packets after loading is completed;
The second resource releasing subunit is configured to release the resource packet or the other resource packet.
In the embodiment of the invention, the tasks in the task pool are determined to be the given working threads according to the categories through the multithreading framework, meanwhile, the tasks which belong to different working threads and can be executed in parallel are formed into task groups, the execution sequence of the task groups is determined according to the dependency relationship among the task groups, and then the tasks in the task groups are respectively executed through a plurality of working threads in the multithreading framework. In the embodiment of the invention, a plurality of working threads can play the calculation advantages of a computer multi-core, for the parallel processing of tasks with dense unordered requirements, different types of tasks are distributed to different working threads, the parallelization of work is realized, the task processing speed is accelerated, the execution order of task groups is determined according to the dependency relationship among the task groups, the tasks with complex ordered requirements can be rapidly solved, the task execution time is optimized, the loading waiting time is shortened, the game fluency is improved, and excellent game experience is given to clients.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
The embodiment of the invention discloses an electronic device, which comprises a processor, a memory and a computer program stored on the memory and capable of running on the processor, wherein the computer program realizes the steps of the task execution method embodiment when being executed by the processor.
The embodiment of the invention discloses a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and the computer program realizes the steps of the task execution method embodiment when being executed by a processor.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or terminal device that comprises the element.
The above description of a task execution method, a task execution device, an electronic device and a storage medium provided by the present invention applies specific examples to illustrate the principles and embodiments of the present invention, and the above description of the examples is only used to help understand the method and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (8)

1. A method of task execution for use in a game developed using a single-threaded game engine, the method comprising:
confirming task categories of tasks in the task pool; wherein, the tasks are tasks of various categories submitted according to various requests for loading game resources;
determining a working thread corresponding to the task according to the task category of the task;
the task groups which belong to different working threads and can be executed in parallel are formed into task groups;
confirming a first dependency relationship between the task groups;
Executing the task group according to the first dependency relationship, wherein the tasks in the task group are tasks executed in parallel by calling the corresponding working threads;
wherein, confirming the task category of the task in the task pool comprises:
Determining tasks containing game engine native application program interfaces as MAIN type tasks, and determining other tasks as SUB type tasks;
and executing the task group according to the first dependency relationship, including:
determining the execution sequence of the task group according to the first dependency relationship;
sequentially executing the task groups according to the execution sequence of the task groups;
the sequentially executing the task group includes:
When the task of the task group is executed, loading a resource package corresponding to the task of the task group;
And releasing the resource package after the task execution is completed.
2. The method of claim 1, wherein releasing the resource package after the task execution is completed comprises:
returning a result of the task execution after the task execution is completed;
and after returning the result of the task execution, releasing the resource package.
3. The method of claim 1, wherein prior to said loading the resource package corresponding to the task of the task group, the method further comprises:
Carrying out logic processing on a resource packet to be loaded corresponding to the task of the task group; wherein the logic process includes at least one of: file name checking, resource path checking, resource version checking, and error handling.
4. The method of claim 1, further comprising, prior to said loading the corresponding resource packages for the tasks of the task group:
Acquiring a second dependency relationship between the resource package and other resource packages;
and loading the other resource packages on which the resource packages depend according to the second dependency relationship.
5. The method of claim 4, wherein said releasing said resource package after said task execution is completed comprises:
Determining whether the resource package or the other resource packages are depended by other resource packages to be loaded;
if yes, after loading is finished, caching the resource package or the other resource packages;
and if not, releasing the resource package or the other resource packages.
6. A task execution device for use in a game developed using a single-threaded game engine, the device comprising:
the category confirming module is used for confirming task categories of tasks in the task pool; wherein, the tasks are tasks of various categories submitted according to various requests for loading game resources;
The thread determining module is used for determining a working thread corresponding to the task according to the task category of the task;
the task composition module is used for composing the tasks which belong to different working threads and can be executed in parallel into task groups;
the relation determining module is used for confirming a first dependency relation among the task groups;
The task execution module is used for executing the task group according to the first dependency relationship, wherein the tasks in the task group are tasks executed in parallel by calling the corresponding working threads;
wherein, confirming the task category of the task in the task pool comprises:
Determining tasks containing game engine native application program interfaces as MAIN type tasks, and determining other tasks as SUB type tasks;
the task execution module includes:
The order determining submodule is used for determining the execution order of the task group according to the first dependency relationship;
the execution sub-module is used for sequentially executing the task groups according to the execution sequence of the task groups;
the execution sub-module includes:
The resource loading unit is used for loading a resource packet corresponding to the task of the task group when the task of the task group is executed;
and the resource releasing unit is used for releasing the resource package after the task execution is completed.
7. An electronic device comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, which when executed by the processor performs the steps of the task execution method of any one of claims 1 to 5.
8. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the steps of the task execution method according to any one of claims 1 to 5.
CN202110548546.0A 2021-05-19 2021-05-19 Task execution method, device, electronic equipment and storage medium Active CN113126968B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110548546.0A CN113126968B (en) 2021-05-19 2021-05-19 Task execution method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110548546.0A CN113126968B (en) 2021-05-19 2021-05-19 Task execution method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113126968A CN113126968A (en) 2021-07-16
CN113126968B true CN113126968B (en) 2024-05-10

Family

ID=76782520

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110548546.0A Active CN113126968B (en) 2021-05-19 2021-05-19 Task execution method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113126968B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011008617A (en) * 2009-06-26 2011-01-13 Toyota Motor Corp Multithread execution device, method of generating object program, and program
CA2691306A1 (en) * 2010-01-28 2011-07-28 Ibm Canada Limited - Ibm Canada Limitee Interdependent task management
CN102567084A (en) * 2010-12-31 2012-07-11 新奥特(北京)视频技术有限公司 Multi-task parallel scheduling mechanism
KR101171149B1 (en) * 2011-06-15 2012-08-06 전자부품연구원 Multi-thread encoding and decoding method and encoder, decoder and computer readable recording medium applying the same
CN105760234A (en) * 2016-03-17 2016-07-13 联动优势科技有限公司 Thread pool management method and device
CN106874031A (en) * 2017-01-03 2017-06-20 青岛海信电器股份有限公司 A kind of startup method and device of terminal device system program
CN107729139A (en) * 2017-09-18 2018-02-23 北京京东尚科信息技术有限公司 A kind of method and apparatus for concurrently obtaining resource
CN108228189A (en) * 2018-01-15 2018-06-29 西安交通大学 The relational structure and the mapping method based on it of a kind of multithreading in hiding isomerism parallel programming
CN109408104A (en) * 2018-09-18 2019-03-01 天津龙拳风暴科技有限公司 A kind of method and device for obtaining game and integrating information
CN110187958A (en) * 2019-06-04 2019-08-30 上海燧原智能科技有限公司 A kind of task processing method, device, system, equipment and storage medium
CN110865888A (en) * 2019-11-28 2020-03-06 米哈游科技(上海)有限公司 Resource loading method and device, server and storage medium
CN112395054A (en) * 2019-08-15 2021-02-23 杭州海康威视***技术有限公司 Thread scheduling method, device and system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7614040B2 (en) * 2004-05-22 2009-11-03 Bea Systems, Inc. System and method for efficiently analyzing and building interdependent resources in a software project
US8887163B2 (en) * 2010-06-25 2014-11-11 Ebay Inc. Task scheduling based on dependencies and resources
US9250953B2 (en) * 2013-11-12 2016-02-02 Oxide Interactive Llc Organizing tasks by a hierarchical task scheduler for execution in a multi-threaded processing system
US9720737B2 (en) * 2014-10-31 2017-08-01 Microsoft Technology Licensing, Llc Controlling resource allocation with automated consumption against a work breakdown structure
CN109395395A (en) * 2018-09-20 2019-03-01 Oppo广东移动通信有限公司 Game running method and Related product
US20210134124A1 (en) * 2019-10-31 2021-05-06 Scoretrade Inc. In-stadium and location-based user inputs to adjust in-game bet pricing and probabilities

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2011008617A (en) * 2009-06-26 2011-01-13 Toyota Motor Corp Multithread execution device, method of generating object program, and program
CA2691306A1 (en) * 2010-01-28 2011-07-28 Ibm Canada Limited - Ibm Canada Limitee Interdependent task management
CN102567084A (en) * 2010-12-31 2012-07-11 新奥特(北京)视频技术有限公司 Multi-task parallel scheduling mechanism
KR101171149B1 (en) * 2011-06-15 2012-08-06 전자부품연구원 Multi-thread encoding and decoding method and encoder, decoder and computer readable recording medium applying the same
CN105760234A (en) * 2016-03-17 2016-07-13 联动优势科技有限公司 Thread pool management method and device
CN106874031A (en) * 2017-01-03 2017-06-20 青岛海信电器股份有限公司 A kind of startup method and device of terminal device system program
CN107729139A (en) * 2017-09-18 2018-02-23 北京京东尚科信息技术有限公司 A kind of method and apparatus for concurrently obtaining resource
CN108228189A (en) * 2018-01-15 2018-06-29 西安交通大学 The relational structure and the mapping method based on it of a kind of multithreading in hiding isomerism parallel programming
CN109408104A (en) * 2018-09-18 2019-03-01 天津龙拳风暴科技有限公司 A kind of method and device for obtaining game and integrating information
CN110187958A (en) * 2019-06-04 2019-08-30 上海燧原智能科技有限公司 A kind of task processing method, device, system, equipment and storage medium
CN112395054A (en) * 2019-08-15 2021-02-23 杭州海康威视***技术有限公司 Thread scheduling method, device and system
CN110865888A (en) * 2019-11-28 2020-03-06 米哈游科技(上海)有限公司 Resource loading method and device, server and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
陶皖.《大数据导论=INTRODUCTION TO BIG DATA》.西安电子科技大学出版社,2020,第64页. *

Also Published As

Publication number Publication date
CN113126968A (en) 2021-07-16

Similar Documents

Publication Publication Date Title
CN105893126B (en) A kind of method for scheduling task and device
US9582312B1 (en) Execution context trace for asynchronous tasks
CN109144710B (en) Resource scheduling method, device and computer readable storage medium
EP2879055B1 (en) System and method facilitating performance prediction of multi-threaded application in presence of resource bottlenecks
US20160085601A1 (en) Transparent user mode scheduling on traditional threading systems
US20170093988A1 (en) Workflow service using state transfer
JP2016129056A (en) Fault tolerant batch processing
CN103365718A (en) Thread scheduling method, thread scheduling device and multi-core processor system
CN113918101A (en) Method, system, equipment and storage medium for writing data cache
CN107479981B (en) Processing method and device for realizing synchronous call based on asynchronous call
CN111932257A (en) Block chain parallelization processing method and device
US20070088871A1 (en) Implementation of shared and persistent job queues
US20060036810A1 (en) System, application and method of reducing cache thrashing in a multi-processor with a shared cache on which a disruptive process is executing
CN111176831A (en) Dynamic thread mapping optimization method and device based on multithread shared memory communication
CN113051049B (en) Task scheduling system, method, electronic device and readable storage medium
CN113126968B (en) Task execution method, device, electronic equipment and storage medium
JP7122299B2 (en) Methods, apparatus, devices and storage media for performing processing tasks
CN111831408A (en) Asynchronous task processing method and device, electronic equipment and medium
CN108062224B (en) Data reading and writing method and device based on file handle and computing equipment
CN115114022A (en) Method, system, device and medium for using GPU resources
CN112130900B (en) User information management method, system, equipment and medium for BMC
CN113760524A (en) Task execution method and device
CN111581041A (en) Method and equipment for testing performance of magnetic disk
CN110874269B (en) Method and device for realizing high-performance Golang memory pool and electronic equipment
CN113704297B (en) Processing method, module and computer readable storage medium for business processing request

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