Task scheduling method, device, electronic device and readable storage medium

By determining the idle status of the device on low-configuration terminals and executing tasks at staggered peaks, the problem of lagging and user experience when running applications on low-configuration terminals is solved, and the user experience and retention rate are improved.

CN113282390BActive Publication Date: 2025-01-21BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110554268.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-20
Publication Date
2025-01-21
Estimated Expiration
2041-05-20

AI Technical Summary

Technical Problem

When running applications on low-configuration terminals, problems such as lag, blurred screens, and crashes are prone to occur, resulting in poor user experience and low retention rate.

Method used

By determining the values ​​of memory usage and processor usage in electronic devices, we can determine whether the device is in an idle state, and perform time-consuming and memory-consuming target tasks at off-peak times in advance when idle, thereby reducing the pressure on memory and processors.

Benefits of technology

Without affecting the function of the application, it avoids problems such as lagging, blurry images, and crashes when the electronic device runs the application, and improves the user experience and retention rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113282390B_ABST
    Figure CN113282390B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a task scheduling method, device, electronic device and readable storage medium, and relates to the field of operating system technology to solve the problems affecting user experience and retention rate in related technologies. The task scheduling method includes: determining the value of a target parameter in an electronic device; the target parameter includes at least one of memory usage and processor usage; when the value of the target parameter is less than a first threshold, determining N tasks in the target task; the target task is a task to be executed whose task parameter is greater than a second threshold, and the task parameter includes at least one of task duration, task memory usage and task memory occupancy time; N is a positive integer; calling N tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of operating system technology, and in particular to a task scheduling method, device, electronic device and readable storage medium. Background Art

[0002] When an application is used on different terminals, the presentation effect of the application varies due to differences in terminal configurations. For low-configuration terminals, the application is prone to freezes, blurred images, and flashbacks during operation, resulting in poor user experience and low retention rates.

[0003] In the related art, in order not to affect the use of applications on low-configuration terminals, a method of functional downgrading is generally adopted, that is, some functions of the application are not used so that the application can adapt to low-configuration terminals. However, functional downgrading of applications will still affect user experience and retention rate. Summary of the invention

[0004] The present disclosure provides a task scheduling method, device, electronic device and readable storage medium to at least solve the problems affecting user experience and retention rate in the related art. The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a task scheduling method, which is applied to an electronic device, and includes: determining a numerical value of a target parameter in the electronic device; the target parameter includes at least one of a memory usage rate and a processor usage rate; when the numerical value of the target parameter is less than a first threshold value, determining N tasks in the target task; the target task is a task to be executed whose task parameter is greater than a second threshold value, and the task parameter includes at least one of a frame loss rate, a task duration, a task memory usage rate, and a task memory occupancy time; N is a positive integer; and calling the N tasks.

[0006] In one possible implementation, determining the N tasks in the target task includes: obtaining a scenario identifier of a current business scenario; reading a mapping relationship to determine a task identifier in the mapping relationship that corresponds to the scenario identifier of the current business scenario; the mapping relationship includes a task identifier for each of the target tasks and a scenario identifier for the business scenario corresponding to each task identifier; and determining the N tasks based on the determined task identifiers.

[0007] In another possible implementation, determining the N tasks based on the determined task identifiers includes: determining the execution priority of the task indicated by each of the determined task identifiers; determining the N tasks based on the determined execution priorities, the execution priorities of the N tasks being higher than the execution priorities of other tasks in the target task except the N tasks.

[0008] In another possible implementation, the task scheduling method also includes: obtaining a scenario identifier of a target business scenario; the target business scenario is the next scenario to which the current business scenario jumps; determining an execution status of the task under the scenario identifier of the target business scenario; and when the execution status is not executed, calling the task under the scenario identifier of the target business scenario.

[0009] In another possible implementation, before determining the value of the target parameter in the electronic device, the method further includes: connecting the target task to a pre-created task scheduling framework.

[0010] In another possible implementation, connecting the target task to a pre-created task scheduling framework includes: determining task parameters of the task to be executed; and connecting the task to be executed to a pre-created task scheduling framework when the task parameters of the task to be executed are greater than a second threshold.

[0011] In another possible implementation, N is a positive integer less than or equal to the number of processor cores of the electronic device.

[0012] In another possible implementation, determining the value of the target parameter in the electronic device includes: determining the value of the target parameter in the electronic device at a preset time interval.

[0013] In another possible implementation, the task scheduling method further includes: determining a value of N according to a processor usage rate and the number of processor cores of the electronic device.

