Method for starting an application, related device and computer program product
By building a directed acyclic graph and configuring components in order of priority, the problems of long waiting times and exceptions during application startup are solved, achieving more efficient and stable application startup.
Patent Information
- Application Number
- CN202411087878.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-08-08
AI Technical Summary
The existing technology has problems of long waiting time and abnormal startup during the application startup process, especially when the number of components increases, resulting in low startup efficiency.
Build a directed acyclic graph, determine the sub-directed acyclic graph based on the execution dependencies and priorities between components, configure high-priority components in order of priority, and start the application after all high-priority components are configured.
Improves application startup stability and efficiency, shortens startup time, and avoids startup exceptions caused by component configuration errors.
Smart Images

Figure CN119166232B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for starting an application, an electronic device, a computer-readable medium, and a computer program product. Background Art
[0002] As society develops, computer technology continues to advance. To facilitate the convenience brought by computer technology, ease user access to services, and lower the barrier to entry, these services are often implemented through "applications" or "apps." For example, users can download applications that provide corresponding services and use them to access them.
[0003] In this context, considering that the use and implementation of applications often require the use of certain components to provide operational support (for example, the application's runtime environment components), how to more efficiently and efficiently configure, provide, and launch the components required for applications for users, and how to better support users' application usage, are worthy of consideration and urgent needs. Summary of the Invention
[0004] Various aspects of the present application provide a method, apparatus, electronic device, computer-readable storage medium, and computer program product for starting an application, which can improve the startup and running stability of the application and improve the startup efficiency of the application.
[0005] In one aspect of the present application, a method for starting an application is provided, comprising: in response to receiving a start request for a target application, constructing a directed acyclic graph based on the execution dependency relationship between each to-be-started component in a group of to-be-started components serving the target application; determining a sub-directed acyclic graph from the directed acyclic graph based on the start priority of each to-be-started component, wherein the sub-directed acyclic graph includes all high-priority to-be-started components, and the start priority of the high-priority to-be-started components is greater than or equal to a preset priority level; based on the configuration order indicated by the sub-directed acyclic graph, continuously configuring each high-priority to-be-started component; in response to the high-priority to-be-started components corresponding to the sub-directed acyclic graph being fully configured, starting the target application.
[0006] Another aspect of the present application provides an apparatus for starting an application, comprising: a directed acyclic graph construction module, configured to, in response to receiving a start request for a target application, construct a directed acyclic graph based on the execution dependency relationship between each to-be-started component in a group of to-be-started components serving the target application; a sub-directed acyclic graph determination module, configured to determine a sub-directed acyclic graph from the directed acyclic graph based on the start priority of each to-be-started component, wherein the sub-directed acyclic graph includes all high-priority to-be-started components, and the start priority of the high-priority to-be-started components is greater than or equal to a preset priority level; a first startup component configuration module, configured to continuously configure each high-priority to-be-started component based on the configuration order indicated by the sub-directed acyclic graph; and a first application startup module, configured to start the target application in response to all the high-priority to-be-started components corresponding to the sub-directed acyclic graph being configured.
[0007] Another aspect of the present application provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method for launching an application provided above.
[0008] In another aspect of the present application, a computer-readable storage medium is provided, on which computer program instructions are stored. The computer program instructions can be executed by a processor to implement the method for starting an application provided above.
[0009] In another aspect of the present application, a computer program product includes a computer program having computer program instructions stored thereon. When the computer program is executed by a processor, the method for starting an application as provided above can be implemented.
[0010] In the solution provided by the embodiment of the present application, in response to receiving a startup request for a target application, a directed acyclic graph is constructed based on the execution dependency relationship between each component to be started in a group of components to be started that serve the target application; based on the startup priority of each component to be started, a sub-directed acyclic graph is determined from the directed acyclic graph, wherein the sub-directed acyclic graph includes all high-priority components to be started, and the startup priority of the high-priority components to be started is greater than or equal to the preset priority level; based on the configuration order indicated by the sub-directed acyclic graph, each high-priority component to be started is continuously configured; in response to the high-priority components to be started corresponding to the sub-directed acyclic graph being fully configured, the target application is started. In this way, the startup and operation stability of the application can be improved, and the startup efficiency of the application can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, a brief introduction is given below to the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0012] Other features, objects and advantages of the present application will become more apparent upon reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0013] Figure 1 A schematic diagram of a process for starting an application provided in an embodiment of the present application;
[0014] Figure 2 A schematic diagram of a process of starting an application in an application scenario provided by another embodiment of the present application;
[0015] Figure 3 A schematic diagram of a process for configuring a high-priority component to be started according to an embodiment of the present application;
[0016] Figure 4 A schematic diagram of the structure of a device for starting an application provided in one embodiment of the present application;
[0017] Figure 5 The figure is a schematic diagram of the structure of an electronic device suitable for implementing the solution in the embodiment of the present application.
[0018] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0019] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0020] In a typical configuration of the present application, the terminal and the equipment of the service network each include one or more processors (CPUs), input / output interfaces, network interfaces and memories.
[0021] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0022] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology for information storage. The information can be computer program instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc-read only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
[0023] As discussed above, how to more efficiently and effectively configure, provide, and launch the components required for applications for users, and how to better support users' application usage process are worthy of consideration and are urgently needed.
[0024] In some solutions, you can choose to continuously determine the components required to start and run the application, complete the configuration one by one in the order of acquisition and determination, and after completing the configuration, actually start the application to provide services to users.
[0025] However, in this way, as the application becomes more advanced and complex, the required components gradually increase, resulting in, for example, a long waiting time when cold starting the application and a high probability of startup anomalies.
[0026] In this regard, an embodiment of the present application provides a method for determining an application. In response to receiving a startup request for a target application, the method constructs a directed acyclic graph based on the execution dependency relationship between each component to be started in a group of components to be started that serve the target application; based on the startup priority of each component to be started, a sub-directed acyclic graph is determined from the directed acyclic graph, wherein the sub-directed acyclic graph includes all high-priority components to be started, and the startup priority of the high-priority components to be started is greater than or equal to a preset priority level; based on the configuration order indicated by the sub-directed acyclic graph, each high-priority component to be started is continuously configured; in response to the high-priority components to be started corresponding to the sub-directed acyclic graph being fully configured, the target application is started. In this way, the startup and operation stability of the application can be improved, and the startup efficiency of the application can be improved.
[0027] In practical scenarios, the execution subject of this method can be a user device, or a device formed by integrating a user device and a network device via a network, or an application running on such a device. User devices include but are not limited to computers, mobile phones, tablets, smart watches, wristbands, and other terminal devices. Network devices include but are not limited to network hosts, single network servers, multiple network server clusters, or cloud computing-based computer clusters. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing. Cloud computing is a type of distributed computing, consisting of a group of loosely coupled computers forming a virtual computer.
[0028] When the execution subject is software, it can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules, or as a single software or software module, and is not specifically limited here.
[0029] Figure 1 A process 100 for starting an application provided by an embodiment of the present application is shown. The process 100 includes at least the following processing steps:
[0030] (Step) S101 : In response to receiving a start request for a target application, a directed acyclic graph is constructed based on execution dependency relationships between components to be started in a group of components to be started that serve the target application.
[0031] In an embodiment of the present application, upon receiving a user's request to use a target application, the execution entity responds and determines the target application. For example, if the execution entity is a terminal device used by the user, the launch request may be manifested as a user's launch operation or click operation on the application. For another example, if the execution entity is a server, the launch request may be manifested as a user's launch operation or click operation on the application using the terminal device.
[0032] After determining the target application, the execution entity constructs a directed acyclic graph based on the execution dependency relationship between each to-be-started component in a set of to-be-started components serving the target application (i.e., the "components" that are currently in an unstarted and unconfigured state and are required when the target application is used).
[0033] The components to be started, i.e., the components that need to be started to provide, for example, an environment and functions when the target application is used, can generally be independent code libraries that the application depends on during runtime, such as image loading libraries, databases, log libraries, etc.
[0034] Execution dependencies can be determined based on a pre-configured dependency list between components. For example, component A to be started may rely on the runtime environment provided by components B and C to be configured. In this case, the dependency list can adaptively record that component A depends on components B and C.
[0035] Accordingly, the execution entity can construct a directed acyclic graph based on the execution dependency relationship between the components to be started. A directed acyclic graph (DAG) refers to a directed graph without loops. Directed means that the edges in the graph have directions, that is, they point from one vertex to another, indicating a directed relationship between the vertices. Acyclic means that there is no path through any vertex in the graph that can form a loop. In other words, there is no path starting from a vertex and passing through several edges back to the vertex. In other words, if a directed graph cannot start from a vertex and pass through several edges back to the point, then the graph is a directed acyclic graph.
[0036] In some embodiments, during the process of constructing a directed acyclic graph, each component to be started in a set of components to be started that serve the target application can be initially constructed as a corresponding startup task. For example, each component to be started can be initialized and constructed as a corresponding startup task. Accordingly, after being executed, the corresponding startup task can complete the configuration and startup operations of the corresponding component to be started, thereby actually starting and configuring the "component" to be started.
[0037] Then, similarly, the task dependencies between the various startup tasks are determined. For example, the execution entity can adaptively determine the pre-dependencies of the startup tasks based on the dependencies between components, and then construct a directed acyclic graph in the form of "startup tasks."
[0038] Specifically, the execution entity can determine each startup task as a vertex of a directed acyclic graph. For example, the execution entity can mark and locate the corresponding startup task based on the task unique identifier (Task Name) of the startup task (for example, the unique identifier can be read from the relevant code to determine the task). Then, based on the task dependencies determined in the above process, each "vertex" (i.e., startup task) is connected to form and construct a directed acyclic graph. Thus, a directed acyclic graph is constructed in the form of a task of the startup task, so that the directed acyclic graph can be further used to directly call and indicate the startup task in the future, thereby improving the indication and use efficiency of the directed acyclic graph.
[0039] In some embodiments, for the task dependencies between various startup tasks, the execution entity may choose to use an annotation mechanism to read a pre-dependency list of the startup tasks, and then determine the task dependencies between various startup tasks based on the pre-dependency list.
[0040] Specifically, the execution subject can read the pre-dependency list of the current task of each startup task from the annotation of the startup task class based on the annotation mechanism of the programming language in the programming process associated with the startup task (for example, List <task>).
[0041] For example, a pre-dependency list can be used in project management or software development to record and manage tasks and their dependencies. In the pre-dependency list, each startup task may have a set of pre-determined tasks, i.e., other tasks that must be completed before the startup task is executed. Accordingly, each startup task can also typically contain a list of other tasks it depends on (dependencies). Thus, by adding a dependency, a startup task can be marked as a dependency of another startup task, and these dependencies can be set and managed when creating a pre-dependency list.
[0042] Accordingly, the execution entity can search for the pre-dependency nodes of each startup task as a vertex based on the pre-dependency list and build a bidirectional reference relationship between them. Thus, using the pre-dependency list can more efficiently and accurately determine the task dependency relationship between each startup task.
[0043] S102 : Determine a sub-directed acyclic graph from the directed acyclic graph based on the startup priority of each component to be started.
[0044] In an embodiment of the present application, after the execution entity determines and constructs a directed acyclic graph based on the above steps, it can determine a sub-directed acyclic graph from the directed acyclic graph based on the startup priority of each component to be started included in the directed acyclic graph.
[0045] The startup priority can be determined based on the pre-configured startup priority tag of the component to be started. Usually, the startup priority is directly related to the "contribution" of the component to starting the application. For example, the "basic component" that directly affects whether the application can be started has a higher startup priority than the "extension component" used to provide "some non-common functions in the application". In an embodiment of the present application, the above-mentioned preset level can be determined based on the minimum startup standard of the "application" (that is, the target application discussed above) (for example, the bottom line, the component required to start the application). For example, the "preset level" can be set in advance with the startup priority corresponding to the component with the lowest startup priority among the components required for the minimum standard for the "application" to be started.
[0046] Alternatively or additionally, when predetermining each startup priority, the startup priority and the preset level can be adaptively configured based on the contribution that each component can provide (for example, the above-mentioned "basic component" can be configured as "necessary" or "basic" level, and then the "preset level" can be set corresponding to such "necessary" or "basic" level). In this way, the execution entity can determine the startup priority of the component across applications to reduce the cost of configuring the startup priority of the component (for example, there is no need to configure the startup priority of the corresponding component for each application).
[0047] Then, the execution subject can select a "branch" in the directed acyclic graph that includes all components to be started whose startup priority is greater than or equal to the preset level (for the convenience of description, they are directly referred to as high-priority components to be started), and use this branch as a sub-directed acyclic graph. That is, the sub-directed acyclic graph includes all high-priority components to be started, and the startup priority of the high-priority components to be started is greater than or equal to the preset priority level. For example, based on the directed acyclic graph, the execution subject can use the high-priority component to be started with the highest priority and the lowest level in the dependency relationship as the starting point, and then search for other high-priority components to be started in sequence according to the path and order indicated by the directed acyclic graph, until the high-priority component at the top of the dependency relationship is found, and then use this search path as a "branch" to determine the sub-directed acyclic graph.
[0048] In some embodiments, a directed acyclic graph may contain some high-priority components to be started that do not have dependencies on other components, for example, high-priority components to be started that are not directly or indirectly connected to other high-priority components to be started (connected through other components that are not high-priority components to be started). For such high-priority components to be started, the execution entity can add them to a sub-directed acyclic graph based on a "branch method" by describing them as independent "points" to avoid loss. (For example, in the form of separate nodes, they are combined with branches to ultimately obtain a sub-directed acyclic graph).
[0049] Alternatively or additionally, when the execution subject is selecting a "branch", if there are multiple "branches" that can include all high-priority components to be started, the execution subject will give priority to selecting the target branch among the "branches" that includes the most high-priority components to be started and the least total number of vertices as the sub-directed acyclic graph. That is, if there are multiple candidate sub-directed acyclic graphs, the execution subject can respond to this and select the target sub-directed acyclic graph among the candidate sub-directed acyclic graphs that includes the least number of components to be started other than high-priority components to be started (for the convenience of description, it will be described as low-priority components to be started) as the "sub-directed acyclic graph" discussed above.
[0050] In some embodiments, the startup priority of a component can also be obtained using an annotation reading mechanism. For example, a corresponding startup priority (identifier) can be added directly to the code to indicate the startup priority of the component. Subsequently, the execution entity can read the startup priority based on the annotation mechanism to improve efficiency.
[0051] For the purpose of easier understanding, you can also refer to Figure 2 , Figure 2 A schematic diagram of a process 200 for starting an application in an application scenario provided by another embodiment of the present application is shown. The process 200 is specifically as follows:
[0052] In process 200 , the execution subject executes S201 for a target application (eg, application 210 ) to obtain various components to be started (eg, components 211 - 215 ) serving the application 210 .
[0053] Then, the execution subject executes S202 to construct corresponding startup tasks for each component to be started (e.g., components 211-215). For example, component 211 corresponds to startup task 221, component 212 corresponds to startup task 222, component 213 corresponds to startup task 223, component 214 corresponds to startup task 224, and component 215 corresponds to startup task 225.
[0054] Next, the execution entity can use the pre-dependency list 230 (for example, which can be read based on the annotation mechanism) to execute S203 and construct a directed acyclic graph 240 (for example, the directed acyclic graph 240 can be embodied in the form of a "startup task").
[0055] For example, startup task 222 and startup task 223 depend on startup task 221, startup task 224 depends on startup task 223, and startup task 225 depends on startup task 224. Furthermore, startup tasks 221, 222, and 224 are startup tasks corresponding to the "high priority to-be-started components" discussed above.
[0056] Accordingly, the execution entity may determine the sub-directed acyclic graph 243 and the remaining startup task groups 245 .
[0057] S103 , continuously configuring each high-priority component to be started based on the configuration order indicated by the sub-directed acyclic graph.
[0058] In an embodiment of the present application, after determining the sub-directed acyclic graph based on the above S102, the execution entity continuously configures each high-priority component to be started based on the configuration order indicated by the sub-directed acyclic graph (for example, continuously executes the startup tasks corresponding to each high-priority component to be started). As an alternative or in addition, for example, as discussed above, a separate, independent high-priority component to be started that may not have a dependency relationship with other high-priority components to be started can be considered to be after the branch based on pre-configured rules and configured in order from high to low startup priority.
[0059] Therefore, the execution entity can prioritize and specifically configure high-priority startup applications based on the sub-directed acyclic graph to provide "basic support" for the target application, so that the target application can be started as early and faster as possible.
[0060] For this, please refer to Figure 2 Process 200 is shown.
[0061] After determining the sub-directed acyclic graph 243 , the execution entity may choose to use the configuration sequence indicated by the sub-directed acyclic graph 243 to continuously execute the startup tasks 221 , 222 and 224 to complete the configuration of the high-priority components to be started.
[0062] And, as Figure 2 In the process 200 shown, in the process of continuously executing the startup tasks 221, 222 and 224 using the configuration sequence indicated by the sub-directed acyclic graph 243, the execution subject can at least choose to use the task execution queue 250 to execute the startup tasks 221, 222 and 224. This will be discussed and explained in detail below, please refer to, for example, the following description of the Figure 3 Description of the content shown.
[0063] In some embodiments, during the use of the sub-directed acyclic graph, the execution entity may also choose to topologically sort the sub-directed acyclic graph, and after obtaining the sorted sub-directed acyclic graph, continuously configure each high-priority component to be started based on the configuration order indicated by the sorted sub-directed acyclic graph.
[0064] Topological sorting is to arrange all the vertices of a (sub) directed acyclic graph into a linear sequence so that any pair of vertices u and v in the sub-directed acyclic graph has an edge.<u,v> ∈E(G), then u appears before v in the linear sequence. Such a linear sequence is called a sequence that satisfies the topological order, and is therefore also called a topological sort. Typically, topological sorting can be performed using either depth-first search (DFS) or breadth-first search (BFS).
[0065] Therefore, topological sorting can be used to optimize the sub-directed acyclic graph to improve the usage quality of the sub-directed acyclic graph.
[0066] S104 , in response to the high-priority to-be-started components corresponding to the sub-directed acyclic graph being completely configured, starting the target application.
[0067] In an embodiment of the present application, the execution entity can monitor the startup and configuration status of the high-priority components to be started corresponding to the sub-directed acyclic graph, and respond when all the high-priority components to be started corresponding to the sub-directed acyclic graph are fully configured, and select to start the target application.
[0068] Thus, the execution subject can directly start the target application when the target application has "basic" starting conditions, thereby shortening the waiting time for starting the target application.
[0069] It should be understood that during this process, the execution entity's startup of the target application can be considered a "trial" startup. In such a case, the "startup" may succeed or fail (for example, due to an error in the startup priority determination, a component that should be determined as a high-priority component to be started is not determined as a high-priority component to be started, and this "omission" causes the target application to fail to start).
[0070] In such cases, in some embodiments, the execution entity can continuously monitor and obtain the target application's startup status after "attempting" to launch the target application. If the target application is successfully launched, the execution entity can choose to respond by successively configuring lower-priority components to be launched, in addition to the higher-priority components to be launched, based on the configuration order indicated by the directed acyclic graph. This "start first, expand later" approach improves the target application's startup efficiency while ensuring its usability.
[0071] For this, please refer to Figure 2 The process 200 is shown. In the process 200, the execution subject may select the startup application 210 in response to the startup tasks 221, 222 and 224 being completed based on S206.
[0072] In some embodiments, if the target application is not successfully started, the execution entity may also respond to this by continuously configuring the low-priority components to be started in addition to the high-priority components to be started based on the configuration order indicated by the directed acyclic graph. Then, in response to the low-priority components to be started being fully configured, the execution entity starts the target application. Thus, in the event of a startup failure, the execution entity can choose to first refer to the complete directed acyclic graph to complete the configuration and deployment of all startup components, and then try to start the "target application" again after completing the configuration. This avoids the startup process of the target application falling into a "stuck state" when it fails to start due to reasons such as inaccurate determination of the high-priority components to be started.
[0073] For example, in Figure 2 In the process shown, after executing S206 , the execution subject may further configure components to be started (eg, low-priority components to be started) other than high-priority components to be started for the remaining startup task groups 245 , which will not be repeated here.
[0074] It should be understood that if the low-priority components to be started in the remaining startup task groups 245 also have dependencies similar to those shown in the sub-directed acyclic graph 240 (for example, dependencies determined based on the directed acyclic graph 240), then the execution subject can also execute continuously based on the dependencies in the process of executing the startup tasks corresponding to the low-priority components to be started in the remaining startup task groups 245, which will not be repeated here.
[0075] In some embodiments, the execution subject may also sort the remaining startup task groups 245 by topological sorting during the execution of the remaining startup task groups 245 to improve efficiency.
[0076] Then, the method for starting an application provided by the present application, in response to receiving a start request for a target application, constructs a directed acyclic graph based on the execution dependency relationship between each to-be-started component in a group of to-be-started components serving the target application; based on the startup priority of each to-be-started component, determines a sub-directed acyclic graph from the directed acyclic graph, wherein the sub-directed acyclic graph includes all high-priority to-be-started components, and the startup priority of the high-priority to-be-started components is greater than or equal to a preset priority level; based on the configuration order indicated by the sub-directed acyclic graph, continuously configures each high-priority to-be-started component; in response to the high-priority to-be-started components corresponding to the sub-directed acyclic graph being fully configured, starts the target application. In this way, the startup and operation stability of the application can be improved, and the startup efficiency of the application can be improved.
[0077] Furthermore, as discussed above, in some embodiments, the execution entity can also manage the component startup and configuration process more efficiently and effectively through the use of a task execution queue. For example, the task execution queue can be used to sequentially execute configuration operations for each high-priority component to be started in the startup order.
[0078] For this, please refer to Figure 3 , Figure 3 This is a schematic diagram of a process 300 for configuring a high-priority component to be started, provided in one embodiment of the present application. For example, process 300 can be used as an alternative or replacement for step S103 described above. Process 300 includes at least the following processing steps:
[0079] S301: Determine a first number of startup tasks corresponding to the to-be-started components indicated by the sub-directed acyclic graph.
[0080] Specifically, after the execution subject determines the sub-directed acyclic graph from the directed acyclic graph through, for example, the above-mentioned S102, the execution subject can read and determine the number of components to be started indicated in the sub-directed acyclic graph (for ease of understanding, it is described as the first number). For example, if the sub-directed acyclic graph is composed only of high-priority components to be started, then the first number is actually determined by the total number of high-priority components to be started. In some scenarios, the sub-directed acyclic graph may include some low-priority components (for example, it may include a low-priority component for bridging the dependency relationship between two high-priority components to be started) in addition to the high-priority components to be started. Then the first number is based on the total number of high-priority components to be started, and also includes the total number of these included low-priority components.
[0081] S302: Determine whether the first number exceeds the second number allowed by the task execution queue.
[0082] Specifically, as discussed above, the execution subject can choose to configure and call the task execution queue to configure the components to be started (for example, to execute the startup tasks corresponding to each component to be started) to perform these tasks. Considering that the task objects stored in the task execution queue may occupy a certain amount of memory space. If the queue is too large, the system's memory resources may be exhausted, causing the system to run slowly or crash, and the tasks in the task execution queue need to be executed by the processor. Too many tasks may cause the processor to be overloaded, affecting the system's response speed and performance. Therefore, it is possible to choose to set an upper limit on the length of the task execution queue to indicate that it can only handle a certain number (described as the second number for ease of understanding) of startup tasks.
[0083] After determining the first quantity based on the above S301, the execution entity chooses to compare the first quantity with the second quantity in this step to determine whether the first quantity exceeds the second quantity allowed by the task execution queue.
[0084] Next, if the execution entity determines that the first number does not exceed the second number allowed by the task execution queue, it may choose to continue executing S303.
[0085] S303 , sequentially storing the startup tasks corresponding to the components to be started indicated by the sub-directed acyclic graph into a task execution queue based on the configuration order indicated by the sub-directed acyclic graph.
[0086] Specifically, if the executing entity determines that the first number does not exceed the second number allowed by the task execution queue, the executing entity selects the startup tasks corresponding to each component to be started indicated by the sub-directed acyclic graph (the startup tasks corresponding to the high-priority component to be started, or the startup tasks corresponding to the high-priority component to be started and the startup tasks corresponding to the low-priority component to be started) in the configuration order indicated by the sub-directed acyclic graph.
[0087] S304: Utilize the execution queue to continuously complete each startup task based on the configuration order indicated by the sub-directed acyclic graph.
[0088] Specifically, as discussed above, the execution queue continuously completes each startup task based on the configuration order indicated by the sub-directed acyclic graph, so as to continuously configure each to-be-started component indicated by the sub-directed acyclic graph.
[0089] In some embodiments, during the process of generating and determining the startup tasks, the execution subject may also determine the running threads (e.g., application main threads or child threads) corresponding to each startup task. For example, the execution subject may also use an annotation mechanism to read the running threads.
[0090] Typically, the application's main thread is the primary thread responsible for updating the user interface and responding to events. It handles user input, draws UI elements, and updates UI status. Application child threads, on the other hand, are background threads responsible for handling I / O-intensive tasks and executing time-consuming operations. By differentiating and configuring threads, we can improve the completion quality of initiated tasks.
[0091] In some embodiments, the first number may exceed the second number allowed by the task execution queue. In this case, an alternative task execution queue can be used to temporarily "cache" the overflowing startup tasks. This ensures that the task execution queue does not overflow or overload, while still completing the execution plan for the startup tasks in one go, improving the execution efficiency of the startup tasks.
[0092] For example, in the above Figure 3 The process 300 shown may further include S305 , where S305 may be selected by the execution subject to execute when the execution subject determines that the first number exceeds the second number allowed by the task execution queue after executing S302 .
[0093] S305 , sequentially storing the startup tasks corresponding to the first second number of components to be started in the configuration sequence indicated by the sub-directed acyclic graph into the task execution queue based on the configuration sequence indicated by the sub-directed acyclic graph.
[0094] Specifically, the execution entity can use the second number as a reference to "temporarily split" the sub-directed acyclic graph, and only store the startup tasks corresponding to the first second number of components to be started in the sub-directed acyclic graph into the task execution queue in sequence based on the configuration order indicated by the sub-directed acyclic graph, so as to use the task execution queue to continuously process the startup tasks while controlling the task execution queue to prevent task overflow.
[0095] S306 , storing the startup tasks corresponding to the components to be started that are located after the second number in the configuration order indicated by the sub-directed acyclic graph into the candidate task execution queue based on the configuration order indicated by the sub-directed acyclic graph.
[0096] Specifically, as discussed above, the execution entity may further maintain an alternative task execution queue for temporarily storing, or "caching," startup tasks that cannot currently be stored in the task execution queue all at once (e.g., the portion of the sub-directed acyclic graph that exceeds and is located after the second quantity). In response to the existence of startup task vacancies in the task execution queue, the alternative task execution queue sequentially provides the execution queue with startup tasks for replenishment in the order of the startup tasks stored in the alternative task execution queue.
[0097] Correspondingly, the execution subject can store the startup tasks corresponding to the components to be started after the second quantity into the alternative task execution queue based on the configuration order indicated by the sub-directed acyclic graph. Then, the execution subject and / or the alternative task execution queue can continuously monitor the execution of the startup tasks in the task execution queue. If a startup task is completed in the task execution queue, so that a startup task vacancy is generated and exists in the task execution queue (that is, the startup task vacancy is generated because the startup task that originally occupied the startup task vacancy is removed from the task execution queue after execution), then the alternative task execution queue can continuously provide supplementary startup tasks for the task execution queue based on the storage order. For example, when the task execution queue generates a startup task vacancy, the alternative task execution queue can provide the startup tasks that are stored and ranked first to the task execution queue for supplementation. For another example, when the task execution queue generates two startup task vacancies, the alternative task execution queue can provide the startup tasks that are stored and ranked first and second to the task execution queue for supplementation.
[0098] For this, please refer to Figure 2 As discussed above, the execution entity may choose to schedule, manage, and execute the startup tasks 221, 222, and 224 by at least utilizing the task execution queue 250. For ease of understanding, illustratively, the upper limit number allowed by the task execution queue 250 (i.e., the "second number" mentioned above) is two startup tasks.
[0099] Accordingly, the execution subject determines that the first number of startup tasks corresponding to the components to be started indicated by the sub-directed acyclic graph 243 is three, which exceeds the second number of two. The execution subject may choose to execute S204 and only store the first two startup tasks (startup tasks 221 and 222) in the task execution queue 250 (based on the configuration order indicated by the sub-directed acyclic graph 243, the execution order of startup task 221 is before startup task 222). Then, execute S205 and store the startup task 224 that cannot be temporarily stored in the task execution queue 250 in the alternative task execution queue 255.
[0100] Accordingly, the execution entity (or the alternative task execution queue 255) can, when determining that there is a startup task vacancy in the task execution queue 250 (for example, because after the execution of startup task 221 is completed, startup task 221 is removed from the startup task vacancy generated by the task execution queue 250), add startup task 224 to the task execution queue 250 based on the instruction of the alternative task execution queue 255 (for example, startup task 224 is located after startup task 222), so as to control and manage the startup tasks corresponding to the components to be started indicated by the sub-directed acyclic graph 243 to be executed in sequence and completely, so as to realize the configuration of all the components to be started indicated by the sub-directed acyclic graph 243.
[0101] The embodiment of the present application also provides a device for starting an application, the structure of which is as follows: Figure 4 The device 400 shown. The device 400 includes: a directed acyclic graph construction module 410, which is configured to, in response to receiving a startup request for a target application, construct a directed acyclic graph based on the execution dependency relationship between each to-be-started component in a group of to-be-started components serving the target application; a sub-directed acyclic graph determination module 420, which is configured to determine a sub-directed acyclic graph from the directed acyclic graph based on the startup priority of each to-be-started component, wherein the sub-directed acyclic graph includes all high-priority to-be-started components, and the startup priority of the high-priority to-be-started components is greater than or equal to a preset priority level; a first startup component configuration module 430, which is configured to continuously configure each high-priority to-be-started component based on the configuration order indicated by the sub-directed acyclic graph; a first application startup module 440, which is configured to start the target application in response to the high-priority to-be-started components corresponding to the sub-directed acyclic graph being fully configured.
[0102] In some embodiments, the apparatus 400 further includes: a second startup component configuration module configured to, in response to the target application being successfully started, continuously configure low-priority components to be started other than the high-priority components to be started based on the configuration order indicated by the directed acyclic graph.
[0103] In some embodiments, the directed acyclic graph construction module 410 is further configured to: construct each to-be-started component in a group of to-be-started components serving the target application as a corresponding startup task; determine the task dependency relationship between each startup task; and construct a directed acyclic graph based on the startup tasks and the task dependency relationship, wherein the vertices of the directed acyclic graph are determined based on the startup tasks, and the edges of the directed acyclic graph are determined based on the task dependency relationship.
[0104] In some embodiments, determining the task dependency relationship between each startup task includes: reading a pre-dependency list of the startup task using an annotation mechanism; and determining the task dependency relationship between each startup task using the pre-dependency list.
[0105] In some embodiments, the first startup component configuration module 430 includes: a first quantity determination submodule, configured to determine a first quantity of startup tasks corresponding to the components to be started indicated by the sub-directed acyclic graph; a first startup task storage submodule, configured to store the startup tasks corresponding to each component to be started indicated by the sub-directed acyclic graph in the task execution queue in sequence based on the configuration order indicated by the sub-directed acyclic graph in response to the first quantity not exceeding the second quantity allowed by the task execution queue; the first startup component configuration submodule, configured to use the execution queue to continuously complete each startup task based on the configuration order indicated by the sub-directed acyclic graph, so as to continuously configure each component to be started indicated by the sub-directed acyclic graph.
[0106] In some embodiments, the first startup component configuration module 430 includes: a second startup task storage sub-module, which is configured to, in response to the first number exceeding the second number, store the startup tasks corresponding to the components to be started before the second number in the configuration order indicated by the sub-directed acyclic graph, based on the configuration order indicated by the sub-directed acyclic graph, in the task execution queue in sequence; a supplementary task management sub-module, which is configured to store the startup tasks corresponding to the components to be started after the second number in the configuration order indicated by the sub-directed acyclic graph, based on the configuration order indicated by the sub-directed acyclic graph, in the alternative task execution queue, wherein the alternative task execution queue provides the startup tasks for supplementation to the execution queue in sequence according to the order of the startup tasks stored in the alternative task execution queue in response to the existence of startup task vacancies in the task execution queue.
[0107] In some embodiments, the device 400 also includes: a sub-directed acyclic graph sorting module, configured to perform topological sorting on the sub-directed acyclic graph to obtain a sorted sub-directed acyclic graph; and the first startup component configuration module 430 is further configured to continuously configure each high-priority component to be started based on the configuration order indicated by the sorted sub-directed acyclic graph.
[0108] In some embodiments, the device 400 also includes: a third startup component configuration module, which is configured to, in response to the target application not being successfully started, continuously configure low-priority components to be started other than the high-priority components to be started based on the configuration order indicated by the directed acyclic graph; and a second application startup module, which is configured to start the target application in response to all low-priority components to be started being configured.
[0109] Based on the same inventive concept, an electronic device, a readable storage medium, and a computer program product are also provided in an embodiment of the present application. The method corresponding to the electronic device may be the method for starting an application in the aforementioned embodiment, and its principle of solving the problem is similar to that of the method. The electronic device provided in an embodiment of the present application includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the methods and / or technical solutions of the aforementioned multiple embodiments of the present application.
[0110] An electronic device can be a user device, or a device formed by integrating a user device and a network device via a network, or an application running on any of the above devices. User devices include, but are not limited to, computers, mobile phones, tablets, smart watches, wristbands, and other terminal devices. Network devices include, but are not limited to, network hosts, single network servers, multiple network server clusters, or cloud computing-based computer clusters, and can be used to implement some of the processing functions required for setting an alarm. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing. Cloud computing is a type of distributed computing, consisting of a virtual computer composed of a group of loosely coupled computers.
[0111] Figure 5 The structure of an electronic device suitable for implementing the method and / or technical solution in the embodiment of the present application is shown. The electronic device 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 into the random access memory (RAM) 503. In the RAM 503, various programs and data required for system operation are also stored. The CPU 501, ROM 502 and RAM 503 are connected to each other through a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0112] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, a touch screen, a microphone, an infrared sensor, etc.; an output section 507 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), an LED display, an OLED display, etc., and a speaker; a storage section 508 including one or more computer-readable media such as a hard disk, an optical disk, a magnetic disk, a semiconductor memory, etc.; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet.
[0113] In particular, the methods and / or embodiments in the embodiments of the present application can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the method of the present application are performed.
[0114] Another embodiment of the present application further provides a computer-readable storage medium and a computer program product, on which computer program instructions are stored. The computer program instructions can be executed by a processor to implement the methods and / or technical solutions of any one or more embodiments of the present application.
[0115] Specifically, the present embodiment can adopt any combination of one or more computer-readable media.Computer-readable media can be computer-readable signal media or computer-readable storage media.Computer-readable storage media can be, for example, systems, devices or components including but not limited to electricity, magnetism, light, electromagnetic, infrared, or semiconductors, or any combination thereof.More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination thereof.In this document, computer-readable storage media can be any tangible medium containing or storing a program that can be used by an instruction execution system, device or device or used in combination with it.
[0116] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0117] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0118] The computer program code for performing the operations of the present application can be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0119] The flow chart or block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the equipment, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code include one or more executable instructions for realizing the logical function of the specification. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated system for hardware that performs the function or operation of the specification, or can be implemented with a combination of dedicated hardware and computer instructions.
[0120] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0121] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules and units is only a logical function division. There may be other division methods in actual implementation. For example, with units as an example, for example, multiple units or page components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0122] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0123] In addition, the functional modules and units in the various embodiments of the present application may be integrated into a single processing module or unit, or each module or unit may exist physically separately, or two or more units may be integrated into a single module or unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional modules or units.
[0124] The above-mentioned integrated modules and units implemented in the form of software functional modules and units can be stored in a computer-readable storage medium. The above-mentioned software functional modules and units are stored in a storage medium, including a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program code.
[0125] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
[0126] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a device claim may also be implemented by a single unit or device through software or hardware. Terms such as "first" and "second" are used to indicate names and do not imply any particular order.< / task>
Claims
1. A method for starting an application, comprising: In response to receiving a start request for a target application, constructing a directed acyclic graph based on execution dependency relationships between components to be started in a set of components to be started that serve the target application; Based on the startup priorities of the components to be started, determining a sub-directed acyclic graph from the directed acyclic graph, wherein the sub-directed acyclic graph includes all high-priority components to be started, and the startup priorities of the high-priority components to be started are greater than or equal to a preset priority level; Continuously configuring each of the high-priority components to be started based on the configuration order indicated by the sub-directed acyclic graph; In response to the high-priority to-be-started components corresponding to the sub-directed acyclic graph being completely configured, the target application is started.
2. The method according to claim 1, further comprising: In response to the target application being successfully started, the low-priority to-be-started components other than the high-priority to-be-started components are continuously configured based on the configuration order indicated by the directed acyclic graph.
3. The method according to claim 1, wherein In response to receiving a start request for a target application, constructing a directed acyclic graph based on execution dependency relationships between components to be started in a group of components to be started that serve the target application, including: Each component to be started in a group of components to be started that serve the target application is constructed as a corresponding startup task; Determining task dependencies between the startup tasks; A directed acyclic graph is constructed based on the startup tasks and the task dependencies, wherein vertices of the directed acyclic graph are determined based on the startup tasks, and edges of the directed acyclic graph are determined based on the task dependencies.
4. The method according to claim 3, wherein: Determining the task dependency relationship between the startup tasks includes: Using the annotation mechanism to read the pre-dependency list of the startup task; The task dependency relationship between each of the startup tasks is determined using the pre-dependency list.
5. The method according to claim 3, wherein: The step of continuously configuring each of the high-priority components to be started based on the configuration order indicated by the sub-directed acyclic graph includes: Determine a first number of startup tasks corresponding to the to-be-started components indicated by the sub-directed acyclic graph; In response to the first number not exceeding a second number allowed by the task execution queue, sequentially storing the startup tasks corresponding to the components to be started indicated by the sub-directed acyclic graph into the task execution queue based on the configuration order indicated by the sub-directed acyclic graph; The execution queue is utilized to continuously complete each of the startup tasks based on the configuration sequence indicated by the sub-directed acyclic graph, so as to continuously configure each to-be-started component indicated by the sub-directed acyclic graph.
6. The method according to claim 5, further comprising: In response to the first number exceeding the second number, sequentially storing the startup tasks corresponding to the second number of components to be started in the configuration order indicated by the sub-directed acyclic graph into the task execution queue based on the configuration order indicated by the sub-directed acyclic graph; The startup tasks corresponding to the components to be started that are located after the second number in the configuration order indicated by the sub-directed acyclic graph are stored in an alternative task execution queue based on the configuration order indicated by the sub-directed acyclic graph, wherein the alternative task execution queue responds to the existence of startup task vacancies in the task execution queue and provides the execution queue with startup tasks for supplementation in sequence according to the order of the startup tasks stored in the alternative task execution queue.
7. The method according to claim 1, further comprising: Performing topological sorting on the sub-directed acyclic graph to obtain a sorted sub-directed acyclic graph; And the step of continuously configuring each of the high-priority components to be started based on the configuration order indicated by the sub-directed acyclic graph includes: Based on the configuration order indicated by the sorted sub-directed acyclic graphs, each of the high-priority components to be started is configured continuously.
8. The method according to any one of claims 1 to 7, further comprising: In response to the target application not being successfully started, continuously configuring low-priority components to be started other than the high-priority components to be started based on the configuration order indicated by the directed acyclic graph; In response to the low-priority components to be started being completely configured, the target application is started.
9. A device for starting an application, comprising: a directed acyclic graph construction module configured to, in response to receiving a start request for a target application, construct a directed acyclic graph based on execution dependencies between components to be started in a set of components to be started that serve the target application; a sub-directed acyclic graph determining module configured to determine a sub-directed acyclic graph from the directed acyclic graph based on the startup priorities of the components to be started, wherein the sub-directed acyclic graph includes all high-priority components to be started, and the startup priorities of the high-priority components to be started are greater than or equal to a preset priority level; a first startup component configuration module configured to continuously configure each of the high-priority to-be-started components based on a configuration order indicated by the sub-directed acyclic graph; The first application startup module is configured to start the target application in response to the high-priority to-be-started components corresponding to the sub-directed acyclic graph being completely configured.
10. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
11. A computer-readable medium having computer program instructions stored thereon, wherein the computer program instructions can be executed by a processor to implement the method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 8.