Service fusing method and electronic device
By identifying and shutting down unnecessary background services in real time within electronic devices, the performance degradation caused by user-interrupted operation is resolved, thereby improving device performance and battery life.
Patent Information
- Application Number
- CN202410042438.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-10
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2044-01-10
AI Technical Summary
When an electronic device is in a specific state and a service is running in the background, user actions may disrupt that state, leading to a decrease in device performance, including rapid battery drain and lag in foreground applications.
The system continuously collects hardware information via hardware drivers, determines whether preset conditions are met, starts preset services, and decides whether to circuit break the service based on the remaining task resources when conditions are not met, thus avoiding unnecessary background execution.
It reduces the impact of background services on foreground applications, lowers battery consumption, and improves the performance of electronic devices.
Smart Images

Figure CN119248429B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic technology, specifically to a service circuit breaker method and an electronic device. Background Technology
[0002] Currently, to improve the performance of electronic devices, services can be started in the background while the device is in a certain state, enabling it to complete update or recommended tasks. For example, when an electronic device is charging, screen off, and idle for a period of time, it can start system updates and other services in the background.
[0003] However, since users cannot control how they use electronic devices, they may operate the device while it is in the aforementioned state, thus breaking the state (i.e., the device is no longer in the aforementioned state). However, the device is still performing corresponding services in the background, which will lead to a decrease in the device's performance. Summary of the Invention
[0004] This application provides a service circuit breaker method and an electronic device that can improve the performance of the electronic device.
[0005] In a first aspect, this application provides a service circuit breaker method, which is executed by an electronic device and includes: acquiring first hardware information, the first hardware information being information collected by a hardware driver at a first moment; starting a preset service if a preset condition is met based on the first hardware information, the preset condition representing the start condition of the preset service; after starting the preset service, acquiring second hardware information, the second hardware information being information collected by the hardware driver at a second moment, the second moment being longer than the first moment; if the preset condition is not met based on the second hardware information, and the preset service is still being executed, determining the amount of resources required for the remaining tasks corresponding to the preset service; and if the amount of resources required for the remaining tasks is greater than a preset threshold, then breakering the preset service.
[0006] During operation, the electronic device's hardware driver continuously collects hardware information. Upon receiving the first piece of hardware information, the device can determine if preset conditions are met. If so, a preset service is initiated. Subsequently, the hardware driver continues collecting hardware information. Upon receiving the second piece of hardware information, the device can determine if the preset conditions are still met. If the preset conditions are no longer met but the preset service continues to run, it may affect the device's performance. The device can then determine the resource consumption of the remaining tasks corresponding to the preset service. If the resource consumption of the remaining tasks exceeds a preset threshold, continuing to run the preset service in the background will lead to rapid resource consumption and affect performance. Therefore, the device can circuit-break and discard the preset service, ceasing its background execution. This reduces the impact of background preset services on foreground applications and decreases battery consumption, thereby improving the device's performance.
[0007] In some implementations, the resources required for the remaining tasks mentioned above may include processor (such as CPU) runtime and / or battery power.
[0008] In conjunction with the first aspect, in some implementations of the first aspect, when the amount of resources required for the remaining tasks includes processor runtime, the above-mentioned determination of the amount of resources required for the remaining tasks corresponding to the preset service includes: determining the processor runtime required for the remaining tasks based on the single-round execution time and the remaining execution rounds during the execution of the preset service.
[0009] When a pre-defined service runs in the background, it typically requires multiple rounds to complete its task. The execution time of a single round is the execution time of one round. Therefore, electronic devices can determine the processor time required for the remaining tasks based on the execution time of a single round and the remaining execution rounds.
[0010] In some implementations, the processor runtime required for the remaining tasks is determined based on the single-round execution time and the remaining execution rounds in the preset service execution process, including:
[0011] According to the inclusion The relationship is used to calculate the processor runtime required for the remaining tasks, where, The `CurEpoch` function is used to calculate the execution time of a single round during the execution of a preset service. `(TotalEpoch-CurEpoch)` is used to calculate the remaining execution rounds. `CurParams` represents the current size of the feature parameters during a single round of execution during the execution of the preset service. This can include the number of samples and the feature dimensions. The number of samples can include the number of operations performed by the user while using the electronic device (such as the number of times the screen is turned on and off, the number of clicks, etc.). The feature dimensions can include the relationship between the current preset service and the services executed previously, the charging status of the electronic device, the network status, the location status, etc. `MaxParams` represents the maximum size of the feature parameters during a single round of execution during the execution of the preset service obtained through training. The `F` function is the function (or model) obtained through training that calculates the execution time of a single round based on `CurParams` and `MaxParams`. The `F` function can be a linear or non-linear function. `TotalEpoch` represents the total number of execution rounds corresponding to the preset service, and `CurEpoch` represents the current number of rounds executed corresponding to the preset service.
[0012] Using the above formula, the electronic device can calculate the processor running time required for the remaining tasks corresponding to the preset service. Then, based on the comparison between the processor running time and the preset threshold (such as the time threshold), it can determine whether to interrupt the preset service to improve the performance of the electronic device.
[0013] In conjunction with the first aspect, in some implementations of the first aspect, the above-mentioned determination of the processor running time required for the remaining task based on the single-round execution time and the remaining execution rounds in the preset service execution process includes: determining the processor running time required for the remaining task based on the single-round execution time in the preset service execution process, the computing power coefficient of the electronic device, and the remaining execution rounds.
[0014] Because electronic devices use different types of chips in real-world scenarios, their computing power also varies. Therefore, when determining the remaining processing time required for a task, the electronic device can take its chip computing power into account. That is, the electronic device determines the remaining processing time required for the task based on the single-round execution time in the preset service execution process, the electronic device's computing power coefficient, and the remaining execution rounds.
[0015] In some implementations, the processor time required for the remaining tasks is determined based on the single-round execution time in the preset service execution process, the computing power coefficient of the electronic device, and the remaining execution rounds. This includes:
[0016] According to the inclusion The relationship is used to calculate the processor runtime required for the remaining tasks, where, Used to calculate the execution time of a single round during the execution of a preset service. The computational power coefficient of the electronic device is used to calculate the remaining execution rounds. CurParams represents the current feature parameter size during a single execution round in the execution of the preset service. MaxParams represents the maximum feature parameter size during a single execution round in the execution of the preset service obtained through training. MinPower represents the lowest chip computational power among electronic devices of different chip types. CurPower represents the chip computational power of the electronic device. TotalEpoch represents the total number of execution rounds corresponding to the preset service. CurEpoch represents the current number of execution rounds corresponding to the preset service.
[0017] Using the above formula, the electronic device can calculate the processor running time required for the remaining tasks corresponding to the preset service. Then, based on the comparison between the processor running time and the preset threshold (such as the time threshold), it can determine whether to interrupt the preset service to improve the performance of the electronic device.
[0018] In conjunction with the first aspect, in some implementations of the first aspect, when the remaining tasks require resources including battery power, the above-mentioned determination of the remaining tasks corresponding to the preset service requires the following: determining the remaining tasks require battery power based on the processor running time required by the remaining tasks and the power consumption per unit time.
[0019] Since running preset services in the background will consume additional battery power, the electronic device can also determine the battery power required for the remaining tasks. Subsequently, based on the comparison between the required battery power and a preset threshold (such as a power threshold), it can determine whether to cut off the preset service to improve the performance of the electronic device.
[0020] In some implementations, the determination of the remaining battery power required by the remaining tasks based on the processor runtime required for the remaining tasks and the power consumption per unit time includes:
[0021] The remaining battery power required for the task is calculated based on the relationship between EstimatedRemainTime and PowerRatio, where EstimatedRemainTime represents the remaining processor runtime required for the task. Relations or containing The EstimatedRemainTime is calculated using the following formula, where PowerRatio represents the amount of electricity consumed per unit time.
[0022] Using the above formula, the electronic device can calculate the remaining battery power required for the preset service, and then determine whether to cut off the preset service based on the comparison between the battery power and a preset threshold (such as a power threshold), so as to improve the performance of the electronic device.
[0023] In conjunction with the first aspect, in some implementations of the first aspect, the first hardware information includes at least one of the following: display status information of the electronic device's screen, operating status information of the processor, and charging status information of the battery.
[0024] The aforementioned hardware driver may include, but is not limited to, a display driver, a CPU driver, and a battery driver. The acquired first hardware information may include, but is not limited to, display status information, processor operating status information, and battery charging status information. After acquiring this hardware information, the hardware driver can broadcast this hardware information so that registered modules or applications that receive broadcasts can receive the hardware information broadcast by the hardware driver. Correspondingly, the acquired second hardware information may also include, but is not limited to, display status information, processor operating status information, and battery charging status information.
[0025] In conjunction with the first aspect, in some implementations of the first aspect, determining that the preset conditions are met based on the first hardware information includes: if the display screen is in a screen-off state, the battery is in a charging state, and the processor is in an idle state for a preset duration, then the preset conditions are determined to be met.
[0026] In other words, when the electronic device determines, based on the first hardware information, that it is currently in a charging, screen-off state and has been idle for a preset duration, the preset condition is deemed met. In some implementations, the preset duration can be 30 minutes. Correspondingly, after the preset service is started, when the electronic device determines, based on the second hardware information, that it is no longer in a charging, screen-off state or is no longer idle, the preset condition is deemed no longer met, and a subsequent determination is made as to whether the preset service needs to be interrupted.
[0027] In conjunction with the first aspect, in some implementations of the first aspect, the preset services initiated by the electronic device include one or more services.
[0028] The preset service can include one or more services, such as system update service, application update service, or smart service. The preset can run in a process. If multiple services (including the preset service and other services) are currently running in a process, the electronic device can only stop the preset service from running, while other services can still run normally.
[0029] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device includes a hardware driver and a task scheduler. The above-mentioned activation of the preset service when the preset conditions are met based on the first hardware information includes: the task scheduler receiving the first hardware information broadcast by the hardware driver; the task scheduler determining that the preset conditions are met based on the first hardware information and activating the preset service.
[0030] In this implementation, the hardware driver can collect first hardware information and broadcast it. After receiving the first hardware information, the JobScheduler can determine whether preset conditions are met based on the first hardware information. If the JobScheduler determines that the preset conditions are met, it can start the preset service asynchronously in the background.
[0031] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device also includes a monitoring module and a circuit breaker judgment module. When the preset conditions are not met based on the second hardware information, if the preset service is still being executed, the remaining tasks corresponding to the preset service are determined to consume a certain amount of resources. This includes: the monitoring module receiving the second hardware information broadcast by the hardware driver; and the monitoring module calling the circuit breaker judgment module to determine the remaining tasks corresponding to the preset service if the preset conditions are not met based on the second hardware information.
[0032] After the preset service starts, the monitoring module can start and continuously receive hardware information broadcast by the aforementioned hardware driver, and determine whether the preset conditions are still met based on the received second hardware information. In some scenarios, user actions may cause the preset conditions to be broken, meaning the preset conditions are no longer met. If the preset conditions are not met but the preset service is still running, the monitoring module can call the circuit breaker module to determine the amount of resources required for the remaining tasks corresponding to the preset service. If the amount of resources required for the remaining tasks is still relatively large, the preset service can be circuit-broken, preventing it from running in the background and improving the performance of the electronic device.
[0033] Secondly, this application provides an apparatus included in an electronic device, which has the function of implementing the behaviors of the electronic device in the first aspect and possible implementations thereof. The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above-described functions. For example, a receiving module or unit, a processing module or unit, etc.
[0034] Thirdly, this application provides an electronic device, which includes: one or more processors, and a memory;
[0035] The memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, which the one or more processors call to cause the electronic device to perform any one of the methods of the first aspect of the technical solution.
[0036] Fourthly, this application provides a chip system applied to an electronic device, the chip system including one or more processors, the one or more processors being configured to invoke computer instructions to cause the electronic device to perform the methods in the first aspect and any possible implementation thereof.
[0037] Optionally, the chip system also includes a memory, which is connected to the processor via circuitry or wires.
[0038] Alternatively, the chip system may also include a communication interface.
[0039] Fifthly, this application provides a computer-readable storage medium including instructions that, when executed on an electronic device, cause the electronic device to perform any one of the methods in the first aspect of the technical solution.
[0040] Sixthly, this application provides a computer program product, which includes computer program code that, when executed on an electronic device, causes the electronic device to perform any one of the methods in the first aspect of the technical solution. Attached Figure Description
[0041] Figure 1 This is an application scenario diagram of a service circuit breaker method provided in an embodiment of this application;
[0042] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0043] Figure 3 This is a software structure block diagram of an electronic device provided in an embodiment of this application;
[0044] Figure 4 This is a timing flowchart of an example of a service circuit breaker method provided in an embodiment of this application;
[0045] Figure 5 This is a flowchart illustrating an example of a service circuit breaker method provided in an embodiment of this application. Detailed Implementation
[0046] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0047] Hereinafter, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include one or more of that feature.
[0048] Currently, to improve the performance of electronic devices, services can be initiated in the background when the device is in a certain state, enabling it to complete update or recommendation tasks. For example, when an electronic device is charging, screen off, and idle for a period of time, it can initiate system update services, application update services, or proactive recommendation services based on user usage patterns. These proactive recommendation services, also known as intelligent services, can use intelligent capabilities (or artificial intelligence capabilities) to recommend more suitable applications or experiences based on the user's context, usage patterns, and habits. Another example is when the electronic device detects that the system time is a specific time in the early morning; these services can also be initiated in the background.
[0049] For example, taking an electronic device using the Android system as an example, the Android system provides a service startup mechanism called JobScheduler. JobScheduler is a task scheduler, which is mainly used to trigger the execution of a task when certain conditions are met at a certain time. When using this service startup mechanism, you can create a subclass of JobService and override its onStartJob() method to implement this function.
[0050] It is understandable that when an electronic device is in a certain state and needs to start a service in the background, the asynchronously started service can be one or more services, as long as it is set to start in this state.
[0051] However, because user behavior regarding electronic devices is unpredictable, users may interact with the device while it is in the aforementioned state, disrupting this state. Even if the device continues to run services in the background, this can lead to a decrease in performance. For example, if an electronic device is in a charging, screen-off state and idle for a period of time, and then a system update service starts in the background, followed by the user waking the device to a screen-on state or stopping charging, the device no longer meets the corresponding state conditions. If the user wakes the device to a screen-on state, other applications may be running in the foreground. In this case, the device will have to perform a system update in the background in addition to running foreground applications, potentially causing foreground applications to lag. If the user stops charging, but the device continues to perform a system update in the background, the battery will drain faster. In short, this leads to a decrease in performance and negatively impacts the user experience.
[0052] For example, such as Figure 1 As shown, if an electronic device is in a charging, screen-off state and idle for 30 minutes, and a smart service is started in the background, and charging ends shortly after the smart service starts (e.g., the user unplugs the power adapter or charging is complete), but the smart service continues to run in the background, the electronic device's battery will drain quickly. If the user is also operating foreground applications at the same time, it will also cause the foreground applications to lag.
[0053] In view of this, this application provides a service circuit breaker method. When the service startup conditions are no longer met during the background execution of a service, the method determines how much resource (such as running time or power) the remaining task corresponding to the service still needs to consume, and then determines whether to continue executing the service. If the service is not to continue, the service is circuit-broken and discarded, and the service is no longer executed in the background. This can reduce the impact of running preset services in the background on foreground applications and reduce battery power consumption, thereby improving the performance of electronic devices.
[0054] It should be noted that the service circuit breaker method provided in this application embodiment can be applied to electronic devices that support background service startup mechanisms, such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application embodiment does not impose any restrictions on the specific type of electronic device.
[0055] For example, Figure 2 This is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of this application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identity module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0056] Processor 110 may include one or more processing units, such as a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.
[0057] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0058] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0059] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0060] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, external memory, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0061] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0062] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0063] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0064] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0065] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0066] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0067] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0068] Figure 3 This is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer. The application layer may include a series of application packages.
[0069] like Figure 3 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0070] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0071] like Figure 3 As shown, the application framework layer can include at least a task scheduler (JobScheduler), a listening module, a circuit breaker judgment module, and a circuit breaker execution module.
[0072] The JobScheduler receives hardware information broadcast from the kernel layer, such as the charging status of electronic devices, the display status of screens, and the working status of processors. It can also determine whether preset conditions are met based on the received hardware information and start preset services if the conditions are met. After the preset service is started, the monitoring module also receives hardware information broadcast from the kernel layer and determines whether the preset conditions continue to be met. If the preset conditions are no longer met at some point, the circuit breaker module is activated. The circuit breaker module uses a preset algorithm to determine how many resources the remaining tasks corresponding to the started service still need to consume. If the required resources exceed a preset threshold, the circuit breaker execution module drops the service; otherwise, the service continues to run. In some implementations, the circuit breaker execution module can be coupled internally to the service and terminate the service execution process itself. In other implementations, the circuit breaker execution module can send a message to the kernel layer to interrupt the service process.
[0073] In addition to the above, the application framework layer may also include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc. (not shown in the diagram). The window manager manages window programs. It can obtain the screen size, determine if a status bar is present, lock the screen, and capture the screen. The content provider stores and retrieves data, making this data accessible to applications. The view system includes visual controls, such as controls for displaying text and images. The view system can be used to build applications. The display interface can consist of one or more views. The phone manager provides communication functions for the electronic device 100, such as managing call status (including connection and disconnection). The resource manager provides various resources to the application, such as localized strings, icons, images, layout files, video files, etc. The notification manager allows the application to display notification information in the status bar, which can be used to convey informational messages and can disappear automatically after a short pause without user interaction. For example, the notification manager is used to notify of download completion or message alerts.
[0074] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.
[0075] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0076] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0077] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0078] The Surface Manager manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The Media Library supports playback and recording of various common audio and video formats, as well as still image files. The Media Library supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG. The 3D Graphics Processing Library implements 3D graphics drawing, image rendering, compositing, and layer processing. The 2D Graphics Engine is the drawing engine for 2D graphics.
[0079] The kernel layer is the layer between hardware and software. It contains at least hardware drivers such as display drivers, CPU drivers, and battery drivers. The display driver obtains the display status information of the electronic device's screen, such as whether the screen is on or off. The CPU driver obtains the processor's operating status information, such as whether it is active or idle. The battery driver obtains the charging status and power information of the electronic device's battery, such as whether it is charging or not. In some implementations, the kernel layer hardware drivers can broadcast the obtained hardware information through an interface, allowing the JobScheduler and listening modules mentioned above to receive this information.
[0080] For ease of understanding, the following embodiments of this application will be described using the following methods: Figure 2 and Figure 3 Taking the electronic device with the structure shown as an example, and in conjunction with the accompanying drawings and application scenarios, the service circuit breaking method provided in this application embodiment will be specifically described.
[0081] Figure 4 This is a timing flowchart of an example service circuit breaker method provided in an embodiment of this application, which can be applied to the above. Figure 2 In the software architecture shown, the method includes:
[0082] S11, The hardware driver obtains and broadcasts hardware information.
[0083] The hardware driver may include, but is not limited to, display drivers, CPU drivers, and battery drivers. The acquired hardware information may include, but is not limited to, display status information, processor operating status information, and battery charging status information. After acquiring this hardware information, the hardware driver can broadcast this information so that registered broadcast-receiving modules or applications can receive the broadcast hardware information. In some implementations, the hardware driver can continuously broadcast the acquired hardware information.
[0084] S12, JobScheduler receives hardware information broadcast by the hardware driver.
[0085] In some implementations, if the JobScheduler is enabled to receive broadcast messages from the hardware driver, the JobScheduler can register a broadcast request with the hardware driver in advance so that it can receive the broadcast hardware information when the hardware driver broadcasts hardware information.
[0086] S13. JobScheduler determines whether the preset conditions are met based on the hardware information. If they are met, it executes S14.
[0087] Among them, the preset conditions can represent the conditions for starting the preset service, that is, the preset service can be started when the preset conditions are met.
[0088] In some implementations, the preset conditions may include: the electronic device's display screen is in an off state, the battery is charging, and the processor has been idle for a preset duration. The JobScheduler can then determine whether the preset conditions are met based on the received hardware information. If they are met, it executes step S14 below. For example, the preset duration could be 30 minutes.
[0089] In some implementations, the preset conditions may include any one or two of the following: the electronic device's display screen is off, the battery is charging, or the processor has been idle for a preset duration. In still other implementations, the preset conditions may also include: the system time is within a preset time period, such as 1:00 AM to 4:00 AM. In this implementation, JobScheduler also needs to obtain the current system time information.
[0090] S14, JobScheduler starts the default service.
[0091] In other words, if the JobScheduler determines that the above preset conditions are met, it can start the preset service asynchronously in the background. In some implementations, the preset service may include one or more services, such as system update service, application update service, and smart service.
[0092] It's understandable that a pre-installed service, once started in the background, will automatically execute its own tasks until they are completed. It's also understandable that once JobScheduler starts the pre-installed service, it no longer participates in the execution of other started services.
[0093] S15. The monitoring module receives hardware information broadcast by the hardware driver.
[0094] S16. The monitoring module determines whether the preset conditions are met based on the hardware information. If not, and the preset service is still being executed, then S17 is executed.
[0095] After the preset service starts, the listening module can start and continuously receive the hardware information broadcast by the aforementioned hardware driver, and determine whether the preset conditions are still met based on the received hardware information. There may be scenarios where the preset conditions are broken. For example, if the preset conditions include the electronic device's display being off, the battery being charged, and the processor being idle for a preset duration, and then the display switches to on or the battery switches to off state, the preset conditions are no longer met. Therefore, if the preset conditions are not met but the aforementioned preset service is still running, the following step S17 can be executed.
[0096] S17. The monitoring module calls the circuit breaker judgment module to determine the amount of resources required by the remaining tasks corresponding to the preset service.
[0097] If the preset conditions are not met—that is, the startup conditions of the preset service are no longer met, but the preset service is still running in the background—this can affect the performance of the electronic device. For example, if the battery is switched to an uncharged state and the preset service is still running in the background, the electronic device's battery will be consumed quickly. In this scenario, the monitoring module can call the circuit breaker module to determine the amount of resources required by the remaining tasks corresponding to the preset service. If the amount of resources required by the remaining tasks is still relatively large, the preset service can be circuit-broken, preventing it from running in the background and improving the performance of the electronic device.
[0098] In some implementations, the amount of resources required by the remaining tasks may include processor (such as CPU) runtime and / or battery power.
[0099] When the remaining resources required for the task include processor runtime, in some implementations, the circuit breaker module can determine the remaining processor runtime based on the single-round execution time of the preset service and the remaining execution rounds. Typically, when the preset service runs in the background, it requires multiple rounds to complete its task; the single-round execution time is the execution time of one round. Therefore, the circuit breaker module can calculate the remaining processor runtime based on the single-round execution time and the remaining execution rounds.
[0100] For example, the circuit breaker determination module can determine the circuit breaker based on the included... The remaining processor time (EstimatedRemainTime) required for relational computation tasks. This is especially relevant when the preset services include intelligent services (such as gallery search and intelligent recommendation applications). The `CurEpoch` function is used to calculate the execution time of a single round during the execution of a preset service. `(TotalEpoch - CurEpoch)` is used to calculate the remaining execution rounds. `CurParams` represents the current size of the feature parameters during a single round of execution during the preset service execution process. This can include the number of samples and the feature dimensions. The number of samples can include the number of operations performed by the user while using the electronic device (such as screen on / off times, clicks, etc.). The feature dimensions can include the relationship between the currently executed preset service and other previously executed services, the charging status of the electronic device, network status, location status, etc. `MaxParams` represents the maximum size of the feature parameters during a single round of execution during the preset service execution process obtained through training. The `F` function is the trained function (or model) that calculates the single round execution time based on `CurParams` and `MaxParams`. The `F` function can be a linear or non-linear function. `TotalEpoch` represents the total number of execution rounds corresponding to the preset service, and `CurEpoch` represents the current number of rounds already executed for the preset service. It is understandable that CurParams and CurEpoch can be read from the running parameters (or the information carried) during the execution of the preset service. MaxParams and TotalEpoch are fixed parameters obtained during training. Optionally, MaxParams can be the default value of 7332000 and TotalEpoch can be the default value of 100000.
[0101] In other implementations, the circuit breaker determination module can determine the remaining processor time required for the task based on the single-round execution time during the preset service execution process, the computing power coefficient of the electronic device, and the remaining execution rounds.
[0102] For example, the circuit breaker determination module can determine the circuit breaker based on the included... The relational computation of the remaining tasks requires processor execution time. Used to calculate the execution time of a single round during the preset service execution process, (TotalEpoch-CurEpoch) is used to calculate the remaining execution rounds. The computing power coefficient of electronic devices is used to calculate the computing power coefficient. MinPower represents the lowest chip computing power among electronic devices with different chip types, and CurPower represents the chip computing power of the current electronic device. It can be understood that if the impact of chip computing power is not considered, then... It can take the value 1 or other constant terms. If the impact of chip computing power is taken into account, the stronger the chip computing power of the current electronic device, the shorter the processor running time required.
[0103] In some other implementations, the circuit breaker judgment module can calculate the total processor running time required for the preset service based on the single-round execution time during the preset service execution process, the computing power coefficient of the electronic device, and the total number of execution rounds corresponding to the preset service. Then, based on the total processor running time required for the preset service and the processor running time already consumed, it can determine the processor running time required for the remaining tasks.
[0104] For example, the circuit breaker determination module can calculate the total processor runtime (EstimatedTime) required for a preset service based on the following formula:
[0105]
[0106] Then, the processor runtime required for the remaining tasks is calculated based on the relationship between EstimatedTime and ConsumedTime. Used to calculate the execution time of a single round during the execution of a preset service. Used to calculate the computing power coefficient of electronic devices, TotalEpoch represents the total number of execution rounds corresponding to the preset service, and ConsumedTime represents the processor running time consumed.
[0107] In some implementations, when the remaining task requires resources including battery power, the circuit breaker module can determine the remaining task's battery power consumption based on the processor runtime (EstimatedRemainTime) and the power consumption per unit time.
[0108] For example, the circuit breaker determination module can calculate the remaining battery power (EstimatedRemainPower) required for the task based on the formula containing EstimatedRemainPower × PowerRatio. Here, PowerRatio represents the power consumption per unit time, and the power consumption process of the electronic device can be regarded as uniform consumption. For example, PowerRatio is 10 mAh per minute.
[0109] In other implementations, the circuit breaker determination module can calculate the total battery power required for the preset service based on the total processor runtime (EstimatedTime) and the power consumption per unit time, and then determine the battery power required for the remaining tasks based on the total battery power required for the preset service and the consumed battery power.
[0110] For example, the circuit breaker determination module can calculate the total battery power (EstimatedPower) required for the preset service based on the formula containing EstimatedTime×PowerRatio, and then calculate the battery power required for the remaining tasks based on the formula containing EstimatedPower-ConsumedPower, where ConsumedPower represents the battery power already consumed.
[0111] S18. The circuit breaker judgment module determines whether the amount of resources required by the remaining tasks is greater than the preset threshold. If it is greater, then execute S19. If it is not greater, then keep the preset service running.
[0112] If the remaining tasks corresponding to a preset service require more resources than a preset threshold, continuing to run the preset service will lead to rapid resource consumption of the electronic device, affecting its performance. Therefore, the process of circuit breaking the preset service in S19 below can be executed. If the remaining tasks corresponding to a preset service do not require more resources than the preset threshold, the impact on the performance of the electronic device may be small, so the preset service can continue to run.
[0113] In some implementations, when the remaining resources required by the task include processor runtime and / or battery power, the preset thresholds may include a time threshold and a power threshold. In this case, the circuit breaker module can determine whether the remaining processor runtime required by the task exceeds the time threshold and whether the remaining battery power required by the task exceeds the power threshold, respectively. For example, the time threshold could be 10 minutes, and the power threshold could be 10% × the total battery power of the electronic device.
[0114] S19. The circuit breaker determination module sends an instruction message to the circuit breaker execution module to instruct the circuit breaker execution module to activate the preset circuit breaker service.
[0115] S20, Circuit Breaker Execution Module Circuit Breaker Preset Service.
[0116] In other words, if the amount of resources required by the remaining tasks exceeds the preset threshold, the preset service needs to be circuit-broken. In this case, the circuit-broken judgment module can send an instruction message to the circuit-broken execution module, which will then circuit-broken and discard the preset service.
[0117] Since preset services typically run within processes, in some implementations, if a process is currently running multiple services (including preset services and other services), the circuit breaker module can terminate only the preset service, effectively stopping its operation. In other implementations, if the process is dedicated to the preset service and is used solely for running it, the circuit breaker module can interrupt or destroy the process. Alternatively, in scenarios where process freezing is possible, the circuit breaker module can also freeze the process.
[0118] The aforementioned service circuit breaker method involves the electronic device executing a preset service in the background when the preset conditions are met. If the preset conditions are no longer met during the execution of the preset service, the method determines how much resource the remaining task corresponding to the preset service still needs to consume. If the amount of resources to be consumed exceeds a preset threshold, the preset service is circuit-broken and discarded, and the service is no longer executed in the background. This reduces the impact of the preset service running in the background on the foreground application and reduces battery power consumption, thereby improving the performance of the electronic device.
[0119] based on Figure 4 The embodiment shown, Figure 5 This is a flowchart illustrating an example of a service circuit breaker method provided in an embodiment of this application. This method can be executed by an electronic device and may specifically include:
[0120] S101, Obtain first hardware information.
[0121] The first hardware information can be the information collected by the hardware driver at the first moment. The hardware driver usually collects hardware information in real time. The first moment can be any moment in the process of collecting hardware information, that is, the electronic device can also obtain the first hardware information in real time.
[0122] S102. Determine whether the preset conditions are met based on the first hardware information. If they are met, start the preset service.
[0123] After acquiring the first hardware information, the electronic device can determine whether the preset conditions are met based on the first hardware information. The determination process can be found in the description of S13 in the above embodiment, and will not be repeated here. It can be understood that if the electronic device acquires the first hardware information in real time, then the electronic device can also determine whether the preset conditions are met in real time. In some implementations, the electronic device can use a service startup mechanism based on JobScheduler to start the preset service.
[0124] S103. After the preset service is started, obtain the second hardware information.
[0125] After the preset conditions are met and the preset service is started, the electronic device will continue to acquire hardware information. The acquired hardware information can be recorded as the second hardware information. The second hardware information can be the information collected by the hardware driver at the second moment, which is greater than the first moment.
[0126] S104. Determine whether the preset conditions are met based on the second hardware information. If not, and the preset service is still being executed, determine the amount of resources required for the remaining tasks corresponding to the preset service.
[0127] After acquiring the second hardware information, the electronic device can continue to determine whether the preset conditions are still met based on the second hardware information. If the preset conditions are no longer met but the preset service is still being executed, it may affect the performance of the electronic device. In this case, the electronic device can determine the amount of resources required for the remaining tasks corresponding to the preset service. The process by which the electronic device determines the amount of resources required for the remaining tasks corresponding to the preset service can be found in S17 above, and will not be repeated here.
[0128] S105. If the amount of resources required by the remaining tasks corresponding to the preset service is greater than the preset threshold, then the preset service will be suspended.
[0129] In other words, if the amount of resources required by the remaining tasks corresponding to the preset service exceeds the preset threshold, continuing to run the preset service in the background will cause the electronic device to consume resources quickly and affect the performance of the electronic device. Therefore, the preset service can be circuit-broken and discarded, that is, the preset service will no longer be executed in the background.
[0130] The aforementioned service circuit breaker method involves the electronic device executing a preset service in the background when the preset conditions are met. If the preset conditions are no longer met during the execution of the preset service, the method determines how much resource the remaining task corresponding to the preset service still needs to consume. If the amount of resources to be consumed exceeds a preset threshold, the preset service is circuit-broken and discarded, and the service is no longer executed in the background. This reduces the impact of the preset service running in the background on the foreground application and reduces battery power consumption, thereby improving the performance of the electronic device.
[0131] The foregoing has detailed examples of the service circuit breaker method provided in the embodiments of this application. It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0132] This application embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into a separate functional module, such as a detection unit, a processing unit, a display unit, etc., or two or more functions can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0133] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0134] The electronic device provided in this embodiment is used to execute the above-described service circuit breaker method, and thus can achieve the same effect as the above-described implementation method.
[0135] When using integrated units, the electronic device may further include a processing module, a storage module, and a communication module. The processing module is used to control and manage the operation of the electronic device. The storage module supports the execution of stored program code and data. The communication module supports communication between the electronic device and other devices.
[0136] The processing module can be a processor or a controller. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a digital signal processor (DSP), and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, or other devices that interact with other electronic devices.
[0137] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in this embodiment can be a device having... Figure 2 The device with the structure shown.
[0138] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it causes the processor to perform the service circuit breaker method of any of the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0139] This application also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the service circuit breaker method described above.
[0140] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the service circuit breaker method in the above method embodiments.
[0141] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0142] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0143] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0144] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A service circuit breaker method, said method being executed by an electronic device, characterized in that, The method includes: Obtain first hardware information, which is information collected by the hardware driver at the first moment; If the preset conditions are met based on the first hardware information, the preset service is started, where the preset conditions represent the conditions for starting the preset service. After the preset service is started, second hardware information is obtained. The second hardware information is the information collected by the hardware driver at a second time, which is greater than the first time. If the preset conditions are not met based on the second hardware information, and the preset service is still being executed, then the amount of resources required for the remaining tasks corresponding to the preset service is determined. If the amount of resources required by the remaining tasks exceeds a preset threshold, the preset service will be suspended. Wherein, when the remaining tasks require resources including processor runtime, determining the remaining tasks corresponding to the preset service require resources including: Based on the product relationship between the single-round execution time and the remaining execution rounds in the preset service execution process, the processor running time required for the remaining tasks is determined.
2. The method according to claim 1, characterized in that, The step of determining the processor execution time required for the remaining tasks based on the product relationship between the single-round execution time and the remaining execution rounds in the preset service execution process includes: According to the inclusion The relationship is used to calculate the processor runtime required for the remaining tasks, where, The total epoch is used to calculate the execution time of a single round during the execution of the preset service. The total epoch is used to calculate the remaining execution rounds. CurParams represents the current feature parameter size during a single round of execution during the execution of the preset service. MaxParams represents the maximum feature parameter size during a single round of execution during the execution of the preset service obtained through training. TotalEpoch represents the total number of execution rounds corresponding to the preset service. CurEpoch represents the current number of execution rounds corresponding to the preset service.
3. The method according to claim 1, characterized in that, The step of determining the processor execution time required for the remaining tasks based on the product relationship between the single-round execution time and the remaining execution rounds in the preset service execution process includes: Based on the single-round execution time during the preset service execution process, the product relationship between the computing power coefficient of the electronic device and the remaining execution rounds, the processor running time required for the remaining tasks is determined.
4. The method according to claim 3, characterized in that, The step of determining the processor runtime required for the remaining task based on the product relationship between the single-round execution time in the preset service execution process, the computing power coefficient of the electronic device, and the remaining execution rounds includes: According to the inclusion The relationship is used to calculate the processor runtime required for the remaining tasks, where, Used to calculate the execution time of a single round during the execution of the preset service. The computational power coefficient of the electronic device is used to calculate the remaining execution rounds. CurParams represents the current feature parameter size during a single execution round of the preset service. MaxParams represents the maximum feature parameter size during a single execution round of the preset service obtained through training. MinPower represents the lowest chip computational power among electronic devices of different chip types. CurPower represents the chip computational power of the electronic device. TotalEpoch represents the total number of execution rounds corresponding to the preset service. CurEpoch represents the current number of execution rounds corresponding to the preset service.
5. The method according to claim 1, characterized in that, If the remaining resources required for the task also include battery power, the method further includes: The battery power required for the remaining tasks is determined based on the processor runtime required for the remaining tasks and the power consumption per unit time.
6. The method according to claim 5, characterized in that, The step of determining the battery power required by the remaining tasks based on the processor runtime required by the remaining tasks and the power consumption per unit time includes: The remaining battery power required for the task is calculated based on the formula containing EstimatedRemainTime × PowerRatio, where EstimatedRemainTime represents the processor runtime required for the remaining task, and PowerRatio represents the power consumption per unit time.
7. The method according to any one of claims 1 to 6, characterized in that, The first hardware information includes at least one of the following: display status information of the electronic device's screen, operating status information of the processor, and charging status information of the battery.
8. The method according to claim 7, characterized in that, The step of determining that the preset condition is met based on the first hardware information includes: If the display screen is off, the battery is charging, and the processor is idle for a preset duration, then the preset condition is determined to be met.
9. The method according to any one of claims 1 to 6, characterized in that, The preset services initiated by the electronic device include one or more services.
10. The method according to claim 1, characterized in that, The electronic device includes a hardware driver and a task scheduler. The step of activating a preset service when a preset condition is met based on the first hardware information includes: The task scheduler receives the first hardware information broadcast by the hardware driver; The task scheduler determines that the preset conditions are met based on the first hardware information and then starts the preset service.
11. The method according to claim 10, characterized in that, The electronic device further includes a monitoring module and a circuit breaker determination module. If, based on the second hardware information, it is determined that the preset condition is not met, and the preset service is still being executed, then the amount of resources required for the remaining tasks corresponding to the preset service is determined, including: The monitoring module receives the second hardware information broadcast by the hardware driver; If the preset service is still being executed when the monitoring module determines that the preset condition is not met based on the second hardware information, the monitoring module calls the circuit breaker judgment module to determine the amount of resources required for the remaining tasks corresponding to the preset service.
12. An electronic device, characterized in that, The electronic device includes: One or more processors, and memory; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 11.
13. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the one or more processors being used to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1 to 11.
Citation Information
Patent Citations
Centralized task scheduling
CN105190555A