[0014] According to a second aspect of an embodiment of the present disclosure, a task scheduling device is provided, comprising: a determination module, configured to execute determination of a numerical value of a target parameter in the electronic device; the target parameter includes at least one of a memory usage rate and a processor usage rate; the determination module is further configured to execute, when the numerical value of the target parameter is less than a first threshold value, determination of N tasks in the target task; the target task is a task to be executed whose task parameters are greater than a second threshold value, and the task parameters include at least one of a frame loss rate, a task duration, a task memory usage rate and a task memory occupancy time; N is a positive integer; and a calling module, configured to execute calling of the N tasks.

[0015] In one possible implementation, the determination module is specifically configured to execute: obtaining a scenario identifier of a current business scenario; reading a mapping relationship to determine a task identifier in the mapping relationship that corresponds to the scenario identifier of the current business scenario; the mapping relationship includes a task identifier for each of the target tasks and a scenario identifier for the business scenario corresponding to each task identifier; and determining the N tasks based on the determined task identifiers.

[0016] In another possible implementation, the determination module is specifically configured to perform: determining the execution priority of the task indicated by each determined task identifier; determining the N tasks based on the determined execution priority, the execution priority of the N tasks being higher than the execution priority of other tasks in the target task except the N tasks.

[0017] In another possible implementation, the task scheduling device also includes: a backup module, configured to execute: obtaining the scenario identifier of the target business scenario; the target business scenario is the next scenario to which the current business scenario jumps; determining the execution status of the task under the scenario identifier of the target business scenario; and when the execution status is not executed, calling the task under the scenario identifier of the target business scenario.

[0018] In another possible implementation, the task scheduling device further includes: a scheduling framework module configured to execute: connecting the target task to a pre-created task scheduling framework.

[0019] In another possible implementation, the scheduling framework module is specifically configured to execute: determining task parameters of the task to be executed; and connecting the task to be executed to a pre-created task scheduling framework when the task parameters of the task to be executed are greater than a second threshold.

[0020] In another possible implementation manner, the determination module is specifically configured to execute: determining a value of a target parameter in the electronic device at a preset time interval.

[0021] In another possible implementation, the determination module is further configured to execute: determining a value of N according to a processor usage rate and the number of processor cores of the electronic device.

[0022] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the task scheduling method described in any one of the first aspects of the present embodiment.

[0023] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute a task scheduling method as described in any one of the first aspects of this embodiment.

[0024] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, wherein the computer program product comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes a task scheduling method as described in any one of the first aspects of the present embodiment.

[0025] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: by determining the value of at least one of the memory usage rate and the processor usage rate in the electronic device, it is determined whether the electronic device is in an idle state, so that when the memory or processor of the electronic device is idle, the time-consuming and memory-consuming target tasks can be executed in advance to reduce the pressure on the memory and processor, thereby avoiding the problems of freeze, blurred screen, and crash when the electronic device runs the application without affecting the application function, thereby improving the user experience and retention rate.

[0026] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0028] Figure 1 is a flowchart of a task scheduling method according to an exemplary embodiment;

[0029] Figure 2 is a schematic diagram showing an operating state of a processor of an electronic device according to an exemplary embodiment;

[0030] Figure 3 is a schematic diagram showing an operating state of a processor of another electronic device according to an exemplary embodiment;

[0031] Figure 4 is a flow chart showing another task scheduling method according to an exemplary embodiment;

[0032] Figure 5 is a schematic diagram of a business scenario according to an exemplary embodiment;

[0033] Figure 6 is a flow chart showing another task scheduling method according to an exemplary embodiment;

[0034] Figure 7 is a flow chart showing another task scheduling method according to an exemplary embodiment;

[0035] Figure 8 is a schematic diagram of task memory occupation of tasks to be executed according to an exemplary embodiment;

[0036] Fig. 9 is a block diagram of a task scheduling device according to an exemplary embodiment;

[0037] Fig.10 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0038] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0040] Before introducing the task scheduling method provided by the present disclosure in detail, a brief introduction is first given to the application scenarios and implementation environment involved in the present disclosure.

[0041] First, the application scenarios involved in the present disclosure are briefly introduced.

[0042] There are large differences in models on mobile platforms such as Android and iOS. For example, the Android platform has a wide range of system versions and many manufacturers, and the user experience of the same application on different electronic devices is very different.

[0043] In the prior art, online and offline performance tests are generally biased towards mid-to-high-end electronic devices of Android and iOS to optimize the user experience of high-end devices. If low-end electronic devices have a poor user experience, consider downgrading the function, that is, not using certain functions of the application to adapt to the poor performance of the processor and memory conditions on low-end electronic devices. However, applications with downgraded functions will still affect the user experience and retention rate.

