WO2020078314A1 - 加速应用的冷启动的方法、装置和终端 - Google Patents

加速应用的冷启动的方法、装置和终端 Download PDF

Info

Publication number
WO2020078314A1
WO2020078314A1 PCT/CN2019/111015 CN2019111015W WO2020078314A1 WO 2020078314 A1 WO2020078314 A1 WO 2020078314A1 CN 2019111015 W CN2019111015 W CN 2019111015W WO 2020078314 A1 WO2020078314 A1 WO 2020078314A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
cold start
terminal
operating system
items
Prior art date
Application number
PCT/CN2019/111015
Other languages
English (en)
French (fr)
Inventor
李涛
姚旺来
叶飞
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP19872828.9A priority Critical patent/EP3851956B1/en
Publication of WO2020078314A1 publication Critical patent/WO2020078314A1/zh
Priority to US17/230,737 priority patent/US20210232429A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44568Immediately runnable code
    • G06F9/44578Preparing or optimising for loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3055Monitoring arrangements for monitoring the status of the computing system or of the computing system component, e.g. monitoring if the computing system is on, off, available, not available
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3877Concurrent instruction execution, e.g. pipeline or look ahead using a slave processor, e.g. coprocessor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5044Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering hardware capabilities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/541Interprogram communication via adapters, e.g. between incompatible applications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/865Monitoring of software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/508Monitor
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the invention relates to the field of computers, and in particular to a method, device and terminal for cold start applications.
  • the cold start of an application means that when the application is started, there is no process for running the application in the operating system, that is, during the startup process of the application, the operating system creates a new process and assigns it to the application.
  • resources may include processors, such as central processing unit (CPU) or graphics processing unit (GPU), memory, I / O (input / output) resources, and network resources. Since there are many applications installed on a terminal, the resource allocation method will affect the application startup time.
  • embodiments of the present invention provide a cold start application method, device, and terminal.
  • a cold start application method By analyzing terminal usage scenarios, current terminal operating system load and cold start application system overhead and other dimensions of information, more accurate A set of optimization strategies are determined more specifically. The combined use of these optimization strategies can enable the terminal to complete the cold start of the application more quickly.
  • an embodiment of the present invention provides a method for cold-starting an application.
  • the method includes: a terminal collects status information based on a detected startup event, the startup event instructs the terminal's operating system to cold-start an application, and the status information includes The hardware configuration of the terminal, the current load of the operating system, the resource overhead of cold-starting the application, and the respective duration of multiple tasks in the process of cold-starting the application; based on the current status information, a set of acceleration items corresponding to the application are determined , The set of speedable items indicates multiple objects that need to be optimized during the cold start of the application; determine multiple optimization strategies corresponding to the set of speedable items, the multiple optimization strategies including the first optimization strategy and the first At least one of two optimization strategies, wherein the first optimization strategy instructs to adjust the resources allocated by the operating system to the cold start, and the second optimization strategy is used to accelerate tasks during the cold start; During the process, the multiple optimization strategies are executed.
  • the accelerating items during the cold start process are determined, so that these accelerating items are more accurate and more accurate.
  • a set of optimization strategies is determined in a targeted manner. The combined use of these optimization strategies can more fully optimize the cold start process of the application, so that the terminal can complete the cold start of the application more quickly.
  • terminals with different hardware configurations, operating systems with different working states, and different applications can use different optimization strategies. Such optimization can more effectively accelerate the cold start of applications.
  • the plurality of objects include at least one of resources and tasks.
  • the resources include hardware resources and software resources (that is, how to use these hardware resources).
  • the hardware resources include at least one of processing resources, storage resources, and network resources.
  • Software resources are used to represent the management of a process by the operating system, such as when and how much hardware resources are allowed to be used by a process.
  • Software resources include management of other active processes in the operating system, such as freezing or cleaning up other active processes, releasing memory occupied by other active processes, and releasing locks occupied by other processes for allocation to cold start At least one of the progress of the application.
  • the hardware configuration of the terminal includes specifications of the terminal's processor (for example, at least one of a central processing unit, an image processor, and a co-processor), a storage device, a network device, and a storage device.
  • the terminal's processor for example, at least one of a central processing unit, an image processor, and a co-processor
  • the resource overhead of the cold-starting the application, and the duration of executing multiple events and various operations during the cold-starting of the application are preset values; In the case of cold-starting the application, the resource overhead of the cold-starting the application, and the duration of executing multiple events and various operations during the cold-starting of the application are historical values.
  • the operating system's analysis process of the collected status information which can be analyzed according to the judgment logic and thresholds stored in the system.
  • the correspondence between the above-mentioned evaluation information and the acceleration items can be stored in at least one of the framework layer and the core library layer.
  • the correspondence between the evaluation information and the acceleration items can be Different levels correspond to a set of acceleration items.
  • determining a set of acceleration items based on the current status information includes: analyzing the current status information to obtain evaluation information corresponding to the current application, and the evaluation information corresponding to the current application includes the hardware configuration of the terminal The level of the operating system, the current load of the operating system, the type of resource overhead of the application, and the time-consuming task of the cold start; according to the current corresponding evaluation information of the application, and the correspondence between the evaluation information and the accelerating items To determine the set of acceleration items that the application currently corresponds to.
  • the hardware configuration may be: according to specific hardware specifications, determine the terminal is a high-end machine, mid-range machine or low-end machine.
  • the load on the operating system may be: according to the collected information on the operating system load, determine the load level of the operating system, such as light, medium, and heavy loads, or the first, second, third, and fourth load.
  • the evaluation of the operating system load may first specifically evaluate the use of one or more resources by the operating system, that is, the load of multiple hardware resources and software resources, and then according to the load level of these evaluated resources To evaluate the load level of the operating system.
  • the operating system load level is determined directly based on the collected status information.
  • a set of accelerating items currently corresponding to the application is determined, including: the hardware of the terminal Configured as the first level, the operating system is currently under the first level load, the application is the first resource overhead type, and the task that takes a long time in the cold start is the first group of tasks, the application currently corresponds to the first group Accelerable items; the hardware configuration of the terminal is at the second level, the operating system is currently at the second level of load, the application is of the second resource overhead type, and the task that takes a long time in the cold start is the second group of tasks Next, the application currently corresponds to the second set of speedable items.
  • the first level and the second level, the first level load and the second level load, the first resource overhead type and the second resource overhead type, and the first group task and the second group task are different,
  • the first level and the second level may be different levels, and the other three groups are the same level; of course, the four groups may be different.
  • the first set of accelerating items and the second set of accelerating items are two different sets of accelerating items. That is to say, in some scenarios, when the hardware level is different and / or the load level is different, even if the application is cold-started, the acceleration items obtained are different.
  • the determination of multiple optimization strategies corresponding to the set of acceleration items includes: a set of acceleration items currently corresponding to the application, and the correspondence between the acceleration items and the optimization strategy To determine multiple optimization strategies corresponding to the set of acceleration items.
  • the terminal stores the correspondence between the acceleration items and the optimization strategy, which may be multiple tables, or pointers, linked lists, and so on.
  • the current load of the operating system indicates the operating system's current usage of the terminal's hardware resources
  • the hardware resources include at least one of processing resources, storage resources, and network resources
  • the resource overhead indicates the usage of at least one of the terminal's processor, memory, disk, and network bandwidth for the cold start.
  • the multiple tasks during the cold start of the application process include at least one first task and at least one second task, and the respective durations of the multiple tasks include execution of each of the at least one first task.
  • the duration, and the respective duration of waiting to execute the at least one second task are possible implementation manners.
  • the first optimization strategy includes adjusting at least one of processing resources, storage resources, and network resources allocated to the cold start.
  • the first optimization strategy includes: increasing the operating frequency of the terminal's CPU, extending the terminal's CPU frequency increase time, adjusting the terminal's CPU energy consumption parameter, and will be used for cold start
  • the application process is migrated to another CPU core for execution, the memory corresponding to the cold start process of the application is released in advance, at least one other process is frozen or cleared, and the read / write bandwidth or network allocated to the at least one other process is adjusted Bandwidth, where the at least one other process is a process of at least one other application running in the operating system in addition to the application;
  • the second optimization strategy includes at least one of the following optimization strategies, enabling TCP corresponding to the application In the connected Nagle algorithm, the more important threads in the process corresponding to the cold start preferentially use processing resources, read the file pages required for the cold start application in advance, perform class verification in advance, perform image decoding in advance, and load the basic library in advance.
  • optimization strategies include scheduling of resources and accelerating specific tasks, which are more targeted and comprehensive .
  • the present application describes a device for a cold start application, which includes: a collection module for collecting current status information based on a detected startup event, the startup event indicating an operating system of the terminal Cold start an application, the current status information includes the hardware configuration of the terminal, the current load of the operating system, the resource overhead of cold starting the application, and the respective duration of multiple tasks during the cold start of the application; analysis A module, the analysis module is used to determine a set of acceleration items corresponding to the application according to the current status information, the set of acceleration items indicating a plurality of objects to be optimized during the cold start of the application process; An optimization strategy determination module, the optimization strategy determination module used to determine a plurality of optimization strategies corresponding to the set of accelerating items, the plurality of optimization strategies including at least one of a first optimization strategy and a second optimization strategy , Wherein the first optimization strategy instructs to adjust the resources allocated to the cold start by the operating system, and the second optimization strategy is used to accelerate Cold start of said task; execution module, the execution module during
  • an embodiment of the present invention describes a device including a logic circuit, a communication interface, and a storage medium, where the storage medium stores a protocol stack program, and the communication interface is used to send and receive data to other devices by executing the protocol stack program A data packet, the processor is used to implement the first aspect and the method of the cold start application in various implementation manners of the first aspect by running instructions in the storage medium.
  • the device is a terminal.
  • the second aspect and the third aspect 5 are the devices and devices corresponding to the first aspect.
  • the second aspect and the third aspect 5 are the devices and devices corresponding to the first aspect.
  • a computer program product that stores program code for storing a method that can implement any of the various implementation manners of the first aspect.
  • a computer-readable storage medium including instructions, which when executed on a computer, causes the computer to execute the method of any one of the various implementation manners of the first aspect.
  • FIG. 1 is a schematic diagram of a terminal architecture provided by an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of a terminal software architecture provided by an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a cold start application method provided by an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a device for cold start application provided by an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a cold start application device provided by an embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
  • the embodiments of the present invention provide a message feedback method, device and system based on the multi-path transmission control protocol MPTCP.
  • MPTCP multi-path transmission control protocol
  • a and / or B A and B, or A or B.
  • Kernel state A process running in the kernel address space can also be said to be in a kernel state.
  • User mode A process running in the user's address space can also be said to be in user mode.
  • Task In a multi-program or multi-process environment, the basic work element to be completed by a physical machine, it is a sequence of one or more instructions processed by the control program.
  • Running A type of thread state. Indicates that the thread is running on the CPU.
  • Runnable a kind of thread state. Indicates that the conditions required for the thread to run have been met, queued in the CPU running queue, waiting for CPU scheduling, that is, waiting to use the CPU.
  • Uniterruptable sleep (uninterruptible sleep): a kind of thread state, referred to as sleep. Indicates that the thread is in an uninterruptible block. In this state, it is generally waiting for various lock resources.
  • WakeKill A kind of thread state. Indicates that the thread is blocked uninterruptably, blocked by a more deadly signal, usually waiting to read and write to the disk.
  • Block I / O input / output
  • the input / output of the disk of the block device that is, the read / write of the disk.
  • Inflate In the Android system, the process of generating the corresponding view (View) according to the resource file context and parameters.
  • DDR Double Rate Dynamic Random Access Memory (Double Data Rate Synchronous Dynamic Random Access Memory, referred to as DDR SDRAM), a type of memory.
  • VerifyClass In the Android system, some classes of the application cannot complete class verification at compile time due to some reasons, and the process of class verification is performed while the application is running. For example, after the application uses the hot patch function, such a process is prone to occur.
  • Blocking Suspend a thread to wait for a condition to occur, which can be a resource ready.
  • Killing a process means ending a process or releasing the resources (such as memory, CPU, I / O, and locks) occupied by a process.
  • the cold start of the application is divided into three stages, namely the preparation before the cold start of the application process, the application initialization and the cold start application displayed on the terminal interface.
  • the intuitive description is the process from when the user clicks on the screen or a button, or when the user speaks a voice to the terminal, and the application interface is completely displayed to the user.
  • the preparation of the application process before a cold start includes the terminal receiving a touch screen event input by the user and a series of triggered processes, for example, the touch screen causes the terminal operating system to recognize that an application is required to be cold started .
  • the series of processing includes identifying touch screen events, which are passed to the click callback function of the desktop application (Graphical, User Interface, GUI) through the input daemon, and also include front-to-back background switching, specifically requesting system services for the desktop application
  • the (SystemServer) process performs process initialization, window initialization, etc. of the application to be started, and then SystemServer switches the application running on the desktop to the background application, and sets the application to be started as the foreground application.
  • Application initialization includes the initialization of the common components of the application, and the initialization of services and data required by processes running the application.
  • the public component may include at least one of a network request library, a JavaScript object notation (JavaScript Object Notation, Json) parser, a big data statistics library, and an application encryption library.
  • Display the launched applications on the terminal's interface including loading data to be displayed, layout and drawing of the interface and other operations. For example, download text, pictures or videos from the Internet, decode pictures and read the database where the data to be displayed is located.
  • the operating system cold-starts applications through processes.
  • One process includes one or more threads, such as component loading threads and main threads.
  • the cold start process requires the cooperation of threads in the process to execute the tasks in the above-mentioned stages in a certain order, which requires the consumption of terminal resources.
  • the tasks in the above-mentioned stages may affect the time of the cold start of the application.
  • Existing solutions for accelerating the application of cold start often use certain fixed methods to accelerate the cold start, such as using the CPU to increase the frequency, or using the kill process to release the memory. These methods are not optimized in a targeted manner. In many cases, it will worsen the performance degradation of cold-start applications.
  • startup delay The time it takes to cold start an application can be called a startup delay.
  • the startup delay is the accumulation of the corresponding lengths of multiple tasks during the cold start of the application. Among them, the greater impact on the startup delay is the delay in the execution of some time-consuming tasks, and the contention (including software resources and hardware resources) between multiple threads of the process.
  • Startup delays can include CPU delays on one or more threads, slow memory path delays, zram compression delays, I / O delays, network delays, and threads in Sleep state, waiting for locks during the execution of the application At least one of the delay (sleep lock delay for short), the delay of the thread in the Runnable state, and the delay caused by the thread blocking in the thread (for example, the component loading thread blocks the main thread).
  • the CPU delay is the length of time that a thread waits to use the CPU, that is, the length of time that a thread remains in the Runnable state.
  • Memory slow path delay is the time it takes for a thread to use memory through a slow path.
  • the memory read by the slow path is memory occupied by other applications or processes released by the device according to the read / write instruction.
  • Zram compression delay the time it takes for a thread to read compressed data in memory.
  • Zram or zip RAM, is a feature of the Linux kernel that provides virtual memory compression. In order to store more data in the memory, some memory will have a part of the address to store the compressed data, which needs to be decompressed before being read.
  • I / O latency The time it takes for a thread to execute a batch of instructions to read / write to disk. I / O latency is mainly due to the waiting time of these instructions in the queue.
  • the operating system of the terminal always has instructions to read / write disks from various threads. These instructions are placed in the queue. The instructions to read / write the disk triggered by the cold start are issued in batches, so they often need to be in the queue. Wait for a while to complete all execution.
  • I / O latency accounts for about 15% of the application's cold start time.
  • the cold start application method described in this application is for a terminal, and the terminal is a device for users to install applications.
  • the terminal obtains the current status information related to the cold start of the application from multiple dimensions through the current status collection, so as to analyze the problems faced by accelerating the cold start of an application under the specific scenario based on the collected current status information (that is, to obtain a Group can be accelerated items), and according to the determined acceleration items to get the corresponding optimization strategy, use these specific problems to optimize the application of the cold start process, thereby reducing the application of cold start time, and more reasonable allocation
  • the software and hardware resources of the terminal are improved, and the user experience is improved.
  • One or more optimization strategy libraries can be stored in the terminal, and each optimization strategy library stores multiple optimization strategies.
  • the optimization strategy can be to adjust hardware resources as needed.
  • Adjustable methods include at least one of the following: increase the operating frequency of the CPU, bind the process that executes the application to a certain CPU core or reallocate the CPU core used to execute the application, adjust the operating frequency of the L3 cache, adjust the GPU Operating frequency, adjust the power management (always-on) parameters, adjust the operating frequency of CPU and DDR together so that the adjusted operating frequency of CPU and DDR still match, etc.
  • optimization strategies can include: critical thread Runnable status is long, VIP thread scheduling; long I / O delay, use page-level file read-ahead; long network delay, no delay ( No-delay) using the TCP protocol to send packets; Uniterruptable, Sleep long, please use page lock to downgrade, etc., and use long-running tasks to be executed in other processes in advance, where these tasks can be compiled functions, decoded pictures, verification classes , At least one of so library loading and TCP pre-connection.
  • CPU Boost Used to improve the processing performance of the CPU.
  • Common technical methods are frequency raising and nuclear tying. Raising the frequency refers to raising the operating frequency of the CPU to the highest or higher value of its operating frequency range. Tethering refers to fixing some applications on certain cores with higher CPU configuration to ensure that these applications can be allocated to more processing resources. It should be understood that the CPU can operate within a frequency range. Due to considerations such as service life and power consumption, generally speaking, the CPU will work at an intermediate value or a smaller value within the frequency range.
  • the terminal will have a default frequency increase time, that is, after the operating system receives the instruction to increase the frequency, adjust the CPU to work for a longer time, such as 1.5s.
  • VIP thread scheduling refers to inserting some of the threads in the processor's running queue that are waiting for the processor to execute, that is, executing in advance, such as mentioning the head of the queue; or removing some of the threads from a processor core Switch to another processor core to run, the certain threads may be more important threads after priority ordering, or may be a specific one or several types of threads set in advance.
  • the other processor core to be switched to is a processor core with light load or short waiting time or idle.
  • Process killing means that when the KILL_SIG used to terminate a process is received, the reference count of the virtual memory shared by the thread of the process in the running state is reduced to 0 before the memory is released. And, adjust these shared virtual memory to the memory of anonymous pages and file pages released first.
  • KILL_SIG is a signal sent to the process that causes it to terminate immediately. Process killing can improve the problem of quickly releasing memory when memory pressure is tight.
  • Please page lock downgrade refers to a dynamic memory allocation technology, specifically postponing the allocation of pages until the page to be accessed by the process is not in physical memory, which causes a page fault (Speculative Page Fault).
  • a page fault Seulative Page Fault
  • the process-level semaphore lock is no longer used, and a more fine-grained thread-level lock is used instead. Change from a process-level lock to a thread-level lock, which is the downgrade of the lock. This optimization strategy can provide better in-process concurrency performance.
  • Page-level file read-ahead Identify the pages of the file that need to be read during the cold start process in advance. During the cold start process, use other processes to read these pages from the cache in advance, instead of pre-reading the entire file where the page is located . Specifically, this optimization strategy of the terminal can reduce the IO waiting time of the startup time.
  • No-delay is used to send packets using the TCP protocol, also known as TCP packet no-delay. It is used when the application needs to interact with the network side through the TCP protocol or MPTCP protocol during the cold start process. Specifically, during the cold start process of the application, the Nagle algorithm in the TCP protocol is started. Under this algorithm, the packet sending delay is small, and there is no need to wait for other packets, thereby saving packet sending time.
  • Image pre-decoding so library pre-loading and function pre-compilation are all in the cold start process, the necessary pre-processing of the data to be used in advance, these pre-processing is to use another process after the operating system detects the startup event When executed, often when another process performs these preprocessing, the process for cold starting the application is still in the construction stage.
  • This method can ensure that when the process used to cold start the application needs to use the data, there is no need to wait for the data to be processed or read.
  • picture pre-decoding refers to identifying a group of pictures that need to be decoded during a cold start before the start of a cold start, and after detecting a start event, another process is used to decode these pictures. For example, these pictures can be determined based on the historical cold start process of the application.
  • So library preloading refers to identifying the information of the so library that needs to be loaded during a cold start before the start of a cold start, and another thread is used to load these files in advance during the cold start process.
  • the so library stores the files in the Android system in the format of .so.
  • Function pre-compilation refers to the history-based cold start process. Identify some functions or code blocks that take a long time or run frequently during the cold start process, and pre-compile these code blocks in the background. Specifically, the JIT compiler in the virtual machine can be used to determine frequently running code blocks, and these frequently running code blocks are also referred to as hot spot codes.
  • Background application freezing refers to freezing applications that are still running in the background through the cgroup's freezer mechanism during the cold start of an application, that is, freezing processes running these background applications, such as prohibiting these processes from accessing memory or occupying CPU, etc., And unfreeze these processes after the app ’s cold start is complete.
  • This optimization strategy can improve the impact of applications running in the background on the cold start duration under high-load conditions.
  • Application management and control sorting refers to generating a list of processes that can be controlled by the background, such as a killable process list, a compressible process list, and a non-killable list, based on the priorities of services corresponding to multiple processes running in the current operating system. These process lists can be used in conjunction with some of the aforementioned optimization strategies.
  • a file cache classification mechanism which manages the cache of files used in the cold start process.
  • the classification management file cache is implemented by classifying the least recently used (LRU) queue. Specifically, for the more important file caches, join the higher priority LRU queue, and for other file caches, join the lower priority LRU queue. When deleting the file cache, first delete the lower priority LRU queue In the cache.
  • LRU least recently used
  • optimization strategies are only examples, and the optimization strategies that may be used in the method described in this application are not limited to the above types.
  • the terminal is a physical machine, which may also be called a user equipment (User Equipment, referred to as "UE"), a mobile station (Mobile Station, referred to as "MS”), a mobile terminal (Mobile Terminal), etc.
  • the terminal may have the capability to communicate with one or more core networks via a radio access network (Radio Access Network, RAN), for example, the terminal may be a mobile phone (or called a "cellular" phone), or Mobile computers, etc.
  • the terminal may also be a portable, pocket-sized, handheld, built-in computer or mobile device such as a mobile phone, tablet computer, laptop computer, PDA, smart wearable device, mobile Internet device ( English: mobile internet device, referred to as MID) and so on.
  • MID mobile internet device
  • the load of the operating system of the terminal may also be referred to as the operating state of the operating system, and indicates that the software of the terminal uses the hardware resources of the terminal.
  • the current load of the operating system of the terminal includes the current load of the operating system itself and the resource overhead of applications currently running by the operating system.
  • the hardware resources include but are not limited to at least one of the following: CPU, memory (such as DDR), disk, network, and GPU.
  • the application process reads data from memory, disk, or data from the network through the CPU or GPU.
  • These hardware resources themselves, and how these hardware resources are used, can be described by various parameters, and this application does not limit it.
  • the disk-related parameters are local disk capacity, read / write rate, I / O wait, etc.
  • the network-related parameters are network bandwidth, network delay, etc.
  • the operating system load is described at least in terms of the usage of the three resources CPU, memory, and disk.
  • the terminal can determine the state of the operating system according to the real-time data of the three resources used by the operating system.
  • CPU load refers to the utilization rate of CPU, available memory, which can be the amount of available memory, or the ratio of available memory to the total amount of memory.
  • I / O wait can be described by the length of I / O wait, It can also be described by the number of concurrent I / Os. In Linux-based operating systems, there are special instructions to obtain the values of the above three parameters.
  • the terminal can access the network through an access node of a wireless network or a wired network.
  • an access point Access Point, AP
  • AP access point of a wireless WI-FI network
  • Ethernet router or an access point of a Winmax network
  • base station of a wireless cellular mobile network
  • the operating system can determine the current system usage in three aspects of CPU, memory, and disk to determine the status of the operating system. This analysis can be compared with a preset threshold. For example, if the CPU load exceeds the first threshold, it is considered to be a high CPU load, and between the first threshold and the second threshold is considered to be a medium CPU load, and the amount of available memory is below a certain percentage. It is considered to be low available memory.
  • the state of the operating system is divided into several levels, such as three levels, namely light, moderate, and heavy loads.
  • the operating system may directly determine the state of the operating system according to the obtained values of the above three parameters, or may determine the state of the operating system according to the levels corresponding to the values of the three parameters. For example, an operating system with high CPU load, low available memory, and high I / O latency is under heavy load.
  • the use of the three resources of CPU, memory, and disk are also used to describe the resource cost of cold-starting the application, also referred to as the application's startup cost, that is, processing resource cost (such as CPU cost), memory Overhead and I / O overhead.
  • processing resource cost such as CPU cost
  • memory Overhead I / O overhead
  • these three aspects can be expressed using different parameters.
  • the CPU overhead is the CPU resources occupied by the process executing the cold start application, for example, it can be expressed as a percentage of the total CPU resources.
  • the memory overhead is the memory used by the process to execute the cold start application, for example, it can be expressed as a percentage of the total memory, or as the amount of used memory.
  • I / O overhead is the amount of disk data that a process needs to read or write to perform a cold start application.
  • Some thresholds can also be saved in the operating system, so that the operating system analyzes the above three overhead values obtained. For example, if the CPU overhead exceeds a threshold, the cold start process of the application is considered to be high CPU overhead. It should be understood that the startup cost of an application can also be indicated using a combination of other resources, such as at least one of a processor, memory, disk, and network bandwidth.
  • FIG. 1 is a schematic structural diagram of a terminal 100 according to an embodiment of the present invention.
  • the terminal 100 may be a device according to an embodiment of the present invention, and some modules that may be included in the software layer and the hardware layer of the terminal are schematically drawn in the figure.
  • the software layer of the terminal includes driver layer, core library layer, framework layer and application layer.
  • the driver layer may include a CPU driver, a GPU driver, a display controller driver, etc.
  • the kernel of the operating system (such as the kernel of the Android system) is also located in the driver layer.
  • FIG. 1 is only a possible schematic hierarchical division, and some layers may have different names in other divisions.
  • FIG. 2 shows another division method.
  • the driver layer in FIG. 1 is called a Linux kernel in FIG. 2, and the Linux kernel includes the driver described in the driver layer in FIG.
  • the core library layer is the core part of the operating system, including the appearance manager, media framework, relational database, 2G graphics engine library, Web browser engine, kernel library and virtual machine (such as Dalvik Virtual Machine).
  • the framework layer may include a browser engine, a typesetting engine, a file parser, etc .
  • the application layer may include various applications such as a home interface, a media player (Media Player), a browser (Browser), and so on.
  • the hardware layer of the terminal includes the central processing unit (CPU), graphics processing unit (GPU), etc. Of course, it can also include memory, input / output devices, memory, memory controller, network interface, etc.
  • the input device may include a keyboard, a mouse, a touch screen, etc.
  • the output device may include a display device such as a liquid crystal display (Liquid Crystal), LCD, cathode ray tube (Cathode Ray Tube, CRT), holographic imaging (Projector), etc. .
  • Operating systems such as Android, Firefox, OS, etc.
  • Some applications can be run on the hardware layer.
  • FIG. 1 can be used to perform the method described in this application, while FIG. 2 describes the position of various subsystems that can be used to perform the method described in this application in another system architecture.
  • the system architecture described in Figure 1 is similar.
  • Figure 2 includes the software layer of the terminal, including: Linux kernel (kernel), core library layer, framework layer and application layer.
  • the interaction of data is indicated by two-way arrows in Figure 2.
  • the in-application scheduling subsystem, real-time processing subsystem, acquisition and execution adaptation subsystem, kernel extension subsystem, and non-real-time processing subsystem shown in FIG. 2 are some implementations. Improved part of the terminal operating system.
  • Application processes are used to run applications.
  • An application process involves the application layer and the framework layer. If an application runs in a virtual machine, the application process also involves the core library layer. Among them, an application process exchanges information through interfaces between parts of different layers.
  • FIG. 2 illustrates three application processes in the operating system, and the left side of the application process 1 running in the virtual machine is illustrated in each layer.
  • Application process 1 executes application business logic at the application layer.
  • the intra-application scheduling subsystem including the framework layer and the virtual machine, can manage multiple applications in the system, including the collection, identification, recording, and storage of time-consuming situations within the application (that is, the (Applications are time-consuming to collect and execute) and implement optimization strategies that belong to in-app scheduling (stored in the in-app scheduling scheme set).
  • the application process 1 runs on a virtual machine, so the intra-application scheduling subsystem shown in FIG. 2 is distributed at the framework layer and the virtual machine layer.
  • In-app scheduling subsystems are concentrated at the framework level, and optimization strategies include but are not limited to: picture pre-decoding, class (View) inflate, TCP pre-connection, so library pre-loading, etc .; at the framework level, program concentration, Optimization strategies include but are not limited to: function pre-compilation, class pre-loading, etc.
  • the framework layer includes real-time processing subsystem and non-real-time processing subsystem.
  • the real-time processing subsystem is used to implement functions such as on-site collection, cost evaluation, policy formulation, and event recognition. These functions are also the focus of the cold start method described in this application, which will be described in further detail below in conjunction with the method flow.
  • the on-site collection functionality corresponds to the collection module 401 of FIG. 4
  • the cost evaluation and strategy formulation correspond to the analysis module 402 of FIG.
  • the modules corresponding to event recognition are not drawn in Figure 4.
  • the subsystem also includes a set of real-time solutions, which collectively record some improvement solutions belonging to the framework layer for the formulation of overall improvement strategies.
  • the solutions in this solution set may include accelerating the CPU on demand, and if the application that requires a cold start uses a large amount of memory, changing the memory allocation strategy to ensure its memory usage.
  • the non-real-time processing subsystem stores the configuration and data related to the application cold start, where the data can be stored in the disk. For example, the application of historical data on cold start under different system load conditions, the default configuration of each sub-program, the default parameter values, and the optimized parameter values obtained after the time of the sub-program.
  • configuration and data can be obtained from non-real-time processing subsystems.
  • the core layer includes the acquisition and execution adaptation subsystem, as well as the core layer part of the above application process.
  • the collection and execution adaptation subsystem is used to process the strategies formulated by the real-time processing subsystem so that the kernel extension subsystem executes these strategies.
  • the acquisition execution adaptation subsystem has higher authority.
  • the collection execution adaptation subsystem includes execution status collection, which is used to provide a query interface for the practice subsystem's status collection module; policy issuance, used to receive real-time subsystem strategy formulation module commands, and issued to the kernel subsystem ; And platform adaptation, used to adapt and encapsulate heterogeneous kernel nodes, such as CPU, GPU and other resource interfaces into a unified interface for real-time processing subsystem calls.
  • the driver layer includes the kernel extension subsystem, which is used to execute the strategy formulated by the real-time processing subsystem during the application cold start process.
  • These strategies can include scheduling related to CPU or DDR or GPU, VIP thread scheduling, process killing, lock (e.g. PageFault) degradation, page-level file read-ahead, low memory killing process (Low Memory Killer, LMK) and no delay (no-delay) Use one of the TCP protocol to send packets.
  • the operating system maintains analysis rules that analyze the acceleration items based on the current status information.
  • the operating system also maintains a mapping relationship between accelerating items and optimization strategies.
  • the mapping relationship may include a combination of a set of accelerating items, a mapping relationship between a combination of a set of optimization strategies, and an accelerating item and At least one of the mapping relationships between at least one optimization strategy.
  • the determined optimization strategy can be a set of optimization strategies directly obtained through the combination of accelerating items, or it can be at least one corresponding optimization strategy for each accelerating item obtained, and all the obtained optimization strategies Is the optimization strategy to be executed for this cold start application. It is also possible to obtain at least one corresponding optimization strategy for each accelerating item obtained, and then remove a part of the optimization strategies from all the obtained optimization strategies according to the combination rules to obtain the optimization to be executed for this cold start application Strategy.
  • the device shown in FIG. 2 can be used to execute the application cold start method described in this application. It can be seen that the program code corresponding to the method of the present application exists in the operating system platform software. When running, the program code of the present invention runs in the host memory of the server.
  • a mobile phone is taken as an example to describe the application cold start method described in this application.
  • various terms involved in this method please refer to the corresponding paragraphs of this application.
  • the embodiment corresponding to FIG. 3 is merely an exemplary description.
  • the operating system of the terminal recognizes an application startup event, and the startup event instructs the operating system of the terminal to cold start an application.
  • the event may be a user's click on the terminal screen, or a voice instruction issued by the user to the terminal, or a signal received by the terminal, or a signal or software instruction recognized by the terminal operating system.
  • This application does not limit the way of initiating events.
  • the terminal collects current status information based on the detected startup event, where the status information includes the terminal's hardware configuration, operating system load, startup overhead of the application, and the duration of multiple tasks in the cold start process of the application.
  • the resource overhead of cold starting the application and the corresponding time duration of multiple tasks in the process of cold starting the application are not real-time values of this cold start. It may be the value of the cold start process of the application recorded in the history of the terminal, the default value stored by the terminal, or the estimated value of the operating system of the terminal. It should be understood that the startup cost of the application will vary according to the system load. For example, in a high-load system state and a low-load system state, the parameter value of the startup cost of the same application may be different. In one implementation, the terminal saves the value of the startup load of the same application in different operating systems, so that a more appropriate value is used to describe the startup load in a certain operating system state. During a cold start, the terminal can collect the parameter values of the load during the cold start and record the state of the operating system during the cold start for future cold start of the application.
  • the hardware configuration of the terminal includes specifications of various hardware of the terminal, and the various hardware includes at least one of CPU, DDR, GPU, memory, and network resources.
  • the hardware specifications can be expressed by various parameters, such as CPU frequency, CPU core number, DDR bandwidth frequency point, GPU frequency point, GPU core number, memory and disk read and write rates, memory capacity, etc.
  • the load of the operating system can be characterized by three parameters: system processing, storage and network. It may include at least one of the system's CPU load, available memory, I / O wait, and network conditions.
  • the startup overhead of the application also known as the overhead required to cold start the application.
  • the overhead includes the average time for each application startup, computing power MIPS, CPU load, GPU load, memory occupied, amount of read and write I / O, read and write At least one of I / O bandwidth and network read volume.
  • the duration corresponding to multiple tasks in the process is determined based on the application startup historical data on the mobile phone.
  • the duration of the task can be the duration of executing a task, such as the class verification, function compilation, image decoding, so library loading, and the establishment of a TCP link at run time. It can also be the duration of a task.
  • the length of execution such as at least one of CPU delay, memory slow path delay, zram compression delay, I / O delay, and network delay on the main thread and other critical paths.
  • preset or estimated values can be used for the first cold start.
  • S303 The terminal analyzes the collected information to determine a set of acceleration items corresponding to the application.
  • this step includes: analyzing the current status information to obtain evaluation information currently corresponding to the application.
  • the evaluation information currently corresponding to the application includes the hardware configuration level of the terminal, the current load level of the operating system, The resource overhead type of the application, and the time-consuming task in the cold start; based on the current corresponding evaluation information of the application and the correspondence between the evaluation information and the accelerating items, determine a set of accelerating current corresponding to the application item.
  • determining the speedable item includes performing cost evaluation, that is, analyzing the status information to obtain the current corresponding evaluation information of the application.
  • the cost evaluation includes evaluation levels such as hardware configuration, operating system load, start-up overhead of the application, and scheduling delay and running time of the application.
  • the evaluation can include grading various types of information and identifying events that affect the cold start delay of the application.
  • the various evaluations described below can be judged based on preset thresholds.
  • the hardware configuration may be: according to specific hardware specifications, determine the terminal is a high-end machine, mid-range machine or low-end machine.
  • the load on the operating system may be: according to the collected information on the operating system load, determine the load level of the operating system, such as light, medium, and heavy loads, or the first, second, third, and fourth load.
  • the evaluation of the operating system load may first specifically evaluate the use of one or more resources by the operating system, that is, the load of multiple hardware resources and software resources, and then according to the load level of these evaluated resources To evaluate the load level of the operating system.
  • the operating system load level is determined directly based on the collected status information.
  • the rules for evaluating the load of the operating system are stored in the terminal, which may be, for example, high CPU load, low available memory, high I / O, and a small available network bandwidth, the system is under heavy load. It may also be that the CPU load is higher than the first threshold and the available memory is lower than the second threshold, the system is under heavy load.
  • the startup cost of the application may be: according to the resource consumption when the application is started, it is determined that the application is at least one of CPU consumption type, GPU consumption type, memory consumption type, I / O consumption type, and network consumption type.
  • the application it may be a task that takes a long time to identify the application startup. Specifically, based on the historical data of the application startup on the mobile phone, the key bottleneck of the application startup is identified in terms of resource scheduling and application running delay.
  • resource scheduling delay it can be: according to the terminal's current resource load (which can be expressed in terms of load level), the historical scheduling delay information of this application startup determines whether the application is such as run queue waiting type, memory allocation delay At least one of the type or I / O delay type.
  • the application is determined to be function compilation time-consuming type, picture decoding time-consuming type, layout time-consuming type, class verification time-consuming type or network waiting time-consuming type At least one of them.
  • the cost evaluation also includes obtaining a corresponding set of acceleration items based on the results of the above analysis. These speedable items are used to indicate at least one of the resources and tasks that need to be adjusted for this cold start. Specifically, according to the identified hardware of the mobile phone, the operating system load, and the overhead of the application to be started, the items with the largest estimated resource gap for this application startup are evaluated in order of resource gap. According to the historical data of the application to be started on this phone, according to the proportion of the scheduling delay time, the estimated scheduling gap of the application startup is the largest, and the most tasks that need to be optimized during the cold start process.
  • the hardware configuration of the terminal is at the first level, the operating system is currently at the first level of load, the application is of the first resource overhead type, and the task that takes a long time during cold start is the first group of tasks
  • the application currently corresponds to the first set of acceleration items
  • the hardware configuration of the terminal is at the second level, the operating system is currently at the second level load, the application is at the second resource overhead type, and the cold start
  • the time-consuming task is the second set of tasks
  • the application currently corresponds to the second set of speedable items.
  • S304 The terminal determines multiple optimization strategies corresponding to the set of acceleration items according to the evaluated set of acceleration items.
  • the correspondence between the acceleration items and the optimization strategy is stored in the terminal, and this correspondence may be one or more tables, or implemented through pointers or linked lists. These correspondences can be stored in at least one of the framework layer, the Linux kernel and the core library layer.
  • This correspondence can be the correspondence between multiple sets of accelerating items and multiple sets of optimization strategies, where one set of accelerating items corresponds to one set of optimization strategies; it can also be between multiple accelerating items and multiple optimization strategies Correspondence, where one acceleration item corresponds to one or more optimization strategies. In this way, by looking up the optimization strategies corresponding to the evaluated group of acceleration items one by one, all optimization strategies corresponding to the group of acceleration items can be obtained.
  • Opposite optimization strategies have opposite optimization directions. For example, optimization strategy one instructs the CPU to increase the frequency, and optimization strategy two instructs the CPU to decrease the frequency, then these two optimization strategy ideas.
  • the multiple optimization strategies include at least one of a first optimization strategy and a second optimization strategy, where the first optimization strategy instructs to adjust the resources allocated by the operating system to the cold start, and the second optimization strategy is used to accelerate This cold start task.
  • the determined optimization strategy may be called from an existing library, or the parameters in the existing strategy may be modified according to the information collected in the current situation.
  • the optimization strategy may be to adjust the parameters of the hardware resources as needed.
  • Adjustable parameters include at least one of the following: frequency increase in the CPU dimension, core binding, frequency modulator parameters, L3 cache frequency, etc .; GPU frequency, power management (always-on) parameters, etc .; frequency in the DDR dimension and the CPU Linkage etc.
  • optimization strategies can include: long runnable state of critical threads, VIP thread scheduling; long I / O delay, using page-level cache read-ahead; long network delay, using TCP no-delay; UniterruptableSleep long , Please use page lock to downgrade etc. And the optimization strategy also includes asynchronous execution of a long time-consuming startup process, which may be at least one of compiling hotspot functions, decoding pictures, verification classes, so library loading, and TCP pre-connection.
  • S302 to S304 correspond to the status quo collection, overhead evaluation, event recognition, and policy formulation in the real-time processing subsystem of FIG. 2.
  • the real-time processing subsystem may also include a set of real-time system sub-schemes, which are used to implement scheduling optimization strategies from the service side of the framework layer.
  • the sub-scheme set includes but is not limited to: on-demand CPU acceleration, large memory application startup memory guarantee, etc.
  • the process from S302 to S304 also involves obtaining historical data and default configuration from the non-real-time processing subsystem.
  • S305 The terminal executes the determined optimization strategy during the cold start of the application.
  • the real-time processing subsystem in FIG. 2 collects and executes the adaptation subsystem, and issues instructions corresponding to these optimization strategies to the kernel expansion subsystem to execute these optimization strategies.
  • the terminal obtains the software and hardware configuration related to the cold start of the application from multiple dimensions by collecting current status information, so as to analyze the problems faced by accelerating the cold start of an application under the specific scenario based on the collected information, and Use the strategies for these specific problems to optimize the application's cold start process, thereby reducing the application's cold start time, and more rationally allocating the software and hardware resources of the terminal to improve the user experience.
  • the hardware configuration of the terminal affects the cold start strategy applied on the terminal.
  • the following uses two specific scenarios as examples. In one scenario, an application on terminal A is cold-started, and the hardware configuration of terminal A is low; in another scenario, an application on cold-starting terminal B and the hardware configuration of terminal B are high.
  • the terminal collects current status information, including hardware configuration, operating system load, resource overhead of cold-starting the application, and the respective duration of multiple tasks during cold-starting the application.
  • the hardware configuration may be obtained by the operating system of the terminal A through some hardware configuration collection means, for example, tested or sensed through a sensor or an interface, or may be the read hardware configuration pre-stored in the terminal A.
  • the operating system of terminal A gets the following hardware configuration: the CPU is a dual-core chip, the specific model is Qualcomm 8917, the memory of terminal A is 2GB, the GPU is 308 chips, and the flash memory is Hynix Universal Flash Storage (UFS). It can be seen that Terminal A is a mobile phone with low hardware configuration. The main bottleneck is that the CPU configuration is low and it is easy to deal with insufficient resources. Terminal A uses the Android 8.2 version of the operating system. Due to the low hardware configuration, after booting, the terminal A's operating system enters a moderate load under standby.
  • the operating system detects that the CPU load of terminal A is maintained at around 60%, the available memory is around 300MB, and the I / O wait is maintained at 10%. Generally speaking, I / O waits above 4% belong to high I / O wait. In other words, the operating system of terminal A is in a state of high CPU load, low available memory, and high I / O waiting, and it can be considered that the operating system is under heavy load. That is, when the operating system is under heavy load, the terminal detects the user's instruction, which instructs the terminal to start the camera application.
  • the terminal determines that the resource overhead of the cold start camera application is 30% of CPU overhead, 30MB of I / O overhead (disk data to be read), and 800MB of memory overhead.
  • the memory slow path delay is 1200ms
  • the I / O delay is 600ms
  • the running application thread delay is 500ms in the Runnable state
  • the lock delay such as Sleep is 120ms
  • the component loading thread blocks the main thread.
  • terminal A evaluates the main problem of limiting the cold start speed based on the collected information. From the information collected above, Terminal A analyzes that the local hardware capability is weak, mainly due to insufficient CPU processing capability. Terminal A is under heavy system load, which is reflected in the running applications that make the available memory rate low and the I / O utilization rate high.
  • the startup overhead of camera applications is high memory overhead, high CPU overhead, and general I / O overhead.
  • the startup delay of the camera application mainly comes from the slow path delay of the memory, I / O delay, the delay of the thread running the application in the Runnable state, and the delay of locks such as sleep.
  • the optimization strategy includes: improving hardware resources, the optimization strategy includes extending the CPU boost time to 5s. This is because the default boost time of the CPU of terminal A is 1.5s, and the CPU configuration is low, and processing resources are insufficient.
  • optimization strategies include improvements in terms of reducing memory allocation time, reducing Runntime time, and reducing I / O latency.
  • the background application of the operating system can be frozen for a period of time (for example, with the cold start of the application CPUboost time is the same), where freezing background applications means that the background applications are temporarily unable to use CPU resources during the camera's cold start. It may also be to increase the priority of the scheduling CPU of the initialization thread of the component of the camera application. To reduce I / O latency, you can pre-read the files needed to start the camera application.
  • the terminal can execute these optimization strategies during the camera's cold start to accelerate the cold start.
  • the terminal obtains the software and hardware configurations related to the cold start of the application from multiple dimensions through the current status collection, so as to analyze the problems faced by accelerating the cold start of an application under the specific scenario based on the collected information, and use The strategy for these specific problems optimizes the application's cold start process, thereby reducing the application's cold start time, and more rationally allocating the software and hardware resources of the terminal to improve the user experience.
  • the cold-start camera application time is 5975 ms; using the above-mentioned method, the cold-start camera application time is 3885 ms.
  • the following uses another specific scenario as an example to illustrate.
  • the hardware configuration of terminal B used in this scenario is relatively high.
  • the application that requires cold start is an e-commerce application, such as Taobao or Amazon. ).
  • the terminal collects status information.
  • the operating system of terminal B gets the following hardware configuration: the CPU is an 8-core chip, the specific model is Kirin 970, the memory of terminal B is 6GB, and the flash memory is Toshiba UFS2.0. It can be seen that Terminal A is a mobile phone with a high hardware configuration, but the flash memory configuration is slightly insufficient. Terminal A uses the Android 8.2 version of the operating system. Due to the high hardware configuration, most users are under light load or moderate load when using it.
  • the operating system of terminal B detects that the CPU load of terminal B is about 10%, the available memory is about 4GB, the I / O wait is almost 0%, and the network status is good.
  • the operating system of terminal B is under a light load. That is, when the operating system is under a light load, the terminal detects the user's instruction, which instructs the terminal to cold start the e-commerce application.
  • the terminal determines that the application load of the camera application is 30% of CPU overhead.
  • the I / O overhead includes 100 MB of disk data to be read and 1 MB of disk data to be written, and 259 MB of memory overhead.
  • the network delay is 200ms
  • the I / O delay is 500ms
  • the delay of some functions in the application (Just in Time, JIT)
  • the delay of the thread waiting for the lock in the Sleep state is 100ms.
  • the delay caused by tasks such as user identity verification (Verifyclass) is 200ms and the delay caused by image decoding is 60ms.
  • terminal B evaluates the main problem of limiting the cold start speed based on the collected information. Based on the information collected above, Terminal B analyzes that the native hardware is strong, the operating system is under a light load, and there are sufficient resources to cold start the application. This application is a cold start overhead application, and the application's startup delay mainly comes from the network. Delays, I / O delays, and delays caused by just-in-time compilation of functions.
  • the hard resource scheduling parameters do not need to be adjusted, and the default strategy is adopted, such as maintaining a 1.5 second frequency increase during cold start and interface switching.
  • the page-level file pre-reading is used to solve; for the long network delay, the TCP packet no-delay method is used; for the Sleep time, the page lock downgrade scheme is adopted.
  • the page lock downgrade scheme is adopted for in-app calls, use the early compilation speed-profile hotspot function to solve the JIT time-consuming problem; use the early asynchronous verification type solution for the verification class length; use the early asynchronous decoding solution for the long decoding time.
  • the terminal can execute these strategies during the cold start process of the application to accelerate the cold start.
  • the terminal analyzes the problems that cause the application cold start to face in this specific scenario, and uses the strategies for these specific problems to optimize the application cold start process, thereby reducing the application cold start time, and it is more reasonable
  • the software and hardware resources of the terminal are allocated to improve the user experience. For example, in the above scenario, if the above method is not used to optimize the cold start process, the time to cold start the e-commerce application is 3534ms; using the above method, the time to cold start the e-commerce application is 2163ms.
  • FIG. 4 depicts an apparatus 400 for a cold start application provided by the present application.
  • the apparatus 400 includes a collection module 401 for collecting current status information based on a detected startup event, which indicates the operating system of the terminal Cold start an application, the current status information includes the hardware configuration of the terminal, the current load of the operating system, the resource overhead of cold starting the application, and the respective duration of multiple tasks during the cold start of the application; analysis module 402, the analysis The module 402 is used to determine a set of acceleration items corresponding to the application according to the current status information, and the set of acceleration items indicates a plurality of objects to be optimized during the cold start of the application process; the optimization strategy determination module 403, the optimization The strategy determination module 403 is used to determine a plurality of optimization strategies corresponding to the set of acceleration items, the plurality of optimization strategies including at least one of a first optimization strategy and a second optimization strategy, wherein the first optimization strategy indicates Adjust the resources allocated by the operating system to the cold start, and the second optimization strategy is used to accelerate the tasks during the cold start;
  • the collection module 401 in FIG. 4 can be implemented in the framework layer and the core library layer in FIG. 2, for example, the instruction to collect the current status information can be issued in the framework layer, the hardware configuration of the terminal in the current status information, the operating system
  • the current load, the resource overhead of cold-starting the application, and the time corresponding to a part of the tasks during the cold-start application are all derived from the core library layer, and the time corresponding to the tasks during the cold-start application may be derived from the framework layer.
  • the analysis module 402 and the optimization strategy determination module 403 can also be implemented in the framework layer in FIG. 2, and the execution module 404 can be implemented in the Linux kernel in FIG. 2.
  • the accelerating items during the cold start process can be determined by analyzing information on multiple dimensions such as terminal usage scenarios, current terminal operating system load, and system overhead of cold start applications, so that these accelerating items can be more accurate and accurate
  • a set of optimization strategies are targeted to determine the application's cold start process, so that the terminal can complete the application's cold start more quickly.
  • the multiple tasks during the cold start of the application include at least one first task and at least one second task, and the respective durations of the multiple tasks include the respective durations of executing the at least one first task, And the respective duration of waiting for the execution of the at least one second task.
  • the first task may be at least one of image decoding, class verification, So file loading, and function compilation mentioned above
  • the second task may be at least one of waiting for CPU, zram compression, and reading / writing disk data. Species.
  • the analysis module 402 is specifically configured to analyze the current status information to obtain the current evaluation information corresponding to the application.
  • the current evaluation information corresponding to the application includes the hardware configuration level of the terminal and the current load of the operating system. Degree, the resource overhead type of the application, and the time-consuming tasks in the cold start; and according to the current evaluation information corresponding to the application, and the correspondence between the evaluation information and the accelerable items, determine the current corresponding one of the application Group speedable items.
  • the operating system's analysis process of the collected status information which can be analyzed according to the judgment logic and thresholds stored in the system.
  • the correspondence between the above-mentioned evaluation information and the acceleration items can be stored in at least one of the framework layer and the core library layer.
  • the correspondence between the evaluation information and the acceleration items can be Different levels correspond to a set of acceleration items.
  • the aspect of the set of acceleration items corresponding to the application is determined.
  • the analysis module 402 specifically uses In the case where the hardware configuration of the terminal is the first level, the operating system is currently under the first level load, the application is the first resource overhead type, and the task that takes a long time in the cold start is the first group of tasks, the The application currently corresponds to the first set of speedable items; and the hardware configuration of the terminal is at the second level, the operating system is currently at the second level load, the application is at the second resource overhead type, and the long time-consuming task in the cold start In the case of the second set of tasks, the application currently corresponds to the second set of speedable items.
  • the first level and the second level, the first level load and the second level load, the first resource overhead type and the second resource overhead type, and the first group task and the second group task are different,
  • the first level and the second level may be different levels, and the other three groups are the same level; of course, the four groups may be different.
  • the first set of accelerating items and the second set of accelerating items are two different sets of accelerating items. That is to say, in some scenarios, when the hardware level is different and / or the load level is different, even if the application is cold-started, the acceleration items obtained are different.
  • acceleration items corresponding to the application are all the same set of acceleration items when the information levels of the above four aspects are not completely consistent, for example, they are all the first group of acceleration items.
  • the optimization strategy determination module 403 is specifically configured to determine the corresponding to the set of acceleration items based on the set of acceleration items currently corresponding to the application and the correspondence between the acceleration items and the optimization strategy Multiple optimization strategies.
  • the current load of the operating system indicates the operating system's current usage of the terminal's hardware resources.
  • the hardware resources include at least one of processing resources, storage resources, and network resources; resources for cold-starting the application
  • the overhead indicates the use of at least one of the terminal's processor, memory, disk, and network bandwidth for the cold start.
  • the first optimization strategy includes adjusting at least one of processing resources, storage resources, and network resources allocated to the cold start.
  • the first optimization strategy includes: increasing the operating frequency of the terminal's CPU, extending the time of the terminal's CPU frequency increase, adjusting the terminal's CPU energy consumption parameter, and will be used to cold start the application Process is migrated to another CPU core for execution, the memory corresponding to the cold start process of the application is released in advance, at least one other process is frozen or cleared and the read / write bandwidth or network bandwidth allocated to the at least one other process is adjusted,
  • the at least one other process is a process of at least one other application running in the operating system in addition to the application
  • the second optimization strategy includes at least one of the following optimization strategies to open the TCP connection corresponding to the application With the Nagle algorithm, the more important threads in the process corresponding to the cold start preferentially use processing resources, read the file pages required by the cold start application in advance, perform class verification in advance, perform image decoding in advance, and load the basic library in advance.
  • FIG. 5 describes the structure of a device 500 for applying cold start provided by the present application.
  • the device 500 includes: at least one processing circuit 501, a storage medium 502, and a communication interface 504, which may include at least one network interface, at least one Communication bus 605.
  • the communication bus 605 is used to implement connection communication between these components.
  • the device 50 optionally includes a user interface, including a display (eg, touch screen, LCD, CRT, holographic or projector, etc.), a keyboard or a pointing device (eg, mouse, trackball, touch) Board or touch screen, etc.).
  • the storage medium 502 may include a read-only memory and a random access memory, and provide instructions and data to the processing circuit 501.
  • a portion of the storage medium 502 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • the storage medium 502 stores the following elements, executable modules or data structures, or their subsets, or their extensions:
  • the operating system 5021 includes various system programs, such as the framework layer, core library layer, and driver layer shown in FIG. 1, or the framework layer, core library layer, and Linux kernel shown in FIG. 2. Used to implement various basic services and handle hardware-based tasks.
  • analysis module 402. optimization strategy determination module 403 and execution module 404 are both included in the operating system 5021.
  • the application module 5022 includes various application programs, such as the cold-started application described in this application, and for example, the image library, media player (Media Player), browser (Browser), etc. shown in FIG. Various application services.
  • the processing circuit 501 collects current status information based on the detected start event, the start event instructs the operating system of the terminal to cold start an application, and the current status information includes the The hardware configuration of the terminal, the current load of the operating system, the resource overhead of cold-starting the application, and the duration of multiple tasks in the cold-starting process of the application; based on the current status information, a set of acceleration items corresponding to the application are determined, The set of speedable items indicates multiple objects that need to be optimized during the cold start of the application process; determine multiple optimization strategies corresponding to the set of speedable items, the multiple optimization strategies including the first optimization strategy and the second At least one of optimization strategies, wherein the first optimization strategy instructs to adjust the resources allocated by the operating system to the cold start, and the second optimization strategy is used to accelerate tasks during the cold start; the process of cold starting the application , Execute the multiple optimization strategies.
  • the device corresponding to FIG. 5 can invoke any program or instruction stored in the storage medium 502, and the processing circuit 501 can execute any possible method and apparatus implementation manner described above, and details are not described herein again.
  • the hardware of the hardware layer described in FIG. 1 can also be regarded as a specific implementation manner of FIG. 5.
  • the processing circuit 501 in FIG. 5 is represented as a central processor and a graphics processor in FIG. 1, and the storage medium 502 is illustrated as a memory in FIG. 1.
  • the accelerating items during the cold start process are determined, so that these accelerating items are more accurate and more accurate.
  • a set of optimization strategies is determined in a targeted manner. The combined use of these optimization strategies can more fully optimize the cold start process of the application, so that the terminal can complete the cold start of the application more quickly.
  • FIG. 6 is a schematic structural diagram of a terminal disclosed in an embodiment of the present invention.
  • the terminal may be used to perform part or all of the steps of applying the cold start method described above.
  • the terminal 600 includes: a radio frequency (Radio Frequency) circuit 601, a memory 602, an input unit 603, a display unit 604, a sensor 605, an audio circuit 606, a wireless fidelity (WiFi) module 607, Processor 608, power supply 609 and other components.
  • a radio frequency (Radio Frequency) circuit 601 the terminal 600 includes: a radio frequency (Radio Frequency) circuit 601, a memory 602, an input unit 603, a display unit 604, a sensor 605, an audio circuit 606, a wireless fidelity (WiFi) module 607, Processor 608, power supply 609 and other components.
  • WiFi wireless fidelity
  • FIG. 6 can be understood as a specific implementation manner based on FIG. 5, and there is a correspondence between some of the components shown in the two figures.
  • the memory 602 in FIG. 6 corresponds to the storage medium 502 in FIG. 5
  • the processor in FIG. 6 608 corresponds to the processing circuit 501 in FIG. 5, etc.
  • the radio frequency (Radio Frequency, RF) circuit 601 in FIG. 6 and the wireless fidelity (WiFi) module 607 are a specific implementation of the communication interface 504 in FIG. . Therefore, the application layer, the framework layer, the core layer and the driver layer in FIG. 1, the various layers and subsystems in FIG. 2 and the various modules in FIG. 4 can also be implemented by the processor 608 by calling the code in the memory 602 .
  • the terminal corresponding to FIG. 6 describes more hardware components than FIG. 5.
  • the RF circuit 601 can be used for receiving and sending signals during receiving and sending information or during a call. In particular, after receiving the downlink information of the base station, it is processed by the processor 608; in addition, the uplink data designed to be sent to the base station.
  • the RF circuit 601 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, and the like.
  • the RF circuit 601 can also communicate with other devices via a wireless communication network.
  • the above wireless communication can use any communication standard or protocol, including but not limited to Global Mobile System (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (Code Division) Multiple Access (CDMA), Wideband Code Division Multiple Access (Wideband Code Multiple Division Access, WCDMA), Long Term Evolution (LTE), e-mail, Short Message Service (SMS), etc.
  • GSM Global Mobile System
  • GPRS General Packet Radio Service
  • CDMA Code Division Multiple Access
  • WCDMA Wideband Code Division Multiple Access
  • LTE Long Term Evolution
  • SMS Short Message Service
  • the memory 602 stores a computer program including an application program 6021 and an operating system program 6022.
  • the processor 608 is used to read the computer program in the memory 602 and then execute the method defined by the computer program, for example, the processor 608 reads the operating system program 6022 thus runs an operating system on the terminal 600 and implements various functions of the operating system, or reads one or more application programs 6021 to run applications on the terminal 600.
  • the operating system 6022 includes a computer program that can implement the memory recycling method provided by the embodiment of the present invention, so that after the processor 608 reads the operating system program 6022 and runs the operating system, the operating system can have the embodiment of the present invention Provided memory reclamation function.
  • the memory 602 also stores other data 6023 in addition to the computer program.
  • the other data 6023 may include data generated after the operating system 6022 or application program 6021 is run, and the data includes system data (such as configuration parameters of the operating system) and User data.
  • the memory 602 generally includes memory and external memory.
  • the memory can be random access memory (RAM), read only memory (ROM), and cache (CACHE).
  • the external storage can be a hard disk, optical disk, USB disk, floppy disk, or tape drive.
  • Computer programs are usually stored on external storage, and the processor loads the computer programs from external storage into memory before performing processing.
  • the input unit 603 can be used to receive input numeric or character information, and generate key signal input related to user settings and function control of the terminal 600.
  • the input unit 603 may include a touch panel 6031 and other input devices 6032.
  • the touch panel 6031 also known as a touch screen, can collect user's touch operations on or near it (for example, the user uses any suitable objects or accessories such as fingers, stylus, etc. on or near the touch panel 6031 Operation), and drive the corresponding connection device according to the preset program.
  • the touch panel 6031 may include a touch detection device and a touch controller.
  • the touch detection device detects the user's touch orientation, and detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device and converts it into contact coordinates, and then sends To the processor 608, and can receive the command sent by the processor 608 and execute it.
  • the touch panel 6031 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 603 may also include other input devices 6032.
  • other input devices 6032 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), trackball, mouse, joystick, and so on.
  • the display unit 604 can be used to display information input by the user or information provided to the user and various menus of the mobile phone.
  • the display unit 604 may include a display panel 6041.
  • the display panel 6041 may be configured in the form of a liquid crystal display (Liquid Crystal) (LCD), an organic light emitting diode (Organic Light-Emitting Diode, OLED), or the like.
  • the touch panel 6031 may cover the display panel 6041, and when the touch panel 6031 detects a touch operation on or near it, it is transmitted to the processor 608 to determine the type of touch event, and then the processor 608 according to the touch event The type provides corresponding visual output on the display panel 6041.
  • the touch panel 6031 and the display panel 6041 are implemented as two independent components to realize the input and input functions of the mobile phone, in some embodiments, the touch panel 6031 and the display panel 6041 may be integrated to Realize the input and output functions of the mobile phone.
  • the sensor 605 may be a light sensor, a motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 6041 according to the brightness of the ambient light, and the proximity sensor may close the display panel 6041 and / or when the mobile phone moves to the ear Or backlight.
  • the accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes), and can detect the magnitude and direction of gravity when at rest, and can be used to identify mobile phone gesture applications (such as horizontal and vertical screen switching, related Games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, percussion), etc .; other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that can also be configured on mobile phones are no longer here Repeat.
  • mobile phone gesture applications such as horizontal and vertical screen switching, related Games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, percussion), etc .
  • other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that can also be configured on mobile phones are no longer here Repeat.
  • the start event described in this application may be that the user touches the display unit 604, and the pressure signal is transmitted to the terminal by the sensor 605.
  • the audio circuit 606, the speaker 6061, and the microphone 6062 can provide an audio interface between the user and the mobile phone.
  • the audio circuit 606 can convert the received electrical signals into audio speakers 6061, which are converted into sound signals by the speaker 6061; on the other hand, the microphone 6062 converts the collected sound signals into electrical signals, and the audio circuit 606 After receiving, it is converted into audio data, and then processed by the audio data output processor 608, and then sent to, for example, another mobile phone through the RF circuit 601, or the audio data is output to the memory 602 for further processing.
  • WiFi is a short-range wireless transmission technology.
  • the terminal can help users send and receive emails, browse web pages, and access streaming media through the WiFi module 607. It provides users with wireless broadband Internet access.
  • FIG. 6 shows the WiFi module 607, it can be understood that it is not a necessary configuration of the terminal, and can be omitted as needed without changing the essence of the invention.
  • the processor 608 is the control center of the terminal, and uses various interfaces and lines to connect the various parts of the entire terminal, executes or executes the software programs and / or modules stored in the memory 602, and calls the data stored in the memory 602 to execute Various functions and processing data of the terminal, so as to monitor the terminal as a whole.
  • the processor 608 may include one or more processors.
  • the processor 608 may include one or more central processors, or include a central processor and a graphics processor.
  • the processor 608 includes multiple processors, the multiple processors may be integrated on the same chip, or may be independent chips.
  • a processor may include one or more processing cores.
  • the terminal 600 further includes a power supply 609 (such as a battery) that supplies power to various components.
  • a power supply 609 (such as a battery) that supplies power to various components.
  • the power supply can be logically connected to the processor 608 through the power management system, so as to realize functions such as charging, discharging, and power consumption management through the power management system.
  • the terminal may also include a camera, a Bluetooth module, etc., which will not be repeated here.
  • the device 400 corresponding to FIG. 4 may also be implemented based on the structure of the terminal. All of them in FIG. 1 can be regarded as components of the abstract structure of the processor 608.
  • the processor 608 is used to perform the following operations by calling the program code stored in the memory 602:
  • the terminal collects current status information based on the detected startup event, which indicates that the operating system of the terminal cold-starts an application.
  • the current status information includes the hardware configuration of the terminal, the current load of the operating system, and the resource overhead of cold-starting the application.
  • the duration of multiple tasks in the process of cold restarting the application based on the current status information, a set of acceleration items corresponding to the application is determined, and the set of acceleration items indicates the number of optimizations that need to be optimized during the cold start of the application Object; determine a plurality of optimization strategies corresponding to the set of speedable items, the plurality of optimization strategies including at least one of a first optimization strategy and a second optimization strategy, wherein the first optimization strategy instructs to adjust the operating system
  • the resources allocated to the cold start, the second optimization strategy is used to accelerate the tasks during the cold start; during the cold start of the application, the multiple optimization strategies are executed.
  • the device corresponding to FIG. 6 can invoke any program or instruction stored in the memory 602, and the processor 608 can execute any possible method and apparatus implementation manner described above, and details are not described herein again.
  • the accelerating items during the cold start process are determined, so that these accelerating items are more accurate and more accurate.
  • a set of optimization strategies is determined in a targeted manner. The combined use of these optimization strategies can more fully optimize the cold start process of the application, so that the terminal can complete the cold start of the application more quickly.
  • the disclosed device may be implemented in other ways.
  • the device embodiments described above are only schematic.
  • the division of the module is only a division of logical functions.
  • there may be other divisions for example, multiple modules or components may be combined or integrated To another system, or some features can be ignored, or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in electrical or other forms.
  • the module described as a separate component may or may not be physically separated, and the component displayed as a module may or may not be a physical module, that is, it may be located in one place, or may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or software function modules.
  • the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable memory.
  • the technical solution of the present invention can be embodied in the form of a software product in essence or a part that contributes to the existing technology or all or part of the technical solution, and the computer software product is stored in a memory.
  • a computer device which may be a personal computer, server, network device, etc.
  • the aforementioned memory includes: U disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
  • the program may be stored in a computer-readable memory, and the memory may include: a flash disk , Read-Only Memory (English: Read-Only Memory, abbreviation: ROM), Random Access Device (English: Random Access Memory, abbreviation: RAM), magnetic disk or optical disk, etc.
  • ROM Read-Only Memory
  • RAM Random Access Device
  • magnetic disk or optical disk etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Computer Hardware Design (AREA)
  • Stored Programmes (AREA)

