A method and device for adjusting processor frequency
By detecting the operating status of intra-frame tasks in electronic devices, identifying burst heavy loads and timely adjusting the CPU frequency, the lag problem caused by unregulating frequency in the interactive scenarios is solved, and efficient frequency adjustment and low power consumption are achieved .
Patent Information
- Application Number
- CN202211187165.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2042-09-28
AI Technical Summary
In interactive scenarios such as clicking and sliding, electronic devices may cause a burst of heavy load in the frame due to the failure to adjust the CPU frequency in a timely manner under high refresh rate, resulting in unregulated frequency within the frame, which leads to stuttering in the display screen. The existing technology exists The problems of large frequency modulation delay and high power consumption.
By detecting frame drawing events, obtaining the running status information of current and historical intra-frame tasks, identifying burst heavy loads in-frame, adjusting processor frequency in time, avoiding frame loss, and reducing CPU frequency when not needed to reduce power consumption.
It improves the in-frame load perception accuracy and timeliness of CPU frequency adjustment, reduces the probability of frame drop and overall power consumption, and ensures the performance and user experience of electronic devices.
Smart Images

Figure CN116737357B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of frequency modulation technology, and in particular to a method and device for adjusting processor frequency. Background Art
[0002] For interactive scenes such as clicking and sliding, the screen is required to work at a high refresh rate, which requires the CPU to work at a high frequency. The CPU frequency, i.e., the clock frequency of the CPU, refers to the operating frequency of the CPU during operation, which determines the operating speed of the electronic device. The higher the CPU frequency, the faster the operation speed, and the more complex operations can be processed. In related technologies, the delay of the perceived frequency modulation of sudden heavy loads in interactive operations such as clicking and sliding in applications is large, resulting in the phenomenon of non-frequency modulation within the frame, which in turn causes frame loss, and may eventually cause the display screen of the electronic device to freeze. Summary of the invention
[0003] In view of this, the present application provides a method and device for adjusting processor frequency to solve at least part of the above problems. The disclosed technical solution is as follows:
[0004] In the first aspect, the present application provides a method for adjusting the processor frequency, which is applied to an electronic device, the electronic device including a touch screen and a processor, the method including: in response to detecting a frame drawing event, obtaining the running status information of the task in the current drawing frame, the running status information including the load of the task in the current drawing frame; obtaining the frame rate corresponding to the current running state of the electronic device; based on the running status information of the task in the current drawing frame, and the running status information of the task in the pre-recorded historical drawing frame, determining that the current drawing frame has frame loss; and increasing the operating frequency of the processor. In this way, it is possible to avoid the situation where frame loss occurs due to a sudden heavy load in the frame but the CPU frequency is not increased in time. Moreover, the scheme adjusts the CPU frequency only when a sudden heavy load is sensed in the frame, rather than allowing the CPU to run at a high frequency regardless of whether there is a sudden heavy load in the frame. Therefore, the method reduces the overall power consumption while ensuring the performance of the electronic device.
[0005] In a possible implementation of the first aspect, based on the running status information of the task in the current drawing frame and the running status information of the task in the pre-recorded historical drawing frame, it is determined that the current drawing frame has frame loss, including: if the running status information of the task in the current drawing frame is greater than the running status information of the task in the historical drawing frame, it is determined that the current drawing frame has frame loss.
[0006] In another possible implementation of the first aspect, the running status information includes the running time of the task in the drawing frame; if the running status information of the task in the current drawing frame is greater than the running status information of the task in the historical drawing frame, it is determined that the current drawing frame has frame loss, including: if the running time of the task in the current drawing frame is greater than the running time of the same task in the historical drawing frame, it is determined that the current drawing frame has frame loss. This scheme compares the running time of each task in the current frame and the historical frame to determine whether the current frame may have frame loss. If the running time of the task in the current frame is greater than the running time of the same task in the historical frame, the current frame may have frame loss. The method of identifying whether the current frame has frame loss based on the running time of the task in the frame can accurately perceive the running time of the task in the frame, improve the perception accuracy of the load in the frame, and then improve the speed of perceiving possible sudden heavy loads in the frame. Further, when it is perceived that there may be sudden heavy loads in the frame, the CPU frequency is adjusted in time to reduce the probability of frame loss.
[0007] In another possible implementation of the first aspect, the running status information includes the stage load of the task in the drawing frame within a specified time period; if the running status information of the task in the current drawing frame is greater than the running status information of the task in the historical drawing frame, it is determined that the current drawing frame has frame loss, including: obtaining the stage load of the task in the current drawing frame within the specified time period; if the stage load of the task in the current drawing frame within the specified time period is greater than the stage load of the task in the historical drawing frame within the same time period, it is determined that the current drawing frame has frame loss. This method can be applied to scenarios where the drawing thread performs any task. In other words, it can be applied to scenarios where the current frame is a doframe drawing process, and it is also applicable to scenarios where the current frame is a non-doframe drawing process, which expands the scope of application of this solution, so that more scenarios can promptly perceive the sudden heavy load in the frame and adjust the CPU frequency in time, thereby improving the overall performance of the electronic device.
[0008] In another possible implementation of the first aspect, the stage load of the task in the current drawing frame within the specified time period is obtained, including: collecting the total number of instructions of the task in the current drawing frame within the specified time period, and determining the total number of instructions as the stage load; or, obtaining the running time of the task in the current drawing frame within the specified time period, and determining the running time as the stage load.
[0009] In yet another possible implementation of the first aspect, increasing the operating frequency of the processor includes: increasing a minimum frequency value; and increasing the operating frequency of the processor so that the increased operating frequency is greater than or equal to the increased minimum frequency value.
[0010] In another possible implementation of the first aspect, the method further includes: determining that the current drawing frame will not have frame loss based on the running status information of the task in the current drawing frame and the running status information of the task in the pre-recorded historical drawing frames; and controlling the processor to maintain the original frequency.
[0011] In another possible implementation of the first aspect, the running status information includes the running time of the task in the drawing frame; based on the running status information of the task in the current drawing frame and the running status information of the task in the pre-recorded historical drawing frames, it is determined that the current drawing frame will not have frame loss, including: if the running time of the task in the current drawing frame is less than or equal to the running time of the same task in the historical drawing frame, it is determined that the current drawing frame will not have frame loss.
[0012] In another possible implementation of the first aspect, the running status information includes the running time of the task in the drawing frame; based on the running status information of the task in the current drawing frame and the running status information of the task in the historical drawing frame recorded in advance, it is determined that the current drawing frame will not have frame loss, including: the running status information includes the stage load of the task in the drawing frame within a specified time period; based on the running status information of the task in the current drawing frame and the running status information of the task in the historical drawing frame recorded in advance, it is determined that the current drawing frame will not have frame loss, including: if the stage load of the task in the current drawing frame in the specified time period is less than the stage load of the task in the historical drawing frame in the same time period, it is determined that the current drawing frame will not have frame loss.
[0013] In another possible implementation of the first aspect, the method further includes: based on the running status information of the tasks in the current drawing frame, identifying the key tasks in the current drawing frame, and determining the load value of the key tasks, the key tasks are tasks that affect the user's perceived experience, and the running status information also includes the task content of the tasks in the current drawing frame and the relationship between different drawing frames; if it is determined that the current drawing frame has frame loss, the key tasks are assigned to the processor core whose computing power matches the load of the key tasks for execution. It can be seen that this solution can timely increase the CPU frequency after a sudden heavy load in the frame, and can further reselect the core for the key tasks in the frame, that is, reallocate the key tasks in the frame to the CPU core with higher computing power, further improving the overall performance of the electronic device.
[0014] In a second aspect, the present application also provides an electronic device, comprising one or more processors, a memory and a touch screen; the memory is used to store program code; the processor is used to run the program code, so that the electronic device implements the method for adjusting the processor frequency as described in any one of the first aspects.
[0015] In a third aspect, the present application further provides a computer-readable storage medium having instructions stored thereon, which, when the instructions are executed on an electronic device, enables the electronic device to execute the method and apparatus for adjusting the processor frequency as described in any one of the first aspects.
[0016] In a fourth aspect, the present application further provides a computer program product having an executable program stored thereon, which, when the computer program product is run on an electronic device, enables the electronic device to implement the method and apparatus for adjusting the processor frequency as described in any one of the first aspects.
[0017] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single embodiment. On the contrary, it is understood that the description of features or beneficial effects means that specific technical features, technical solutions or beneficial effects are included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in this specification does not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions and beneficial effects described in the present embodiment can also be combined in any appropriate manner. Those skilled in the art will understand that the embodiment can be realized without one or more specific technical features, technical solutions or beneficial effects of a specific embodiment. In other embodiments, additional technical features and beneficial effects can also be identified in a specific embodiment that does not embody all embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 is a schematic diagram of a sliding interaction scenario provided in an embodiment of the present application;
[0020] Figure 2 is a block diagram of an electronic device provided in an embodiment of the present application;
[0021] Figure 3 It is a software structure block diagram of an electronic device provided in an embodiment of the present application;
[0022] Figure 4 This is a method flow for adjusting processor frequency provided by an embodiment of the present application;
[0023] Figure 5 is a schematic diagram of a stage load provided in an embodiment of the present application;
[0024] Figure 6 is a schematic diagram of a frame drawing process provided by an embodiment of the present application;
[0025] Figure 7 It is a schematic diagram of another frame drawing process provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The terms "first", "second", "third", etc. in the specification, claims and drawings of this application are used to distinguish different objects rather than to limit a specific order.
[0027] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0028] See also Figure 1 , shows a schematic diagram of a sliding interaction scenario provided by an embodiment of the present application, and this embodiment is described by taking a mobile phone as an example of an electronic device. Figure 1 As shown in (1), the screen of the mobile phone 10 displays page 100, and the current content displayed on page 100 is text. When the finger slides upward on page 100, page 100 moves upward, and the content included in page 100 displayed on the screen moves along with the sliding operation. For example, as the user slides the finger upward, the content displayed on page 100 changes to Figure 1 The content shown in (2) is as follows. Figure 1 As shown in (2), the page 100 includes a video window 101, and the video content is displayed in the video window 101. Obviously, the refresh rate required when the screen displays video content is higher than the refresh rate required for displaying text content. It can be seen that the user's sliding operation this time will cause a burst of heavy load frames.
[0029] In the related art, one way to adjust the processor frequency is to periodically calculate the overall load of the CPU and adjust the CPU frequency according to the overall load of the CPU. There is a time difference between the time when the overall load of the CPU is calculated and the start time of drawing the frame, that is, the frequency modulation timing is not aligned with the drawing frame, which may cause a large delay in the frequency modulation. In addition, when calculating the overall load of the CPU, a linear accumulation form is usually adopted. In interactive scenarios such as clicking and sliding, for sudden heavy-load frames, the delay of load-aware frequency modulation is large, and even the frequency modulation within the frame may not occur, which may cause the display screen to become stuck.
[0030] In addition, another method of adjusting the processor frequency in the related art is: global frequency increase, that is, regardless of whether the drawing frame is suddenly heavily loaded, the CPU will operate at the increased frequency, which will cause the electronic device to consume more power. For example, when the drawing frame does not require more system resources, the CPU still operates at a higher frequency, which will cause a waste of system resources and increase the power consumption of the electronic device.
[0031] The method for adjusting the processor frequency provided in the embodiment of the present application quickly perceives the sudden heavy load in the frame by identifying the running state of the drawing frame (i.e., the current frame) in an interactive scene (such as click and slide operations in social, news, shopping, browsing, music, video, games, etc.), combined with the running state of the historical frame (referring to the drawing frame that has been drawn before the current frame), and further adjusts the CPU frequency in time, reducing the delay of the sudden load perception and CPU frequency adjustment in the frame. Moreover, this method only increases the CPU frequency for tasks with sudden heavy loads in the frame, reducing the overall power consumption while ensuring the performance of the electronic equipment.
[0032] In some embodiments, the electronic device can be a mobile phone, a tablet computer, a desktop, a laptop, a notebook computer, an ultra-mobile personal computer (UMPC), a handheld computer, a netbook, a personal digital assistant (PDA), a wearable electronic device, a smart watch, or the like.
[0033] See also Figure 2 , shows a block diagram of an electronic device provided in an embodiment of the present application.
[0034] like Figure 2 As shown, the electronic device may include a processor 201 , a memory 202 and a touch screen 203 .
[0035] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0036] The processor 201 may include one or more processing units, for example, the processor 201 may include an application processor (AP), a graphics processing unit (GPU), an image signal processor (ISP), a digital signal processor (DSP), etc. Among them, different processing units may be independent devices or integrated into one or more processors. For example, in an embodiment of the present application, the processor may sense a sudden heavy load in a frame and adjust the operating frequency of the processor in a timely manner.
[0037] The memory 202 may be used to store computer executable program codes, which include instructions. The processor 201 executes various functional applications and data processing of the electronic device by running the instructions stored in the memory 202. For example, in an embodiment of the present application, the processor 201 may quickly sense a burst heavy load within a frame by executing the instructions in the memory 202, and adjust the operating frequency of the processor in a timely manner.
[0038] The processor 201 executes various functional applications and data processing of the electronic device by running instructions stored in the memory 202 and / or instructions stored in the memory provided in the processor.
[0039] The touch screen 203 includes a display screen and a touch screen, and the display screen is used to display images, videos, etc. The display screen can display a series of graphical user interfaces (GUIs), and these GUIs are the main screens of the electronic device.
[0040] The touch screen is used to detect touch operations applied thereto or thereabout, and the touch screen can pass the detected touch operations to the application processor to determine the type of touch event. Visual output related to the touch operations can be provided through the display screen.
[0041] The touch screen may be disposed above the display screen, and the touch screen covers the display screen. In other embodiments, the touch screen may also be disposed on the surface of the electronic device, at a position different from that of the display screen.
[0042] In addition, an operating system is run on the above components, and application programs can be installed and run on the operating system.
[0043] The operating system of the electronic device may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device.
[0044] Figure 3 It is a software structure block diagram of the electronic device according to an embodiment of the present application.
[0045] The layered architecture divides the software into several layers, each with clear roles and division of labor. The 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 library, and the kernel layer.
[0046] The application layer can include a series of application packages. Figure 3 As shown, the application package may include applications such as video, music, map, call, etc. For example, in the embodiment of the present application, the application package may also include social applications, which will not be described in detail here.
[0047] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 3 As shown, the application framework layer may include a frame identification and frame event identification module, which is used to identify frames and frame drawing events.
[0048] In addition, the application framework layer may also include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.
[0049] For example, in an embodiment of the present application, when adjusting the processor frequency, the application framework layer can provide the application layer with an API related to the function of adjusting the processor frequency, and provide the application layer with corresponding interface management services to implement the scene orchestration function.
[0050] The system library can include multiple functional modules, such as surface manager, media libraries, etc.
[0051] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0052] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0053] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0054] The kernel layer is a layer between hardware and software. In the embodiment of the present application, the kernel layer may include: a stable frame sniffer module, a key task group scheduling module, a load prediction engine module and a frame scheduler module. In addition, the kernel layer may also include a display driver, a camera driver, an audio driver, and a sensor driver.
[0055] The stable frame sniffer module mainly identifies the refresh rate in the current running state (i.e., the target frame rate in the figure) and passes it to the load prediction engine module. This application involves interactive scenes, and the refresh rates of 60Hz, 90Hz, 120Hz and other values are supported by default in the interactive scenes.
[0056] The key task group scheduling module mainly realizes the identification of key tasks and non-key tasks of drawing frames, creates groups (cgroups) for key tasks of drawing frames, and performs group scheduling and task core selection for key task groups.
[0057] The load prediction engine module receives the frame information transmitted by the frame identification and frame event identification module, such as the running status of the current frame, for example, the task running time in the current frame, the stage load, etc. At the same time, the module records the running status of the historical frames, for example, the task running time in the historical frames, the stage load and the historical running status (for example, whether there is a frame loss).
[0058] The load prediction engine module combines the running status of the current frame and the running status of the historical frames to determine whether the current frame is likely to be lost. If it is determined that the current frame is likely to be lost, the CPU frequency can be adjusted in time in combination with the platform energy efficiency model.
[0059] In a possible implementation, load prediction can be implemented by a load prediction model, such as Figure 3 As shown, the input of the load prediction model is the information of the current frame and historical frames. The load prediction model uses the target frame rate output by the stable frame sniffer module and the platform energy efficiency model as the optimization target. When it is determined that there is a high probability of frame loss in the current frame, it is determined that the processor frequency needs to be increased. Finally, the minimum frequency value minFreq after the value is increased is output and passed to the frame scheduler module.
[0060] In some embodiments, the frame scheduler module includes an intra-frame frequency modulation submodule. The intra-frame frequency modulation submodule determines that the minimum frequency value output by the load prediction engine module is greater than the minimum frequency value currently used by the frame scheduler module, and then increases the CPU frequency according to the latest received minimum frequency value, thereby meeting the demand for increasing the CPU frequency when the intra-frame burst is heavily loaded, and avoiding the phenomenon of frame loss due to intra-frame timeout.
[0061] In some other embodiments, the frame scheduler module may further include a task core selection submodule. The task core selection submodule receives the information of the key task transmitted by the key task group scheduling module. When the load prediction engine module determines that the current frame may have a frame loss situation, the task core selection submodule allocates the key task to a CPU core with stronger capability to run according to the received information of the key task, thereby ensuring that the key task can be completed within the preset time.
[0062] It should be noted that although the embodiments of the present application are described using the Android system as an example, its basic principles are also applicable to electronic devices based on other operating systems.
[0063] The following will be combined Figure 4 , introduces a method for adjusting processor frequency provided by an embodiment of the present application. The method is applied to Figure 2 In the electronic device shown.
[0064] like Figure 4 As shown, the method may include the following steps:
[0065] S11, the user performs interactive operations on the APP interface, such as clicking, sliding, etc.
[0066] S12, after the frame recognition and frame drawing event recognition module detects the user's interactive operation, it recognizes the drawing frame and obtains the running state information of the drawing frame.
[0067] The frame identification and frame drawing event identification module can identify the drawing frame and the drawing frame event, and further can obtain the running state information of the drawing frame. In one embodiment, the running state information of the drawing frame may include the process identifier (PID) of the current frame, the start time of a frame, the running state (such as the running time), and other information.
[0068] S13, the frame identification and frame drawing event identification module sends the running status information of the drawing frame to the key task group scheduling module.
[0069] In one embodiment of the present application, the frame identification and frame drawing event identification modules send the running status information of the drawing frame to the key task group scheduling module and the load prediction engine module respectively at S13 and S16.
[0070] S14, the key task group scheduling module identifies the key tasks in the current frame drawing event.
[0071] In the time period between the start and end of a frame, there are multiple dimensions and multiple entity objects. Entity objects include CPUs, tasks, etc. Multiple entity objects are interdependent, and have different states and relationships in different time and order dimensions. Each thread corresponds to a different CPU frequency at different time points, and different CPU frequencies correspond to different computing capabilities.
[0072] The critical task group scheduling module can analyze the task correlation and association between frames according to the task content, status, and load of the tasks in the acquisition frame, extract the features of the tasks in the frame, and classify the tasks. In one example, a cluster analysis method can be used to count the load, correlation, and other features of each task in the frame, and cluster and classify the tasks according to these features to obtain critical tasks and non-critical tasks.
[0073] The most obvious feature of critical tasks and non-critical tasks is whether they affect the user's perceived experience. If a task has an impact on the user's perceived experience, it is a critical task. If a task has no impact or little impact on the user's perceived experience, it is considered a non-critical task.
[0074] S15, the critical task group scheduling module sends the critical task information to the frame scheduler module.
[0075] S16, the frame identification and frame drawing event identification module sends the running status information of the drawing frame to the load prediction engine module.
[0076] S17, the frame recognition and frame drawing event recognition module triggers the stable frame sniffer module to obtain the target frame rate in the current operating state of the system.
[0077] When the frame recognition and frame drawing event recognition module recognizes a frame drawing event, it triggers the stable frame sniffer module to obtain the frame rate of the electronic device in the current operating state, that is, the target frame rate. The frame rate (Frame Per Second, FPS) is the frequency at which images in frames appear continuously on the display, that is, the number of frames displayed per second, in Hz. The higher the frame rate, the more stable the image, and the more natural and clear the image display is. The lower the frame rate, the more severe the image flickering and jittering. The higher the frame rate, the higher the requirement for the CPU operation speed, that is, the higher the CPU frequency required. Therefore, obtaining the frame rate of the system in the current operating state can determine the CPU frequency that matches the frame rate.
[0078] In an embodiment of the present application, the frame rate in an interactive scenario (such as a click or slide operation scenario) can be identified by a display driver module. The frame rate in the interactive scenario can be any one of 60 Hz, 90 Hz, 120 Hz, 144 Hz, etc.
[0079] S18, the frame sniffer module sends the target frame rate to the load prediction engine module.
[0080] The frame sniffer obtains the target frame rate and sends it to the load prediction engine module, so that the load prediction engine module adjusts the CPU frequency with reference to the target frame rate.
[0081] S19, the load prediction engine module predicts whether the current frame is lost based on the running status information of the current frame and the historical frames; if yes, execute S111; if not, execute S110.
[0082] The current frame refers to the frame that the drawing thread is drawing, and the historical frame is the frame that has been drawn before the current frame.
[0083] If the total running time of the drawing thread and rendering thread of a frame exceeds the duration of a frame, frame loss will occur. The duration of a frame is the time interval for refreshing a frame. The duration of a frame depends on the frame rate. The higher the frame rate, the shorter the frame duration. For example, the refresh rate is 60Hz, that is, the screen is refreshed once at 16.6ms, and the duration of a frame is about 16ms; the refresh rate is 90Hz, and the duration of a frame is about 11ms; the refresh rate is 120Hz, and the duration of a frame is about 8ms.
[0084] In a possible implementation, the load prediction engine module predicts whether the current frame has a burst heavy load based on the running status information of the current frame and the running status information of the historical frame. If it is determined that the current frame has a burst heavy load, it is determined that the current frame may have a frame loss. If it is determined that the current frame will not have a burst heavy load, it is determined that the current frame will not have a frame loss.
[0085] In one scenario, you can detect whether a sudden heavy load occurs in the current frame by recording the stage load of the UI thread in the historical frame and calculating the stage load of the UI thread in the current frame. Calculate the stage load of the current frame and compare it with the stage load of the historical frame in the same time period to determine whether a sudden heavy load occurs in the current frame. If the stage load of the current frame is greater than the stage load of the historical frame, it is determined that the current frame may suddenly experience a heavy load; if the stage load of the current frame is less than the stage load of the historical frame, it is determined that the current frame will not suddenly experience a heavy load.
[0086] The stage load is the load value within a period of time. For example, the running time of the UI thread in the current frame can be obtained through the sum_exec_time thread in the kernel, or the number of UI thread instructions in the current frame can be collected through the pmu information to obtain the stage load value of the UI thread. For example, the longer the running time of the thread, the greater the load value of the thread. Similarly, the more instructions a thread has, the greater the load value of the thread.
[0087] In a possible implementation, a timer with a preset duration can be pre-set, and the timer is started after the drawing thread is detected to be started. After the timer reaches the preset duration, the running duration or number of instructions of the thread is obtained to obtain the stage load corresponding to the time period. The entire running process of the drawing thread can usually include multiple time periods with preset durations. Figure 5 As shown, assuming that the start time of the drawing thread is t0, the preset duration is T, and the timing starts from t0. When the timing duration reaches T, it is recorded as time t1. At this time, the load value L1 of the drawing thread is obtained, that is, the load value corresponding to the time period t0 to t1. At time t1, the timer is reset and the timing starts again. When the timing duration reaches T, it is recorded as time t2, and the load value L2 of the time period t0 to t2 is obtained. By analogy, the load value L3 of the time period t0 to t3 is obtained at time t3, the load value L4 of the time period t0 to t4 is obtained at time t4, and the load value L5 of the time period t0 to t5 is obtained at time t5.
[0088] In one example, if Figure 6 As shown, frame1 is a historical frame, frame2 is a current frame, and the Vsync signal is a screen refresh signal emitted by the screen, wherein the Vsync signal is used to synchronize the start time of the UI drawing thread with the screen refresh time.
[0089] Frame1 executes the frame drawing process (executed by the UI thread and running in the CPU), which may include multiple tasks (or tasks), such as Task 1 to Task 3. For example, in the Android system, the frame drawing process (such as the doframe process) mainly includes tasks such as input, animation, and traversal. It should be understood that in other operating systems, the frame drawing process may include other tasks, and this application does not limit this.
[0090] After the UI task of frame1 is completed, the render thread (i.e., the rendering thread, running in the GPU) is awakened to work. At the same time, the UI thread handles other drawing tasks. For example, in the Android system, other drawing tasks may include other logical computing tasks such as prefetch and inflation. For example, the prefetch task is mainly used to pre-fetch the drawing computing task of the next frame in advance, and the inflation task is mainly used to perform more complex logical tasks. Of course, other drawing tasks can also be tasks other than prefetch and inflation, and this application does not limit other drawing tasks.
[0091] Assume that the running time of task 1 in frame 1 is T1, the running time of task 2 is T2, and the running time of task 3 is T3. Assume that the running time of other drawing tasks after the UI task of frame 1 is completed is T4. Figure 6 As shown, the timer starts timing when it receives the Vsync signal after frame1 ends (i.e., the start time of frame2). Assuming that the timing duration of the timer is T, when the timer reaches the timing duration, other drawing tasks have not yet ended, so the running duration of frame2 is T. The running duration of task 1 of frame1 is T1, and T1<T. That is, in the same time period, the running duration of the task in the current frame frame2 is greater than the running duration of task 1 in the historical frame frame1, that is, the stage load of frame2 is greater than the stage load of frame1 in the same time period. Therefore, it can be determined that frame2 may have a sudden heavy load, that is, frame2 may have a frame loss situation.
[0092] In addition, if Figure 6 As shown, after the rendering thread of frame1 ends, that is, the drawing thread and rendering thread of frame1 have completed their corresponding tasks, the other tasks executed by the UI thread have not yet ended, and the other tasks have not yet ended after receiving the Vsync signal, that is, the UI thread should execute the drawing process of the next frame in frame2, but at this time the UI thread is still executing other tasks and cannot execute the drawing process of the next frame. It can be seen that frame2 will have frame loss, that is, the picture of frame1 is still displayed in frame2.
[0093] The above method of determining whether there is an intra-frame burst heavy load through the intra-frame stage load can be applied to scenarios where the current frame is a normal drawing process (such as a doframe drawing process) and can also be applied to scenarios where the current frame is other drawing processes (such as a non-doframe drawing process).
[0094] In another scenario, by monitoring the running time of each task in the current frame and the historical frame and the historical running relationship, it is possible to perceive whether there is a sudden heavy load in the current frame. In one possible implementation, the running time of the task in the current frame is monitored, and the running time of the currently monitored task is compared with the running time of the same task in the historical frame. If the running time of the task in the current frame is greater than the running time of the same task in the historical frame, it is determined that the current frame may have a sudden heavy load. If the running time of the task in the current frame is less than or equal to the running time of the same task in the historical frame, continue to monitor whether the running time of the next task in the current frame is greater than the running time of the same task in the historical frame. If the running time of all tasks in the current frame is not greater than the running time of the same task in the historical frame, it is determined that the current frame will not have a sudden heavy load.
[0095] In one example, for example, Figure 7 As shown, frame1 is the historical frame and frame2 is the current frame. Both frame1 and frame2 are doframe drawing processes. When task 1 in frame2 is detected to be finished, the running time of task 1 is 10ms, while the running time of task 1 in the historical frame frmae1 is 4ms. It can be seen that the running time of task 1 in the current frame is greater than the running time of task 1 in the historical frame. The current frame may have a sudden heavy load, that is, frame2 may drop frames.
[0096] In other embodiments of the present application, if the running time of Task 1 of frame 2 is not greater than the running time of Task 1 of frame 1, then the running time of Task 2 of the current frame and the historical frame is continued to be compared. If Task 2 of frame 2 is not greater than the running time of Task 2 of frame 1, then the running time of Task 3 of frame 2 is continued to be compared to see whether it is greater than the running time of Task 3 of frame 1. If Task 3 of the current frame 2 has not yet ended, and Task 3 has run for 6ms as of the current moment, and the total running time of Task 3 of frame 1 is 4ms, it can be seen that the running time of Task 3 in frame 2 is greater than the running time of Task 3 in frame 1, so it is determined that frame 2 may have a sudden heavy load.
[0097] The above method of determining whether there is a sudden heavy load in a frame by the running time of the task in the frame is applied to the normal drawing process (such as the doframe drawing process) scenario. In addition, this method can accurately perceive the running time of the task in the frame, and can determine whether the current frame is suddenly heavily loaded when executing a certain task in the frame, thereby improving the perception accuracy of the load in the frame, and can adjust the CPU frequency in time when there is a sudden heavy load in the frame, thereby improving the timeliness of CPU frequency adjustment.
[0098] S110, the load prediction engine module does not update the output frequency value.
[0099] If the load prediction engine module determines that the current frame will not have a sudden heavy load, that is, no frame loss will occur, there is no need to update the output frequency value. The frame scheduler module controls the CPU frequency according to the locally saved frequency value, wherein the locally saved frequency value of the frame scheduler module can be the output frequency value when the load prediction engine module last adjusted the CPU frequency.
[0100] S111, the load prediction engine module updates the output frequency value based on the target frame rate and the platform energy efficiency model.
[0101] The platform energy efficiency model here is the basic energy efficiency model of Energy Aware Scheduling (EAS), which needs to consider the CPU's computing power and power consumption. The load prediction engine module determines the CPU frequency and selects which CPU core the task runs on based on the target frame rate and the platform energy efficiency model, ultimately meeting the task running requirements while ensuring low CPU power consumption.
[0102] If it is determined that the current frame may burst into heavy load, that is, frame loss may occur, in this case, the CPU frequency needs to be increased, and the load prediction engine module updates the output frequency value, such as increasing the minimum frequency value of the output. In this way, the frame adjustment module adjusts the CPU frequency according to the updated output frequency value (the increased minimum frequency value).
[0103] In other embodiments of the present application, if the load prediction engine module determines that the execution time of the frame drawing process is less than one frame, it is determined that no frame will be lost, and a decision is made based on the platform energy efficiency model whether to reduce the CPU frequency (e.g., reduce the maximum frequency value).
[0104] In a possible implementation, the load prediction engine module may output a target CPU frequency value, and the frame scheduler module may directly adjust the CPU frequency based on the target CPU frequency value. When the CPU frequency needs to be adjusted, the target CPU frequency value is updated and passed to the frame scheduling module.
[0105] In another possible implementation, the load prediction engine module may output a maximum frequency value and a minimum frequency value, and when the CPU frequency needs to be increased, the minimum frequency value is increased, and when the CPU frequency needs to be reduced, the maximum frequency value can be reduced.
[0106] In another possible implementation, when the CPU frequency needs to be increased, only the minimum frequency value of the output is updated. When the CPU frequency needs to be reduced, only the maximum frequency value of the output can be updated.
[0107] S112, the load prediction engine module sends the updated output frequency value to the frame scheduler module.
[0108] S113, the frame scheduler module adjusts the CPU frequency based on the updated output frequency value.
[0109] After receiving the updated output frequency value, the frame scheduler module adjusts the frequency of the CPU based on the received frequency value.
[0110] For example, when the load prediction engine module outputs an increased minimum frequency value, the frame scheduler module increases the CPU frequency based on the increased minimum frequency value. When the load prediction engine module outputs a decreased maximum frequency value, the frame scheduler module decreases the CPU frequency based on the decreased maximum frequency value.
[0111] S114, selecting a CPU core that matches the critical task for the critical task.
[0112] The method for adjusting the processor frequency provided in this embodiment obtains the running status of the current frame, analyzes the running status of the current frame in combination with the running status of the historical frame, determines whether the current frame will be lost, and if the current frame may be lost, adjusts the CPU frequency in time, thereby avoiding the situation where a sudden heavy load occurs in the frame but the CPU frequency is not increased in time, resulting in frame loss. Moreover, the scheme adjusts the CPU frequency only when a sudden heavy load is sensed in the frame, rather than allowing the CPU to run at a high frequency regardless of whether there is a sudden heavy load in the frame. Therefore, the method reduces the overall power consumption while ensuring the performance of the electronic device.
[0113] Moreover, the method for adjusting the processor frequency provided by the present embodiment can be performed by calculating the stage load of the current frame within a period of time. If the stage load of the current frame is greater than the stage load of the historical frame in the same period of time, it is determined that the current frame may have a sudden heavy load, that is, a frame loss may occur. If the stage load of the current frame is less than the stage load of the historical frame in the same period of time, it is determined that the current frame will not have a sudden heavy load, that is, a frame loss will not occur. Further, the method also provides a method for calculating the running time of the task in the current frame, and combining the running time of the same task in the historical frame and the running conditions of the historical frame to determine whether the current frame has a sudden heavy load. If the running time of the task in the current frame is greater than the running time of the same task in the historical frame, it is determined that the current frame will have a frame loss. If the running time of the task in the current frame is less than the running time of the same task in the historical frame, it is determined that the current frame will not have a frame loss. It can be seen that the scheme can accurately monitor the running conditions of the tasks in the drawing frame, improve the accuracy of the load perception in the frame, and thus improve the frequency modulation speed in the frame.
[0114] The above embodiment uses an electronic device running the Android system as an example to illustrate the process of sensing the load within a frame and adjusting the CPU frequency in time after sensing a sudden heavy load within the frame. It should be understood that the process of sensing a sudden heavy load within a frame and adjusting the CPU in time is also applicable to other operating systems, and adaptive modifications can be made according to the software architecture of other operating systems. This application will not go into details.
[0115] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, 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 is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0116] In the several embodiments provided in this embodiment, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0117] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0118] In addition, each functional unit in each embodiment of the present embodiment may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0119] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment. The aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk and other media that can store program codes.
[0120] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for adjusting processor frequency, characterized in that: Applied to an electronic device, the electronic device includes a touch screen and a processor, the processor runs a frame recognition and frame drawing event recognition module, a stable frame sniffer module, a load prediction engine module and a frame scheduler, the method includes: After the frame recognition and frame drawing event recognition module detects the user's interactive operation on the application interface, it recognizes the application's drawing frame event, and obtains and records the running state information of the task in the current drawing frame, wherein the running state information includes the stage load of the task in the frame; The frame identification and frame drawing event identification module transmits the running status information of the current drawing frame and the running status information of the historical drawing frames that record no frame loss to the load prediction engine module; The stable frame sniffer module obtains the target frame rate corresponding to the current operating state of the electronic device and transmits it to the load prediction engine module; The load prediction engine module obtains the stage load of the task in the current drawing frame within the specified time period, and determines that the current drawing frame has frame loss if the stage load of the task in the current drawing frame within the specified time period is greater than the stage load of the task in the historical drawing frame within the same time period, wherein the stage load is the total number of instructions of the task in the current drawing frame within the specified time period, or is the running time of the task in the current drawing frame within the specified time period; After determining that the current rendering frame has frame loss, the load prediction engine module updates the output frequency value based on the target frame rate, the computing capability and power consumption of the processor and transmits the updated value to the frame scheduler; The frame scheduler increases the operating frequency of the processor based on the updated output frequency value.
2. The method according to claim 1, characterized in that The updated output frequency value is the minimum frequency value after the increase; The frame scheduler increases the operating frequency of the processor based on the updated output frequency value, including: increasing the operating frequency of the processor so that the increased operating frequency is greater than or equal to the increased minimum frequency value.
3. The method according to claim 1, characterized in that The method further comprises: The load prediction engine module detects that the load state of the task in the current drawing frame is lower than the load state of the task in the pre-recorded historical drawing frame, determines that the current drawing frame will not be lost, and controls the processor to maintain the original frequency operation.
4. The method according to claim 3, characterized in that The running status information includes the running time of the task in the drawing frame; The load prediction engine module detects that the load state of the task in the current drawing frame is lower than the load state of the task in the pre-recorded historical drawing frame, and determines that the current drawing frame will not be lost, including: The load prediction engine module detects that the running time of the task in the current drawing frame is less than or equal to the running time of the same task in the historical drawing frame, and determines that the current drawing frame will not be lost.
5. The method according to claim 3, characterized in that: The running status information includes the stage load of the task in the drawing frame within a specified time period; The load prediction engine module detects that the load state of the task in the current drawing frame is lower than the load state of the task in the pre-recorded historical drawing frame, and determines that the current drawing frame will not be lost, including: The load prediction engine module detects that the stage load of the task in the current drawing frame in a specified time period is less than the stage load of the task in the historical drawing frame in the same time period, and determines that the current drawing frame will not be lost.
6. The method according to claim 1, characterized in that The electronic device further includes a key task group scheduling module, and the method further includes: The key task group scheduling module identifies the key tasks in the current drawing frame based on the running status information of the tasks in the current drawing frame, and determines the load value of the key tasks, wherein the key tasks are tasks that affect the user's perceived experience, and the running status information further includes the task content of the tasks in the current drawing frame and the relationship between different drawing frames; After receiving the updated output frequency value, the frame scheduler allocates the critical task to a processor core whose computing power matches the load of the critical task for execution.
7. An electronic device, characterized in that: The electronic device comprises: one or more processors, a memory and a touch screen; the memory is used to store program code; the processor is used to run the program code, so that the electronic device implements the method for adjusting the processor frequency as described in any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that: Instructions are stored thereon, and when the instructions are executed on an electronic device, the electronic device executes the method for adjusting the processor frequency as claimed in any one of claims 1 to 6.
Citation Information
Patent Citations
Regulating method and regulating device for hardware refresh rate of terminal
CN105094272A
Scheduling device working frequency adjusting method and device and storage medium
CN111221654A
Load processing method and device, electronic equipment and computer readable storage medium
CN115048221A