[0044] In response to the above problems, the present disclosure provides a task scheduling method, device, electronic device and readable storage medium, which determines whether the electronic device is in an idle state by determining at least one of the memory usage rate and the processor usage rate in the electronic device, so that when the memory or processor of the electronic device is idle, the time-consuming and memory-consuming target tasks can be executed in advance to reduce the pressure on the memory and processor, thereby avoiding the problems of freeze, blurred screen, and crash when the electronic device runs the application without affecting the application function, thereby improving the user experience and retention rate.

[0045] The following is a brief introduction to the implementation environment (implementation architecture) involved in the present disclosure.

[0046] The task scheduling method provided in the embodiment of the present disclosure can be applied to an electronic device. The electronic device can be a terminal device or a server. The terminal device can be a smart phone, a tablet computer, a handheld computer, a vehicle terminal, a desktop computer, and a notebook computer. The server can be any server or server cluster, which is not limited in the present disclosure.

[0047] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0048] Figure 1 is a flowchart of a task scheduling method according to an exemplary embodiment. Figure 1 As shown, the task scheduling method is applied to an electronic device, and includes the following S101-S103.

[0049] In S101 , a value of a target parameter in an electronic device is determined.

[0050] The target parameter includes at least one of a memory usage rate and a processor usage rate.

[0051] By determining the value of the target parameter in the electronic device, it is possible to determine whether the electronic device is currently in an idle state, and then determine the current operating capacity of the electronic device, thereby avoiding calling time-consuming and memory-consuming tasks when the operating capacity of the electronic device is insufficient.

[0052] In one example, the load state of the processor or the load state of the memory of the electronic device can be detected periodically to determine the value of the processor usage rate or the memory usage rate, and whether the electronic device is in an idle state can be determined based on the relationship between the processor usage rate or the memory usage rate and the first preset threshold.

[0053] In a possible implementation, the step of determining the value of the target parameter in the electronic device includes: determining the value of the target parameter in the electronic device at a preset time interval. By determining the value of the target parameter in the electronic device at a preset time interval, it is possible to implement a cyclic call of the target task, thereby increasing the number of calls to the target task, and avoiding the exhaustion of processor or memory resources due to the excessive number of target tasks called at one time when there are too many target tasks to be called, thereby ensuring that only a limited number of target tasks need to be called each time, so that all target tasks can be called in advance before the business scenario corresponding to the target task is displayed.

[0054] It is understandable that the time interval between each RunLoop cycle of the electronic device system is fixed.

[0055] In one example, the frequency of calling the target task can be controlled according to the RunLoop cycle. Exemplarily, the target task can be called once by controlling the preset number of RunLoops at intervals. For example, the target task can be called once every time the RunLoop cycle comes.

[0056] In S102 , when the value of the target parameter is less than the first threshold, N tasks in the target task are determined.

[0057] Among them, the target task is a task to be executed whose task parameters are greater than a second threshold, and the task parameters include at least one of frame loss rate, task time consumption, task memory usage rate and task memory occupancy time; N is a positive integer.

[0058] It is understandable that when the value of the target parameter is less than the first threshold, the memory or processor of the electronic device is in an idle state. For example, when the value of the processor usage is 10%, it is determined that the processor of the electronic device is in an idle state. When the value of the memory usage is 10%, it is determined that the memory of the electronic device is in an idle state. By setting the target task to be executed that is time-consuming and memory-consuming when the processor or memory of the electronic device is idle, it is possible to ensure that the application runs the target task under the optimal conditions on the electronic device.

[0059] In one example, the target task may be a time-consuming task among the tasks to be executed. Specifically, whether the task to be executed is a time-consuming task can be determined based on the task time or frame loss rate of the task to be executed. Exemplarily, when the task time of the task to be executed is greater than a second threshold, the task to be executed is determined to be a time-consuming task. In addition, when the frame loss rate of the task to be executed is greater than the second threshold, the task to be executed is determined to be a time-consuming task.

[0060] In another example, the target task may be a memory-consuming task among the tasks to be executed. Specifically, whether the task to be executed is a memory-consuming task can be determined based on at least one of the task memory usage rate and the task memory occupancy duration of the task to be executed. Exemplarily, when the task memory usage rate of the task to be executed is greater than a second threshold, the task to be executed is determined to be a memory-consuming task. In addition, when the task memory occupancy duration of the task to be executed is greater than a second threshold, the task to be executed can be determined to be a memory-consuming task. Among them, the task memory occupancy duration is the duration that the memory is occupied when the task to be executed is executed.

[0061] It is understandable that different values ​​of the second threshold value may be selected according to different task parameters to ensure the accuracy of determining the target task.