Abstract

一种加速应用冷启动的方法、装置和终端。该加速应用冷启动的方法包括:终端识别出指示终端的操作系统冷启动一个应用的事件后,从多个维度获取与应用冷启动相关的现状信息,该现状信息包括终端的硬件配置,终端的操作系统当前的负载,冷启动所述应用的资源开销和冷启动所述应用过程中多个任务各自对应的时长,通过分析这些现状信息,确定出本次冷启动所述应用过程中需优化的多个对象,再根据确定出的对象,得到与这些对象相对应的多条优化策略,从而在冷启动该应用的过程中,执行该多条优化策略,以加速应用的冷启动,其中,该多条优化策略从调整该应用的资源分配和加速冷启动过程中的任务这两方面中的至少一个加速冷启动。

Description

加速应用的冷启动的方法、装置和终端 技术领域
本发明涉及计算机领域,尤其涉及一种冷启动应用的方法、装置和终端。
背景技术
随着智能终端的普及,终端上安装的应用越来越多,用户往往会打开多个应用,以及在这多个应用之间切换。在安卓系统中,应用有三种启动方式,其中,应用的冷启动是比较费时的一种启动方式。应用的冷启动是指,当启动应用时,操作系统中没有用于运行应用的进程,即在应用的启动过程中,操作系统创建一个新的进程分配给该应用。
在上述冷启动过程中,用于启动应用的进程,以及运行该应用的操作系统需要耗费各种资源。这些资源可以包括处理器,例如中央处理器(Central Processing Unit,CPU)或者图形处理器(Graph Processing Unit,GPU),内存,I/O(input/output)资源,以及网络资源等。由于一个终端上安装的应用很多,资源的分配方式会影响应用的启动时间。
现有的应用启动方法,已经开始考虑资源的分配对应用的启动时间的影响。例如考虑CPU资源分配的高通公司的提频方案,考虑内存和I/O资源分配的谷歌(Google)公司的安卓(Android)系统的低内存杀进程(Low Memory Killer)方案。然而,这些方案对缩短应用的冷启动时间的效果不理想,甚至在一些使用场景下,还会使应用的冷启动变得更加缓慢,终端反而需要更多的时间才能在屏幕上显示出应用的界面。
发明内容
有鉴于此,本发明实施例提供了一种冷启动应用方法、装置和终端,通过分析终端的使用场景,当前终端操作系统的负载以及冷启动应用的系统开销等多个维度的信息,更准确更有针对性地确定出一组优化策略,这些优化策略的配合使用,可以使得终端能够更快速地完成应用的冷启动。
第一方面,本发明实施例提供一种冷启动应用的方法,该方法包括:终端基于检测到的启动事件采集现状信息,该启动事件指示该终端的操作系统冷启动一应用,该现状信息包括该终端的硬件配置,该操作系统当前的负载,冷启动该应用的资源开销,冷启动该应用过程中多个任务各自对应的时长;根据该现状信息,确定该应用对应的一组可加速项,该一组可加速项指示本次冷启动该应用过程中需优化的多个对象;确定与该一组可加速项对应的多条优化策略,该多条优化策略包括第一优化策略和第二优化策略中的至少一种,其中,该第一优化策略指示调整该操作系统分配给该冷启动的资源,该第二优化策略用于加速该冷启动中的任务;在冷启动该应用的过程中,执行该多条优化策略。
这样,通过分析终端的使用场景,当前终端操作系统的负载以及冷启动应用的系统开销等多个维度的信息,确定出冷启动过程中的可加速项,从而根据这些可加速项更准确更有针对性地确定出一组优化策略,这些优化策略的配合使用,可以更全面地优化应用的冷启动过程,使得终端能够更快速地完成应用的冷启动。也就是说,不同硬件配置的终端,不同工作状态的操作系统,不同的应用,所使用的优化策略都可以是不同的,这样的优化能更有效地加速应用的冷启动。
其中,该多个对象包括资源和任务中的至少一种。其中资源包括硬件资源和软件资源(即如何使用这些硬件资源)。硬件资源包括处理资源,存储资源和网络资源中的至少一种。软件资源用于表示操作系统对一个进程的管理,例如什么时机允许一个进程使用多少硬件资源。软件资源包括对操作系统中对其他活动(active)的进程的管理,例如冻结或清理其他活动的进程、释放其他活动的进程所占用的内存,释放其他进程占用的锁以便分配给用于冷启动该应用的进程中的至少一种。
一种实现方式下,该终端的硬件配置包括该终端的处理器(例如中央处理器、图像处理器和协处理器中的至少一种)、存储器件、网络器件和存储器件的规格。
在该终端首次冷启动该应用的情况下,该冷启动该应用的资源开销,以及冷启动该应用过程中,执行多个事件和多种操作各自的时长均为预设值;在该终端首次冷启动该应用的情况下,该冷启动该应用的资源开销,以及冷启动该应用过程中,执行多个事件和多种操作各自的时长均为历史值。
这是操作系统对收集来的现状信息的分析过程,具体可以是根据系统中保存的判断逻辑和阈值来分析。其中,可以在框架层和核心库层中的至少一层保存有上述评估信息与可加速项之间的对应关系,评估信息与可加速项之间的对应关系,可以是每个维度的信息在不同的等级各自对应一组可加速项。
一种可能的实现方式下,根据该现状信息,确定一组可加速项,包括:分析该现状信息,以得到该应用当前对应的评估信息,该应用当前对应的评估信息包括该终端的硬件配置的等级、该操作系统当前的负载的程度、该应用的资源开销类型,以及该冷启动中耗时长的任务;根据该应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出该应用当前对应的一组可加速项。
这是一个解析收集到的现状信息的过程。
其中,对硬件配置可以是:根据具体的硬件规格,确定终端为高端机、中端机或者低端机。对操作系统负载可以是:根据收集到的操作系统负载的信息,确定操作系统处于何种负载等级,例如轻、中、重度负载,或者一级,二级,三级,四级负载等。
需理解的是,评估操作系统负载,可以具体是先评估操作系统使用一种或者多种资源的情况,也即是多种硬件资源和软件资源的负载,再根据这些评估出的资源的负载等级,来评估操作系统的负载等级。另一种实现方式下,则直接根据收集到的现状信息,确定操作系统负载的等级。
一种可能的实现方式下,根据该应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出该应用当前对应的一组可加速项,包括:在该终端的硬件配置为第一等级,该操作系统当前处于第一级负载,该应用为第一资源开销类型,以及该冷启动中耗时长的任务为第一组任务的情况下,该应用当前对应第一组可加速项;在该终端的硬件配置为第二等级,该操作系统当前处于第二级负载,该应用为第二资源开销类型,以及该冷启动中耗时长的任务为第二组任务的情况下,该应用当前对应第二组可加速项。
其中,第一等级和第二等级,第一级负载和第二级负载,第一资源开销类型和第二资源开销类型以及第一组任务和第二组任务中,至少有一组是不同的,例如,可以是第一等级和第二等级是不同的等级,而其他三组是相同的等级;当然,也可以这四组都不相同。而第一组可加速项和第二组可加速项是两组不同的可加速项。也就是说,在一些场景下,在硬件等级不同和/或负载等级不同的情况下,即使是冷启动相同的应用,获得的可加速项也不同。
也就是说,在现状信息中至少有一方面的信息分析出的等级不同的情况下,对应不同组的可加速项。
一种可能的实现方式下,该确定与该一组可加速项对应的多条优化策略,包括:根据该应用当前对应的一组可加速项,以及可加速项与优化策略之间的对应关系,确定与该一组可加速项对应的多条优化策略。
终端中存储有可加速项和优化策略之间的对应关系,具体可以是多张表,或者指针,链表等。
一种可能的实现方式下,该操作系统当前的负载指示操作系统当前对该终端的硬件资源的使用情况,该硬件资源包括处理资源、存储资源和网络资源中的至少一种;冷启动该应用的资源开销指示对该冷启动对终端的处理器,内存,磁盘和网络带宽中至少一种的使用情况。
一种可能的实现方式下,该冷启动该应用过程中多个任务包括至少一个第一任务和至少一个第二任务,该多个任务各自对应的时长,包括执行该至少一个第一任务各自的时长,以及等待执行该至少一个第二任务各自的时长。
一种可能的实现方式下,该第一优化策略包括调整分配给该冷启动的处理资源、存储资 源和网络资源中的至少一种。
一种可能的实现方式下,该第一优化策略包括,该提高该终端的CPU的工作频率,延长该终端的CPU提频的时间,调整该终端的CPU的能耗参数,将用于冷启动该应用的进程迁移到另一个CPU的核上执行,提前释放该应用的冷启动过程对应的内存,冻结或者清理除至少一个其他进程以及调整分配给该至少一个其他进程的读/写带宽或者网络带宽,其中,该至少一个其他进程是除该应用之外,该操作系统中运行的至少一个其他应用的进程;该第二优化策略包括以下优化策略中的至少一种,开启该应用对应的TCP连接的Nagle算法,该冷启动对应的进程中较重要的线程优先使用处理资源,提前读取冷启动该应用所需的文件页,提前执行类验证,提前执行图片解码,提前加载基础库。
可见,综合考虑了多种现状信息后,得到的是一组基于当前操作系统和应用本身特点的优化策略,这些优化策略包括了对资源的调度和加速具体的任务,更有针对性也更加全面。
第二方面,本申请记载了一种冷启动应用的装置,该装置包括:采集模块,所述采集模块用于基于检测到的启动事件采集现状信息,所述启动事件指示所述终端的操作系统冷启动一应用,所述现状信息包括所述终端的硬件配置,所述操作系统当前的负载,冷启动所述应用的资源开销,冷启动所述应用过程中多个任务各自对应的时长;分析模块,所述分析模块用于根据所述现状信息,确定所述应用对应的一组可加速项,所述一组可加速项指示本次冷启动所述应用过程中需优化的多个对象;优化策略确定模块,所述优化策略确定模块用于确定与所述一组可加速项对应的多条优化策略,所述多条优化策略包括第一优化策略和第二优化策略中的至少一种,其中,所述第一优化策略指示调整所述操作系统分配给所述冷启动的资源,所述第二优化策略用于加速所述冷启动中的任务;执行模块,所述执行模块用于在冷启动所述应用的过程中,执行所述多条优化策略。
第三方面,本发明实施例记载一种设备,该设备包括理电路、通信接口和存储介质,该存储介质中存储有协议栈程序,该通信接口用于通过执行该协议栈程序与其他设备收发数据包,该处理器用于通过运行该存储介质中的指令,以实现第一方面及第一方面各种实现方式下的冷启动应用的方法。
一种实现方式下,该设备为终端。
应理解,第二方面和第三方面五是第一方面对应的装置和设备,其各种具体的实现方式、说明以及技术效果请参考第一方面,不再赘述。
第四方面,提供一种计算机程序产品,该计算机程序产品中存储有用于存储可以实现第一方面中各种实现方式中任意一种的方法的程序代码。
第五方面,提供一种计算机可读存储介质,包括指令,当该指令在计算机上运行时,使得该计算机执行第一方面中各种实现方式中任意一种的方法。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种终端架构示意图;
图2为本发明实施例提供的一种终端软件架构示意图;
图3为本发明实施例提供的一种冷启动应用的方法示意图;
图4为本发明实施例提供的一种冷启动应用的装置示意图;
图5为本发明实施例提供的一种冷启动应用的设备的示意图;
图6为本发明实施例提供的一种终端的结构示意图。
具体实施方式
本发明实施例提供了一种基于多路径传输控制协议MPTCP的报文反馈方法、装置和系统,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描 述。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
下面解释本申请出现的一些名词。
A和/或B:表示A和B,或者A或B。
内核态:运行在内核地址空间的进程,也可以称运行在内核地址空间的进程为处于内核态。
用户态:运行在用户地址空间的进程,也可以称运行在用户地址空间的进程为处于用户态。
任务(task):在多道程序或多进程环境中,由物理机来完成的基本工作元,它是由控制程序处理的一个或多个指令序列。
Running(运行):线程状态的一种。表示线程正在CPU上运行。
Runnable(可运行):线程状态的一种。表示线程运行所需的条件均已满足,正在CPU运行队列中排队,等待CPU调度,也就是等待使用CPU。
Uniterruptable sleep(不可中断的睡眠):线程状态的一种,简称sleep。表示线程处于不可中断堵塞,这种状态下一般是在等待各种锁资源。
WakeKill:线程状态的一种。表示线程在不可中断堵塞,被较致命的信号堵塞,一般为等待读写磁盘。
Block I/O(input/output):块设备的磁盘的输入/输出,也就是对磁盘的读/写。
Inflate:安卓系统中表示根据资源文件上下文以及参数,生成对应视图(View)的过程。
DDR:双倍速率动态随机存取存储器(Double Data Rate Synchronous Dynamic Random Access Memory,简称DDR SDRAM),内存的一种。
VerifyClass:安卓系统中,应用的一些类因为某些原因无法在编译时完成类验证,而在应用运行时进行类验证的过程。比如应用使用热补丁功能后,易发生此类过程。
阻塞:暂停某个线程以等待某个条件发生,该条件可以是某种资源准备就绪。
杀进程,即结束一个进程,或者释放一个进程占用的资源(如内存,CPU,I/O以及锁等)。
应用的冷启动分为三个阶段,即应用进程冷启动前的准备,应用初始化和在终端的界面上展示已冷启动的应用。直观的描述,就是从用户点击屏幕或者某个按钮,或者用户对终端说出一段语音,到应用界面完整展示给用户的过程。
一种实现方式下,应用进程冷启动前的准备包括终端收到由用户输入的触屏事件,以及触发的一系列处理,例如将该触屏使得终端的操作系统识别出一个应用被要求冷启动。其中,该一系列处理包括识别触屏事件,该事件经input守护进程传递到桌面应用(Graphical User Interface,GUI)的点击回调函数,还包括前后台切换,具体为桌面应用请求系统服务
(SystemServer)进程进行该待启动的应用的进程初始化、窗口初始化等,然后SystemServer将桌面上运行的应用切换为后台应用,将该待启动应用设置为前台应用。
应用初始化包括该应用的公共组件的初始化,和运行该应用的进程所需的服务和数据的初始化。其中,该公共组件可以包括网络请求库、JavaScript对象表示法(JavaScript Object Notation,Json)解析器、大数据统计库以及应用加密库中的至少一种。
在终端的界面上展示已启动的应用,包括加载需要显示的数据,界面的布局和绘制等操作。例如从网络下载文本、图片或者视频、解码图片和读取待显示的数据所在数据库等。
操作系统通过进程来冷启动应用,一个进程中包括一个或多个线程,例如组件加载线程,主线程等。冷启动过程需要进程中的线程配合,以按照一定次序执行上述的几个阶段中的任务,需要耗费终端的资源,上述几个阶段中的任务都有可能影响应用冷启动的时间。现有的加速应用冷启动的方案,往往使用固定的某几种方式加速冷启动,比如单一地使用CPU提频方式,或者使用杀进程以释放内存的方式,这些方式并不是有针对性地优化,很多时候反而会加剧冷启动应用的性能劣化。
冷启动一个应用所耗费的时间,可称为启动延迟。启动延迟也就是冷启动该应用过程中 多个任务各自对应的时长的累加。其中,对启动延迟影响较大的,是执行一些比较耗时的任务的延迟,以及进程的多个线程之间对资源(包括软件资源和硬件资源)的争抢。启动延迟可以包括执行该应用的进程中,一个或多个线程上的CPU延迟,内存慢速路径延迟、zram压缩延迟、I/O延迟、网络延迟、线程在Sleep状态下,等待锁带来的延迟(简称sleep锁延迟)、线程在Runnable状态下的延迟、线程在线程阻塞造成的延迟(例如组件加载线程阻塞主线程)中的至少一个。
其中,CPU延迟为线程等待使用CPU的时长,也就是一个线程维持在Runnable状态的时长。
内存慢速路径延迟为线程通过慢速路径使用内存所耗费的时间。其中,慢速路径读取的内存是根据读/写指令,设备释放出的被其他应用或者进程占用的内存。
zram压缩延迟:线程读取内存中被压缩的数据所耗费的时间。zram,也就是zip RAM,是Linux内核的一项功能,可提供虚拟内存压缩。为了使更多数据存入内存,某些内存中会有一部分地址存储被压缩的数据,这些数据在被读取前需要先解压。
I/O延迟:线程执行一批读/写磁盘的指令所耗费的时间,I/O延迟主要源于这些指令在队列中的等待时间。冷启动过程中,需要读取冷启动该应用所需的数据,例如应用的用户界面,用户数据,本地缓存等,故CPU会批量下发读/写磁盘的指令。终端的操作系统中时刻都有来自各个线程的读/写磁盘的指令,这些指令被放在队列中,应用冷启动所触发的读/写磁盘的指令由于是批量下发,故往往需要在队列中等待一段时间才可以全部执行完成。通常,I/O延迟占应用冷启动时长的15%左右。
本申请描述的冷启动应用的方法用于终端,该终端为可以安装应用的供用户使用的设备。终端通过现状采集,从多个维度获取与应用冷启动相关的现状信息,从而基于采集到的现状信息,分析出在该具体场景下,加速一个应用的冷启动所面临的问题(也就是得到一组可加速项),并根据确定出的可加速项得到与其对应的优化策略,使用针对这些具体问题的策略对应用的冷启动过程进行优化,从而降低应用冷启动的时间,也更合理地分配了终端的软硬件资源,提高了用户体验。
终端中可以保存一个或者多个优化策略库,每个优化策略库中都保存有多种优化策略。硬件资源方面,优化策略可以是按需调整硬件资源。可调整的方式包括以下至少一种:提高CPU的工作频率,将执行该应用的进程与某一CPU核绑定或者重新分配用于执行该应用的CPU核,调整L3 cache的工作频率,调整GPU的工作频率、调整电源管理(always-on)参数,将CPU和DDR的工作频率一起调整以使得调整后的CPU和DDR的工作频率仍然匹配等。加速该冷启动中的任务方面,优化策略可以包括:关键线程Runnable状态长的,进行VIP线程调度;I/O延迟较长的,使用页级别的文件预读;网络延迟长的,无延迟(no-delay)地使用TCP协议发包;Uniterruptable Sleep长的,使用请页锁降级等,以及将耗时较长的任务提前使用其他进程执行等,其中这些任务可以是编译函数、解码图片、验证类、so库加载和TCP预连接等中的至少一种。
下面介绍一些优化策略的具体含义。
CPU Boost:用于提高CPU的处理性能。常见的技术手段为提频和绑核。提频是指将CPU的工作频率提高到其工作频率范围的最高值或者较高值。绑核是指将一些应用固定在CPU的某些配置较高的核上执行,以保证这些应用可分配到较多的处理资源。应理解CPU可在一个频率范围内工作。出于使用寿命和功耗等方面的考虑,一般来说,CPU会以一个该频率范围内的中间值或较小的值来工作。另外,终端会有一个默认的提频时间,也就是操作系统收到提频的指令后,将CPU调整到在较高频率上工作的时长,例如1.5s。
VIP线程调度,是指将处理器运行队列中正在排队等待处理器执行的线程中的某些线程插队,也就是提前执行,例如提到队列头;或者将其中的某些线程从一个处理器核切换到其他的处理器核上运行,该某些线程可以是经过优先级排序后的较重要的线程,也可以是预先设置的特定的一类或几类线程。切换到的其他处理器核为负载较轻或者等待时间较短或者空 闲的处理器核。
进程快杀,是指在接到用于终止一个进程的KILL_SIG时,将该进程的线程在运行状态共享的虚拟内存的引用计数降为0后,才释放内存。以及,将这些共享的虚拟内存调整为先释放的匿名页与文件页的内存。KILL_SIG是发送给进程导致它立即终止的信号。进程快杀可以改善内存压力紧张时快速释放内存的问题。
请页锁降级:请页,也就是请求调页,指的是一种动态内存分配技术,具体是把页面的分配推迟到进程要访问的页不在物理内存时为止,由此引起一个缺页错误(Speculative Page Fault)。例如,可以是在请页流程中(例如page fault请页流程),不再使用进程级别的信号量锁mm semaphore,而改使用更细粒度的线程级别的锁。从进程级别的锁更改为线程级别的锁,也就是锁的降级。这种优化策略可以提供更好的进程内的并发性能。
页级别的文件预读:提前识别冷启动过程中需要读取的文件的页,在冷启动过程中,使用其他进程提前从缓存中读取这些页,而不是将页所在的文件整体都预读。具体的,是终端该优化策略可降低启动时间的IO等待。
无延迟(no-delay)地使用TCP协议发包,也称TCP发包no-delay,使用于应用在冷启动过程中需要通过TCP协议或者MPTCP协议与网络侧交互的场景。具体为在应用冷启动过程中,开启TCP协议中的Nagle算法,该算法下,发包延迟小,无需等待其他包,从而节省发包时间。
图片预解码,so库预加载以及函数预编译,都是在冷启动过程中,提前对需要使用的数据做必要的预处理,这些预处理是在操作系统检测到启动事件后,使用另一个进程执行的,往往该另一进程执行这些预处理时,用于冷启动该应用的进程还在构建的阶段。这种方式可以保障在用于冷启动该应用的进程需要使用这些数据时,无需等待这些数据的处理或者读取。
其中,图片预解码,指在一次冷启动开始之前,识别冷启动中,需要解码的一组图片,在检测到启动事件后,就使用另一个进程解码这些图片。例如,可根据历史上该应用的冷启动过程确定这些图片。so库预加载,指在一次冷启动开始之前,识别冷启动中需要加载的so库的信息,冷启动过程中使用另一线程提前加载这些文件。其中,so库中保存有安卓系统中,格式为.so的文件。
函数预编译,指基于历史的冷启动过程,识别冷启动过程中的一些预编译耗时较长或者运行频繁的函数或代码块,并在后台提前预编译这些代码块。具体的,可通过虚拟机中的JIT编译器,确定出运行频繁的代码块,这些运行频繁的代码块也称为热点代码(hot spot code)。
后台应用冻结,指在冷启动一个应用的过程中,通过cgroup的freezer机制,冻结仍然在后台运行的应用,也就是冻结运行这些后台应用的进程,例如禁止这些进程访问内存或占用CPU等等,以及在该应用的冷启动完成后解除对这些进程的冻结。该优化策略可以改善系统高负载情况下后台运行的应用对冷启动时长的影响。
应用管控排序,指根据当前操作系统运行的多个进程对应的业务的优先级,生成可杀进程列表、可压缩进程列表、不可杀列表等可供后台管控的进程列表。这些进程列表可以配合前述的一些优化策略使用。
文件缓存分类机制,分类管理该冷启动过程中使用到的文件的缓存,其中,分类管理文件缓存是通过将最近最少使用(Least Recently Used,LRU)队列分类来实现的。具体的,对较为重要的文件缓存,加入更高优先级的LRU队列,而对其他文件缓存,则加入较低优先级的LRU队列,在删除文件缓存时,先删除较低优先级的LRU队列中的缓存。
上述的多种优化策略只是举例,本申请描述的方法中可能使用到的优化策略并不局限于上述的种类。
下面从多个方面具体描述该冷启动应用的方法。
本申请中,终端是一种物理机,也可称之为用户设备(User Equipment,简称为“UE”)、移动台(Mobile Station,简称为“MS”)、移动终端(Mobile Terminal)等,可选的,该终端可以具备经无线接入网(Radio Access Network,RAN)与一个或多个核心网进行通信的能 力,例如,终端可以是移动电话(或称为“蜂窝”电话)、或具有移动性质的计算机等,例如,终端还可以是便携式、袖珍式、手持式、计算机内置的或者车载的移动装置,如手机、平板电脑、笔记本电脑、掌上电脑、智能穿戴设备,移动互联网设备(英文:mobile internet device,简称:MID)等等。应理解的是,除了终端以外,本发明实施例提供的方法也可以应用于其他类型的计算机系统。
终端的操作系统的负载,也可以称为操作系统的运行状态,表示终端的软件使用终端的硬件资源的情况。终端的操作系统的当前的负载包括该操作系统当前自身的负载,和该操作系统当下运行的应用的资源开销。其中硬件资源包括但不限于下述的至少一种:CPU,内存(如DDR),磁盘,网络和GPU。例如,应用的进程通过CPU或GPU,读取内存,磁盘的数据或者读取来自网络中的数据。这些硬件资源本身,以及这些硬件资源如何被使用,都可以用多种参数来描述,本申请不做限制。例如,与磁盘相关的参数是本地磁盘的容量,读/写速率,I/O等待(I/O wait)等,与网络相关的参数是网络带宽,网络时延等。
一种实现方式下,至少从CPU,内存和磁盘这三种资源的使用情况来描述操作系统的负载。终端可以根据操作系统使用三种资源的实时数据,确定操作系统的状态,上述三个方面的每个方面都可以用不同的参数来描述,例如,使用CPU负载,可用内存和I/O等待。其中,CPU负载指CPU的使用率,可用内存,可以是可用的内存量,也可以是可用的内存占内存总量的比例,再例如,I/O等待可以用I/O等待的时长描述,也可以用I/O的并发数目来描述。在以Linux为基础的操作系统中,有专门的指令获取上述三方面参数的值。当然,也可以用与其他资源有关的参数来描述操作系统的负载,本申请不做限定。例如,如果冷启动的应用需要从网络设备侧下载数据,那么还应考虑网络资源,如网络信号强度,网络带宽,终端当下的数据传输情况等。其中,终端可通过无线网络或者有线网络的接入节点接入网络。例如可以是无线WI-FI网络的接入点(Access Point,AP)、以太网的路由器、或者Winmax网络的接入点或者无线蜂窝移动网络的基站等等,本发明不限定网络的种类以及接入节点具体的形式。
对获得的上述三种参数的值,操作系统经过分析,可确定出当前系统在CPU,内存和磁盘三方面的使用情况,从而确定操作系统的状态。该分析可通过与预设的阈值比较,例如,CPU负载超过第一阈值则认为是高CPU负载,在第一阈值和第二阈值之间则认为是中CPU负载,可用内存量低于一定比例则认为是低可用内存等。
一种实现方式下,操作系统的状态分为若干个等级,例如三个等级,即轻度,中度和重度负载。操作系统可以根据获得的上述三种参数的值直接确定操作系统的状态,也可以根据三种参数的值对应的等级,确定操作系统的状态。例如,高CPU负载、低可用内存量和高I/O等待的操作系统,处于重度负载的状态。
一种实现方式下,同样用CPU,内存和磁盘这三种资源的使用情况来描述冷启动该应用的资源开销,也简称为应用的启动开销,也就是处理资源开销(如CPU开销),内存开销和I/O开销。其中,这三个方面都可以使用不同的参数来表示。CPU开销为进程执行冷启动应用,所占的CPU资源,例如,可以占CPU总资源的百分比来表示。内存开销为进程执行冷启动应用所使用的内存,例如可以占内存总量百分比来表示,或者以使用的内存量来表示。I/O开销为进程执行冷启动应用所要读或写的磁盘数据量。操作系统中同样可以保存一些阈值,以便操作系统分析获得的上述三种开销的值。例如,CPU开销超过一个阈值,则认为该应用的冷启动过程为高CPU开销。需要理解的是,应用的启动开销也可以使用其他资源的组合来指示,例如处理器,内存,磁盘以及网络带宽中至少一种。
图1为本发明实施例提供的终端100的结构示意图。该终端100可以本发明实施例的设备,图中示意性地画出的该终端的软件层和硬件层中可能包括的一些模块。该终端的软件层包括驱动层、核心库层、框架层和应用层。驱动层可包括CPU驱动、GPU驱动、显示控制器驱动等,操作系统的内核(例如安卓系统的kernel)也位于驱动层。需要理解的是,图1只是一种可能的示意性的层次划分,某些层在其他方式的划分中可能有不同的名称。例如在另一示意 图图2表示了另一种划分方式,图1中驱动层在图2中被称为Linux内核,该Linux内核中包括图1驱动层中描述驱动。
其中,核心库层是操作系统的核心部分,包括外观管理器、媒体框架、关系数据库、2G图形引擎库、Web浏览器引擎,内核库和虚拟机(例如Dalvik Virtual Machine)等。除此之外,框架层可包括浏览器引擎、排版引擎、文件解析器等;应用层可包括主界面(home)、媒体播放器(Media Player)、浏览器(Browser)等多种应用程序。
该终端的硬件层包括中央处理器(Center Processing Unit,CPU)、图形处理器(Graphic Processing Unit,GPU)等,当然还可以包括存储器、输入/输出设备、内存、内存控制器、网络接口等,输入设备可包括键盘、鼠标、触摸屏等,输出设备可包括显示设备如液晶显示器(Liquid Crystal Display,LCD)、阴极射线管(Cathode Ray Tube,CRT)、全息成像(Holographic)、投影(Projector)等。在硬件层之上可运行有操作系统(如Android、Firefox OS等)以及一些应用程序。
图1所示的系统架构可以用来执行本申请描述的方法,而图2则描述可用于执行本申请描述的方法的各种子系统在另一种系统架构中的位置,这种系统架构与图1描述的系统架构相似。图2包括终端的软件层,包括:Linux内核(kernel)、核心库层、框架层和应用层。图2中以双向箭头表示数据的交互。图2中示出的应用内调度子系统,实时处理子系统,采集执行适配子系统以及内核扩展子系统和非实时处理子系统,是一些实现方式下,本申请涉及到的对现有的终端操作系统的改进部分。
应用进程用于运行应用,一个应用进程涉及到应用层和框架层,如果一个应用运行在虚拟机中,那么该应用进程还涉及到核心库层。其中,一个应用进程在不同层的部分之间通过接口交互信息。图2示意了操作系统中的三个应用进程,且将左侧的,运行于虚拟机中的应用进程1在各个层中的部分都示意了出来。应用进程1在应用层执行应用的业务逻辑。应用内调度子系统,包括框架层的部分和虚拟机内的部分,可以管理系统中的多个应用,包括用于实现应用内的耗时情况的采集、识别、记录以及存储(即图中的应用高耗时采集执行)以及实现属于应用内调度的优化策略(保存在应用内调度方案集中)。应用进程1运行于虚拟机,故图2示出的应用内调度子系统在框架层和虚拟机层均有分布。应用内调度子系统在框架层的方案集中,优化策略包括但不限于:图片预解码、类(View)预验证(inflate)、TCP预连接、so库预加载等;在框架层的方案集中,优化策略包括但不限于:函数提前编译、类提前加载等。
框架层中包括实时处理子系统和非实时处理子系统。其中,实时处理子系统用于实现现场采集,开销评估,策略制定,事件识别等功能,这些功能也是本申请描述的应用冷启动方法的重点,在下文中将结合方法流程的做进一步详细描述。例如,现场采集功能度对应图4的采集模块401,开销评估和策略制定对应图4的分析模块402。事件识别对应的模块未在图4中画出。该子系统中还包括实时方案集,该方案集中记录有属于框架层的一些改进方案,供制定整体的改进策略使用。例如,该方案集中的方案可以包括按需加速CPU,以及若该需要冷启动的应用对内存使用量大,则改变内存分配策略,以保障其内存使用等。
非实时处理子系统中保存着与应用冷启动相关的配置和数据,其中,数据可以存储在磁盘内。例如,应用在不同系统负载状态下冷启动的历史数据,各子方案的默认配置,默认的参数取值,以及在子方案使用时间后,得到的优化参数值。在实施处理子系统制定策略的过程中,可以从非实时处理子系统中获取配置和数据。
核心层包括采集执行适配子系统,以及上述的应用进程中属于核心层的部分。采集执行适配子系统用于将实时处理子系统制定出的策略进行处理,以便内核扩展子系统执行这些策略。一种实现方式下,该采集执行适配子系统拥有较高权限。该采集执行适配子系统包括执行现状采集,用于提供查询接口供实习子系统的现状采集模块用;策略下发,用于接收实时子系统策略制定模块的命令,并下发到内核子系统;以及平台适配,用于将异构的内核节点,例如CPU、GPU等资源的接口,适配封装成统一接口,供实时处理子系统调用。
驱动层包括内核扩展子系统,用于在应用冷启动过程中执行实时处理子系统制定出的策略。这些策略可以包括与CPU或DDR或GPU有关的调度、VIP线程调度、进程快杀、锁(例如PageFault)降级、页级别的文件预读、低内存杀进程(Low Memory Killer,LMK)和无延迟(no-delay)地使用TCP协议发包中的一种。
可见,操作系统中维护有根据现状信息分析出可加速项的分析规则。操作系统中还维护有可加速项和优化策略之间的映射关系,该映射关系可以包括一组可加速项的组合,与一组优化策略的组合之间的映射关系,以及一个可加速项与至少一条优化策略之间的映射关系中的至少一种。确定出的优化策略,可以是通过可加速项的组合,直接得到一组优化策略,也可以是对得到的每一个可加速项,分别得到其对应的至少一条优化策略,所有得到的这些优化策略,就是本次冷启动应用待执行的优化策略。还可以对得到的每一个可加速项,分别得到其对应的至少一条优化策略,再根据组合规则,从所有得到的这些优化策略中剔除一部分优化策略,以得到本次冷启动应用待执行的优化策略。
这样,图2所示的设备就可以用于执行本申请记载的应用冷启动方法。可见,本申请方法对应的程序代码存在于操作系统平台软件中。运行时,本发明的程序代码运行于服务器的主机内存。
下面结合图3,以手机为例,描述本申请记载的应用冷启动方法。该方法中涉及的各种名词的解释,可参见本申请的相应段落,图3对应的实施例只是示例性说明。
S301,终端的操作系统识别到一个应用的启动事件,该启动事件指示终端的操作系统冷启动一应用。
例如,该事件可以是用户对终端屏幕的点击,或者用户向终端发出的语音指令,或者是终端接收到某个图像,或者终端操作系统能识别的某个信号或软件指令。本申请不限制启动事件的方式。
S302,终端基于检测到的启动事件采集当前的现状信息,其中现状信息包括终端的硬件配置,操作系统负载,该应用的启动开销以及冷启动该应用过程中多个任务各自对应的时长。
本申请描述的方法流程中所使用的,冷启动该应用的资源开销以及冷启动该应用过程中多个任务各自对应的时长不是本次冷启动的实时值。可以是终端记录的历史上该应用的冷启动过程的值,也可以是终端存储的默认值,也可以是终端的操作系统的估计值。需要理解的是,应用的启动开销会根据系统负载变化。例如,在高负载系统状态下和低负载系统状态下,同一应用的启动开销的参数值可能不同。一种实现方式下,终端保存同一应用在不同的操作系统的状态下的启动负载的值,以便在某一操作系统状态下使用更加合适的值来描述启动负载。在一次冷启动中,终端可以采集本次冷启动过程中启动负载的各项参数值,记录该次冷启动时的操作系统的状态,以供未来冷启动该应用时使用。
其中,终端的硬件配置包括终端多种硬件的规格,该多种硬件包括CPU、DDR、GPU、内存、网络资源中的至少一种。硬件的规格可以用多种参数表示,例如,CPU频点、CPU核数,DDR带宽频点、GPU频点、GPU核数,内存和磁盘的读写速率,内存的容量等。
操作系统的负载,可以系统的处理,存储和网络三方面的参数表征。可以包括系统的CPU负载、可用内存、I/O等待和网络状况中的至少一种。
该应用的启动开销,也称冷启动该应用所需的开销,开销包括各应用启动的平均时间、计算力MIPS、CPU负载、GPU负载、占用的内存、读写I/O的量、读写I/O的带宽和网络读取量中的至少一种。
在该应用非首次冷启动的情况下,基于手机上应用启动历史数据,确定该过程中多个任务对应的时长。该任务对应的时长,可以是执行某个任务的时长,如运行时的类验证、函数编译、图片解码、so库加载以及建立TCP链接中任一种任务的时长,也可以是某个任务等待执行的时长,例如主线程及其他关键路径上等待使用CPU延迟、内存慢速路径延迟、zram压缩延迟、I/O延迟以及网络延迟中的至少一种。首次冷启动,则可使用预设值或者估计值。
S303:终端解析采集到的信息,确定该应用对应的一组可加速项。
一种实现方式下,该步骤包括:分析该现状信息,以得到该应用当前对应的评估信息,该应用当前对应的评估信息包括该终端的硬件配置的等级、该操作系统当前的负载的程度、该应用的资源开销类型,以及该冷启动中耗时长的任务;根据该应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出该应用当前对应的一组可加速项。
其中,确定可加速项包括进行开销评估,也就是分析现状信息,以得到该应用当前对应的评估信息。
开销评估包括对硬件配置,操作系统负载、该应用的启动开销以及该应用的调度延迟和运行耗时等评估等级。该评估可以包括将各类信息分级,以及确定出影响应用的冷启动延迟的事件。下述的各种评估,可以是根据预设的阈值来判断。
其中,对硬件配置可以是:根据具体的硬件规格,确定终端为高端机、中端机或者低端机。
对操作系统负载可以是:根据收集到的操作系统负载的信息,确定操作系统处于何种负载等级,例如轻、中、重度负载,或者一级,二级,三级,四级负载等。
需理解的是,评估操作系统负载,可以具体是先评估操作系统使用一种或者多种资源的情况,也即是多种硬件资源和软件资源的负载,再根据这些评估出的资源的负载等级,来评估操作系统的负载等级。
另一种实现方式下,则直接根据收集到的现状信息,确定操作系统负载的等级。
可见,终端中保存有用于评估操作系统负载的规则,可以是,例如CPU高负载、低可用内存、高I/O,网络可用带宽小,则系统处于重度负载。也可以是CPU负载高于第一阈值,可用内存低于第二阈值,则系统处于重度负载。
对应用启动开销可以是:根据应用启动时的资源消耗,确定该应用为CPU消耗型、GPU消耗型、内存消耗型、I/O消耗型和网络消耗型中的至少一种。
对应用可以是识别应用启动中耗时长的任务。具体为基于手机上应用启动历史数据,识别出在资源调度和应用运行的延迟方面,该应用启动的关键瓶颈点。在资源调度延迟方面,可以是:根据终端在当前的资源负载情况下(可以是用负载的等级表示),此应用启动的历史调度延迟信息,确定应用的是如运行队列等待型、内存分配延迟型或I/O延迟型等中的至少一种。在应用运行的延迟方面:根据采集到的应用启动耗时执行信息,确定该应用为函数编译耗时型、图片解码耗时型、布局耗时型、类验证耗时型或者网络等待耗时型等中的至少一种。
开销评估还包括根据上述分析的结果,得到对应的一组可加速项。这些可加速项用于指示本次冷启动需要调整的资源和任务中的至少一种。具体可以是,根据识别出的本手机硬件、操作系统负载和待启动应用的开销,按资源差距排序评估出本次应用启动预估的资源差距最大的几项。根据本手机上待启动应用历史数据,按调度时延时间比例,评估出本次应用启动预估的调度差距最大的几项,以及冷启动过程内最需优化的几个任务。
一种实现方式下,在该终端的硬件配置为第一等级,该操作系统当前处于第一级负载,该应用为第一资源开销类型,以及该冷启动中耗时长的任务为第一组任务的情况下,该应用当前对应第一组可加速项;在该终端的硬件配置为第二等级,该操作系统当前处于第二级负载,该应用为第二资源开销类型,以及该冷启动中耗时长的任务为第二组任务的情况下,该应用当前对应第二组可加速项。
S304:终端根据评估出的一组可加速项,确定出与该一组可加速项对应的多条优化策略。
其中,终端中保存有可加速项和优化策略之间的对应关系,这种对应关系可以是一个或者多个表,或者通过指针或者链表实现。这些对应关系可存储在框架层,Linux内核和核心库层中的至少一层。这种对应关系可以是多组可加速项和多组优化策略之间对应关系,其中,一组可加速项对应一组优化策略;也可以是多条可加速项和多条优化策略之间的对应关系,其中,一条可加速项对应一条或多条优化策略,这样,逐条查找评估出的一组可加速项对应的优化策略,就可以得到该组可加速项对应的所有优化策略。这种方式下,还可以包括必要的去重,去除相互对立的优化策略等操作。对立的优化策略优化方向相反,例如,优化策略 一指示CPU提频,优化策略二指示CPU降频,则这两条优化策略想法。
其中,多条优化策略包括第一优化策略和第二优化策略中的至少一种,其中,该第一优化策略指示调整该操作系统分配给该冷启动的资源,该第二优化策略用于加速该冷启动中的任务。
具体的,确定出的优化策略可以是从现有的库中调用的,也可以根据现状采集中的信息,修改现有策略中的参数。
关于优化策略的确定方式,以及优化策略的种类的说明,请参照前文的相关段落,此处仅做简单的举例说明。
资源方面,优化策略可以是按需调整硬件资源的参数。可调整的参数包括以下至少一种:CPU维度的提频、绑核、调频器参数、L3 cache频率等;GPU频点、电源管理(always-on)参数等;DDR维度的频点及与CPU联动等。
任务方面,优化策略可以包括:关键线程Runnable状态长的,VIP线程调度;I/O延迟较长的,使用页级别的缓存预读;网络延迟长的,使用TCP发包no-delay;Uniterruptable Sleep长的,使用请页锁降级等。以及优化策略还包括将耗时较长的启动过程提前异步执行,这些启动过程可以是编译热点函数、解码图片、验证类、so库加载和TCP预连接等中的至少一种。
可见,S302到S304对应图2的实时处理子系统中的现状采集,开销评估,事件识别和策略制定。当然,实时处理子系统还可以包括实时系统子方案集,用于实现从框架层的服务侧调度各优化策略。子方案集包括但不限于:按需CPU加速、大内存应用启动内存保障等。以及,S302到S304的过程中也涉及到从非实时处理子系统中获取历史数据以及默认的配置等。
S305:终端在冷启动该应用的过程中,执行确定出的优化策略。
具体的,可以是图2中的实时处理子系统通过采集执行适配子系统,将这些优化策略对应的指令下发给内核扩展子系统,以执行这些优化策略。
这样,终端通过采集现状信息,从多个维度获取与应用冷启动相关的软硬件配置,从而基于采集到的信息,分析出在该具体场景下,加速一个应用的冷启动所面临的问题,并使用针对这些具体问题的策略对应用的冷启动过程进行优化,从而降低应用冷启动的时间,也更合理地分配了终端的软硬件资源,提高了用户体验。
可见,本申请描述的方法中,终端的硬件配置会影响终端上应用的冷启动策略。下面以两种具体场景为例进行说明。一个场景中,冷启动终端A上的一个应用,终端A硬件配置较低;另一个场景中,冷启动终端B上的一个应用,终端B硬件配置较高。
对终端A,首先,终端采集现状信息,其中包括硬件配置,操作系统负载,冷启动该应用的资源开销和冷启动该应用过程中多个任务各自对应的时长。硬件配置可以是终端A的操作系统通过一些硬件配置采集手段得到的,例如测试或者通过传感器或接口等感知到的,也可以是读取的预存储在终端A中的硬件配置。
终端A的操作系统得到以下的硬件配置:CPU为双核芯片,具体型号为高通8917,终端A的内存为2GB,GPU为308芯片,闪存为海力士通用闪存存储(Universal Flash Storage,UFS)。可见,终端A是一款硬件配置较低的手机,其主要瓶颈在于CPU配置低,很容易处理资源不足。终端A使用Android 8.2版本的操作系统,由于硬件配置较低,开机后,在待机情况下,终端A的操作系统即进入了中度负载。
在用户使用了3-4个应用后,操作系统检测到终端A的CPU负载维持在60%上下,可用内存在300MB左右,I/O等待维持在10%。一般来说,I/O等待在4%以上就属于高I/O等待。也就是说,终端A的操作系统处于高CPU负载、低可用内存和高I/O等待的状态,可以认为操作系统均处于重度负载。也就是说,在操作系统处于重度负载的情况下,终端检测到用户的指令,该指令指示终端启动相机应用。
另外终端根据操作系统的状态,确定冷启动相机应用的资源开销为CPU开销(overhead)30%,I/O开销(要读的磁盘数据)30MB,内存开销800MB。该相机应用启动过程中,内存慢速路径延迟1200ms,I/O延迟600ms,运行应用的线程在Runnable状态下的延迟500ms, Sleep等锁延迟120ms,组件加载线程堵塞主线程造成的延迟300ms。
接着,终端A基于采集到的上述信息评估限制冷启动速度的主要问题。由上述采集到的信息,终端A分析出本机硬件能力弱,主要是CPU处理能力不足。终端A处于重度系统负载,体现在正在运行的应用使得可用内存率低,I/O使用率高。相机应用的启动开销是高内存开销、高CPU开销,以及一般I/O开销。相机应用的启动延迟方面,主要来自内存慢速路径延迟、I/O延迟、运行应用的线程在Runnable状态下延迟和sleep等锁的延迟。
接着,根据评估的结果,确定对应多个优化策略。
例如,该优化策略包括:改善硬件资源方面,优化策略包括延长CPU的boost时间到5s。这是由于终端A的CPU的boost时间默认值为1.5s,且CPU配置较低,处理资源不足。改善启动延迟方面,优化策略包括从减小内存分配时间、减小Runntime时间以及减小I/O延迟等方面来改善。例如,减小内存分配时间方面,可以执行以下优化策略中的至少一种,包括在相机应用冷启动过程中,给相机应用分配内存快杀接口,提前计算需要杀的内存量,判定更多内存为可杀,被杀的内存不再被其他应用占用,启动阶段后台应用被杀禁止拉起,以及减小Runntime时间方面,可以将操作系统后台的应用冻结一段时间(例如与冷启动该应用的CPUboost时间等长),其中冻结后台应用就是在相机冷启动过程中,后台应用都暂时不能使用CPU资源。还可以是提高相机应用的组件的初始化线程的调度CPU的优先级。减小I/O延迟方面,可以预读启动相机应用所需的文件。
确定了优化策略后,终端即可在相机冷启动过程中执行这些优化策略,以加速冷启动。
这样,终端通过现状采集,从多个维度获取与应用冷启动相关的软硬件配置,从而基于采集到的信息,分析出在该具体场景下,加速一个应用的冷启动所面临的问题,并使用针对这些具体问题的策略对应用的冷启动过程进行优化,从而降低应用冷启动的时间,也更合理地分配了终端的软硬件资源,提高了用户体验。例如在上述的终端A冷启动相机应用的场景中,不使用上述方式优化冷启动过程,则冷启动相机应用的时间为5975ms;使用上述方式,则冷启动相机应用的时间为3885ms。
下面以另一种具体场景为例进行说明,该场景中使用的终端B的硬件配置较高,需要冷启动的应用是一电子商务应用,例如用于网上购物的淘宝(taobao)或者亚马逊(Amazon)。同样,首先,终端采集现状信息。
终端B的操作系统得到以下的硬件配置:CPU为8核芯片,具体型号为麒麟970,终端B的内存为6GB,闪存为东芝UFS2.0。可见,终端A是一款硬件配置较高的手机,唯有闪存配置稍显不足。终端A使用Android 8.2版本的操作系统,由于硬件配置较高,大部分用户在使用时都是处于轻度负载或者中度负载。
终端B的操作系统检测到终端B的CPU负载在10%左右,可用内存在4GB左右,I/O等待几乎是0%,网络状态良好。终端B的操作系统处于轻度负载。也就是说,在操作系统处于轻度负载的情况下,终端检测到用户的指令,该指令指示终端冷启动该电子商务应用。
另外终端根据操作系统的状态,确定相机应用的应用负载为CPU开销(overhead)30%,I/O开销包括需读取的磁盘数据100MB和需写入的磁盘数据1MB,内存开销259MB。该应用冷启动过程中,网络延迟200ms,I/O延迟500ms,应用内某些函数的即时(Just in Time,JIT)编译带来的延迟500ms,线程在Sleep状态下等待锁的延迟100ms,验证用户身份等验证类(Verifyclass)任务带来的延迟200ms以及图片解码带来的延迟60ms。
接着,终端B基于采集到的上述信息评估限制冷启动速度的主要问题。由上述采集到的信息,终端B分析出本机硬件能力强,操作系统处于轻度负载,有足够的资源冷启动该应用,该应用属于冷启动开销一般的应用,应用的启动延迟主要来自网络延迟、I/O延迟以及函数的即时编译带来的延迟。
接着,根据评估的结果,确定对应的多个优化策略。其中,硬资源调度参数无需调整,采用默认的策略,例如在冷启动和界面切换中均维持1.5秒的提频。调度延迟上,针对I/O延迟时间长,采用页级别的文件预读来解决;针对网络延迟长,采用TCP发包no-delay方法; 针对Sleep时间长,采用请页锁降级方案。应用内调用上,针对JIT耗时长,采用提前编译speed-profile热点函数解决;针对验证类长,使用提前异步验证类解决;针对解码耗时长,使用提前异步解码解决。
确定了优化策略后,终端即可在该应用的冷启动过程中执行这些策略,以加速冷启动。
这样,终端经过现状采集,分析出造成应用冷启动在该具体场景下面临的问题,并使用针对这些具体问题的策略对应用的冷启动过程进行优化,从而降低应用冷启动的时间,也更合理地分配了终端的软硬件资源,提高了用户体验。例如上述的场景中,不使用上述方式优化冷启动过程,则冷启动该电子商务应用的时间为3534ms;使用上述方式,则冷启动该电子商务应用的时间为2163ms。
图4描述了本申请提供的一种冷启动应用的装置400,该装置400包括采集模块401,该采集模块401用于基于检测到的启动事件采集现状信息,该启动事件指示该终端的操作系统冷启动一应用,该现状信息包括该终端的硬件配置,该操作系统当前的负载,冷启动该应用的资源开销,冷启动该应用过程中多个任务各自对应的时长;分析模块402,该分析模块402用于根据该现状信息,确定该应用对应的一组可加速项,该一组可加速项指示本次冷启动该应用过程中需优化的多个对象;优化策略确定模块403,该优化策略确定模块403用于确定与该一组可加速项对应的多条优化策略,该多条优化策略包括第一优化策略和第二优化策略中的至少一种,其中,该第一优化策略指示调整该操作系统分配给该冷启动的资源,该第二优化策略用于加速该冷启动中的任务;执行模块404,该执行模块404用于在冷启动该应用的过程中,执行该多条优化策略。
关于该装置的具体实施细节,请参照前文对方法的描述。一种实现方式下,图4中的采集模块401可以在图2中的框架层和核心库层实现,例如,下达采集现状信息的指令可以在框架层,现状信息中终端的硬件配置,操作系统当前的负载,冷启动该应用的资源开销以及一部分冷启动应用过程中的任务对应的时长都来源于核心库层,另一部分冷启动应用过程中的任务对应的时长可能来源于框架层。分析模块402和优化策略确定模块403也可以在图2中的框架层实现,执行模块404则可以在图2中的Linux内核实现。
这样,可以通过分析终端的使用场景,当前终端操作系统的负载以及冷启动应用的系统开销等多个维度的信息,确定出冷启动过程中的可加速项,从而根据这些可加速项更准确更有针对性地确定出一组优化策略,从而优化应用的冷启动过程,使得终端能够更快速地完成应用的冷启动。
一种实现方式下,该冷启动该应用过程中多个任务包括至少一个第一任务和至少一个第二任务,该多个任务各自对应的时长,包括执行该至少一个第一任务各自的时长,以及等待执行该至少一个第二任务各自的时长。例如,第一任务可以是前文提及的图片解码,类验证,So文件加载和函数编译中的至少一种,第二任务可以是等待使用CPU、zram压缩,读/写磁盘数据中的至少一种。
一种实现方式下,分析模块402具体用于分析该现状信息,以得到该应用当前对应的评估信息,该应用当前对应的评估信息包括该终端的硬件配置的等级、该操作系统当前的负载的程度、该应用的资源开销类型,以及该冷启动中耗时长的任务;以及根据该应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出该应用当前对应的一组可加速项。
这是操作系统对收集来的现状信息的分析过程,具体可以是根据系统中保存的判断逻辑和阈值来分析。其中,可以在框架层和核心库层中的至少一层保存有上述评估信息与可加速项之间的对应关系,评估信息与可加速项之间的对应关系,可以是每个维度的信息在不同的等级各自对应一组可加速项。
一种实现方式下,在根据该应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出该应用当前对应的一组可加速项的方面,该分析模块402具体用于在该终端的硬件配置为第一等级,该操作系统当前处于第一级负载,该应用为第一资源开销类型, 以及该冷启动中耗时长的任务为第一组任务的情况下,该应用当前对应第一组可加速项;以及在该终端的硬件配置为第二等级,该操作系统当前处于第二级负载,该应用为第二资源开销类型,以及该冷启动中耗时长的任务为第二组任务的情况下,该应用当前对应第二组可加速项。
其中,第一等级和第二等级,第一级负载和第二级负载,第一资源开销类型和第二资源开销类型以及第一组任务和第二组任务中,至少有一组是不同的,例如,可以是第一等级和第二等级是不同的等级,而其他三组是相同的等级;当然,也可以这四组都不相同。而第一组可加速项和第二组可加速项是两组不同的可加速项。也就是说,在一些场景下,在硬件等级不同和/或负载等级不同的情况下,即使是冷启动相同的应用,获得的可加速项也不同。
也就是说,在现状信息中至少有一方面的信息分析出的等级不同的情况下,对应不同组的可加速项。
当然,也可能在上述四个方面的信息的等级不完全一致的情况下,该应用对应的可加速项都是相同的一组可加速项,例如都是第一组可加速项。
一种实现方式下,该优化策略确定模块403具体用于根据该应用当前对应的一组可加速项,以及可加速项与优化策略之间的对应关系,确定与该一组可加速项对应的多条优化策略。
具体说明请参考前文对应的段落。
一种实现方式下,该操作系统当前的负载指示操作系统当前对该终端的硬件资源的使用情况,该硬件资源包括处理资源、存储资源和网络资源中的至少一种;冷启动该应用的资源开销指示对该冷启动对终端的处理器,内存,磁盘和网络带宽中至少一种的使用情况。
一种实现方式下,该第一优化策略包括调整分配给该冷启动的处理资源、存储资源和网络资源中的至少一种。
一种实现方式下,该第一优化策略包括,该提高该终端的CPU的工作频率,延长该终端的CPU提频的时间,调整该终端的CPU的能耗参数,将用于冷启动该应用的进程迁移到另一个CPU的核上执行,提前释放该应用的冷启动过程对应的内存,冻结或者清理除至少一个其他进程以及调整分配给该至少一个其他进程的读/写带宽或者网络带宽,其中,该至少一个其他进程是除该应用之外,该操作系统中运行的至少一个其他应用的进程;该第二优化策略包括以下优化策略中的至少一种,开启该应用对应的TCP连接的Nagle算法,该冷启动对应的进程中较重要的线程优先使用处理资源,提前读取冷启动该应用所需的文件页,提前执行类验证,提前执行图片解码,提前加载基础库。
图5描述了本申请提供的一种用于应用冷启动的设备500的结构,该设备500包括:至少一个处理电路501,存储介质502,通信接口504,其中可以包括至少一个网络接口,至少一个通信总线605。通信总线605用于实现这些组件之间的连接通信。该设备50可选的包含用户接口,包括显示器(例如,触摸屏、LCD、CRT、全息成像(Holographic)或者投影(Projector)等),键盘或者点击设备(例如,鼠标,轨迹球(trackball),触感板或者触摸屏等)。
存储介质502可以包括只读存储器和随机存取存储器,并向处理电路501提供指令和数据。存储介质502的一部分还可以包括非易失性随机存取存储器(NVRAM)。
在一些实施方式中,存储介质502存储了如下的元素,可执行模块或者数据结构,或者他们的子集,或者他们的扩展集:
操作系统5021,包含各种系统程序,例如图1所示的框架层、核心库层和驱动层等,或者图2所示框架层,核心库层和Linux内核等。用于实现各种基础业务以及处理基于硬件的任务。一种实现方式下,前文提及的采集模块401.分析模块402.优化策略确定模块403以及执行模块404都是包括在操作系统5021内。
应用程序模块5022,包含各种应用程序,例如本申请中描述的被冷启动的应用,又例如图1所示的图库、媒体播放器(Media Player)、浏览器(Browser)等,用于实现各种应用业务。
在本发明实施例中,通过调用存储介质502存储的程序或指令,处理电路501基于检测 到的启动事件采集现状信息,该启动事件指示该终端的操作系统冷启动一应用,该现状信息包括该终端的硬件配置,该操作系统当前的负载,冷启动该应用的资源开销,冷启动该应用过程中多个任务各自对应的时长;根据该现状信息,确定该应用对应的一组可加速项,该一组可加速项指示本次冷启动该应用过程中需优化的多个对象;确定与该一组可加速项对应的多条优化策略,该多条优化策略包括第一优化策略和第二优化策略中的至少一种,其中,该第一优化策略指示调整该操作系统分配给该冷启动的资源,该第二优化策略用于加速该冷启动中的任务;在冷启动该应用的过程中,执行该多条优化策略。
图5对应的设备通过调用存储介质502存储的程序或指令,处理电路501可执行前文描述的任一种可能的方法和装置的实现方式,此处不再赘述。图1中描述的硬件层的硬件,也可以认为是图5的一种具体实现方式。例如,图5的处理电路501,在图1中表现为中央处理器和图形处理器,存储介质502,在图1中示意为内存。
这样,通过分析终端的使用场景,当前终端操作系统的负载以及冷启动应用的系统开销等多个维度的信息,确定出冷启动过程中的可加速项,从而根据这些可加速项更准确更有针对性地确定出一组优化策略,这些优化策略的配合使用,可以更全面地优化应用的冷启动过程,使得终端能够更快速地完成应用的冷启动。
请参见图6,图6是本发明实施例公开的一种终端的结构示意图。其中,该终端可以用于执行前文所描述的应用冷启动方法的部分或全部步骤,例如可参见图3对应的相关描述,具体的说明,以及有益效果的阐述,在此都不再赘述。如图6所示,终端600包括:射频(Radio Frequency,RF)电路601、存储器602、输入单元603、显示单元604、传感器605、音频电路606、无线保真(wireless fidelity,WiFi)模块607、处理器608、以及电源609等部件。本领域技术人员可以理解,图6中示出的终端结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
图6可理解为图5基础上的一种具体实现方式,两张图中示意的一些部件之间有对应关系,例如图6中的存储器602对应图5中的存储介质502,图6中的处理器608对应图5中的处理电路501等,图6中的射频(Radio Frequency,RF)电路601以及无线保真(wireless fidelity,WiFi)模块607是图5中的通信接口504的一种具体实现方式。因此,图1中的应用层,框架层,核心层和驱动层,图2中的各种层和子系统和图4中的各种模块也可以是处理器608通过调用存储器602中的代码实现的。当然,图6对应的终端描述出了比图5更多的硬件部件。
RF电路601可用于收发信息或通话过程中,信号的接收和发送,特别地,将基站的下行信息接收后,给处理器608处理;另外,将设计上行的数据发送给基站。通常,RF电路601包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路601还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(Global System of Mobile communication,GSM)、通用分组无线服务(General Packet Radio Service,GPRS)、码分多址(Code Division Multiple Access,CDMA)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、长期演进(Long Term Evolution,LTE)、电子邮件、短消息服务(Short Messaging Service,SMS)等。
存储器602存储计算机程序,该计算机程序包括应用程序6021和操作系统程序6022,处理器608用于读取存储器602中的计算机程序,然后执行计算机程序定义的方法,例如处理器608读取操作系统程序6022从而在该终端600上运行操作系统以及实现操作系统的各种功能,或读取一种或多种应用程序6021,从而在该终端600上运行应用。操作系统6022中包含了可实现本发明实施例提供的内存回收方法的计算机程序,从而使得处理器608读取到该操作系统程序6022并运行该操作系统后,该操作系统可具备本发明实施例提供的内存回收功能。另外,存储器602还存储有除计算机程序之外的其他数据6023,其他数据6023可包括操作系统6022或应用程序6021被运行后产生的数据,该数据包括系统数据(例如操作系 统的配置参数)和用户数据。此外,存储器602一般包括内存和外存。内存可以为随机存储器(RAM),只读存储器(ROM),以及高速缓存(CACHE)等。外存可以为硬盘、光盘、USB盘、软盘或磁带机等。计算机程序通常被存储在外存上,处理器在执行处理前会将计算机程序从外存加载到内存。
输入单元603可用于接收输入的数字或字符信息,以及产生与终端600的用户设置以及功能控制有关的键信号输入。
具体地,输入单元603可包括触控面板6031以及其他输入设备6032。触控面板6031,也称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板6031上或在触控面板6031附近的操作),并根据预先设定的程式驱动相应的连接装置。可选的,触控面板6031可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器608,并能接收处理器608发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板6031。除了触控面板6031,输入单元603还可以包括其他输入设备6032。具体地,其他输入设备6032可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
显示单元604可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元604可包括显示面板6041,可选的,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板6041。进一步的,触控面板6031可覆盖显示面板6041,当触控面板6031检测到在其上或附近的触摸操作后,传送给处理器608以确定触摸事件的类型,随后处理器608根据触摸事件的类型在显示面板6041上提供相应的视觉输出。虽然在图6中,触控面板6031与显示面板6041是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板6031与显示面板6041集成而实现手机的输入和输出功能。
传感器605可以为光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板6041的亮度,接近传感器可在手机移动到耳边时,关闭显示面板6041和/或背光。作为运动传感器的一种,加速计传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于手机还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。
例如,本申请中描述的启动事件,就可以是用户触摸显示单元604,该压力信号由传感器605传递给终端的。
音频电路606、扬声器6061,传声器6062可提供用户与手机之间的音频接口。音频电路606可将接收到的音频数据转换后的电信号,传输到扬声器6061,由扬声器6061转换为声音信号输出;另一方面,传声器6062将收集的声音信号转换为电信号,由音频电路606接收后转换为音频数据,再将音频数据输出处理器608处理后,经RF电路601以发送给比如另一手机,或者将音频数据输出至存储器602以便进一步处理。
WiFi属于短距离无线传输技术,终端通过WiFi模块607可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图6示出了WiFi模块607,但是可以理解的是,其并不属于终端的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。
处理器608是终端的控制中心,利用各种接口和线路连接整个终端的各个部分,通过运行或执行存储在存储器602内的软件程序和/或模块,以及调用存储在存储器602内的数据,执行终端的各种功能和处理数据,从而对终端进行整体监控。可选的,处理器608可以包括一个或多个处理器,例如,处理器608可以包括一个或多个中央处理器,或者包括一个中央 处理器和一个图形处理器。当处理器608包括多个处理器时,这多个处理器可以集成在同一块芯片上,也可以各自为独立的芯片。一个处理器可以包括一个或多个处理核。
终端600还包括给各个部件供电的电源609(比如电池),优选的,电源可以通过电源管理系统与处理器608逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。
尽管未示出,终端还可以包括摄像头、蓝牙模块等,在此不再赘述。
前述实施例中,各步骤方法流程,图4对应的装置400也可以基于该终端的结构实现。其中图1中的均可视为处理器608的抽象化结构的组成部分。
在本发明实施例中,处理器608通过调用存储于存储器602中的程序代码,用于执行以下操作:
终端基于检测到的启动事件采集现状信息,该启动事件指示该终端的操作系统冷启动一应用,该现状信息包括该终端的硬件配置,该操作系统当前的负载,冷启动该应用的资源开销,冷启动该应用过程中多个任务各自对应的时长;根据该现状信息,确定该应用对应的一组可加速项,该一组可加速项指示本次冷启动该应用过程中需优化的多个对象;确定与该一组可加速项对应的多条优化策略,该多条优化策略包括第一优化策略和第二优化策略中的至少一种,其中,该第一优化策略指示调整该操作系统分配给该冷启动的资源,该第二优化策略用于加速该冷启动中的任务;在冷启动该应用的过程中,执行该多条优化策略。
图6对应的设备通过调用存储器602存储的程序或指令,处理器608可执行前文描述的任一种可能的方法和装置的实现方式,此处不再赘述。
这样,通过分析终端的使用场景,当前终端操作系统的负载以及冷启动应用的系统开销等多个维度的信息,确定出冷启动过程中的可加速项,从而根据这些可加速项更准确更有针对性地确定出一组优化策略,这些优化策略的配合使用,可以更全面地优化应用的冷启动过程,使得终端能够更快速地完成应用的冷启动。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必须的。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如该模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个模块或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或模块的间接耦合或通信连接,可以是电性或其它的形式。
该作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
该集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例该方法的全部或部分步骤。而前述的存储器 包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储器中,存储器可以包括:闪存盘、只读存储器(英文:Read-Only Memory,简称:ROM)、随机存取器(英文:Random Access Memory,简称:RAM)、磁盘或光盘等。
以上对本发明实施例进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法;同时,对于本领域的一般技术人员,依据本申请文件记载的内容,在具体实施方式及应用范围上均会有改变之处,综上该,本说明书内容不应理解为对本发明的限制。

