System resource loading method and apparatus, electronic device, and computer storage medium
By performing type division and loading time analysis of system resources, and using multi-threaded loading method, the problem of too long startup time caused by the large size of the software system is solved, and the system startup speed is improved.
Patent Information
- Application Number
- PCT/CN2024/127727
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-03
- Filing Date
- 2024-10-28
- Publication Date
- 2025-07-10
AI Technical Summary
With the update and expansion of hardware functions and systems, the size of the software system becomes larger, resulting in limited hardware performance on embedded platforms and the problem of too long system startup time.
By obtaining the system resources that the system needs to load during the target startup stage, dividing them according to the resource type, multiple grouping units are obtained, collecting the loading time and dividing it into the first resource group and the second resource group. Multi-threaded loading is used when starting the loading process.
It realizes accurate and efficient division of system resources, improves system startup speed, reduces startup time, and ensures stable system operation.
Smart Images

Figure CN2024127727_10072025_PF_FP_ABST
Abstract
Description
System resource loading method, device, electronic device and computer storage medium
[0001] This application claims priority to Chinese patent application filed on January 3, 2024, with application number 202410011231.6, and application name “System resource loading method, device, electronic device and computer storage medium”, all contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of terminal technology, and in particular to a system resource loading method, device, electronic device and computer storage medium. Background Art
[0003] In various consumer electronic products such as televisions and set-top boxes, software systems, such as the Android system, are required to realize the functions of the hardware devices in which they are installed. Technical issues
[0004] However, with the continuous update and expansion of various hardware functions and systems, the size of the software system itself is also gradually increasing. In addition, due to the highly customizable nature of the software system and users, the system also has a large number of system services and application software built into it. This also limits the inherent hardware performance of the embedded platform, resulting in long system startup times. Technical Solutions
[0005] The embodiments of the present application provide a system resource loading method, device, electronic device and computer storage medium, which can solve the technical problem of long system startup time.
[0006] The present invention provides a method for loading system resources, including:
[0007] Acquire system resources that need to be loaded by the system during a target startup phase, and divide the system resources according to resource types of the system resources to obtain a plurality of grouping units;
[0008] Collecting the loading duration of each of the grouping units, dividing the grouping units according to the loading duration to obtain at least two resource groups, the resource groups including a first resource group and a second resource group;
[0009] A loading process of the system is started, and multi-threaded loading of the system resources is performed in the loading process based on the first resource group and the second resource group.
[0010] Furthermore, the system resources are divided according to their resource types to obtain a plurality of grouping units, including:
[0011] Dividing the system resources according to the resource types to obtain multiple class resources and multiple basic resources;
[0012] Obtaining a class package name to which the class resource belongs, and grouping the class resource according to the class package name to obtain a plurality of first grouping units;
[0013] Resource attributes of the basic resources are acquired, and the basic resources are grouped according to the resource attributes to obtain a plurality of second grouping units.
[0014] Furthermore, the above-mentioned collection of the loading duration of each grouping unit includes:
[0015] Obtaining the sub-loading duration corresponding to each of the system resources;
[0016] The sub-loading durations of the system resources in each of the grouping units are counted to obtain the loading duration of each of the grouping units.
[0017] Furthermore, the grouping unit is divided according to the loading duration to obtain at least two resource groups, the resource groups including a first resource group and a second resource group, including:
[0018] Constructing a first queue and a second queue, and filtering a target queue from the first queue and the second queue according to a first basic duration of the first queue and a second basic duration of the second queue;
[0019] Selecting a grouping unit that meets a preset condition from the plurality of grouping units according to the loading time to obtain a target grouping unit, and adding the target grouping unit to the target queue;
[0020] If there are unselected grouping units among the multiple grouping units, the basic duration of the target queue is updated according to the loading duration, and the updated basic duration is used as the basic duration of the target queue until there are no unselected grouping units. Then, the first queue that has been selected is used as the first resource group, and the second queue that has been selected is used as the second resource group.
[0021] Furthermore, the above-mentioned step of selecting a grouping unit that meets a preset condition from the plurality of grouping units according to the loading duration to obtain a target grouping unit includes:
[0022] sorting the plurality of grouping units according to the loading duration to obtain a sorting sequence;
[0023] According to the position of each grouping unit in the sorting sequence, a grouping unit that meets a preset condition is selected from the sorting sequence as the target grouping unit.
[0024] Furthermore, the above-mentioned selecting, according to the position of each grouping unit in the sorting sequence, a grouping unit that meets a preset condition from the sorting sequence as the target grouping unit includes:
[0025] Selecting a grouping unit from the sorting sequence as a candidate unit according to the position of each grouping unit in the sorting sequence; and determining whether there is a dependency relationship between the candidate unit and the grouping unit in the target queue;
[0026] If the dependency relationship exists between the candidate unit and any grouping unit in the target queue, the candidate unit is determined to be the target grouping unit.
[0027] Furthermore, the system resources are divided according to their resource types to obtain a plurality of grouping units, including:
[0028] Screening out candidate resources and driver resources from the system resources;
[0029] Dividing the candidate resources according to their resource types to obtain a plurality of grouping units;
[0030] The starting of the loading process of the system and performing multi-threaded loading of the system resources in the loading process based on the first resource group and the second resource group include:
[0031] Creating a third resource group corresponding to the driver resource;
[0032] A loading process of the system is started, and based on the first resource group, the second resource group, and the third resource group, multi-threaded loading is performed on the system resources in the loading process.
[0033] Accordingly, an embodiment of the present application provides a system resource loading device, comprising:
[0034] an acquisition module, configured to acquire system resources that need to be loaded by the system during a target startup phase, and to divide the system resources according to their resource types to obtain a plurality of grouping units;
[0035] a grouping module, configured to collect the loading duration of each of the grouping units, and divide the grouping units according to the loading duration to obtain at least two resource groups, wherein the resource groups include a first resource group and a second resource group;
[0036] The loading module is used to start a loading process of the system and perform multi-threaded loading of the system resources in the loading process based on the first resource group and the second resource group.
[0037] In addition, an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the system resource loading method provided in the embodiment of the present application.
[0038] In addition, an embodiment of the present application further provides a computer storage medium, wherein the computer storage medium stores a computer program, and the computer program is suitable for loading by a processor to execute any system resource loading method provided in the embodiment of the present application.
[0039] In addition, an embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements any system resource loading method provided in the embodiment of the present application. Beneficial effects
[0040] In an embodiment of the present application, by obtaining the system resources that need to be loaded by the system in the target startup phase, the system resources are divided according to the resource type of the system resources to obtain multiple grouping units, thereby realizing a preliminary division of the system resources; thereafter, the loading time of each grouping unit is collected, and the grouping units are divided according to the loading time to obtain at least two resource groups, the resource groups including a first resource group and a second resource group, thereby realizing a further precise division of the system resources; then, the loading process of the system is started, and the system resources are multi-threaded loaded in the loading process based on the first resource group and the second resource group, thereby realizing a precise and efficient division of the system resources, thereby improving the system startup speed and reducing the system startup time while ensuring the stable operation of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0042] FIG1 is a flow chart of an embodiment of a method for loading system resources provided by the present application;
[0043] FIG2 is a flow chart of another embodiment of the system resource loading method provided by the present application;
[0044] FIG3 is a flow chart of another embodiment of the system resource loading method provided by the present application;
[0045] FIG4 is a schematic diagram of the structure of a system resource loading device provided in an embodiment of the present application;
[0046] FIG5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Modes for Carrying Out the Invention
[0047] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0048] The embodiments of the present application provide a system resource loading method, device, electronic device, and computer storage medium. The system resource loading device can be integrated into an electronic device, which can be a server, a terminal, or other device.
[0049] Among them, the server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), as well as big data and artificial intelligence platforms.
[0050] The terminal may be a smart system, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited thereto. The terminal and the server may be connected directly or indirectly via wired or wireless communication, and this application does not impose any restrictions thereon.
[0051] In addition, the term "a plurality of" in the embodiments of the present application refers to two or more than two. The terms "first" and "second" in the embodiments of the present application are used to distinguish descriptions and should not be understood to imply relative importance.
[0052] It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.
[0053] Please refer to Figure 1, which is a flow chart of a system resource loading method provided by an embodiment of the present application. The system resource loading method may include:
[0054] S101: Obtain system resources that need to be loaded during a target startup phase of the system, and divide the system resources according to their resource types to obtain a plurality of grouping units.
[0055] In this embodiment, before the system is started, the system resources that need to be loaded during the target startup phase are pre-acquired. The target startup phase is the phase in which the system prepares for virtual machine operation, such as the Zygote phase in the Android system. During this target startup phase, the system needs to pre-load resources required for virtual machine operation, such as classes, so, jar packages, font and graphics libraries, and other resources. These system resources are the resources required to run the virtual machine corresponding to the system. All system resources are divided according to their resource types to obtain multiple grouping units. Specifically, the resource types of system resources can be divided into class resource types and basic types. System resources are divided according to these class resource types and basic types to obtain multiple class resources and multiple basic resources. Class resources are class files required for the current system virtual machine to run and for system services, and basic resources are basic operating resources required for the system's corresponding virtual machine to run, such as graphics operating resources (Drawables). The class resources and basic resources are then grouped separately to obtain multiple grouping units.
[0056] Among them, there are multiple class resources and basic resources. All class resources can be divided into multiple first grouping units based on the categories to which each type of resource belongs. One category corresponds to one first grouping unit. One first grouping unit includes at least one class resource. Class resources in the same first grouping unit correspond to the same category. All basic resources can be divided into multiple second grouping units based on the resource type of the basic resources. One resource type corresponds to one second grouping unit. One second grouping unit includes at least one basic resource. Basic resources in the same second grouping unit correspond to the same resource type.
[0057] S102: Collect the loading duration of each of the grouping units, and divide the grouping units according to the loading duration to obtain at least two resource groups, where the resource groups include a first resource group and a second resource group.
[0058] In this embodiment, each grouping unit includes at least one system resource, and the sub-loading durations of all system resources in the grouping unit are summed up to obtain the loading duration corresponding to each grouping unit. The sub-loading duration of each system resource can be determined by determining the startup loading duration of each type of resource and each basic resource during the test process, and the sub-loading duration corresponding to each system resource may be different. When the loading duration corresponding to each grouping unit is obtained, all grouping units are divided according to the loading duration to obtain a first resource group and a second resource group. Specifically, when the loading duration corresponding to each grouping unit is obtained, a group set consisting of all grouping units is constructed. The group set is divided into a first resource group and a second resource group according to the loading duration, so that the difference between the basic durations corresponding to the first resource group and the second resource group is within a preset range.
[0059] In addition, two empty queues can be constructed, namely the first queue and the second queue. When dividing the group set, two grouping units are selected from the group set. The two grouping units are divided into the first queue and the second queue, respectively, and the loading durations corresponding to the two grouping units are used as the initial base durations of the first queue and the second queue, respectively. Then, the base durations of the first queue and the second queue are compared, and a target queue is selected from the first queue and the second queue based on the comparison results. A grouping unit is selected from the remaining grouping units in the group set except the two grouping units as the target grouping unit, and the target grouping unit is added to the target queue. Each time the target grouping unit is divided, the base duration of the target queue is updated. The base duration of the target queue is the cumulative loading duration of all grouping units in the target queue. The base duration of the current target queue is compared with the base duration of another queue. Based on the comparison results, a target queue is selected again, and a target grouping unit is selected from the group set again and added to the currently selected target queue; this continues until all grouping units in the group set are divided into corresponding queues. Thus, the group set is divided. The first queue obtained after the division is the first resource group, and the second queue obtained after the division is the second resource group.
[0060] S103: Start a loading process of the system, and perform multi-threaded loading of the system resources in the loading process based on the first resource group and the second resource group.
[0061] In this embodiment, the loading process of the system is a process corresponding to the system target startup phase, such as the process corresponding to the Zygote startup phase in the Android system. In the process corresponding to the target startup phase, the resources in the first resource group and the resources in the second resource group are loaded at the same time, that is, the rapid loading of all system resources is achieved. Specifically, a first loading task corresponding to all system resources in the first resource group and a first loading thread corresponding to the first resource group are created; a second loading task corresponding to all system resources in the second resource group and a second loading thread corresponding to the second resource group are created. When the loading process of the system is started, the first loading thread and the second loading thread are run in parallel in the loading process, and the first loading task and the second loading task are executed in parallel based on the first loading thread and the second loading thread. In this way, the rapid loading of system resources in the loading process started by the system is achieved.
[0062] The system resource loading method proposed in the present application obtains all system resources that need to be loaded by the system in the target startup phase, divides the system resources according to the resource type of the system resources, and obtains multiple grouping units; then, collects the loading time of each grouping unit, and divides the grouping units according to the loading time to obtain a first resource group and a second resource group; then, starts the loading process of the system, and performs multi-threaded loading of the system resources based on the first resource group and the second resource group in the loading process, thereby realizing accurate and efficient division of system resources, thereby ensuring stable operation of the system while improving the system startup speed and reducing the system startup time.
[0063] As shown in FIG. 2 , FIG. 2 is a flow chart of another embodiment of the present application. In some embodiments of the present application, the system resources are divided according to the resource type of the system resources to obtain multiple grouping units, including:
[0064] S201, dividing the system resources according to the resource types to obtain multiple class resources and multiple basic resources;
[0065] S202: Obtain the class package name to which the class resource belongs, and group the class resources according to the class package name to obtain a plurality of first grouping units;
[0066] S203: Acquire resource attributes of the basic resources, and group the basic resources according to the resource attributes to obtain a plurality of second grouping units.
[0067] In this embodiment, system resources are divided according to resource types to obtain class resources and basic resources. The class package (pkg) name to which each type of resource belongs is obtained, and the class package to which each class resource belongs can be determined based on the class package name, thereby obtaining a first grouping unit for class resource division. Specifically, each type of resource is grouped according to the class package name to obtain first grouping units corresponding to different class package names, and all class resources under the same first grouping unit have the same class package name. The resource attributes of each basic resource are obtained, and each basic resource is grouped according to the resource attributes to obtain a plurality of second grouping units corresponding to different resource attributes. Among them, the resource attributes of the basic resource can be determined by the file name of the basic resource or the source library of the basic resource, and the resource attributes corresponding to all basic resources under the same second grouping unit are the same.
[0068] This embodiment divides system resources into class resources and basic resources by resource type. Then, the class resources and basic resources are divided according to the class package name and resource attributes respectively to obtain the first grouping unit and the second grouping unit, thereby realizing the preliminary grouping of class resources and basic resources, improving the precision and accuracy of system resource grouping, and avoiding the problem of unstable system operation caused by unclear grouping.
[0069] In some embodiments of the present application, the collecting of the loading duration of each grouping unit includes:
[0070] Obtaining the sub-loading duration corresponding to each of the system resources;
[0071] The sub-loading duration of the system resources in each of the grouping units is counted to obtain the loading duration of each of the grouping units. In this embodiment, the sub-loading duration is the loading duration required for each system resource during the target startup phase. The sub-loading duration corresponding to each system resource is obtained, and then the sub-loading duration of the system resources in each grouping unit is counted to obtain the loading duration of each grouping unit. In one embodiment, while grouping the class resources in the system resources, the loading duration of the grouping units corresponding to the class resources can also be counted. Specifically, when determining all the class resources in the system resources, the class resources are loaded in sequence. Each time a class resource is loaded, it is determined whether the class resource and the previously loaded class resource are resources of the same category. If the current class resource and the previously loaded class resource are class resources of the same category, the sub-loading duration of the current class resource of the category is added to the sub-loading duration of the previously loaded class resource of the category to obtain the loading duration of the current grouping unit corresponding to the category. If the current class resource and the last loaded class resource are not of the same category, a new variable will be created for the category corresponding to the current class resource, and the new variable will be a new grouping unit. The sub-loading durations of the class resources belonging to the new variable are accumulated to obtain the loading duration of the grouping unit corresponding to the new variable. All class resources are loaded in sequence, and the category of the class resource and the last loaded class resource is judged, and the sub-loading durations of class resources of the same category are accumulated; new variables are created for class resources of different categories until all class resources are loaded. In this way, the grouping of all class resources and the calculation of the loading duration of each grouping unit are completed.
[0072] This embodiment obtains the sub-loading duration corresponding to each system resource, and then counts the sub-loading duration of the system resources in each grouping unit to obtain the loading duration of each grouping unit, thereby achieving accurate and efficient statistics of the loading duration of each grouping unit and further improving the system startup speed.
[0073] As shown in FIG3 , FIG3 is a flow chart provided by another embodiment of the present application. In some embodiments of the present application, the grouping unit is divided according to the loading duration to obtain at least two resource groups, the resource groups including a first resource group and a second resource group, including:
[0074] S301: Construct a first queue and a second queue, and select a target queue from the first queue and the second queue according to a first basic duration of the first queue and a second basic duration of the second queue;
[0075] S302: Select a grouping unit that meets a preset condition from the plurality of grouping units according to the loading duration to obtain a target grouping unit, and add the target grouping unit to the target queue;
[0076] S303. If there are unselected grouping units among the multiple grouping units, the basic duration of the target queue is updated according to the loading duration, and the updated basic duration is used as the basic duration of the target queue until there are no unselected grouping units. Then, the first queue that has been selected is used as the first resource group, and the second queue that has been selected is used as the second resource group.
[0077] In this embodiment, the first queue and the second queue are two pre-set empty queues, and the first queue and the second queue respectively correspond to different basic durations, wherein the first queue corresponds to the first basic duration, and the second queue corresponds to the second basic duration, and the basic duration can be a preset duration. Construct the first queue and the second queue, and filter out the target queue from the first queue and the second queue based on the first basic duration and the second basic duration. Specifically, compare the first basic duration and the second basic duration. If the first basic duration is greater than the second basic duration, the second queue is determined to be the target queue; if the second basic duration is greater than the first basic duration, the first queue is determined to be the target queue. In the initial state (that is, when the grouping units are not divided into corresponding queues), the basic durations of the first queue and the second queue are preset durations.
[0078] Then, based on the loading time of each grouping unit, a grouping unit that meets the preset conditions is selected from the multiple grouping units and added to the target queue. The grouping unit that meets the preset conditions is the target grouping unit. Specifically, all grouping units are sorted according to the loading time to obtain a sorted sequence. From the sorted sequence, a grouping unit whose position meets the preset target position is selected as the target grouping unit. For example, the grouping unit whose position is the first in the sorted sequence is selected as the target grouping unit. This target grouping unit is added to the target queue.
[0079] After the target grouping unit is added to the target queue, determine whether there are any unselected grouping units among the current multiple grouping units. If there are unselected grouping units, the basic duration of the target queue is updated according to the loading duration, and the updated basic duration is used as the basic duration of the target queue until there are no unselected grouping units. Specifically, when there are unselected grouping units, the loading duration corresponding to the selected target grouping unit is obtained, and the loading duration is accumulated with the basic duration of the target queue to obtain the updated basic duration; the updated basic duration is used as the basic duration of the target queue. When the target queue is the first queue, the basic duration of the target queue is the first basic duration; when the target queue is the second queue, the basic duration of the target queue is the second basic duration. Then, return to execute the step of filtering out the target queue from the first queue and the second queue according to the first basic duration of the first queue and the second basic duration of the second queue, until all grouping units are selected. If there is no unselected grouping unit among the multiple grouping units, which means that all grouping units have been selected, the first queue that has been selected is used as the first resource group, and the second queue that has been selected is used as the second resource group.
[0080] For example, when the first basic duration corresponding to the first queue and the second basic duration corresponding to the second queue are obtained for the first time, if the first basic duration is greater than the second basic duration, the second queue is determined to be the target queue. The first grouping unit is obtained according to the order of the grouping units in all the grouping units as the target grouping unit. The target grouping unit is divided into the second queue. Then, it is determined whether there are any unselected grouping units among the multiple grouping units. If so, the loading duration corresponding to the target grouping unit is accumulated with the second basic duration of the second queue to obtain an updated second basic duration, and the updated second basic duration is used as the second basic duration of the second queue. Thereafter, the first basic duration and the second basic duration are compared. If the second basic duration is greater than the first basic duration, the first queue is determined to be the target queue. The second grouping unit is obtained according to the order of the grouping units in all the grouping units as the target grouping unit. The target grouping unit is divided into the first queue. Determine whether there are any unselected grouping units among the multiple grouping units. If so, accumulate the loading duration corresponding to the target grouping unit with the first basic duration of the first queue to obtain an updated first basic duration, and use the updated first basic duration as the first basic duration of the first queue. Continue until all grouping units are selected and no unselected grouping units exist among all grouping units. The first resource group is the first queue after division, and the second resource group is the second queue after division.
[0081] This embodiment achieves accurate and efficient division of grouping units, thereby improving the startup speed of the system.
[0082] In some embodiments of the present application, the step of selecting a grouping unit that meets a preset condition from the plurality of grouping units according to the loading duration to obtain a target grouping unit includes:
[0083] sorting the plurality of grouping units according to the loading duration to obtain a sorting sequence;
[0084] According to the position of each grouping unit in the sorting sequence, a grouping unit that meets a preset condition is selected from the sorting sequence as the target grouping unit.
[0085] In this embodiment, there are multiple grouping units, and the grouping units are sorted according to the loading time corresponding to each grouping unit to obtain a sorting sequence. Specifically, the grouping unit corresponding to the smallest loading time among all the grouping units is obtained, and the grouping unit corresponding to the smallest loading time is used as the first grouping unit. All the grouping units are arranged in ascending order according to the loading time to obtain the arranged grouping units, that is, the sorting sequence is obtained. In addition, the grouping unit corresponding to the largest loading time among all the grouping units can also be obtained, and the grouping unit corresponding to the largest loading time is used as the first grouping unit. All the grouping units are arranged in descending order according to the loading time to obtain a sorting sequence. When obtaining the sorting sequence, according to the position of each grouping unit in the sorting sequence, the grouping unit that meets the preset conditions is selected from the sorting sequence as the target grouping unit. The preset condition can be a preset target position. The grouping unit with the preset target position is selected from the sorting sequence as the target grouping unit.
[0086] This embodiment sorts the grouping units by loading time to obtain a sorting sequence, and selects the grouping units that meet preset conditions from the sorting sequence as target grouping units according to the position of each grouping unit in the sorting sequence, thereby achieving rapid sorting of the grouping units and improving the screening efficiency of the target grouping units.
[0087] In some embodiments of the present application, the step of selecting, from the sorted sequence according to the position of each grouping unit in the sorted sequence, a grouping unit that meets a preset condition as the target grouping unit includes:
[0088] Selecting a grouping unit from the sorting sequence as a candidate unit according to the position of each grouping unit in the sorting sequence; and determining whether there is a dependency relationship between the candidate unit and the grouping unit in the target queue;
[0089] If the dependency relationship exists between the candidate unit and any grouping unit in the target queue, the candidate unit is determined to be the target grouping unit.
[0090] In this embodiment, the queue corresponding to the grouping unit can also be determined based on the dependency relationship. Specifically, each grouping unit in the sorted sequence has a corresponding sorting number, and the position of the candidate unit in the sorted sequence can be determined based on this sorting number. When selecting grouping units from the sorted sequence, grouping units can be selected sequentially according to their sorting numbers, either from smallest to largest or from largest to smallest, with the selected grouping units being used as candidate units. Each time a selection is completed, the sorted sequence is updated, i.e., the selected grouping units are removed from the sorted sequence to obtain an updated sorted sequence. The next time a selection is made, the remaining grouping units are selected from the updated sorted sequence. Therefore, when selecting grouping units in the aforementioned ascending order, each selected grouping unit is the first grouping unit in the current sorted sequence; when selecting grouping units in the aforementioned descending order, each selected grouping unit is the last grouping unit in the current sorted sequence. Furthermore, grouping units can also be selected from the middle or other positions based on their position in the sorted sequence to obtain candidate units.
[0091] When selecting a candidate unit from the sorted sequence, determine whether there is a dependency relationship between the candidate unit and the grouping units in the target queue. Specifically, the dependency relationship is the relationship between the candidate unit and the grouping units already in the target queue. If there is a dependency relationship between the candidate unit and any grouping unit already in the target queue, the candidate unit is assigned to the target queue. If there is no dependency relationship between the candidate unit and any grouping unit already in the target queue, the candidate unit is assigned to a queue other than the target queue.
[0092] This embodiment selects candidate units from the sorting sequence and obtains the dependency relationship between the candidate units and the grouping units in the target queue, so that the candidate units with dependencies can be divided into the same queue, and further makes the system have better stability when the first resource group and the second resource group are obtained during operation.
[0093] In some embodiments of the present application, the system resources are divided according to their resource types to obtain multiple grouping units, including:
[0094] Screening out candidate resources and driver resources from the system resources;
[0095] Dividing the candidate resources according to their resource types to obtain a plurality of grouping units;
[0096] The starting of the loading process of the system and performing multi-threaded loading of the system resources in the loading process based on the first resource group and the second resource group include:
[0097] Creating a third resource group corresponding to the driver resource;
[0098] A loading process of the system is started, and based on the first resource group, the second resource group, and the third resource group, multi-threaded loading is performed on the system resources in the loading process.
[0099] In this embodiment, in order to divide the system resources more accurately, when obtaining the system resources that need to be loaded in the target startup phase, candidate resources and driver resources are screened out from the system resources. Among them, candidate resources include class resources and basic resources, and driver resources are resources other than class resources and basic resources in the system resources in the target startup phase. The driver resources specifically include system fonts, drivers, and shared objects (so, share objects) and other resources. In addition, the driver resources can also be divided into the basic resources of the candidate resources. When the driver resources are divided into the basic resources, there is no need to screen candidate resources and driver resources from the system resources. All system resources can be directly divided according to the resource type corresponding to the system resources to obtain grouping units; the grouping units can be processed according to the loading time.
[0100] When candidate resources and driver resources are obtained, the candidate resources are divided according to their resource types to obtain multiple grouping units. The loading time of each grouping unit is collected, and the grouping units are divided according to the loading time to obtain the first resource group and the second resource group finally divided by the candidate resources. For driver resources, a third resource group corresponding to the driver resource is created. When loading system resources, loading threads corresponding to the first resource group, the second resource group, and the third resource group are created respectively. The loading threads corresponding to the three resource groups are run in parallel during the loading process, thereby achieving rapid loading of all system resources.
[0101] This embodiment selects candidate resources and driver resources from system resources, processes the candidate resources and driver resources respectively, and then performs multi-threaded parallel loading on the first resource group, the second resource group corresponding to the candidate resources, and the third resource group corresponding to the driver resources, thereby achieving accurate loading of system resources and further improving the division accuracy and loading speed of system resources. In order to facilitate better implementation of the system resource loading method provided in the embodiment of the present application, the embodiment of the present application also provides a device based on the above-mentioned system resource loading method. The meaning of the terms is the same as in the above-mentioned system resource loading method. For specific implementation details, please refer to the description in the method embodiment.
[0102] For example, as shown in FIG4 , the system resource loading apparatus may include: an acquisition module 401, a grouping module 402, and a loading module 403. The acquisition module 401 is configured to acquire system resources that need to be loaded during the target startup phase, and to divide the system resources according to their resource types to obtain a plurality of grouping units;
[0103] A grouping module 402 is configured to collect the loading duration of each of the grouping units, and divide the grouping units according to the loading duration to obtain at least two resource groups, wherein the resource groups include a first resource group and a second resource group;
[0104] The loading module 403 is configured to start a loading process of the system and perform multi-threaded loading of the system resources in the loading process based on the first resource group and the second resource group.
[0105] In one embodiment of the present application, the acquisition module 401 includes:
[0106] a division unit, configured to divide the system resources according to the resource types to obtain a plurality of class resources and a plurality of basic resources;
[0107] A first grouping unit is configured to obtain a class package name to which the class resource belongs, and group the class resource according to the class package name to obtain a plurality of first grouping units;
[0108] The second grouping unit is configured to obtain resource attributes of the basic resources, and group the basic resources according to the resource attributes to obtain a plurality of second grouping units.
[0109] In one embodiment of the present application, the grouping module 402 includes:
[0110] An acquiring unit, configured to acquire a sub-loading duration corresponding to each of the system resources;
[0111] The statistical unit is used to collect statistics on the sub-loading durations of the system resources in each of the grouping units to obtain the loading durations of each of the grouping units.
[0112] In one embodiment of the present application, the grouping module 402 includes:
[0113] a construction unit, configured to construct a first queue and a second queue, and filter out a target queue from the first queue and the second queue according to a first basic duration of the first queue and a second basic duration of the second queue;
[0114] a selection unit, configured to select a grouping unit that meets a preset condition from the plurality of grouping units according to the loading time, obtain a target grouping unit, and add the target grouping unit to the target queue;
[0115] An updating unit is used to update the basic duration of the target queue according to the loading duration if there are unselected grouping units among the multiple grouping units, and use the updated basic duration as the basic duration of the target queue until there are no unselected grouping units, then the first queue that has been selected will be used as the first resource group, and the second queue that has been selected will be used as the second resource group.
[0116] In one embodiment of the present application, the selection unit includes:
[0117] a sorting unit, configured to sort the plurality of grouping units according to the loading duration to obtain a sorting sequence;
[0118] The selection subunit is used to select a grouping unit that meets a preset condition from the sorting sequence as the target grouping unit according to the position of each grouping unit in the sorting sequence.
[0119] In one embodiment of the present application, the selection subunit includes:
[0120] Candidate units, configured to select grouping units from the sorting sequence as candidate units according to positions of the grouping units in the sorting sequence;
[0121] A dependency confirmation unit is used to determine whether there is a dependency relationship between the candidate unit and the grouping units in the target queue; a target confirmation unit is used to determine that the candidate unit is the target grouping unit if there is the dependency relationship between the candidate unit and any grouping unit in the target queue.
[0122] In one embodiment of the present application, the system resource loading device further includes:
[0123] A screening unit, configured to screen candidate resources and driver resources from the system resources;
[0124] an initial division unit, configured to divide the candidate resources according to their resource types to obtain a plurality of grouping units;
[0125] a creating unit, configured to create a third resource group corresponding to the driving resource;
[0126] The loading unit is configured to start a loading process of the system, and perform multi-threaded loading of the system resources in the loading process based on the first resource group, the second resource group, and the third resource group.
[0127] The system resource loading device proposed in this application realizes the accurate and efficient division of system resources, thereby improving the system startup speed and reducing the system startup time while ensuring the stable operation of the system.
[0128] During specific implementation, the above modules can be implemented as independent entities, or they can be arbitrarily combined and implemented as the same or several entities. The specific implementation methods and corresponding beneficial effects of the above modules can be found in the previous method embodiments and will not be repeated here.
[0129] The present application also provides an electronic device, which may be a server or a terminal, etc. As shown in FIG5 , it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application. Specifically:
[0130] The electronic device may include one or more processing cores (processors 601), one or more computer storage media (memory 602), a power supply 603, an input unit 604, and other components. Those skilled in the art will appreciate that the electronic device structure shown in FIG5 does not limit the electronic device and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0131] Processor 601 is the control center of the electronic device. It connects all parts of the electronic device using various interfaces and circuits. It executes computer programs and / or modules stored in memory 602 and accesses data stored in memory 602 to perform various functions of the electronic device and process data. Optionally, processor 601 may include one or more processing cores. Preferably, processor 601 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 601.
[0132] The memory 602 can be used to store computer programs and modules. The processor 601 executes various functional applications and data processing by running the computer programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, a computer program required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 602 may also include a memory controller to provide the processor 601 with access to the memory 602.
[0133] The electronic device also includes a power supply 603 for supplying power to various components. Preferably, the power supply 603 can be logically connected to the processor 601 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 603 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0134] The electronic device may further include an input unit 604, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically in this embodiment, the processor 601 in the electronic device will load the executable files corresponding to the processes of one or more computer programs into the memory 602 according to the following instructions, and the processor 601 will run the computer programs stored in the memory 602 to implement various functions, such as:
[0135] Acquire system resources that need to be loaded by the system during a target startup phase, and divide the system resources according to resource types of the system resources to obtain a plurality of grouping units;
[0136] Collecting the loading duration of each of the grouping units, dividing the grouping units according to the loading duration to obtain at least two resource groups, the resource groups including a first resource group and a second resource group;
[0137] A loading process of the system is started, and multi-threaded loading of the system resources is performed in the loading process based on the first resource group and the second resource group.
[0138] The electronic device proposed in this application realizes the accurate and efficient division of system resources, thereby ensuring the stable operation of the system while improving the system startup speed and reducing the system startup time.
[0139] The specific implementation methods and corresponding beneficial effects of the above operations can be found in the detailed description of the system resource loading method above, which will not be repeated here.
[0140] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by a computer program, or by controlling related hardware through a computer program. The computer program may be stored in a computer storage medium and loaded and executed by a processor.
[0141] To this end, an embodiment of the present application provides a computer storage medium storing a computer program that can be loaded by a processor to execute the steps of any of the system resource loading methods provided in the embodiments of the present application. For example, the computer program can execute the following steps:
[0142] Acquire system resources that need to be loaded by the system during a target startup phase, and divide the system resources according to resource types of the system resources to obtain a plurality of grouping units;
[0143] Collecting the loading duration of each of the grouping units, dividing the grouping units according to the loading duration to obtain at least two resource groups, the resource groups including a first resource group and a second resource group;
[0144] A loading process of the system is started, and multi-threaded loading of the system resources is performed in the loading process based on the first resource group and the second resource group.
[0145] The computer storage medium proposed in this application realizes the accurate and efficient division of system resources, thereby improving the system startup speed and reducing the system startup time while ensuring the stable operation of the system.
[0146] The specific implementation methods and corresponding beneficial effects of the above operations can be found in the previous embodiments and will not be repeated here. The computer storage medium may include: read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.
[0147] Since the computer program stored in the computer storage medium can execute the steps in any system resource loading method provided in the embodiments of the present application, the beneficial effects that can be achieved by any system resource loading method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0148] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer storage medium. A processor of a computer device reads the computer instructions from the computer storage medium and executes the computer instructions, causing the computer device to perform the above-described system resource loading method.
[0149] The above is a detailed introduction to a system resource loading method, device, electronic device and computer storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A system resource loading method, wherein, The method includes: Obtaining system resources that need to be loaded during a target startup phase, dividing the system resources according to the resource types of the system resources to obtain a plurality of grouping units; Collecting the loading durations of the respective grouping units, dividing the grouping units according to the loading durations to obtain at least two resource groups, the resource groups including a first resource group and a second resource group; Starting the loading process of the system, and performing multi-threaded loading of the system resources based on the first resource group and the second resource group during the loading process.
2. The system resource loading method according to claim 1, wherein, The dividing the system resources according to the resource types of the system resources to obtain a plurality of grouping units includes: Dividing the system resources according to the resource types to obtain a plurality of class resources and a plurality of basic resources; Obtaining the class package names to which the class resources belong, and grouping the class resources according to the class package names to obtain a plurality of first grouping units; Obtaining the resource attributes of the basic resources, and grouping the basic resources according to the resource attributes to obtain a plurality of second grouping units.
3. The system resource loading method according to claim 1, wherein, The collecting the loading durations of the respective grouping units includes: Obtaining the sub-loading durations corresponding to the respective system resources; Counting the sub-loading durations of the system resources in the respective grouping units to obtain the loading durations of the respective grouping units.
4. The system resource loading method according to claim 3, wherein, The counting the sub-loading durations of the system resources in the respective grouping units to obtain the loading durations of the respective grouping units includes: Adding up the sub-loading durations of the system resources in the respective grouping units to obtain the loading durations of the respective grouping units.
5. The system resource loading method according to claim 1, wherein, The dividing the grouping units according to the loading durations to obtain at least two resource groups, the resource groups including a first resource group and a second resource group, includes: Constructing a first queue and a second queue, and screening out a target queue from the first queue and the second queue according to a first basic duration of the first queue and a second basic duration of the second queue; Selecting grouping units that meet a preset condition from the plurality of grouping units according to the loading durations to obtain target grouping units, and adding the target grouping units to the target queue; If there are unselected grouping units among the plurality of grouping units, then updating the basic duration of the target queue according to the loading durations, and using the updated basic duration as the basic duration of the target queue until there are no unselected grouping units, then taking the selected first queue as the first resource group and taking the selected second queue as the second resource group.
6. The system resource loading method according to claim 5, wherein, The constructing a first queue and a second queue includes: Selecting two of the grouping units, and respectively dividing the two grouping units into the first queue and the second queue.
7. The system resource loading method according to claim 6, wherein, The first basic duration includes the loading duration of the grouping unit corresponding to the first queue; The second basic duration includes the loading duration of the grouping unit corresponding to the second queue.
8. The system resource loading method according to claim 5, wherein, The selecting grouping units that meet a preset condition from the plurality of grouping units according to the loading durations to obtain target grouping units includes: Sorting the plurality of grouping units according to the loading durations to obtain a sorting sequence; Select, according to the positions of the grouping units in the sorting sequence, the grouping units that meet the preset conditions from the sorting sequence as the target grouping units.
9. The system resource loading method according to claim 8, wherein, The step of selecting, according to the positions of the grouping units in the sorting sequence, the grouping units that meet the preset conditions from the sorting sequence as the target grouping units includes: Select grouping units from the sorting sequence as candidate units according to the positions of the grouping units in the sorting sequence; Determine whether there is a dependency relationship between the candidate units and the grouping units in the target queue; If there is the dependency relationship between the candidate unit and any one of the grouping units in the target queue, determine the candidate unit as the target grouping unit.
10. The system resource loading method according to claim 1, wherein, The step of dividing the system resources according to the resource types of the system resources to obtain a plurality of grouping units includes: Screen out candidate resources and driver resources from the system resources; Divide the candidate resources according to the resource types of the candidate resources to obtain a plurality of the grouping units; The step of starting the loading process of the system and performing multi-threaded loading on the system resources based on the first resource group and the second resource group in the loading process includes: Create a third resource group corresponding to the driver resources; Start the loading process of the system, and perform multi-threaded loading on the system resources in the loading process based on the first resource group, the second resource group, and the third resource group.
11. The system resource loading method according to claim 1, wherein, The step of starting the loading process of the system and performing multi-threaded loading on the system resources based on the first resource group and the second resource group in the loading process includes: Create a first loading task corresponding to the system resources in the first resource group and a first loading thread corresponding to the first resource group; Create a second loading task corresponding to the system resources in the second resource group and a second loading thread corresponding to the second resource group; Run the first loading thread and the second loading thread in parallel in the loading process, and execute the first loading task and the second loading task in parallel based on the first loading thread and the second loading thread.
12. A system resource loading device, wherein, The device includes: An acquisition module, configured to acquire the system resources that need to be loaded in the target startup phase of the system, and divide the system resources according to the resource types of the system resources to obtain a plurality of grouping units; A grouping module, configured to collect the loading durations of the grouping units, and divide the grouping units according to the loading durations to obtain at least two resource groups, where the resource groups include a first resource group and a second resource group; A loading module, configured to start the loading process of the system, and perform multi-threaded loading on the system resources based on the first resource group and the second resource group in the loading process.
13. The system resource loading device according to claim 12, wherein, The acquisition module includes: A dividing unit, configured to divide the system resources according to the resource types to obtain a plurality of class resources and a plurality of basic resources; A first grouping unit, configured to obtain the class package names to which the class resources belong, and group the class resources according to the class package names to obtain a plurality of first grouping units; A second grouping unit, configured to obtain the resource attributes of the basic resources, group the basic resources according to the resource attributes, and obtain a plurality of second grouping units.
14. The system resource loading device according to claim 12, wherein, The grouping module includes: An obtaining unit, configured to obtain the sub-loading duration corresponding to each of the system resources; A statistical unit, configured to statistically calculate the sub-loading duration of the system resources in each of the grouping units to obtain the loading duration of each of the grouping units.
15. The system resource loading device according to claim 12, wherein, The grouping module includes: A constructing unit, configured to construct a first queue and a second queue, and filter out a target queue from the first queue and the second queue according to the first basic duration of the first queue and the second basic duration of the second queue; A selecting unit, configured to select a grouping unit that meets a preset condition from a plurality of the grouping units according to the loading duration to obtain a target grouping unit, and add the target grouping unit to the target queue; An updating unit, configured to, if there are unselected grouping units among the plurality of grouping units, update the basic duration of the target queue according to the loading duration, and use the updated basic duration as the basic duration of the target queue until there are no unselected grouping units, and then use the selected first queue as the first resource group and the selected second queue as the second resource group.
16. The system resource loading device according to claim 15, wherein, The selecting unit includes: A sorting unit, configured to sort a plurality of the grouping units according to the loading duration to obtain a sorting sequence; A selecting subunit, configured to select a grouping unit that meets a preset condition from the sorting sequence as the target grouping unit according to the positions of the grouping units in the sorting sequence.
17. The system resource loading device according to claim 16, wherein, The selecting subunit includes: A candidate unit, configured to select a grouping unit from the sorting sequence as a candidate unit according to the positions of the grouping units in the sorting sequence; A dependency confirmation unit, configured to determine whether there is a dependency relationship between the candidate unit and the grouping units in the target queue; A target confirmation unit, configured to, if there is the dependency relationship between the candidate unit and any one of the grouping units in the target queue, determine the candidate unit as the target grouping unit.
18. The system resource loading device according to claim 12, wherein, The device further includes: A screening unit, configured to screen out candidate resources and drive resources from the system resources; An initial partitioning unit, configured to partition the candidate resources according to the resource types of the candidate resources to obtain a plurality of the grouping units; A creating unit, configured to create a third resource group corresponding to the drive resources; A loading unit, configured to start the loading process of the system, and perform multi-threaded loading on the system resources in the loading process based on the first resource group, the second resource group, and the third resource group.
19. An electronic device, wherein, The electronic device includes a processor and a memory, the memory stores a computer program, and the processor is configured to run the computer program in the memory to execute the system resource loading method according to any one of claims 1 to 11.
20. A computer storage medium, wherein, The computer storage medium stores a computer program, and the computer program is suitable for being loaded by a processor to execute the system resource loading method according to any one of claims 1 to 11.
Citation Information
Patent Citations
System resource loading method and device, electronic equipment and computer storage medium
CN117891574A
Resource loading method and device thereof, storage medium and electronic device
CN111249744A
Preloading method, electronic equipment and storage medium
CN114706633A
Resource loading method and device, electronic equipment and computer readable storage medium
CN116339860A
Reduced latency for subresource transfer
US9083761B1