[0062] For example, Figure 2 As shown, we can see the operation status of the processors of the electronic device, that is, the operation status of the five processors Cpu0, Cpu1, Cpu2, Cpu3, and Cpu4. It can be understood that in the left half of the figure (the upper part of the figure is basically filled with color, indicating that the processor is not idle, and the darker the color, the heavier the processor load), the processor load is higher. In the right half of the figure (there is a blank space at the top of the figure, indicating that the processor is idle during this period of time), the processor load is lower. Therefore, when the system of the electronic device is in Figure 2 When the system load of the electronic device enters the left half, the task in the target task will not be called, because the processor load is already heavy at this time, and calling other tasks will not have a better effect, and may even cause lag and other phenomena. Figure 2 In the right half of the task, the processor usage is relatively low and the processor is idle for a part of the time. At this time, the tasks in the target task can be called to use the idle processor and make full use of the computing resources of the idle processor.

[0063] In a possible implementation, the task scheduling method further includes: determining the value of N according to the processor usage rate and the number of processor cores of the electronic device. By setting the number of target tasks to be called according to the processor usage rate and the number of processor cores of the electronic device, it is possible to avoid excessive use of processor and memory resources, thereby avoiding problems such as freezes, blurred images, and flashbacks when the electronic device runs an application, thereby improving the user experience and user retention rate.

[0064] Exemplarily, when the processor usage is lower than the third threshold and the number of processor cores of the electronic device is 4, N can be set to be greater than half of the number of processor cores and less than the number of processor cores. For example, when the processor usage is 10% and the number of processor cores is 4, N can be set to 3.

[0065] In a possible implementation, N is a positive integer less than or equal to the number of processor cores of the electronic device. By controlling the number of target tasks to be called, it is possible to avoid excessive occupancy of the memory or processor of the electronic device, thereby improving the calling efficiency of the target tasks.

[0066] For example, Figure 3 As shown, the electronic device has four processors, namely, Cpu0, Cpu1, Cpu2, and Cpu3. In this case, N is less than or equal to four.

[0067] Exemplarily, N may be set to be equal to half of the number of processor cores. For example, when the number of processor cores of the electronic device is 4, N is 2.

[0068] In S103 , N tasks are called.

[0069] The technical solution provided by the above embodiments brings at least the following beneficial effects: by determining the value of at least one of the memory usage rate and the processor usage rate in the electronic device, it is determined whether the electronic device is in an idle state, so that when the memory or processor of the electronic device is idle, the time-consuming and memory-consuming target tasks can be executed in advance to reduce the pressure on the memory and processor, thereby avoiding the problems of freeze, blurred screen, and crash when the electronic device runs the application without affecting the application function, thereby improving the user experience and retention rate.

[0070] In one possible implementation, combining Figure 1 ,like Figure 4 As shown, S102 may include S1021 - S1023 .

[0071] In S1021, a scenario identifier of the current business scenario is obtained.

[0072] For example, Figure 5 As shown, the scene identification may include any one of a consumption scene identification, a social scene identification, and an audio and video playback scene identification.

[0073] In S1022, the mapping relationship is read to determine the task identifier corresponding to the scenario identifier of the current business scenario in the mapping relationship.

[0074] The mapping relationship includes a task identifier of each target task and a scenario identifier of a business scenario corresponding to each task identifier.

[0075] In one example, the target task includes a task identifier and a scenario identifier. The task identifier of the target task and the scenario identifier of the target task are in a mapping relationship. The business scenario of the target task can be determined by the scenario identifier of the target task. By reading the mapping relationship and determining the task identifier corresponding to the scenario identifier of the current business scenario, multiple target tasks in the current business scenario can be quickly determined, thereby improving the task scheduling efficiency and further improving the user experience.

[0076] In S1023, N tasks are determined according to the determined task identifiers.

[0077] By obtaining the scenario identifier of the current business scenario and determining the task identifier corresponding to the scenario identifier, the target task corresponding to the current business scenario can be executed preferentially, thereby avoiding lag when the current business scenario is displayed, thereby improving user experience and retention rate.

[0078] In one possible implementation, combining Figure 3 ,like Figure 6 As shown, S1023 may include S1023a-S1023b.

[0079] In S1023a, the execution priority of each task indicated by the determined task identifier is determined.

[0080] In one example, the target task also includes an execution priority of the target task in a business scenario corresponding to the scenario identifier.

[0081] Exemplarily, the execution priority may include three levels: High, Normal, and Low. The execution priority of the target task may be any one of High, Normal, and Low. Among them, High takes precedence over Normal and Low, and Normal takes precedence over Low.

[0082] By determining the execution priority of the task indicated by each task identifier, the importance of the target task in the business scenario can be determined, and thus the execution order of the tasks in the target task can be determined according to the importance of the target task in the business scenario.