Claims (19)

  1. 一种冷启动应用的方法,其特征在于,所述方法包括:
    终端基于检测到的启动事件采集现状信息,所述启动事件指示所述终端的操作系统冷启动一应用,所述现状信息包括所述终端的硬件配置,所述操作系统当前的负载,冷启动所述应用的资源开销,冷启动所述应用过程中多个任务各自对应的时长;
    根据所述现状信息,确定所述应用对应的一组可加速项,所述一组可加速项指示本次冷启动所述应用过程中需优化的多个对象;
    确定与所述一组可加速项对应的多条优化策略,所述多条优化策略包括第一优化策略和第二优化策略中的至少一种,其中,所述第一优化策略指示调整所述操作系统分配给所述冷启动的资源,所述第二优化策略用于加速所述冷启动中的任务;
    在冷启动所述应用的过程中,执行所述多条优化策略。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述现状信息,确定一组可加速项,包括:
    分析所述现状信息,以得到所述应用当前对应的评估信息,所述应用当前对应的评估信息包括所述终端的硬件配置的等级、所述操作系统当前的负载的程度、所述应用的资源开销类型,以及所述冷启动中耗时长的任务;
    根据所述应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出所述应用当前对应的一组可加速项。
  3. 根据权利要求2所述的方法,其特征在于,根据所述应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出所述应用当前对应的一组可加速项,包括:
    在所述终端的硬件配置为第一等级,所述操作系统当前处于第一级负载,所述应用为第一资源开销类型,以及所述冷启动中耗时长的任务为第一组任务的情况下,所述应用当前对应第一组可加速项;
    在所述终端的硬件配置为第二等级,所述操作系统当前处于第二级负载,所述应用为第二资源开销类型,以及所述冷启动中耗时长的任务为第二组任务的情况下,所述应用当前对应第二组可加速项。
  4. 根据权利要求1到3任一所述的方法,其特征在于,所述确定与所述一组可加速项对应的多条优化策略,包括:
    根据所述应用当前对应的一组可加速项,以及可加速项与优化策略之间的对应关系,确定与所述一组可加速项对应的多条优化策略。
  5. 根据权利要求1到4任一所述的方法,其特征在于,所述操作系统当前的负载指示操作系统当前对所述终端的硬件资源的使用情况,所述硬件资源包括处理资源、存储资源和网络资源中的至少一种;冷启动所述应用的资源开销指示对所述冷启动对终端的处理器,内存,磁盘和网络带宽中至少一种的使用情况。
  6. 根据权利要求1到5任一所述的方法,其特征在于,所述冷启动所述应用过程中多个任务包括至少一个第一任务和至少一个第二任务,所述多个任务各自对应的时长,包括执行所述至少一个第一任务各自的时长,以及等待执行所述至少一个第二任务各自的时长。
  7. 根据权利要求1到6任一所述的方法,其特征在于,所述第一优化策略包括调整分配给所述冷启动的处理资源、存储资源和网络资源中的至少一种。
  8. 根据权利要求1到6任一所述的方法,其特征在于,所述第一优化策略包括,所述提高所述终端的CPU的工作频率,延长所述终端的CPU提频的时间,调整所述终端的CPU的能耗参数,将用于冷启动所述应用的进程迁移到另一个CPU的核上执行,提前释放所述应用的冷启动过程对应的内存,冻结或者清理除至少一个其他进程以及调整分配给所述至少一个其他进程的读/写带宽或者网络带宽,其中,所述至少一个其他进程是除所述应用之外,所述操作系统中运行的至少一个其他应用的进程;
    所述第二优化策略包括以下优化策略中的至少一种,开启所述应用对应的TCP连接的Nagle 算法,所述冷启动对应的进程中较重要的线程优先使用处理资源,提前读取冷启动所述应用所需的文件页,提前执行类验证,提前执行图片解码,提前加载基础库。
  9. 一种冷启动应用的装置,其特征在于,所述装置包括:
    采集模块,所述采集模块用于基于检测到的启动事件采集现状信息,所述启动事件指示所述终端的操作系统冷启动一应用,所述现状信息包括所述终端的硬件配置,所述操作系统当前的负载,冷启动所述应用的资源开销,冷启动所述应用过程中多个任务各自对应的时长;
    分析模块,所述分析模块用于根据所述现状信息,确定所述应用对应的一组可加速项,所述一组可加速项指示本次冷启动所述应用过程中需优化的多个对象;
    优化策略确定模块,所述优化策略确定模块用于确定与所述一组可加速项对应的多条优化策略,所述多条优化策略包括第一优化策略和第二优化策略中的至少一种,其中,所述第一优化策略指示调整所述操作系统分配给所述冷启动的资源,所述第二优化策略用于加速所述冷启动中的任务;
    执行模块,所述执行模块用于在冷启动所述应用的过程中,执行所述多条优化策略。
  10. 根据权利要求9所述的装置,其特征在于,所述分析模块具体用于分析所述现状信息,以得到所述应用当前对应的评估信息,所述应用当前对应的评估信息包括所述终端的硬件配置的等级、所述操作系统当前的负载的程度、所述应用的资源开销类型,以及所述冷启动中耗时长的任务;以及根据所述应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出所述应用当前对应的一组可加速项。
  11. 根据权利要求10所述的装置,其特征在于,在根据所述应用当前对应的评估信息,以及评估信息和可加速项之间的对应关系,确定出所述应用当前对应的一组可加速项的方面,所述分析模块具体用于在所述终端的硬件配置为第一等级,所述操作系统当前处于第一级负载,所述应用为第一资源开销类型,以及所述冷启动中耗时长的任务为第一组任务的情况下,所述应用当前对应第一组可加速项;以及在所述终端的硬件配置为第二等级,所述操作系统当前处于第二级负载,所述应用为第二资源开销类型,以及所述冷启动中耗时长的任务为第二组任务的情况下,所述应用当前对应第二组可加速项。
  12. 根据权利要求9到11任一所述的装置,所述优化策略确定模块具体用于根据所述应用当前对应的一组可加速项,以及可加速项与优化策略之间的对应关系,确定与所述一组可加速项对应的多条优化策略。
  13. 根据权利要求9到12任一所述的装置,其特征在于,所述操作系统当前的负载指示操作系统当前对所述终端的硬件资源的使用情况,所述硬件资源包括处理资源、存储资源和网络资源中的至少一种;冷启动所述应用的资源开销指示对所述冷启动对终端的处理器,内存,磁盘和网络带宽中至少一种的使用情况。
  14. 根据权利要求9到13任一所述的装置,其特征在于,所述冷启动所述应用过程中多个任务包括至少一个第一任务和至少一个第二任务,所述多个任务各自对应的时长,包括执行所述至少一个第一任务各自的时长,以及等待执行所述至少一个第二任务各自的时长。
  15. 根据权利要求9到14任一所述的装置,其特征在于,所述第一优化策略包括调整分配给所述冷启动的处理资源、存储资源和网络资源中的至少一种。
  16. 根据权利要求9到15任一所述的装置,其特征在于,所述第一优化策略包括,所述提高所述终端的CPU的工作频率,延长所述终端的CPU提频的时间,调整所述终端的CPU的能耗参数,将用于冷启动所述应用的进程迁移到另一个CPU的核上执行,提前释放所述应用的冷启动过程对应的内存,冻结或者清理除至少一个其他进程以及调整分配给所述至少一个其他进程的读/写带宽或者网络带宽,其中,所述至少一个其他进程是除所述应用之外,所述操作系统中运行的至少一个其他应用对应的进程;
    所述第二优化策略包括以下优化策略中的至少一种,开启所述应用对应的TCP连接的Nagle算法,所述冷启动对应的进程中较重要的线程优先使用处理资源,提前读取冷启动所述应用所需的文件页,提前执行类验证,提前执行图片解码,提前加载基础库。
  17. 一种冷启动应用的设备,其特征在于,所述设备包括处理电路、通信接口和存储介质,所述存储介质中存储有指令,所述通信接口用于根据所述处理器下发的所述指令与其他设备进行信息交互,所述处理电路用于运行所述存储介质中的所述指令,以实现如权利要求1到8任一所述的方法。
  18. 根据权利要求17所述的设备,其特征在于,所述设备为终端。
  19. 一种计算机可读存储介质,包括指令,当所述指令在计算机上运行时,使得所述计算机执行如权利要求1至8中任一项所述的方法。