[0083] In S1023b, N tasks are determined according to the determined execution priorities.

[0084] The execution priorities of the N tasks are higher than the execution priorities of other tasks in the target task except the N tasks.

[0085] Exemplarily, only the task with the highest execution priority can be called each time. For example, when the execution priority of the task indicated by the task identifier is High, Normal, and Low, the High-level task is executed. When the execution priority of the task indicated by the task identifier is Normal and Low, the Normal-level task is executed. Tasks can also be called in order of their execution priority from high to low.

[0086] For example, in the homepage-double-column scenario, the user may keep swiping down to swipe the feed. At this time, the task that is strongly related to this user scenario will be called first (for example, the homepage interface preloading task will be scheduled first). After the homepage interface preloading task is completed, the user will have a better experience when scrolling down the screen, which will be smoother.

[0087] For example, in this scenario after the user logs in, tasks related to user information synchronization will be called first, because this information may be used in other places later, so it needs to be called in advance.

[0088] Exemplarily, when a video is played, relevant information of the next video is preprocessed, thereby improving the viewing experience of the next video.

[0089] By determining the execution priority of the task indicated by each task identifier and determining N tasks based on the determined execution priority, the task that is most relevant to the current business scenario can be called first, thereby ensuring the smoothness of the business scenario presentation and improving the user experience.

[0090] In one possible implementation, combining Figure 1 ,like Figure 7 As shown, the task scheduling method further includes S104-S106. The task scheduling method is applied to electronic equipment.

[0091] In S104, a scenario identifier of the target business scenario is obtained.

[0092] Among them, the target business scenario is the next scenario to which the current business scenario jumps.

[0093] In S105, the execution status of the task under the scenario identification of the target business scenario is determined.

[0094] In S106, when the execution status is not executed, the task under the scenario identification of the target business scenario is called.

[0095] By obtaining the scenario identifier of the target business scenario, the execution status of the task under the scenario identifier of the target business scenario is determined, so that when the execution status is not executed, the task under the scenario identifier of the target business scenario is called, it can be ensured that when the task under the scenario identifier of the target business scenario is not called in time, the task under the scenario identifier of the target business scenario is called first, thereby ensuring that the task under the scenario identifier of the target business scenario is called before the target business scenario is presented, thereby improving the smoothness of the presentation of the target business scenario. In addition, it can also avoid certain situations where the relevant task is not called in time when the relevant task processing result is required.

[0096] Exemplarily, when an electronic device has only one processor, it will be relatively slow for the electronic device to call and run tasks. In the consumption-double-column business scenario, because it is possible to jump from the home page to the video details page, when the task scheduling method calls the task, the highest priority is to call the "home page interface preloading" task, and the second highest priority is to call the "player preprocessing" task. It can be understood that the "player preprocessing" task is the task required for the video details page display. However, in the case where the "home page interface preloading" task is time-consuming, during the normal use of the consumption-double-column business scenario, there may be no way to call the "player preprocessing" task when the processor or memory is idle before the home page jumps to the video details page. At this time, before the user clicks on a Feed Item on the home page to jump to the video details page, by receiving the execution information of the target business scenario, that is, receiving the execution information of the video details page, the execution status of the "player preprocessing" task under the scene identifier of the video details page is obtained, and when the "player preprocessing" task is not executed, the "player preprocessing" task is called to ensure that the "player preprocessing" task can be completed before the video is played on the video details page. It can be understood that, in this example, the video details page corresponds to the target business scenario, and the task of "player preprocessing" corresponds to the task under the scenario identification of the target business scenario.

[0097] It should be noted that on some electronic devices with poor performance, when the "player preprocessing" task is not called for execution, the limitations of processor usage and memory usage can be bypassed and this task can be executed immediately before the video is played to ensure reliable execution of the task.

[0098] In a possible implementation, before determining the value of the target parameter in the electronic device, the method further includes: connecting the target task to a pre-created task scheduling framework. By connecting the target task to the pre-created task scheduling framework, when the processor or memory is idle, the task scheduling framework can call the task according to a preset scheduling strategy, thereby improving the reliability, efficiency and accuracy of the task call.

[0099] Exemplarily, the scheduling strategy may be to call N tasks in the target task when the value of the target parameter in the electronic device is less than a first threshold.

[0100] In a possible implementation, the target task is connected to a pre-created task scheduling framework, including: determining the task parameters of the task to be executed; when the task parameters of the task to be executed are greater than a second threshold, connecting the task to be executed to the pre-created task scheduling framework. By determining the task parameters of the task to be executed, it is determined whether the task to be executed is a time-consuming or memory-consuming task, and when it is determined that the task to be executed is a time-consuming or memory-consuming task, the task to be executed is connected to the task scheduling framework, so that the task scheduling framework can call the time-consuming or memory-consuming task when the processor or memory is idle, thereby improving the operating efficiency of the time-consuming or memory-consuming task.

[0101] In one example, the offline Systrace tool is used to analyze time-consuming tasks in the application (time-consuming tasks will occupy processor resources for a long time), and the time-consuming tasks are connected to the task scheduling framework. It can be understood that some code access layer modifications need to be made in the task scheduling framework.

[0102] It should be noted that when judging a jam during the running of the application, the average frame time of the previous three frames can be used as a reference as the vsync time interval. If there is no new rendering screen refresh for two consecutive vsyncs, it is considered a potential jam. In other words, if the next frame takes more than twice the average frame time of the previous three frames, it is considered a potential jam. On this basis, when there are more than 2-3 UI frame drops, it will cause user-perceivable jams. At this time, it is not appropriate to execute the UI thread task when the page rendering is heavy, and it is more appropriate to execute it when the page is static (that is, the user cannot perceive the UI update).

[0103] For example, when the task to be executed is a UI thread task that takes 82ms, the time it takes for an electronic device with a general screen refresh rate to render a frame is 16ms. That is to say, when the page is not static, this non-rendering related UI thread will cause 6 UI frame drops, and the user side will feel obvious lag. Therefore, the task to be executed needs to be connected to the task scheduling framework to perform staggered execution.

[0104] In one example, when the task time of the task to be executed is greater than 40ms, the task to be executed is a time-consuming task, that is, the task to be executed needs to be connected to the task scheduling framework so as to be executed when the memory or processor is idle.

[0105] In another example, you can use offline memory analysis tools to analyze tasks with high memory usage and long memory usage time.

[0106] For example, the memory usage of the task to be executed can be analyzed by an offline memory analysis tool to obtain the following: Figure 8 The analysis results are shown in Figure 1. The vertical axis is the value of the memory occupied by the task to be executed, and the horizontal axis is the execution time of the task to be executed. Figure 8 , the memory occupied by the first task indicated by Others at time T2 is 0GB, the memory occupied by the second task indicated by Code at time T2 is 0.5GB, the memory occupied by the third task indicated by Graphics at time T2 is 0GB, the memory occupied by the fourth task indicated by Native at time T2 is 0.1GB, the memory occupied by the fifth task indicated by Java at time T2 is 0.1GB, and the memory occupied by the task indicated by Stack at time T2 is 0GB. It is understandable that at time T2, the memory usage of the second and fourth tasks is relatively high. It should be noted that when the memory upper limit is 1G, the memory level must be kept below a certain threshold (for example, the threshold can be set to 0.8G). Too much memory will cause the electronic device's system to trigger memory recycling (during memory recycling, the electronic device's system will stop other work, resulting in fluency problems such as jamming). In addition, after the start of the operation, the values ​​of the memory occupied by the first task, the second task, the third task, the fourth task, and the fifth task begin to gradually increase. When the tasks to be executed start running to time T1, the values ​​of the memory occupied by the first task, the second task, the third task, the fourth task, and the fifth task begin to gradually decrease. In addition, if the task that causes the memory increase is not related to page rendering, the task can be delayed (that is, called when the memory is idle) to ensure that after the task is called, there will be no excessive memory, which will lead to system memory recovery.

[0107] In another example, the criteria for judging whether the memory is high may be: a threshold of memory usage, the time when the memory usage exceeds the threshold (i.e., the length of time the memory is occupied), and whether the task content related to the memory increase is related to page rendering. For example, when the memory usage during task execution is greater than the second threshold, the task to be executed is a high-memory task, that is, the task to be executed is the target task. It may also be that when the memory usage during task execution is greater than the second threshold, and the length of time the memory is occupied is greater than the threshold, the task to be executed is a high-memory task, that is, the task to be executed is the target task.

[0108] For tasks that occupy memory for a long time, after accessing the task scheduling framework, choose the appropriate time (that is, when the value of the target parameter is less than the first threshold) to start calling the relevant target task. When the memory load is high, provide relevant interfaces to release this part of the resident memory. For the situation where high memory is occupied for a short time, choose to schedule this part of the logic at the appropriate time to avoid memory peaks.

[0109] The above mainly introduces the solution provided by the embodiment of the present disclosure from the perspective of the method. In order to achieve the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present disclosure.

[0110] The disclosed embodiment also provides a task scheduling device.

[0111] Fig. 9 900 is a block diagram of a task scheduling device according to an exemplary embodiment. The task scheduling device 900 can be applied to the electronic device in the above embodiment, and can also be a control module for task scheduling in the above electronic device. Fig. 9 The task scheduling device includes a determination module 901 and a calling module 902.