PCT/CN2019/111015 2018-10-15 2019-10-14 加速应用的冷启动的方法、装置和终端 WO2020078314A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP19872828.9A EP3851956B1 (en) 2018-10-15 2019-10-14 Method and apparatus for accelerating cold-starting of application
US17/230,737 US20210232429A1 (en) 2018-10-15 2021-04-14 Method, apparatus, and terminal for accelerating cold startup of an application

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811198385.1A CN111061516B (zh) 2018-10-15 2018-10-15 加速应用的冷启动的方法、装置和终端
CN201811198385.1 2018-10-15

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/230,737 Continuation US20210232429A1 (en) 2018-10-15 2021-04-14 Method, apparatus, and terminal for accelerating cold startup of an application

Publications (1)

Publication Number Publication Date
WO2020078314A1 true WO2020078314A1 (zh) 2020-04-23

Family

ID=70283651

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/111015 WO2020078314A1 (zh) 2018-10-15 2019-10-14 加速应用的冷启动的方法、装置和终端

Country Status (4)

Country Link
US (1) US20210232429A1 (zh)
EP (1) EP3851956B1 (zh)
CN (1) CN111061516B (zh)
WO (1) WO2020078314A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860439A (zh) * 2021-03-01 2021-05-28 北京字节跳动网络技术有限公司 应用启动方法、装置、终端及存储介质
CN113419825A (zh) * 2021-04-01 2021-09-21 阿里巴巴新加坡控股有限公司 资源性能预估方法和装置、系统、电子设备及计算机可读存储介质
CN114138358A (zh) * 2021-11-03 2022-03-04 乐视新生代(北京)文化传媒有限公司 应用程序的启动优化方法、装置、设备和存储介质