[0112] The determination module 901 is configured to determine the value of a target parameter in the electronic device. The target parameter includes at least one of a memory usage rate and a processor usage rate. Figure 1 , the determination module 901 can be used to execute S101.

[0113] The determination module 901 is further configured to determine N tasks in the target task when the value of the target parameter is less than the first threshold. The target task is a task to be executed whose task parameter is greater than the second threshold, and the task parameter includes at least one of the frame loss rate, task duration, task memory usage rate, and task memory occupancy duration; N is a positive integer. For example, combined with Figure 1 , the determination module 901 can be used to execute S102.

[0114] The calling module 902 is configured to execute the calling of the N tasks. Figure 1 , the calling module 902 can be used to execute S103.

[0115] In a possible implementation, the determination module 901 is specifically configured to execute: obtaining a scene identifier of the current business scene; reading a mapping relationship to determine a task identifier corresponding to the scene identifier of the current business scene in the mapping relationship; the mapping relationship includes a task identifier of each of the target tasks and a scene identifier of the business scene corresponding to each task identifier; determining the N tasks based on the determined task identifiers. For example, in combination with Figure 4 , the determination module 901 can be used to execute S1021-S1023.

[0116] In another possible implementation, the determination module 901 is specifically configured to perform: determining the execution priority of the task indicated by each of the determined task identifiers. According to the determined execution priority, determining the N tasks, the execution priority of the N tasks being higher than the execution priority of other tasks in the target task except the N tasks. For example, in combination Figure 6 , the determination module 901 can be used to execute S1023a-S1023b.

[0117] In another possible implementation, the task scheduling device further includes: a backup module configured to execute: obtaining a scenario identifier of a target business scenario. The target business scenario is the next scenario to which the current business scenario jumps. Determining the execution status of the task under the scenario identifier of the target business scenario. If the execution status is not executed, calling the task under the scenario identifier of the target business scenario. For example, in combination with Figure 7 , the backup module can be used to execute S104-S106.

[0118] In another possible implementation, the task scheduling device further includes: a scheduling framework module configured to execute: connecting the target task to a pre-created task scheduling framework.

[0119] In another possible implementation, the scheduling framework module is specifically configured to perform: determining a task parameter of the task to be executed and, if the task parameter of the task to be executed is greater than a second threshold, connecting the task to be executed to a pre-created task scheduling framework.

[0120] In another possible implementation, N is a positive integer less than or equal to the number of processor cores of the electronic device.

[0121] In another possible implementation manner, the determining module 901 is specifically configured to execute: determining a value of a target parameter in the electronic device at a preset time interval.

[0122] In another possible implementation, the determination module 901 is further configured to execute: determining a value of N according to a processor usage rate and the number of processor cores of the electronic device.

[0123] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0124] Fig.10 1 is a block diagram of an electronic device according to an exemplary embodiment. The electronic device 1000 may be a mobile phone, a tablet computer, a laptop computer, a PDA, a desktop computer, a portable computer, a vehicle-mounted terminal, a wearable device, etc. Fig.10 As shown, the electronic device 1000 includes but is not limited to: a processor 1001 and a memory 1002 .

[0125] The memory 1002 is used to store executable instructions of the processor 1001. It can be understood that the processor 1001 is configured to execute instructions to implement the task scheduling method of S101-S106.

[0126] It should be noted that those skilled in the art can understand that Fig.10 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include Fig.10 More or fewer components may be shown, or certain components may be combined, or the components may be arranged differently.

[0127] The processor 1001 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 1002, and calling data stored in the memory 1002, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 1001 may include one or more processing units. Optionally, the processor 1001 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1001.

[0128] The memory 1002 can be used to store software programs and various data. The memory 1002 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application program required by at least one functional module (such as an image acquisition module, a positioning module, a hidden variable acquisition module or an image generation module, etc.). In addition, the memory 1002 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0129] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 1002 including instructions, and the instructions can be executed by a processor 1001 of an electronic device 1000 to complete the task scheduling method of S101-S106. Optionally, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0130] In one example, see Fig. 9 The processing functions of the above-mentioned determination module 901 and the calling module 902 can be Fig.10 The processor 1001 in the embodiment calls the computer program stored in the memory 1002 for implementation.

[0131] In an exemplary embodiment, the present disclosure also provides a computer program product, including computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the task scheduling method of S101 to S106.

[0132] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0133] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A task scheduling method, characterized in that: Used in electronic equipment, including: Determine task parameters of the task to be performed; When the task parameter of the task to be executed is greater than a second threshold, the task to be executed is connected to a pre-created task scheduling framework as a target task; the task scheduling framework is used to schedule the target task; Determining a value of a target parameter in the electronic device; the target parameter includes at least one of a memory usage rate and a processor usage rate; Determine a value of N according to the processor usage rate and the number of processor cores of the electronic device, where N is a positive integer less than or equal to the number of processor cores of the electronic device; When the value of the target parameter is less than the first threshold, determine N tasks in the target task; the target task is a task to be executed whose task parameter is greater than the second threshold, and the task parameter includes at least one of the frame loss rate, task time consumption, task memory usage rate and task memory occupancy time; Calling the N tasks; Obtaining a scene identifier of a target business scene; the target business scene is the next scene to which the current business scene jumps; Determining the execution status of the task under the scenario identification of the target business scenario; When the execution status is not executed, the task under the scenario identifier of the target business scenario is called to ensure that if the task under the scenario identifier of the target business scenario is not called in time, the restriction of the target parameters is bypassed and the task under the scenario identifier of the target business scenario is called first, thereby ensuring that the task under the scenario identifier of the target business scenario is called before the target business scenario is displayed.

2. The task scheduling method according to claim 1, characterized in that: The determining of N tasks among the target tasks includes: Get the scene ID of the current business scene; Reading a mapping relationship to determine a task identifier corresponding to the scene identifier of the current business scene in the mapping relationship; the mapping relationship includes a task identifier of each of the target tasks and a scene identifier of the business scene corresponding to each task identifier; The N tasks are determined according to the determined task identifiers.

3. The task scheduling method according to claim 2, characterized in that: The determining the N tasks according to the determined task identifiers includes: Determining the execution priority of each task indicated by the determined task identifier; The N tasks are determined according to the determined execution priorities, and the execution priorities of the N tasks are higher than the execution priorities of other tasks in the target task except the N tasks.

4. The task scheduling method according to any one of claims 1 to 3, characterized in that: The determining a value of a target parameter in the electronic device includes: According to a preset time interval, a value of a target parameter in the electronic device is determined.

5. A task scheduling device, characterized in that: Used in electronic equipment, including: A determination module, configured to determine task parameters of a task to be performed; When the task parameter of the task to be executed is greater than a second threshold, the task to be executed is connected to a pre-created task scheduling framework as a target task; the task scheduling framework is used to schedule the target task; A determination module, configured to determine a value of a target parameter in the electronic device; the target parameter includes at least one of a memory usage rate and a processor usage rate; The determination module is further configured to determine a value of N according to the processor usage rate and the number of processor cores of the electronic device, where N is a positive integer less than or equal to the number of processor cores of the electronic device; When the value of the target parameter is less than the first threshold, determine N tasks in the target task; the target task is a task to be executed whose task parameter is greater than the second threshold, and the task parameter includes at least one of a frame loss rate, a task duration, a task memory usage rate, and a task memory occupancy time; A calling module, configured to execute and call the N tasks; The backup module is configured to obtain the scenario identifier of the target business scenario; the target business scenario is the next scenario to which the current business scenario jumps; determine the execution status of the task under the scenario identifier of the target business scenario; and when the execution status is not executed, call the task under the scenario identifier of the target business scenario to ensure that when the task under the scenario identifier of the target business scenario is not called in time, bypass the restriction of the target parameter and give priority to calling the task under the scenario identifier of the target business scenario, thereby ensuring that the task under the scenario identifier of the target business scenario is called before the target business scenario is displayed.

6. The task scheduling device according to claim 5, characterized in that: The determination module is specifically configured to execute: Get the scene ID of the current business scene; Reading a mapping relationship to determine a task identifier corresponding to the scene identifier of the current business scene in the mapping relationship; the mapping relationship includes a task identifier of each of the target tasks and a scene identifier of the business scene corresponding to each task identifier; The N tasks are determined according to the determined task identifiers.

7. The task scheduling device according to claim 6, characterized in that: The determination module is specifically configured to execute: Determining the execution priority of each task indicated by the determined task identifier; The N tasks are determined according to the determined execution priorities, and the execution priorities of the N tasks are higher than the execution priorities of other tasks in the target task except the N tasks.

8. The task scheduling device according to any one of claims 5 to 7, characterized in that: The determination module is specifically configured to execute: According to a preset time interval, a value of a target parameter in the electronic device is determined.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the task scheduling method according to any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the task scheduling method as described in any one of claims 1 to 4.

11. A computer program product, characterized in that The computer program product includes computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the task scheduling method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method and device for balancing load

    CN103150213A

  • Task scheduling method and device, storage medium and electronic equipment

    CN107423123A

  • Game copy processing method, device, electronic equipment and storage medium

    CN111035932A

  • Task delivery method and device, computer equipment and computer readable storage medium

    CN111754189A