Families Citing this family (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11593186B2 (en) * 2019-07-17 2023-02-28 Memverge, Inc. Multi-level caching to deploy local volatile memory, local persistent memory, and remote persistent memory
CN113656089B (zh) * 2020-04-30 2023-02-28 华为技术有限公司 应用程序中的类验证方法和装置
CN111767136B (zh) * 2020-06-02 2023-04-14 Oppo(重庆)智能科技有限公司 进程管理方法、终端及具有存储功能的装置
CN113760515A (zh) * 2020-06-03 2021-12-07 戴尔产品有限公司 利用性能预测的配置优化
CN111930425B (zh) * 2020-06-23 2022-06-10 联宝(合肥)电子科技有限公司 一种数据控制方法、装置以及计算机可读存储介质
CN112256354B (zh) * 2020-11-25 2023-05-16 Oppo(重庆)智能科技有限公司 应用启动方法、装置、存储介质及电子设备
CN112445550B (zh) * 2020-12-08 2024-05-17 中国科学院深圳先进技术研究院 一种预处理函数的无服务器计算方法及其系统
CN114625457B (zh) * 2020-12-11 2024-02-27 深信服科技股份有限公司 桌面云环境优化方法、装置、设备及存储介质
CN112416449A (zh) * 2020-12-15 2021-02-26 北京梧桐车联科技有限责任公司 一种电子设备及其启动方法和启动装置
CN112612543A (zh) * 2020-12-22 2021-04-06 努比亚技术有限公司 应用程序冷启动方法、移动终端及计算机存储介质
WO2023014033A1 (en) * 2021-08-02 2023-02-09 Samsung Electronics Co., Ltd. Method and electronic device for handling resource operating performance configuration in electronic device
US20230118846A1 (en) * 2021-10-19 2023-04-20 Red Hat, Inc. Systems and methods to reserve resources for workloads
CN114168224B (zh) * 2021-12-06 2024-02-20 杭州筑龙信息技术股份有限公司 应用程序的启动方法、装置、电子设备及存储介质
CN114266058A (zh) * 2021-12-24 2022-04-01 北京人大金仓信息技术股份有限公司 针对加密数据的解密预加载方法及装置
TWI794000B (zh) * 2022-01-28 2023-02-21 華碩電腦股份有限公司 程式回收系統與程式回收方法
CN115858047A (zh) * 2023-02-28 2023-03-28 荣耀终端有限公司 一种预加载文件页的方法、电子设备及芯片系统
CN117707716A (zh) * 2023-05-26 2024-03-15 荣耀终端有限公司 线程调度方法、电子设备及计算机可读存储介质
CN117149632A (zh) * 2023-08-31 2023-12-01 重庆赛力斯新能源汽车设计院有限公司 分析车载应用程序冷启动的方法及装置
CN118093348A (zh) * 2024-04-07 2024-05-28 荣耀终端有限公司 关键线程识别方法及应用启动时的线程优化方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013163903A1 (zh) * 2012-05-04 2013-11-07 惠州Tcl移动通信有限公司 基于Android系统的应用程序启动方法和系统
CN105630543A (zh) * 2015-12-21 2016-06-01 北京奇虎科技有限公司 一种应用冷启动加速的方法及装置
CN106445617A (zh) * 2016-10-13 2017-02-22 武汉斗鱼网络科技有限公司 基于Android的应用程序冷启动优化方法及系统
CN106547598A (zh) * 2016-11-22 2017-03-29 四川长虹电器股份有限公司 提升Android应用程序启动速度的方法
CN106681772A (zh) * 2016-12-30 2017-05-17 深圳天珑无线科技有限公司 一种应用启动的加速方法、装置及终端
CN108762833A (zh) * 2018-05-16 2018-11-06 北京安云世纪科技有限公司 安卓系统中的应用启动方法和装置

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6353845B1 (en) * 1998-06-25 2002-03-05 International Business Machines Corporation Computer system, program product and method for tracking asynchronous I/O with timeout support
CN101625647A (zh) * 2009-08-06 2010-01-13 青岛海信电器股份有限公司 加快嵌入式软件系统启动速度的方法
CN102707966B (zh) * 2012-04-12 2014-09-03 腾讯科技(深圳)有限公司 加速操作系统启动的方法及装置、预取信息生成方法及装置和终端
CN103106093A (zh) * 2013-02-21 2013-05-15 北京奇虎科技有限公司 一种系统运行加速方法和装置
CN104572139B (zh) * 2013-10-10 2019-01-08 腾讯科技(深圳)有限公司 一种加速应用程序启动的方法和装置
US9411638B2 (en) * 2013-12-19 2016-08-09 International Business Machines Corporation Application startup page fault management in a hardware multithreading environment
CN106293792B (zh) * 2015-06-02 2019-12-20 腾讯科技(深圳)有限公司 软件启动方法和装置
CN106095489B (zh) * 2016-05-31 2017-11-07 广东欧珀移动通信有限公司 一种应用控制方法及移动终端
CN107066290B (zh) * 2017-01-23 2020-09-01 努比亚技术有限公司 一种根据关联策略启动应用的方法和装置
US10445086B2 (en) * 2017-09-28 2019-10-15 At&T Intellectual Property I, L.P. Virtualization platform for creating, deploying, modifying, and relocating applications
CN107748684A (zh) * 2017-11-21 2018-03-02 广东欧珀移动通信有限公司 实现自启动的处理方法、装置、存储介质及移动终端
CN107943576B (zh) * 2017-12-14 2020-09-29 中国平安人寿保险股份有限公司 应用程序的启动优化方法、装置、设备、系统及介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013163903A1 (zh) * 2012-05-04 2013-11-07 惠州Tcl移动通信有限公司 基于Android系统的应用程序启动方法和系统
CN105630543A (zh) * 2015-12-21 2016-06-01 北京奇虎科技有限公司 一种应用冷启动加速的方法及装置
CN106445617A (zh) * 2016-10-13 2017-02-22 武汉斗鱼网络科技有限公司 基于Android的应用程序冷启动优化方法及系统
CN106547598A (zh) * 2016-11-22 2017-03-29 四川长虹电器股份有限公司 提升Android应用程序启动速度的方法
CN106681772A (zh) * 2016-12-30 2017-05-17 深圳天珑无线科技有限公司 一种应用启动的加速方法、装置及终端
CN108762833A (zh) * 2018-05-16 2018-11-06 北京安云世纪科技有限公司 安卓系统中的应用启动方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3851956A4 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860439A (zh) * 2021-03-01 2021-05-28 北京字节跳动网络技术有限公司 应用启动方法、装置、终端及存储介质
CN113419825A (zh) * 2021-04-01 2021-09-21 阿里巴巴新加坡控股有限公司 资源性能预估方法和装置、系统、电子设备及计算机可读存储介质
CN113419825B (zh) * 2021-04-01 2023-09-29 阿里巴巴新加坡控股有限公司 资源性能预估方法和装置、系统及电子设备
CN114138358A (zh) * 2021-11-03 2022-03-04 乐视新生代(北京)文化传媒有限公司 应用程序的启动优化方法、装置、设备和存储介质

Also Published As

Publication number Publication date
CN111061516A (zh) 2020-04-24
US20210232429A1 (en) 2021-07-29
EP3851956A4 (en) 2021-12-01
EP3851956A1 (en) 2021-07-21
CN111061516B (zh) 2021-09-14
EP3851956B1 (en) 2023-03-01

Similar Documents

Publication Publication Date Title
WO2020078314A1 (zh) 加速应用的冷启动的方法、装置和终端
US11099900B2 (en) Memory reclamation method and apparatus
WO2018032782A1 (zh) 一种启动应用的方法及装置
US9697124B2 (en) Systems and methods for providing dynamic cache extension in a multi-cluster heterogeneous processor architecture
WO2019128540A1 (zh) 资源管理方法、移动终端及计算机可读存储介质
KR102114388B1 (ko) 전자 장치의 메모리 압축 방법 및 장치
US20200242043A1 (en) Interprocess Communication Method and Interprocess Communications System
EP3937016A1 (en) Memory management method and apparatus
WO2018045934A1 (zh) 应用进程的管理方法和终端设备
US20130205092A1 (en) Multicore computer system with cache use based adaptive scheduling
CN107861817B (zh) 基于线程阻塞的内存优化方法、移动终端及可读存储介质
JP2003157170A (ja) プログラムバイナリをデコードおよび実行する方法
CN110032267B (zh) 信息处理方法、装置、移动终端及计算机可读存储介质
CN107590057B (zh) 冻屏监测与解决方法、移动终端及计算机可读存储介质
WO2019196878A1 (zh) 一种内存管理的方法以及相关设备
WO2022143446A1 (zh) 内存释放方法及相关设备
CN110032429B (zh) 信息处理方法、装置、移动终端及计算机可读存储介质
CN107967177B (zh) 基于核心进程的内存优化方法、移动终端及可读存储介质
WO2019128588A1 (zh) 进程处理方法和装置、电子设备、计算机可读存储介质
US8756603B2 (en) Virtual machine stage detection
WO2019128542A1 (zh) 应用处理方法、电子设备、计算机可读存储介质
US10613606B2 (en) Wireless component state based power management
WO2019128573A1 (zh) 信息处理方法、装置、计算机设备和计算机可读存储介质
WO2019128569A1 (zh) 应用程序冻结方法、装置、存储介质和终端
US9146876B2 (en) Caching method and caching system using dual disks

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19872828

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2019872828

Country of ref document: EP

Effective date: 20210412

NENP Non-entry into the national phase

Ref country code: DE