WO2022052897A1 - 调整内存配置参数的方法和装置 - Google Patents

调整内存配置参数的方法和装置 Download PDF

Info

Publication number
WO2022052897A1
WO2022052897A1 PCT/CN2021/116838 CN2021116838W WO2022052897A1 WO 2022052897 A1 WO2022052897 A1 WO 2022052897A1 CN 2021116838 W CN2021116838 W CN 2021116838W WO 2022052897 A1 WO2022052897 A1 WO 2022052897A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
pressure
processor
swap
configuration parameters
Prior art date
Application number
PCT/CN2021/116838
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 EP21865951.4A priority Critical patent/EP4130969B1/en
Priority to US17/924,287 priority patent/US11995317B2/en
Publication of WO2022052897A1 publication Critical patent/WO2022052897A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/126Replacement control using replacement algorithms with special data handling, e.g. priority of data or instructions, handling errors or pinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0632Configuration or reconfiguration of storage systems by initialisation or re-initialisation of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0653Monitoring storage devices or systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • 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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/50Control mechanisms for virtual memory, cache or TLB
    • G06F2212/502Control mechanisms for virtual memory, cache or TLB using adaptive policy

Definitions

  • the present application relates to the field of storage, and in particular, to a method and device for adjusting memory configuration parameters.
  • Memory is an integral part of the computer.
  • the data related to the running of the program can be temporarily stored in the memory, waiting for the processor to call. If the memory resources are insufficient, the processor may need to wait for a period of time to obtain the data required for the program to run. Therefore, the usage of the memory resources is related to the program operation (such as the startup rate).
  • One way to manage memory resources is to adjust memory based on the size of available memory. For example, when the available memory is less than the preset value, the value of the extra free memory configuration parameter (extra_free_kbytes) can be increased to prompt the memory management module to reclaim memory more aggressively. to meet the program's memory resource requirements.
  • extra_free_kbytes the value of the extra free memory configuration parameter
  • the present application provides a method, apparatus, computer program product and computer-readable storage medium for adjusting memory configuration parameters, which can improve the effect of memory management.
  • a first aspect provides a method for adjusting memory, including: acquiring multiple resource pressures, where the multiple resource pressures are used to indicate multiple demands for memory compression; and adjusting memory configuration parameters according to the multiple resource pressures, There is a preset correspondence between the memory configuration parameters and the plurality of resource pressures.
  • the resource pressure is, for example, processor pressure, input/output (I/O) pressure, memory reclamation pressure, or memory swap space pressure, wherein the processor pressure, I/O pressure, and memory reclamation pressure can be determined by the processor pressure, respectively.
  • Stall information pressure stall information, PSI
  • I/O PSI and memory reclamation PSI are determined, and the memory swap space pressure can be determined by the available swap space (swap free) and/or the number of anonymous pages (anon pages).
  • Different types of resource pressure correspond to different memory compression requirements. It is difficult to adjust memory configuration parameters based on one type of resource pressure to achieve optimal system performance.
  • the value of the memory swap parameter should be reduced to reduce the frequency of use of zRAM; however, if the I/O pressure is high, the value of swappiness should be increased, A larger swappiness can increase the frequency of zRAM usage, thereby reclaiming more anon pages, avoiding the continuous increase of I/O pressure caused by excessive reclamation of file pages when the memory is insufficient. Among them, the I/O pressure continues to increase.
  • the memory configuration parameter includes swappiness
  • the multiple resource pressures include I/O pressure and memory swap space pressure
  • the adjusting the memory configuration parameter according to the multiple resource pressures includes: when the I/O pressure is When the O pressure decreases, and when the memory swap space pressure decreases, reduce the memory swap parameter; or, when the I/O pressure increases, and when the memory swap space pressure decreases, Adjust the memory swap parameter to a preset value.
  • swap free reflects the remaining capacity of the zRAM device
  • anon pages reflects the amount of data that can be entered into the zRAM device
  • the swap free is low and/or the anon pages is low (ie, the memory swap space pressure is low)
  • the zRAM's The use of the benefits is not large, you can reduce the frequency of zRAM use.
  • the I/O pressure is low, the use frequency of zRAM can be reduced to save computing resources.
  • the value of swappiness can be reduced, so as to achieve optimal system performance and improve memory management efficiency. Effect.
  • swap free When swap free is low and/or anon pages are low (i.e., there is less pressure on memory swap space), the benefit of zRAM usage is not large, and the frequency of zRAM usage can be reduced.
  • the value of swappiness should be increased. Larger swappiness can increase the frequency of zRAM usage, thereby recycling more anon pages and avoiding excessive recycling of file pages when memory is insufficient, which leads to continuous increase in I/O pressure. Big. You can set swappiness to an appropriate value (eg, a preset value) to balance the memory swap space pressure and I/O pressure, so as to achieve optimal system performance and improve the effect of memory management.
  • an appropriate value eg, a preset value
  • the memory configuration parameter includes swappiness
  • the multiple resource pressures include processor pressure and memory swap space pressure
  • the adjusting the memory configuration parameter according to the multiple resource pressures includes: when the processor pressure is When decreasing, and when the memory swap space pressure increases, increase the swappiness.
  • the memory configuration parameter includes swappiness
  • the multiple resource pressures include processor pressure and I/O pressure
  • the adjusting the memory configuration parameter according to the multiple resource pressures includes: when the I/O pressure When the pressure decreases, and when the processor pressure increases, reduce the memory swap parameter; or, when the I/O pressure increases, and when the processor pressure increases, change the The memory swap parameter is adjusted to a preset value.
  • the use frequency of zRAM can be reduced to save computing resources; when the processor pressure is high, it indicates that the current computing pressure is large, and the swappiness should be reduced to save computing resources; comprehensively consider the I/O pressure and processor pressure, it can reduce swappiness to save computing resources, so as to achieve optimal system performance and improve the effect of memory management.
  • swappiness When the I/O pressure is high, the value of swappiness should be increased. Larger swappiness can increase the frequency of zRAM usage, thereby recycling more anon pages, and avoiding excessive recycling of file pages when memory is insufficient, which leads to the continuous increase of I/O pressure.
  • the swappiness When the processor pressure is high, the swappiness should be reduced to save computing resources; the swappiness can be set to an appropriate value (for example, the default value) to balance the I/O pressure and the processor pressure, so as to achieve the highest system performance Excellent, improve the effect of managing memory.
  • the adjusting the memory configuration parameters according to the multiple resource pressures includes: when the current application running scene indicated by the scene information does not conform to the preset scene, adjusting the memory configuration parameters according to the multiple resource pressures.
  • the scene information is, for example, information indicating application startup or application switching.
  • the preset scenario is the application startup scenario
  • the resource requirements of the application startup scenario are relatively fixed, and the memory can be adjusted according to the preset swappiness to achieve optimal system performance.
  • the method further includes: when the memory reclamation pressure increases, reducing the extra free memory configuration parameter (extra_free_kbytes); or, when the memory reclamation pressure decreases, increasing the extra_free_kbytes.
  • extra_free_kbytes is positively related to the amount of memory reserved by the kernel, that is, the larger the value of extra_free_kbytes, the larger the memory reserved by the kernel.
  • the memory reclamation pressure increases, it means that there are many memory reclamation tasks at present, and the third-party APP has a large demand for memory.
  • the adjusting the memory configuration parameters according to the multiple resource pressures includes: when the available memory is less than a memory threshold, adjusting the memory configuration parameters according to the multiple resource pressures.
  • Adjusting the memory configuration parameters will consume computing resources. Therefore, when the available memory is large, there is no need to adjust the memory configuration parameters; when the available memory is small, the memory configuration parameters can be adjusted according to the multiple resource pressures, so that the operation of the application can be adjusted without affecting the application. On the premise of saving computing resources.
  • the ratio of the memory threshold to the physical memory is negatively correlated with the size of the physical memory.
  • the size of the memory threshold can be set according to the size of physical memory.
  • the memory threshold can be set to a value with a relatively low proportion; when the physical memory of the terminal device is small, the memory threshold can be set to a value with a relatively high proportion.
  • the physical memory of terminal device A is 12GB
  • the physical memory of terminal device B is 6GB
  • the memavailable watermark of terminal device A can be set to one third of the physical memory, that is, 4GB
  • the memavailable watermark of terminal device B can be set to It is one-half of the physical memory, that is, 3GB.
  • the terminal device (terminal device A) with a large physical memory can reduce the consumption of computing resources by memory adjustment while ensuring sufficient available memory
  • the terminal device (terminal device B) with a small physical memory can adjust the memory in advance, Reduce the probability of problems such as insufficient memory.
  • an apparatus for adjusting memory including a unit for performing any one of the methods in the first aspect.
  • the apparatus may be a terminal device or a chip in the terminal device.
  • the apparatus may include an input unit and a processing unit.
  • the processing unit may be a processor, and the input unit may be a touch screen, a keyboard, a mouse, a camera, a microphone, or other input devices; the terminal device may also include a memory for storing The computer program code, when the processor executes the computer program code stored in the memory, causes the terminal device to execute any one of the methods in the first aspect.
  • the processing unit may be a processing unit inside the chip, and the input unit may be an input/output interface, a pin or a circuit, etc.; the chip may also include a memory, and the memory may be the On-chip memory (eg, registers, caches, etc.), or memory external to the chip (eg, read-only memory, random access memory, etc.); the memory is used to store computer program code that is executed when the processor executes The computer program code stored in the memory causes the chip to perform any one of the methods in the first aspect.
  • the On-chip memory eg, registers, caches, etc.
  • memory external to the chip eg, read-only memory, random access memory, etc.
  • a computer program product comprising: computer program code, when the computer program code is run by an apparatus for adjusting memory, the apparatus causes the apparatus to perform any one of the methods in the first aspect .
  • a computer-readable storage medium stores computer program codes, and when the computer program codes are executed by an apparatus for adjusting memory, the apparatus is made to execute the method in the first aspect. either method.
  • FIG. 1 is a schematic diagram of a hardware system of a terminal device provided by the present application.
  • FIG. 2 is a schematic diagram of a software system of a terminal device provided by the present application.
  • FIG. 3 is a schematic diagram of a system for adjusting memory provided by the present application.
  • FIG. 4 is a schematic diagram of a workflow of a PSI pressure registration acquisition module provided by the present application.
  • FIG. 5 is a schematic diagram of a workflow of a memory information acquisition module provided by the present application.
  • FIG. 6 is a schematic diagram of a workflow of an application scenario monitoring module provided by the present application.
  • FIG. 7 is a schematic diagram of a workflow of a system pressure decision module provided by the present application.
  • FIG. 8 is a schematic diagram of another workflow of the system pressure decision module provided by the present application.
  • FIG. 9 is a schematic diagram of a device for adjusting memory provided by the present application.
  • FIG. 10 is a schematic diagram of an electronic device for adjusting memory provided by the present application.
  • FIG. 1 shows a hardware structure of a device suitable for this application.
  • the device 100 may be a mobile phone, a smart screen, a tablet computer, a wearable electronic device, an in-vehicle electronic device, an augmented reality (AR) device, a virtual reality (VR) device, a notebook computer, an ultra-mobile personal computer (ultra) -mobile personal computer, UMPC), netbook, personal digital assistant (personal digital assistant, PDA), projector, etc.
  • AR augmented reality
  • VR virtual reality
  • UMPC ultra-mobile personal computer
  • netbook personal digital assistant (personal digital assistant, PDA), projector, etc.
  • PDA personal digital assistant
  • the device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, Mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and user Identity module (subscriber identification module, SIM) card interface 195 and so on.
  • SIM subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
  • the structure shown in FIG. 1 does not constitute a specific limitation on the device 100 .
  • the device 100 may include more or less components than those shown in FIG. 1 , or the device 100 may include a combination of some of the components shown in FIG. 1 , or the device 100 may include subcomponents of some of the components shown in FIG. 1 .
  • the components shown in FIG. 1 may be implemented in hardware, software, or a combination of software and hardware.
  • Processor 110 may include one or more processing units.
  • the processor 110 may include at least one of the following processing units: an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (image signal processor) , ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, neural network processor (neural-network processing unit, NPU).
  • the different processing units may be independent devices or integrated devices.
  • the controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110 . If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the processor 110 may include at least one of the following interfaces: an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, universal asynchronous receiver/transmitter (UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, SIM interface, USB interface.
  • I2C inter-integrated circuit
  • I2S inter-integrated circuit sound
  • PCM pulse code modulation
  • UART universal asynchronous receiver/transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • the I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL).
  • the processor 110 may contain multiple sets of I2C buses.
  • the processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193 and the like through different I2C bus interfaces.
  • the processor 110 may couple the touch sensor 180K through the I2C interface, so that the processor 110 and the touch sensor 180K communicate through the I2C bus interface, so as to realize the touch function of the device 100 .
  • the I2S interface can be used for audio communication.
  • the processor 110 may contain multiple sets of I2S buses.
  • the processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170 .
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communications, sampling, quantizing and encoding analog signals.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM interface.
  • the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • a UART interface is typically used to connect the processor 110 with the wireless communication module 160 .
  • the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function.
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, so as to realize the function of playing music through the Bluetooth headset.
  • the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 .
  • MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc.
  • the processor 110 communicates with the camera 193 through a CSI interface to implement the shooting function of the apparatus 100 .
  • the processor 110 communicates with the display screen 194 through the DSI interface to implement the display function of the device 100 .
  • the GPIO interface can be configured by software.
  • the GPIO interface can be configured as a control signal interface or as a data signal interface.
  • the GPIO interface may be used to connect the processor 110 with the camera 193 , the display screen 194 , the wireless communication module 160 , the audio module 170 and the sensor module 180 .
  • the GPIO interface can also be configured as an I2C interface, I2S interface, UART interface or MIPI interface.
  • the USB interface 130 is an interface conforming to the USB standard specification, for example, it may be a mini (Mini) USB interface, a micro (Micro) USB interface or a USB Type C (USB Type C) interface.
  • the USB interface 130 can be used to connect a charger to charge the device 100 , can also be used to transmit data between the device 100 and peripheral devices, and can also be used to connect an earphone to play audio through the earphone.
  • the USB interface 130 may also be used to connect other devices 100, such as AR devices.
  • connection relationship between the modules shown in FIG. 1 is only a schematic illustration, and does not constitute a limitation on the connection relationship between the modules of the device 100 .
  • each module of the apparatus 100 may also adopt a combination of various connection manners in the foregoing embodiments.
  • the charge management module 140 is used to receive power from the charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 140 may receive current from the wired charger through the USB interface 130 .
  • the charging management module 140 may receive electromagnetic waves through the wireless charging coil of the device 100 (current paths are shown in dotted lines). While the charging management module 140 charges the battery 142 , the device 100 can also be powered by the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.
  • the power management module 141 may also be used to monitor parameters such as battery capacity, battery cycle times, and battery health (eg, leakage, impedance).
  • the power management module 141 may be provided in the processor 110, or the power management module 141 and the charging management module 140 may be provided in the same device.
  • the wireless communication function of the apparatus 100 may be implemented by components such as the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modulation and demodulation processor, and a baseband processor.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
  • the mobile communication module 150 may provide a wireless communication solution applied on the device 100, such as at least one of the following solutions: a second generation (2 th generation, 2G) mobile communication solution, a third generation (3 th generation, 3G) ) mobile communication solutions, fourth generation ( 4th generation, 5G) mobile communication solutions, fifth generation ( 5th generation, 5G) mobile communication solutions.
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA) and the like.
  • the mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and then transmit them to a modulation and demodulation processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and the amplified signal is converted into electromagnetic waves through the antenna 1 and radiated out.
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 110 .
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low frequency baseband signal is processed by the baseband processor and passed to the application processor.
  • the application processor outputs sound signals through audio devices (eg, speaker 170A, receiver 170B), or displays images or video through display screen 194 .
  • the modem processor may be a stand-alone device.
  • the modem processor may be independent of the processor 110, and may be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can also provide a wireless communication solution applied on the device 100, such as at least one of the following solutions: wireless local area networks (WLAN), bluetooth (BT) , global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication (near field communication, NFC), infrared (infrared, IR).
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110 , perform frequency modulation and amplification on the signal, and the signal is converted into electromagnetic waves and radiated out through the antenna 2 .
  • the antenna 1 of the device 100 is coupled to the mobile communication module 150
  • the antenna 2 of the device 100 is coupled to the wireless communication module 160 .
  • the device 100 may implement a display function through the GPU, the display screen 194 and the application processor.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
  • Display screen 194 may be used to display images or video.
  • Display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible Light-emitting diode (flex light-emitting diode, FLED), mini light-emitting diode (mini light-emitting diode, Mini LED), micro light-emitting diode (micro light-emitting diode, Micro LED), micro OLED (Micro OLED) or quantum dot light-emitting Diodes (quantum dot light emitting diodes, QLED).
  • device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
  • the device 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, the application processor, and the like.
  • the ISP is used to process the data fed back by the camera 193 .
  • the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye.
  • ISP can algorithmically optimize the noise, brightness and color of the image, and ISP can also optimize parameters such as exposure and color temperature of the shooting scene.
  • the ISP may be provided in the camera 193 .
  • Camera 193 is used to capture still images or video.
  • the object is projected through the lens to generate an optical image onto the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • DSP converts digital image signals into standard red green blue (RGB), YUV and other formats of image signals.
  • the apparatus 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
  • a digital signal processor is used to process digital signals, in addition to processing digital image signals, it can also process other digital signals. For example, when the device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point, and so on.
  • Video codecs are used to compress or decompress digital video.
  • Device 100 may support one or more video codecs. In this way, the device 100 can play or record videos in various encoding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.
  • MPEG Moving Picture Experts Group
  • MPEG2 MPEG2, MPEG3, and MPEG4.
  • NPU is a processor that draws on the structure of biological neural network. For example, it can quickly process input information by drawing on the transmission mode between neurons in the human brain, and it can also continuously learn by itself. Functions such as intelligent cognition of the device 100 can be realized through the NPU, such as image recognition, face recognition, speech recognition and text understanding.
  • the external memory interface 120 may be used to connect an external memory card, such as a secure digital (SD) card, to realize the expansion of the storage capacity of the device 100 .
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card.
  • Internal memory 121 may be used to store computer executable program code, which includes instructions.
  • the internal memory 121 may include a storage program area and a storage data area.
  • the storage program area may store an operating system, an application program required for at least one function (eg, a sound playback function and an image playback function).
  • the storage data area may store data (eg, audio data and phonebook) created during use of the device 100 .
  • the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as: at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), and the like.
  • the processor 110 executes various processing methods of the apparatus 100 by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
  • the device 100 may implement audio functions, such as music playback and recording, through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor.
  • audio functions such as music playback and recording
  • the audio module 170 is used for converting digital audio information into analog audio signal output, and can also be used for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 or some functional modules of the audio module 170 may be provided in the processor 110.
  • Speaker 170A also referred to as a horn, is used to convert audio electrical signals into sound signals.
  • the device 100 can listen to music or talk hands-free through the speaker 170A.
  • the receiver 170B also referred to as an earpiece, is used to convert audio electrical signals into sound signals.
  • the voice can be answered by bringing the receiver 170B close to the ear.
  • Microphone 170C also known as a microphone or microphone, is used to convert acoustic signals into electrical signals.
  • a sound signal can be input into the microphone 170C by sounding close to the microphone 170C.
  • the apparatus 100 may be provided with at least one microphone 170C.
  • the device 100 may be provided with two microphones 170C to implement a noise reduction function.
  • the device 100 may further be provided with three, four or more microphones 170C, so as to realize functions such as sound source identification and directional recording.
  • the processor 110 can process the electrical signal output by the microphone 170C.
  • the audio module 170 and the wireless communication module 160 can be coupled through a PCM interface. After the microphone 170C converts the ambient sound into an electrical signal (such as a PCM signal), The electrical signal is transmitted to the processor 110; volume analysis and frequency analysis are performed on the electrical signal from the processor 110 to determine the volume and frequency of the ambient sound.
  • the earphone jack 170D is used to connect wired earphones.
  • the earphone interface 170D may be the USB interface 130, or may be a 3.5mm open mobile terminal platform (open mobile terminal platform, OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.
  • OMTP open mobile terminal platform
  • CTIA cellular telecommunications industry association of the USA
  • the pressure sensor 180A is used to sense pressure signals, and can convert the pressure signals into electrical signals.
  • the pressure sensor 180A may be provided on the display screen 194 .
  • the capacitive pressure sensor may include at least two parallel plates with conductive material. When a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes, and the device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the device 100 detects the touch operation according to the pressure sensor 180A. The device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A.
  • touch operations acting on the same touch position but with different touch operation intensities may correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, the instruction to view the short message is executed; when a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon , execute the instruction to create a new short message.
  • the gyro sensor 180B may be used to determine the motion attitude of the device 100 .
  • the angular velocity of the device 100 about three axes ie, the x-axis, the y-axis, and the z-axis
  • the gyro sensor 180B can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle at which the device 100 shakes, calculates the distance to be compensated by the lens module according to the angle, and allows the lens to counteract the shake of the device 100 through reverse motion to achieve anti-shake.
  • the gyro sensor 180B can also be used in scenarios such as navigation and somatosensory games.
  • the air pressure sensor 180C is used to measure air pressure. In some embodiments, the device 100 calculates the altitude from the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.
  • the magnetic sensor 180D includes a Hall sensor.
  • the device 100 can detect the opening and closing of the flip holster using the magnetic sensor 180D. In some embodiments, when the device 100 is a flip machine, the device 100 can detect the opening and closing of the flip according to the magnetic sensor 180D.
  • the device 100 can set characteristics such as automatic unlocking of the flip cover according to the detected opening and closing state of the holster or the opening and closing state of the flip cover.
  • the acceleration sensor 180E can detect the magnitude of the acceleration of the device 100 in various directions (generally the x-axis, the y-axis and the z-axis). The magnitude and direction of gravity can be detected when the device 100 is stationary. The acceleration sensor 180E can also be used to identify the posture of the device 100 as an input parameter for switching between horizontal and vertical screens and for applications such as a pedometer.
  • the distance sensor 180F is used to measure the distance.
  • the device 100 can measure distance by infrared or laser. In some embodiments, such as in a shooting scene, the device 100 may utilize the distance sensor 180F for ranging to achieve fast focusing.
  • Proximity light sensor 180G may include, for example, light-emitting diodes (LEDs) and light detectors, such as photodiodes.
  • the LEDs may be infrared LEDs.
  • the device 100 emits infrared light outward through the LEDs.
  • Device 100 uses photodiodes to detect infrared reflected light from nearby objects. When the reflected light is detected, the apparatus 100 can determine that there is an object nearby. When no reflected light is detected, the device 100 can determine that there is no object nearby.
  • the device 100 can use the proximity light sensor 180G to detect whether the user holds the device 100 close to the ear to talk, so as to automatically turn off the screen to save power.
  • Proximity light sensor 180G can also be used for automatic unlocking and automatic screen locking in holster mode or pocket mode.
  • the ambient light sensor 180L is used to sense ambient light brightness.
  • the device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness.
  • the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
  • the ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the device 100 is in a pocket to prevent accidental touch.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the device 100 can use the collected fingerprint characteristics to realize functions such as unlocking, accessing the application lock, taking pictures, and answering incoming calls.
  • the temperature sensor 180J is used to detect the temperature.
  • the device 100 utilizes the temperature detected by the temperature sensor 180J to execute a temperature treatment strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold value, the apparatus 100 reduces the performance of the processor located near the temperature sensor 180J in order to reduce power consumption and implement thermal protection.
  • the device 100 heats the battery 142 to avoid abnormal shutdown of the device 100 due to the low temperature.
  • the device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
  • the touch sensor 180K is also called a touch device.
  • the touch sensor 180K may be disposed on the display screen 194 , and a touch screen is formed by the touch sensor 180K and the display screen 194 , and the touch screen is also called a touch screen.
  • the touch sensor 180K is used to detect a touch operation on or near it.
  • the touch sensor 180K may pass the detected touch operation to the application processor to determine the type of touch event.
  • Visual output related to touch operations may be provided through display screen 194 .
  • the touch sensor 180K may also be disposed on the surface of the device 100 and disposed at a different location from the display screen 194 .
  • the bone conduction sensor 180M can acquire vibration signals.
  • the bone conduction sensor 180M can acquire the vibration signal of the vibrating bone mass of the human voice.
  • the bone conduction sensor 180M can also contact the pulse of the human body and receive the blood pressure beating signal.
  • the bone conduction sensor 180M can also be disposed in the earphone, combined with the bone conduction earphone.
  • the audio module 170 can analyze the voice signal based on the vibration signal of the vocal vibration bone block obtained by the bone conduction sensor 180M, so as to realize the voice function.
  • the application processor can analyze the heart rate information based on the blood pressure beat signal obtained by the bone conduction sensor 180M to realize the heart rate detection function.
  • the keys 190 include a power key and a volume key.
  • the key 190 may be a mechanical key or a touch key.
  • the device 100 can receive a key input signal, and implement functions related to the case input signal.
  • the motor 191 may generate vibration.
  • the motor 191 can be used for incoming call alerts, and can also be used for touch feedback.
  • the motor 191 can generate different vibration feedback effects for touch operations acting on different applications.
  • touch operations acting on different areas of the display screen 194 the motor 191 can also generate different vibration feedback effects.
  • Different application scenarios for example, time reminder, receiving information, alarm clock and game
  • the touch vibration feedback effect can also support customization.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging status and power change, and can also be used to indicate messages, missed calls, and notifications.
  • the SIM card interface 195 is used to connect a SIM card.
  • the SIM card can be inserted into the SIM card interface 195 to achieve contact with the device 100 , and can also be pulled out from the SIM card interface 195 to achieve separation from the device 100 .
  • the device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1. Multiple cards can be inserted into the same SIM card interface 195 at the same time, and the types of the multiple cards can be the same or different.
  • the SIM card interface 195 is also compatible with external memory cards.
  • the device 100 interacts with the network through the SIM card to realize functions such as call and data communication.
  • the device 100 adopts an embedded SIM (embedded-SIM, eSIM) card, and the eSIM card can be embedded in the device 100 and cannot be separated from the device 100 .
  • the hardware system of the apparatus 100 is described in detail above, and the software system of the apparatus 100 is introduced below.
  • the software system may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the embodiments of the present application take the layered architecture as an example to exemplarily describe the software system of the apparatus 100 .
  • a software system using a layered architecture is divided into several layers, and each layer has a clear role and division of labor. Layers communicate with each other through software interfaces.
  • the software system may be divided into four layers, which are, from top to bottom, an application layer, an application framework layer, an Android runtime (Android Runtime) and system libraries, and a kernel layer.
  • the application layer can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, etc.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer can include some predefined functions.
  • the application framework layer includes window manager, content provider, view system, telephony manager, resource manager, notification manager, PSI pressure registration collection module, memory information collection module, application scene monitoring module and system pressure decision module .
  • a window manager is used to manage window programs.
  • the window manager can get the size of the display screen, determine whether there is a status bar, lock screen and screen capture.
  • Content providers are used to store and retrieve data and make these data accessible to applications.
  • the data may include video, images, audio, calls made and received, browsing history and bookmarks, and a phone book.
  • the view system includes visual controls, such as controls that display text and controls that display pictures. View systems can be used to build applications.
  • the display interface may be composed of one or more views, for example, the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
  • the phone manager is used to provide communication functions of the device 100, such as management of call status (connected or hung up).
  • the resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files and video files.
  • the notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction.
  • the notification manager is used for download completion notifications and message alerts.
  • Notification Manager can also manage notifications that appear in the status bar at the top of the system as a graph or scroll bar text, such as notifications from applications running in the background.
  • Notification Manager can also manage notifications that appear on the screen as dialog windows, such as text messages in the status bar, beeps, vibrations of electronic devices, and blinking lights.
  • the PSI pressure registration collection module is used to collect various types of PSI, such as central processing unit (CPU) running time, memory recovery time and I/O waiting time; the memory information collection module is used to collect available memory, swap free Information related to memory such as anon pages; the application scene monitoring module is used to collect scene information such as APP startup and APP switching.
  • PSI central processing unit
  • the system pressure decision module is used to make memory adjustment decisions according to the information collected by the PSI pressure registration collection module, the memory information collection module and the application scenario monitoring module.
  • Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.
  • the core library consists of two parts: one is the function functions that the java language needs to call, and the other is the core library of Android.
  • the application layer and the application framework layer run in virtual machines.
  • the virtual machine executes the java files of the application layer and the application framework layer as binary files.
  • the virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, safety and exception management, and garbage collection.
  • the system library may include multiple functional modules, such as: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES) and 2D graphics engine (eg: SGL).
  • surface manager surface manager
  • media library Media Libraries
  • 3D graphics processing library eg: OpenGL ES
  • 2D graphics engine eg: SGL
  • the Surface Manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of multiple audio formats, playback and recording of multiple video formats, and still image files.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG and PNG.
  • the 3D graphics processing library can be used to implement 3D graphics drawing, image rendering, compositing and layer processing.
  • 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display drivers, camera drivers, audio drivers, and sensor drivers.
  • the software system and the work flow of the hardware system of the apparatus 100 are exemplarily described below in conjunction with the displayed photographing scene.
  • the corresponding hardware interrupt is sent to the operating system layer, and the operating system layer processes the touch operation into an original input event.
  • the original input event includes, for example, information such as touch coordinates and a timestamp of the touch operation. ; Then, the operating system layer identifies the control corresponding to the original access event, and notifies the application (application, APP) corresponding to the control.
  • the camera APP can call the background service through the API, transmit control instructions to the logical port management module, and control the camera 193 to shoot through the logical port management module.
  • the data related to the camera APP can be temporarily stored in the memory, waiting for the processor to call. If the memory resources are insufficient, the processor may need to wait for a period of time to obtain the data of the camera APP. Therefore, the usage of the memory resources is related to the operation of the camera APP (such as the startup rate).
  • Memory resources can be managed by adjusting memory configuration parameters. Two memory configuration parameters applicable to this application are described below.
  • the configuration method of extra_free_kbytes can be /proc/sys/vm/extra_free_kbytes, its meaning is to increase the value of low watermark and high watermark without changing the minimum watermark (min watermark). .
  • the value of extra_free_kbytes is positively related to the amount of memory reserved by the kernel, that is, the larger the value of extra_free_kbytes, the larger the memory reserved by the kernel, and accordingly, the smaller the memory that can be used by third-party APPs (such as camera APPs).
  • third-party APPs such as camera APPs.
  • the memory sorting function kswapd/kcompactd will be triggered more frequently, and the memory recycling function lowmemorykiller will also be triggered more frequently to reserve more memory for the kernel.
  • the third-party APP can use more memory, but the probability of direct reclaim or I/O blocking during memory allocation will increase.
  • the configuration of swappiness can be /proc/sys/vm/swappiness.
  • the kernel will try to swap runtime memory to zRAM, or get more memory by deleting memory pages in the system cache, and swappiness is used to balance the frequency of use of these two methods.
  • the kernel manages memory you can control how the kernel manages memory. If the value of the memory configuration parameter is not set properly, the system performance will be degraded. For example, when the value of swappiness is small, if there are a large number of file reading tasks, the system will fall into a cache thrashing state (that is, insufficient memory causes the file Pages are frequently read into the freed state), even if there is a large amount of remaining space in the current zRAM, it cannot be used, resulting in high system I/O load.
  • the method for adjusting memory provided by the present application can be applied to the system shown in FIG. 3 .
  • the system includes a PSI pressure registration acquisition module, a memory information acquisition module, an application scenario monitoring module and a system pressure decision module.
  • the PSI pressure registration collection module is used to collect various types of PSI from the PSI group time collector.
  • the PSI group time collector is used to count the accumulated time of the tasks in each group, such as the CPU running time. (CPU running time), memory reclaim time and I/O waiting time (I/O waiting time).
  • CPU running time is CPU PSI, which reflects the computing pressure of the system
  • memory reclaim time is memory recycling
  • PSI reflects the memory reclamation pressure of the system
  • I/O waiting time is the I/O PSI, which reflects the I/O pressure of the system.
  • the CPU can process multiple tasks, the multiple tasks include memory reclamation tasks, the time taken by the CPU to complete the multiple tasks is the CPU running time, and the time for the CPU to complete the memory reclamation task is the memory reclamation time.
  • the time taken for reading and writing from and writing to the above-mentioned multiple tasks is the I/O wait time.
  • the memory information collection module is used to read /prof/meminfo through the prof fs file system, and /prof/meminfo is, for example, available memory (memory available), available swap space (swap free) and the number of anonymous pages (anon pages).
  • Swap free reflects the remaining capacity of zRAM, and anon pages reflects the amount of data that can be input into zRAM.
  • anon pages reflects the amount of data that can be input into zRAM.
  • the benefit of using zRAM is not large, and the frequency of use of zRAM can be reduced;
  • the swap free is high and the anon pages is high, the use of zRAM is more profitable, and the frequency of use of zRAM can be increased.
  • Adjusting the memory configuration parameters will consume computing resources. Therefore, when the available memory (physical memory) is large, there is no need to adjust the memory configuration parameters; when the available memory is small, the memory configuration parameters can be adjusted.
  • the application scene monitoring module is used to collect scene information such as APP startup and APP switching.
  • scene information can be obtained through the activity manager service (activity manager service, AMS) in the system service.
  • activity manager service activity manager service, AMS
  • the system pressure decision module can obtain the pressure threshold and adjustment parameters, where the pressure threshold can be the time window size of the statistical PSI, the reporting threshold of different pressures, the threshold of the remaining zRAM space, the threshold of anon page size, etc.; the adjustment parameter can be swappiness Adjust the upper limit, lower limit, preset value, etc.
  • the system pressure decision module can also make memory adjustment decisions based on the information collected by the pressure threshold, adjustment parameters, PSI pressure registration acquisition module, memory information acquisition module and application scenario monitoring module. For example, swappiness and extra_free_kbytes can be adjusted via the proc fs filesystem.
  • the PSI pressure registration collection module can collect various types of PSI, such as CPU PSI, memory reclamation PSI, and I/O PSI. Each type of PSI can be divided into multiple levels. For example, the CPU PSI can correspond to high-stress events, medium-stress events, and low-stress events according to different values.
  • Figure 4 is a collection flow of a single type of PSI.
  • the PSI pressure registration acquisition module After the PSI pressure registration acquisition module starts to work, you can register the memory pressure monitoring and set the initial pressure state to no pressure. Subsequently, the PSI pressure registration acquisition module waits for the kernel to report pressure events based on the epoll_wait mechanism.
  • the PSI pressure registration acquisition module waits for the pressure report in the blocking mode. Subsequently, if a pressure event is received during the waiting period for pressure reporting, the PSI pressure registration acquisition module sets the pressure based on the pressure event; if no pressure event is received during the waiting pressure reporting period, the PSI pressure registration acquisition module continues to wait for the pressure event to be reported.
  • the PSI pressure registration acquisition module can set the timeout time based on the pressure reporting cycle, and determine whether there is pressure reporting before the timeout.
  • the PSI pressure registration acquisition module can set the pressure based on the pressure event; if there is no pressure report before the timeout, the PSI pressure registration acquisition module can set the pressure state to no pressure.
  • S401 refers to the judgment made by the PSI pressure registration collection module based on the information collected in the previous pressure reporting cycle
  • S403 and S404 are the PSI pressure registration collection module based on the current pressure reporting cycle. Judgments made from the information collected.
  • the PSI pressure registration acquisition module may repeatedly execute S401.
  • the PSI pressure registration acquisition module only exposes the one with the largest semantics. For example, when the kernel reports high-pressure events and low-pressure events to the PSI pressure registration and collection module, the PSI pressure registration and collection module only displays high-pressure events to the system pressure decision module.
  • the kernel independently reports the events of each pressure.
  • the PSI pressure registration collection module can register CPU pressure monitoring, memory recovery pressure monitoring, and I/O pressure monitoring; then, the kernel reports CPU pressure events, memory recovery pressure events, and I/O pressure events to the PSI pressure registration collection module, respectively.
  • the processing time of the multiple CPU cores can be converted into the processing time of a single-core CPU through a weighted average algorithm.
  • the CPU pressure is low pressure when the processing time reaches 400ms, the CPU pressure is medium pressure when the processing time reaches 500ms, and the CPU pressure is high pressure when the processing time reaches 600ms.
  • the kernel does not report the CPU pressure event; when the CPU processing event counted by the kernel is greater than or equal to 400ms and less than 500ms, the kernel reports the CPU low pressure event; when the CPU processing event counted by the kernel is greater than or equal to 500ms And when the time is less than 600ms, the kernel reports the CPU pressure event; when the CPU processing event counted by the kernel is greater than or equal to 600ms, the kernel reports the CPU high pressure event.
  • each stress event is reported independently, that is, the PSI stress registration and acquisition module may receive multiple stress events within a time window.
  • the semantic order of multiple pressure events is: high pressure events > medium pressure events > low pressure events > no pressure events. If the PSI pressure registration and acquisition module receives multiple pressure events within a time window, it only needs to report to the system pressure decision. The module displays the event with the most semantics.
  • the stress-free event is not an event reported by the kernel, but an event generated by the PSI pressure registration acquisition module.
  • the PSI pressure registration acquisition module When the kernel does not report any pressure events within a time window, the PSI pressure registration acquisition module generates no pressure events.
  • the kernel can count the processing time of the next time window according to the following method to improve statistical efficiency.
  • time window 1 and time window 2 are two adjacent time windows with a duration of 1s; the CPU processing time in time window 1 is 800ms, and when time window 2 reaches 300ms, the CPU processing time of the kernel statistics is 50ms, then the kernel
  • the CPU processing time of time window 2 can be predicted to be 610ms according to formula (1).
  • T2 (T1/T)*Tn+Tm(1);
  • T2 is the predicted CPU processing time in the current time window
  • T1 is the CPU processing time in the previous time window
  • T is the duration of the time window
  • Tn is the remaining duration of the current time window
  • Tm is the current time window. CPU processing time actually counted in the time window.
  • FIG. 5 is a schematic diagram of a workflow of a memory information collection module provided by the present application.
  • /prof/meminfo is memory information
  • /prof/meminfo can include memory available, swap free and anon pages, among which, swap free and anon pages is memory information that indicates how often zRAM is used.
  • the memory information collection module can determine whether to activate the system pressure decision module according to memory available. When the memory available is lower than the memory threshold, it means that there is less available memory. At this time, starting the system pressure decision-making module can obtain greater benefits, and the system pressure decision-making module can be started. The following will describe the system pressure decision-making module in detail according to swap free and anon Pages and other information to adjust the memory configuration parameters; when the memory available is higher than the memory threshold, it means that there is more memory available. At this time, the system pressure decision module cannot be activated to obtain greater benefits, and the memory information collection module can sleep for a period of time (for example, 2s). , and then read /prof/meminfo.
  • a period of time for example, 2s.
  • the memory information collection module can be monitored by a registered startup scene when it starts to work, and can be triggered by an application scene (eg, an application cold start) to enter the awake state after hibernation, and then read /prof/meminfo.
  • an application scene eg, an application cold start
  • FIG. 6 is a schematic diagram of a workflow of an application scenario monitoring module provided by the present application.
  • the application scene monitoring module can instrument the core callback function of the AMS application life cycle to monitor the application scene.
  • the above-mentioned AMS application life cycle core callback functions may include the creation function (onCreate), the start function (onStart), the resume function (onResume), the pause function (onPause), the stop function (onStop), and the shutdown function (onDestroy) shown in FIG. 6 . and restart function (onRestart).
  • Each function corresponds to an application scenario. By inserting stakes in front of these functions, the application scenario monitoring module can obtain various scenario information.
  • the system pressure decision module loads the pressure thresholds and adjustment parameters shown in Figure 3 after initialization, and then registers the PSI pressure registration acquisition module, memory information acquisition module and application scene monitoring module, and obtains PSI from these three modules respectively. , memory information and scene information.
  • the system pressure decision module can start the memory adjustment function to obtain greater system benefits; when the value of memavailable is lower than the memavailable waterline When the available memory is in a loose state, the system benefit of the system pressure decision module continuing to adjust the memory is not large, and the memory adjustment function can be exited.
  • the size of the memory threshold can be set according to the size of the physical memory.
  • the memory threshold can be set to a value with a relatively low proportion; when the physical memory of the terminal device is small, the memory threshold can be set to a value with a relatively high proportion.
  • the physical memory of terminal device A is 12GB
  • the physical memory of terminal device B is 6GB
  • the memavailable watermark of terminal device A can be set to one third of the physical memory, that is, 4GB
  • the memavailable watermark of terminal device B can be set to It is one-half of the physical memory, that is, 3GB.
  • the terminal device (terminal device A) with a large physical memory can reduce the consumption of computing resources by memory adjustment while ensuring sufficient available memory
  • the terminal device (terminal device B) with a small physical memory can adjust the memory in advance, Reduce the probability of problems such as insufficient memory.
  • FIG. 8 is a schematic diagram of the workflow of the system pressure decision module.
  • the system pressure decision module After the system pressure decision module starts to work (ie, initializes), if the available memory is lower than the memory threshold (ie, the value of memavailable is lower than the memavailable waterline), it is determined whether the memory pressure is high.
  • the time required for the memory reclamation task indicates the memory demand pressure.
  • the time required for the memory reclamation task is greater than the third time threshold, it means that there are currently many memory reclamation tasks, and the third-party APP has no effect on the memory.
  • the system pressure decision module can reduce extra_free_kbytes to reserve more memory for the third-party APP; when the time required for the memory reclamation task is less than the third time threshold, it means that there are currently fewer memory reclamation tasks, and the third-party APP will Memory requirements are small, and the system pressure decision module can increase extra_free_kbytes to reserve more memory for the kernel.
  • the system pressure decision module can adjust swappiness.
  • the system pressure decision-making module first determines whether the current APP running scene conforms to the preset scene. If the current APP running scene conforms to the preset scene, the system pressure decision-making module can deliver the swappiness corresponding to the preset scene. For example, if the preset scenario is an application startup scenario, and the current APP running scenario is also an application startup scenario, the system pressure decision module can determine whether the current APP running scenario complies with the preset scenario; the various resource requirements of the application startup scenario are relatively fixed, according to the preset Optimal system performance can be achieved by adjusting the memory with the highest swappiness, and there is no need to collect information such as PSI, swap free, and anon pages for operation, thereby reducing the complexity of memory adjustment.
  • the system pressure decision module can adjust swappiness based on information such as PSI, swap free, and anon pages.
  • the adjustment method is shown in Table 1.
  • N/A indicates that this parameter is not currently applicable.
  • the I/O PSI is positively correlated with the I/O pressure. The larger the I/O PSI, the greater the I/O pressure.
  • the CPU PSI is positively correlated with the operation pressure. The greater the CPU PSI, the greater the operation pressure.
  • the processing time (the time indicated by the CPU PSI) is greater than the second time threshold, it means that the computing pressure is large, and the frequency of use of the zRAM can be reduced to reduce the computing resource requirement.
  • the I/O time (the time indicated by the I/O PSI) is less than the first time threshold, it means that the current I/O pressure is small and the demand for memory is small, so the frequency of zRAM usage can be reduced, and I/O PSI and CPU PSI can reduce the value of swappiness to reduce the frequency of zRAM usage, so as to achieve optimal system performance and improve the effect of memory management.
  • first time threshold and second time threshold may be preset values, as shown in the thresholds obtained by the system pressure decision module in FIG. 3 .
  • the system pressure decision module may not adjust the swappiness. Regardless of whether the swappiness is adjusted, the system pressure decision module can sleep for a period of time after making the judgment according to Table 1, so as to reduce the consumption of computing resources and memory resources.
  • the startup time of the camera APP under high system load (for example, starting 30 APPs in a row) is compared to the startup without the above method.
  • the time is reduced by 50ms and the available memory is increased by 80MB.
  • the system pressure decision module first adjusts extra_free_kbytes, and then adjusts swappiness; in the process of adjusting swappiness, the system pressure decision module first adjusts swappiness based on the application scenario, and then adjusts swappiness based on PSI, swap free, and anon pages. It should be noted that the sequence of these adjustment steps can be exchanged, which is not limited in this application.
  • the system pressure decision module can adjust swappiness first and then adjust extra_free_kbytes; in the process of adjusting swappiness, the system pressure decision module can first adjust swappiness based on PSI, swap free, and anon pages, and then adjust swappiness based on application scenarios.
  • the present application can divide the device for adjusting memory into functional units according to the above method examples.
  • each function can be divided into each functional unit, or two or more functions can be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units. It should be noted that the division of units in this application is schematic, and is only a logical function division, and other division methods may be used in actual implementation.
  • FIG. 9 is a schematic structural diagram of an apparatus for adjusting memory provided by the present application.
  • the apparatus 900 includes a processing unit 910 and an input unit 920 , wherein the input unit 920 can perform the acquiring step under the control of the processing unit 910 .
  • the input unit 920 can perform the acquiring step under the control of the processing unit 910 .
  • the input unit 920 is configured to: acquire multiple resource pressures, where the multiple resource pressures are used to indicate multiple demands for memory compression;
  • the processing unit 910 is configured to: adjust memory configuration parameters according to the plurality of resource pressures, and there is a preset correspondence between the memory configuration parameters and the plurality of resource pressures.
  • the memory configuration parameters include memory swap parameters
  • the multiple resource pressures include input/output pressure and memory swap space pressure
  • the processing unit 910 is specifically configured to: when the input/output pressure decreases, And, when the memory swap space pressure decreases, reduce the memory swap parameter; or, when the input/output pressure increases, and when the memory swap space pressure decreases, change the memory swap Parameters are adjusted to preset values.
  • the memory configuration parameters include memory swap parameters
  • the multiple resource pressures include processor pressure and memory swap space pressure
  • the processing unit 910 is specifically configured to include: when the processor pressure decreases, And, when the memory swap space pressure increases, the memory swap parameter is increased.
  • the size of the memory swap space pressure is positively related to the number of anonymous pages.
  • the size of the memory swap space pressure is positively related to the size of the available swap space.
  • the memory configuration parameters include memory swap parameters
  • the multiple resource pressures include processor pressure and input/output pressure
  • the processing unit 910 is specifically configured to: when the input/output pressure decreases, and , when the processor pressure increases, reduce the memory exchange parameter; or, when the input/output pressure increases, and when the processor pressure increases, change the memory exchange parameter Adjust to default value.
  • the processing unit 910 is specifically configured to: when the current application running scenario indicated by the scenario information does not conform to the preset scenario, adjust the memory configuration parameter according to the multiple resource pressures.
  • processing unit 910 is further configured to: decrease the additional free memory configuration parameter when the memory reclamation pressure increases; or increase the additional free memory configuration parameter when the memory reclamation pressure decreases.
  • the processing unit 910 is specifically configured to: when the available memory is less than a memory threshold, adjust the memory configuration parameter according to the multiple resource pressures.
  • FIG. 10 shows a schematic structural diagram of an electronic device provided by the present application.
  • the dashed line in Figure 10 indicates that the unit or the module is optional.
  • the device 1000 can be used to implement the methods described in the above method embodiments.
  • the device 1000 may be a terminal device or a server or a chip.
  • the device 1000 includes one or more processors 1001, and the one or more processors 1001 can support the device 1000 to implement the methods in the method embodiments.
  • the processor 1001 may be a general purpose processor or a special purpose processor.
  • the processor 1001 may be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (field programmable gate array) gate array, FPGA) or other programmable logic devices such as discrete gates, transistor logic devices, or discrete hardware components.
  • the processor 1001 may be used to control the device 1000, execute software programs, and process data of the software programs.
  • the device 1000 may also include a communication unit 1005 to enable input (reception) and output (transmission) of signals.
  • the device 1000 may be a chip
  • the communication unit 1005 may be an input and/or output circuit of the chip, or the communication unit 1005 may be a communication interface of the chip, and the chip may be a component of a terminal device or a server or other electronic device part.
  • the device 1000 may be a terminal device or a server
  • the communication unit 1005 may be a transceiver of the terminal device or the server
  • the communication unit 1005 may be a transceiver circuit of the terminal device or the server.
  • the device 1000 may include one or more memories 1002 on which programs 1004 are stored.
  • the program 1004 may be executed by the processor 1001 to generate instructions 1003, so that the processor 1001 executes the methods described in the above method embodiments according to the instructions 1003.
  • data may also be stored in the memory 1002 .
  • the processor 1001 can also read the data stored in the memory 1002 (such as Table 1), the data can be stored in the same storage address as the program 1004, and the data can also be stored in a different storage address with the program 1004.
  • the processor 1001 and the memory 1002 may be provided separately, or may be integrated together, for example, integrated on a system-on-chip (SOC) of the terminal device.
  • SOC system-on-chip
  • Device 1000 may also include antenna 1006 .
  • the communication unit 1005 is used for realizing the transceiver function of the device 1000 through the antenna 1006 .
  • the present application also provides a computer program product, which implements the method described in any method embodiment in the present application when the computer program product is executed by the processor 1001 .
  • the computer program product can be stored in the memory 1002 , such as a program 1004 , and the program 1004 is finally converted into an executable object file that can be executed by the processor 1001 through processing processes such as preprocessing, compilation, assembly, and linking.
  • the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a computer, implements the method described in any method embodiment of the present application.
  • the computer program can be a high-level language program or an executable object program.
  • the computer-readable storage medium is, for example, the memory 1002 .
  • Memory 1002 may be volatile memory or non-volatile memory, or memory 1002 may include both volatile memory and non-volatile memory.
  • the non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically programmable Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • Volatile memory may be random access memory (RAM), which acts as an external cache.
  • RAM random access memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous DRAM
  • SDRAM double data rate synchronous dynamic random access memory
  • double data rate SDRAM double data rate SDRAM
  • DDR SDRAM enhanced synchronous dynamic random access memory
  • ESDRAM enhanced synchronous dynamic random access memory
  • SCRAM synchronous link dynamic random access memory
  • direct rambus RAM direct rambus RAM
  • the disclosed systems, apparatuses and methods may be implemented in other manners.
  • some features of the method embodiments described above may be omitted, or not implemented.
  • the apparatus embodiments described above are only illustrative, and the division of units is only a logical function division. In actual implementation, there may be other division methods, and multiple units or components may be combined or integrated into another system.
  • the coupling between the units or the coupling between the components may be direct coupling or indirect coupling, and the above-mentioned coupling includes electrical, mechanical or other forms of connection.
  • system and “network” are often used interchangeably herein.
  • the term “and/or” in this article is only an association relationship to describe the associated objects, indicating that there can be three kinds of relationships, for example, A and/or B, it can mean that A exists alone, A and B exist at the same time, independently There are three cases of B.
  • the character "/" in this document generally indicates that the related objects are an "or” relationship.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Telephone Function (AREA)

Abstract

本申请提供了一种调整内存配置参数的方法和装置。该方法包括:获取多个资源压力,所述多个资源压力用于指示对内存压缩的多种需求;根据所述多个资源压力调整内存配置参数,所述内存配置参数与所述多个资源压力之间存在预设的对应关系。资源压力例如是处理器压力、I/O压力、内存回收压力或内存交换空间压力,不同类型的资源压力对应的内存压缩需求不同,申请提供的调整内存的方法综合考虑多种信息,能够实现***性能最优,提高管理内存的效果。

Description

调整内存配置参数的方法和装置
本申请要求于2020年09月10日提交国家知识产权局、申请号为202010949797.5、申请名称为“一种内存调节的方法”的中国专利申请的优先权,以及,于2020年12月25日提交国家知识产权局、申请号为202011574300.2、申请名称为“调整内存配置参数的方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及存储领域,具体涉及一种调整内存配置参数的方法和装置。
背景技术
内存(memory)是计算机的组成部分,当计算机运行程序时,与程序运行相关的数据可以暂时存放在内存中,等待处理器调用。若内存资源不足,则处理器可能需要等待一段时间才能获取程序运行所需的数据,因此,内存资源的使用情况与程序运行情况(如启动速率)存在关联关系。
为了提高内存资源利用率,需要对内存资源的使用情况进行管理。一种管理内存资源的方法是基于可用内存的大小调整内存,例如,当可用内存小于预设值时,可以提高额外空闲内存配置参数(extra_free_kbytes)的数值,以促使内存管理模块更积极地回收内存来满足程序对内存资源的需求。但是,应用该方法管理内存的效果仍有待提高。
发明内容
本申请提供了一种调整内存配置参数的方法、装置、计算机程序产品和计算机可读存储介质,能够提高内存管理的效果。
第一方面,提供了一种调整内存的方法,包括:获取多个资源压力,所述多个资源压力用于指示对内存压缩的多种需求;根据所述多个资源压力调整内存配置参数,所述内存配置参数与所述多个资源压力之间存在预设的对应关系。
资源压力例如是处理器压力、输入输出(input/output,I/O)压力、内存回收压力或内存交换空间压力,其中,处理器压力、I/O压力和内存回收压力可以分别由处理器压力失速信息(pressure stall information,PSI)、I/O PSI和内存回收PSI确定,内存交换空间压力可以由可用交换空间(swap free)和/或匿名页数量(anon pages)确定。不同类型的资源压力对应的内存压缩需求不同,基于一种类型的资源压力调整内存配置参数难以实现***性能最优,例如,当swap free较低并且anon pages较低时,说明zRAM(内存压缩技术的一个示例)的使用收益不大,此时应当减小内存交换参数(swappiness)的值,以减小zRAM的使用频率;但是,若I/O压力较大,则应当增大swappiness的值,较大的swappiness能够提高zRAM的使用频率,从而回收更多的anon pages,避免内存不足时文件页(file page)被过量回收导致的I/O压力持续增大,其中,I/O压力持续增大原因是:file page过量回收会导致缓存(cache)命中率下降,file  page需要再次从磁盘读入cache,重读入(refault)I/O现象增多,refault I/O会导致I/O压力持续增大;综合考虑上述两种信息,swappiness需要设置一个合适的值以平衡内存交换空间压力和I/O压力,使得***性能最优。相比于基于一种信息调整内存,本申请提供的调整内存的方法综合考虑多种信息,能够实现***性能最优,提高管理内存的效果。
可选地,所述内存配置参数包括swappiness,所述多个资源压力包括I/O压力和内存交换空间压力,所述根据所述多个资源压力调整内存配置参数,包括:当所述I/O压力减小时,并且,当所述内存交换空间压力减小时,减小所述内存交换参数;或者,当所述I/O压力增大时,并且,当所述内存交换空间压力减小时,将所述内存交换参数调整为预设值。
swap free反映了zRAM设备的剩余容量,anon pages反映了能够输入zRAM设备的数据的数据量,当swap free较低和/或anon pages较低(即,内存交换空间压力较小)时,zRAM的使用收益不大,可以减小zRAM的使用频率。当I/O压力较小时,可以减小zRAM的使用频率以节约运算资源,综合考虑内存交换空间压力和I/O压力,可以减小swappiness的值,从而实现***性能最优,提高管理内存的效果。
当swap free较低和/或anon pages较低(即,内存交换空间压力较小)时,zRAM的使用收益不大,可以减小zRAM的使用频率。当I/O压力较大时,应当增大swappiness的值,较大的swappiness能够提高zRAM的使用频率,从而回收更多的anon pages,避免内存不足时file page过量回收导致I/O压力持续增大。可以将swappiness设置一个合适的值(如,预设值)以平衡内存交换空间压力和I/O压力,从而实现***性能最优,提高管理内存的效果。
可选地,所述内存配置参数包括swappiness,所述多个资源压力包括处理器压力和内存交换空间压力,所述根据所述多个资源压力调整内存配置参数,包括:当所述处理器压力减小时,并且,当所述内存交换空间压力增大时,增大所述swappiness。
处理器压力较小时,增大swappiness可以减小内存不足时缓存颠簸发生的概率,同时不会影响其他任务的运算资源需求;内存交换空间压力较大时,说明使用zRAM的使用收益较大,应当增大swappiness。综合考虑处理器压力和内存交换空间压力,可以增大swappiness的值以提高zRAM的使用频率,从而实现***性能最优,提高管理内存的效果。
可选地,所述内存配置参数包括swappiness,所述多个资源压力包括处理器压力和I/O压力,所述根据所述多个资源压力调整内存配置参数,包括:当所述I/O压力减小时,并且,当所述处理器压力增大时,减小所述内存交换参数;或者,当所述I/O压力增大时,并且,当所述处理器压力增大时,将所述内存交换参数调整为预设值。
当I/O压力较小时,可以减小zRAM的使用频率以节约运算资源;当处理器压力较大时,说明当前运算压力较大,应当减小swappiness以节约运算资源;综合考虑I/O压力和处理器压力,可以减小swappiness以节约运算资源,从而实现***性能最优,提高管理内存的效果。
当I/O压力较大时,应当增大swappiness的值,较大的swappiness能够提高zRAM的使用频率,从而回收更多的anon pages,避免内存不足时file page过量回收导致I/O 压力持续增大;当处理器压力较大时,应当减小swappiness以节约运算资源;可以将swappiness设置一个合适的值(如,预设值)以平衡I/O压力和处理器压力,从而实现***性能最优,提高管理内存的效果。
可选地,所述根据所述多个资源压力调整内存配置参数,包括:当场景信息指示的当前应用运行场景不符合预设场景时,根据所述多个资源压力调整所述内存配置参数。
场景信息例如是指示应用启动或应用切换的信息。当预设场景是应用启动场景时,应用启动场景的各种资源需求比较固定,按照预设的swappiness调整内存即可实现***性能最优,无需再收集PSI和内存交换空间压力信息进行运算,从而减小了内存调整的复杂度。
可选地,所述方法还包括:当内存回收压力增大时,减小额外空闲内存配置参数(extra_free_kbytes);或者,当内存回收压力减小时,增大extra_free_kbytes。
extra_free_kbytes的值与内核保留的内存大小正相关,即,extra_free_kbytes的值越大,内核保留的内存越大。当内存回收压力增大时,说明当前内存回收任务较多,第三方APP对内存的需求较大,可以减小extra_free_kbytes以便于为第三方APP保留更多的内存;当内存回收压力减小时,说明当前内存回收任务较少,第三方APP对内存的需求较小,可以增大extra_free_kbytes以便于为内核保留更多的内存。
可选地,所述根据所述多个资源压力调整内存配置参数,包括:当可用内存小于内存阈值时,根据所述多个资源压力调整所述内存配置参数。
调整内存配置参数会消耗运算资源,因此,当可用内存较大时,无需调整内存配置参数;当可用内存较小时,可以根据所述多个资源压力调整内存配置参数,从而可以在不影响应用运行的前提下节省运算资源。
可选地,所述内存阈值与物理内存的比值与所述物理内存的大小负相关。
可以根据物理内存的大小设置内存阈值的大小。终端设备的物理内存较大时,可以将内存阈值设置为一个占比较低的数值;终端设备的物理内存较小时,可以将内存阈值设置为一个占比较高的数值。
例如,终端设备A的物理内存为12GB,终端设备B的物理内存为6GB,终端设备A的memavailable水线可以设置为物理内存的三分之一,即4GB;终端设备B的memavailable水线可以设置为物理内存的二分之一,即3GB。这样,物理内存较大的终端设备(终端设备A)在保证充足的可用内存的同时,可以减少内存调整对运算资源的消耗;物理内存较小的终端设备(终端设备B)可以提前调整内存,减小内存不足等问题发生的概率。
第二方面,提供了一种调整内存的装置,包括用于执行第一方面中任一种方法的单元。该装置可以是终端设备,也可以是终端设备内的芯片。该装置可以包括输入单元和处理单元。
当该装置是终端设备时,该处理单元可以是处理器,该输入单元可以是触控屏、键盘、鼠标、摄像头、麦克风或其他输入设备;该终端设备还可以包括存储器,该存储器用于存储计算机程序代码,当该处理器执行该存储器所存储的计算机程序代码时,使得该终端设备执行第一方面中的任一种方法。
当该装置是终端设备内的芯片时,该处理单元可以是芯片内部的处理单元,该输入单元可以是输入/输出接口、管脚或电路等;该芯片还可以包括存储器,该存储器可以是该芯片内的存储器(例如,寄存器、缓存等),也可以是位于该芯片外部的存储器(例如,只读存储器、随机存取存储器等);该存储器用于存储计算机程序代码,当该处理器执行该存储器所存储的计算机程序代码时,使得该芯片执行第一方面中的任一种方法。
第三方面,提供了一种计算机程序产品,所述计算机程序产品包括:计算机程序代码,当所述计算机程序代码被调整内存的装置运行时,使得该装置执行第一方面中的任一种方法。
第四方面,提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序代码,当所述计算机程序代码被调整内存的装置运行时,使得该装置执行第一方面中的任一种方法。
附图说明
图1是本申请提供的一种终端设备的硬件***的示意图;
图2是本申请提供的一种终端设备的软件***的示意图;
图3是本申请提供的一种调整内存的***的示意图;
图4是本申请提供的PSI压力注册采集模块的一种工作流程的示意图;
图5是本申请提供的内存信息采集模块的一种工作流程的示意图;
图6是本申请提供的应用场景监控模块的一种工作流程的示意图;
图7是本申请提供的***压力决策模块的一种工作流程的示意图;
图8是本申请提供的***压力决策模块的另一种工作流程的示意图;
图9是本申请提供的一种调整内存的装置的示意图;
图10是本申请提供的一种调整内存的电子设备的示意图。
具体实施方式
下面将结合附图,对本申请实施例中的技术方案进行描述。
图1示出了一种适用于本申请的装置的硬件结构。
装置100可以是手机、智慧屏、平板电脑、可穿戴电子设备、车载电子设备、增强现实(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)、投影仪等等,本申请实施例对装置100的具体类型不作任何限制。
装置100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传 感器180K,环境光传感器180L,骨传导传感器180M等。
需要说明的是,图1所示的结构并不构成对装置100的具体限定。在本申请另一些实施例中,装置100可以包括比图1所示的部件更多或更少的部件,或者,装置100可以包括图1所示的部件中某些部件的组合,或者,装置100可以包括图1所示的部件中某些部件的子部件。图1示的部件可以以硬件、软件、或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元。例如,处理器110可以包括以下处理单元中的至少一个:应用处理器(application processor,AP)、调制解调处理器、图形处理器(graphics processing unit,GPU)、图像信号处理器(image signal processor,ISP)、控制器、视频编解码器、数字信号处理器(digital signal processor,DSP)、基带处理器、神经网络处理器(neural-network processing unit,NPU)。其中,不同的处理单元可以是独立的器件,也可以是集成的器件。
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了***的效率。
在一些实施例中,处理器110可以包括一个或多个接口。例如,处理器110可以包括以下接口中的至少一个:内部集成电路(inter-integrated circuit,I2C)接口、内部集成电路音频(inter-integrated circuit sound,I2S)接口、脉冲编码调制(pulse code modulation,PCM)接口、通用异步接收传输器(universal asynchronous receiver/transmitter,UART)接口、移动产业处理器接口(mobile industry processor interface,MIPI)、通用输入输出(general-purpose input/output,GPIO)接口、SIM接口、USB接口。
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K、充电器、闪光灯、摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现装置100的触摸功能。
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总 线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。
MIPI接口可以被用于连接处理器110与显示屏194和摄像头193等***器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI)、显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现装置100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现装置100的显示功能。
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号接口,也可被配置为数据信号接口。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194、无线通信模块160、音频模块170和传感器模块180。GPIO接口还可以被配置为I2C接口、I2S接口、UART接口或MIPI接口。
USB接口130是符合USB标准规范的接口,例如可以是迷你(Mini)USB接口、微型(Micro)USB接口或C型USB(USB Type C)接口。USB接口130可以用于连接充电器为装置100充电,也可以用于装置100与***设备之间传输数据,还可以用于连接耳机以通过耳机播放音频。USB接口130还可以用于连接其他装置100,例如AR设备。
图1所示的各模块间的连接关系只是示意性说明,并不构成对装置100的各模块间的连接关系的限定。可选地,装置100的各模块也可以采用上述实施例中多种连接方式的组合。
充电管理模块140用于从充电器接收电力。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的电流。在一些无线充电的实施例中,充电管理模块140可以通过装置100的无线充电线圈接收电磁波(电流路径如虚线所示)。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为装置100供电。
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量、电池循环次数和电池健康状态(例如,漏电、阻抗)等参数。可选地,电源管理模块141可以设置于处理器110中,或者,电源管理模块141和充电管理模块140可以设置于同一个器件中。
装置100的无线通信功能可以通过天线1、天线2、移动通信模块150、无线通信模块160、调制解调处理器以及基带处理器等器件实现。
天线1和天线2用于发射和接收电磁波信号。装置100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。
移动通信模块150可以提供应用在装置100上的无线通信的解决方案,例如下列方案中的至少一个:第二代(2 th generation,2G)移动通信解决方案、第三代(3 th generation,3G)移动通信解决方案、***(4 th generation,5G)移动通信解决方案、第五代(5 th generation,5G)移动通信解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波和放大等处理,随后传送至调制解调处理器进行解调。移动通信模块150还可以放大经调制解调处理器调制后的信号,放大后的该信号经天线1转变为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(例如,扬声器170A、受话器170B)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。
与移动通信模块150类似,无线通信模块160也可以提供应用在装置100上的无线通信解决方案,例如下列方案中的至少一个:无线局域网(wireless local area networks,WLAN)、蓝牙(bluetooth,BT)、全球导航卫星***(global navigation satellite system,GNSS)、调频(frequency modulation,FM)、近场通信(near field communication,NFC)、红外(infrared,IR)。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,并将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频和放大,该信号经天线2转变为电磁波辐射出去。
在一些实施例中,装置100的天线1和移动通信模块150耦合,装置100的天线2和无线通信模块160耦合。
装置100可以通过GPU、显示屏194以及应用处理器实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194可以用于显示图像或视频。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD)、有机发光二极管(organic light-emitting diode,OLED)、有源矩阵有机发光二极体(active-matrix organic light-emitting diode,AMOLED)、柔性发光二极管(flex light-emitting diode,FLED)、迷你发光二极管(mini light-emitting diode,Mini LED)、微型发光二极管(micro light-emitting diode,Micro LED)、微型OLED(Micro OLED)或量子点发光二极管(quantum dot light emitting diodes,QLED)。在一些实施例 中,装置100可以包括1个或N个显示屏194,N为大于1的正整数。
装置100可以通过ISP、摄像头193、视频编解码器、GPU、显示屏194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP可以对图像的噪点、亮度和色彩进行算法优化,ISP还可以优化拍摄场景的曝光和色温等参数。在一些实施例中,ISP可以设置在摄像头193中。
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的红绿蓝(red green blue,RGB),YUV等格式的图像信号。在一些实施例中,装置100可以包括1个或N个摄像头193,N为大于1的正整数。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当装置100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。
视频编解码器用于对数字视频压缩或解压缩。装置100可以支持一种或多种视频编解码器。这样,装置100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1、MPEG2、MPEG3和MPEG4。
NPU是一种借鉴生物神经网络结构的处理器,例如借鉴人脑神经元之间传递模式对输入信息快速处理,还可以不断地自学习。通过NPU可以实现装置100的智能认知等功能,例如:图像识别、人脸识别、语音识别和文本理解。
外部存储器接口120可以用于连接外部存储卡,例如安全数码(secure digital,SD)卡,实现扩展装置100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作***,至少一个功能(例如,声音播放功能和图像播放功能)所需的应用程序。存储数据区可存储装置100使用过程中所创建的数据(例如,音频数据和电话本)。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如:至少一个磁盘存储器件、闪存器件和通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令和/或存储在设置于处理器中的存储器的指令,执行装置100的各种处理方法。
装置100可以通过音频模块170、扬声器170A、受话器170B、麦克风170C、耳机接口170D以及应用处理器等实现音频功能,例如,音乐播放和录音。
音频模块170用于将数字音频信息转换成模拟音频信号输出,也可以用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在 一些实施例中,音频模块170或者音频模块170的部分功能模块可以设置于处理器110中。
扬声器170A,也称为喇叭,用于将音频电信号转换为声音信号。装置100可以通过扬声器170A收听音乐或免提通话。
受话器170B,也称为听筒,用于将音频电信号转换成声音信号。当用户使用装置100接听电话或语音信息时,可以通过将受话器170B靠近耳朵接听语音。
麦克风170C,也称为话筒或传声器,用于将声音信号转换为电信号。当用户拨打电话或发送语音信息时,可以通过靠近麦克风170C发声将声音信号输入麦克风170C。装置100可以设置至少一个麦克风170C。在另一些实施例中,装置100可以设置两个麦克风170C,以实现降噪功能。在另一些实施例中,装置100还可以设置三个、四个或更多麦克风170C,以实现识别声音来源和定向录音等功能。处理器110可以对麦克风170C输出的电信号进行处理,例如,音频模块170与无线通信模块160可以通过PCM接口耦合,麦克风170C将环境声音转换为电信号(如PCM信号)后,通过PCM接口将该电信号传输至处理器110;从处理器110对该电信号进行音量分析和频率分析,确定环境声音的音量和频率。
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动装置100平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,例如可以是电阻式压力传感器、电感式压力传感器或电容式压力传感器。电容式压力传感器可以是包括至少两个具有导电材料的平行板,当力作用于压力传感器180A,电极之间的电容改变,装置100根据电容的变化确定压力的强度。当触摸操作作用于显示屏194时,装置100根据压力传感器180A检测所述触摸操作。装置100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如:当触摸操作强度小于第一压力阈值的触摸操作作用于短消息应用图标时,执行查看短消息的指令;当触摸操作强度大于或等于第一压力阈值的触摸操作作用于短消息应用图标时,执行新建短消息的指令。
陀螺仪传感器180B可以用于确定装置100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定装置100围绕三个轴(即,x轴、y轴和z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。例如,当快门被按下时,陀螺仪传感器180B检测装置100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消装置100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航和体感游戏等场景。
气压传感器180C用于测量气压。在一些实施例中,装置100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。
磁传感器180D包括霍尔传感器。装置100可以利用磁传感器180D检测翻盖皮套 的开合。在一些实施例中,当装置100是翻盖机时,装置100可以根据磁传感器180D检测翻盖的开合。装置100可以根据检测到的皮套的开合状态或翻盖的开合状态,设置翻盖自动解锁等特性。
加速度传感器180E可检测装置100在各个方向上(一般为x轴、y轴和z轴)加速度的大小。当装置100静止时可检测出重力的大小及方向。加速度传感器180E还可以用于识别装置100的姿态,作为横竖屏切换和计步器等应用程序的输入参数。
距离传感器180F用于测量距离。装置100可以通过红外或激光测量距离。在一些实施例中,例如在拍摄场景中,装置100可以利用距离传感器180F测距以实现快速对焦。
接近光传感器180G可以包括例如发光二极管(light-emitting diode,LED)和光检测器,例如,光电二极管。LED可以是红外LED。装置100通过LED向外发射红外光。装置100使用光电二极管检测来自附近物体的红外反射光。当检测到反射光时,装置100可以确定附近存在物体。当检测不到反射光时,装置100可以确定附近没有物体。装置100可以利用接近光传感器180G检测用户是否手持装置100贴近耳朵通话,以便自动熄灭屏幕达到省电的目的。接近光传感器180G也可用于皮套模式或口袋模式的自动解锁与自动锁屏。
环境光传感器180L用于感知环境光亮度。装置100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测装置100是否在口袋里,以防误触。
指纹传感器180H用于采集指纹。装置100可以利用采集的指纹特性实现解锁、访问应用锁、拍照和接听来电等功能。
温度传感器180J用于检测温度。在一些实施例中,装置100利用温度传感器180J检测的温度,执行温度处理策略。例如,当温度传感器180J上报的温度超过阈值,装置100执行降低位于温度传感器180J附近的处理器的性能,以便降低功耗实施热保护。在另一些实施例中,当温度低于另一阈值时,装置100对电池142加热,以避免低温导致装置100异常关机。在其他一些实施例中,当温度低于又一阈值时,装置100对电池142的输出电压执行升压,以避免低温导致的异常关机。
触摸传感器180K,也称为触控器件。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,触摸屏也称为触控屏。触摸传感器180K用于检测作用于其上或其附近的触摸操作。触摸传感器180K可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于装置100的表面,并且与显示屏194设置于不同的位置。
骨传导传感器180M可以获取振动信号。在一些实施例中,骨传导传感器180M可以获取人体声部振动骨块的振动信号。骨传导传感器180M也可以接触人体脉搏,接收血压跳动信号。在一些实施例中,骨传导传感器180M也可以设置于耳机中,结合成骨传导耳机。音频模块170可以基于所述骨传导传感器180M获取的声部振动骨块的振动信号,解析出语音信号,实现语音功能。应用处理器可以基于所述骨传导传 感器180M获取的血压跳动信号解析心率信息,实现心率检测功能。
按键190包括开机键和音量键。按键190可以是机械按键,也可以是触摸式按键。装置100可以接收按键输入信号,实现于案件输入信号相关的功能。
马达191可以产生振动。马达191可以用于来电提示,也可以用于触摸反馈。马达191可以对作用于不同应用程序的触摸操作产生不同的振动反馈效果。对于作用于显示屏194的不同区域的触摸操作,马达191也可产生不同的振动反馈效果。不同的应用场景(例如,时间提醒、接收信息、闹钟和游戏)可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。
指示器192可以是指示灯,可以用于指示充电状态和电量变化,也可以用于指示消息、未接来电和通知。
SIM卡接口195用于连接SIM卡。SIM卡可以***SIM卡接口195实现与装置100的接触,也可以从SIM卡接口195拔出实现与装置100的分离。装置100可以支持1个或N个SIM卡接口,N为大于1的正整数。同一个SIM卡接口195可以同时***多张卡,所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容外部存储卡。装置100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,装置100采用嵌入式SIM(embedded-SIM,eSIM)卡,eSIM卡可以嵌在装置100中,不能和装置100分离。
上文详细描述了装置100的硬件***,下面介绍装置100的软件***。软件***可以采用分层架构、事件驱动架构、微核架构、微服务架构或云架构,本申请实施例以分层架构为例,示例性地描述装置100的软件***。
如图2所示,采用分层架构的软件***分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,软件***可以分为四层,从上至下分别为应用程序层、应用程序框架层、安卓运行时(Android Runtime)和***库、以及内核层。
应用程序层可以包括相机、图库、日历、通话、地图、导航、WLAN、蓝牙、音乐、视频、短信息等应用程序。
应用程序框架层为应用程序层的应用程序提供应用程序编程接口(application programming interface,API)和编程框架。应用程序框架层可以包括一些预定义的函数。
例如,应用程序框架层包括窗口管理器、内容提供器、视图***、电话管理器、资源管理器、通知管理器、PSI压力注册采集模块、内存信息采集模块、应用场景监控模块和***压力决策模块。
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏、锁定屏幕和截取屏幕。
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频、图像、音频、拨打和接听的电话、浏览历史和书签、以及电话簿。
视图***包括可视控件,例如显示文字的控件和显示图片的控件。视图***可用于构建应用程序。显示界面可以由一个或多个视图组成,例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。
电话管理器用于提供装置100的通信功能,例如通话状态(接通或挂断)的管理。
资源管理器为应用程序提供各种资源,比如本地化字符串、图标、图片、布局文件和视频文件。
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于下载完成告知和消息提醒。通知管理器还可以管理以图表或者滚动条文本形式出现在***顶部状态栏的通知,例如后台运行的应用程序的通知。通知管理器还可以管理以对话窗口形式出现在屏幕上的通知,例如在状态栏提示文本信息、发出提示音、电子设备振动以及指示灯闪烁。
PSI压力注册采集模块用于采集各种类型的PSI,如中央处理器(central processing unit,CPU)运行时间、内存回收时间和I/O等待时间;内存信息采集模块用于采集可用内存、swap free和anon pages等内存相关的信息;应用场景监控模块用于采集APP启动和APP切换等场景信息。
***压力决策模块用于根据PSI压力注册采集模块、内存信息采集模块和应用场景监控模块采集的信息做出内存调整决策。
Android Runtime包括核心库和虚拟机。Android runtime负责安卓***的调度和管理。
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理、堆栈管理、线程管理、安全和异常的管理、以及垃圾回收等功能。
***库可以包括多个功能模块,例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES)和2D图形引擎(例如:SGL)。
表面管理器用于对显示子***进行管理,并且为多个应用程序提供了2D图层和3D图层的融合。
媒体库支持多种音频格式的回放和录制、多种视频格式回放和录制以及静态图像文件。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG和PNG。
三维图形处理库可以用于实现三维图形绘图、图像渲染、合成和图层处理。
2D图形引擎是2D绘图的绘图引擎。
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。
下面结合显示拍照场景,示例性说明装置100的软件***以及硬件***的工作流程。
当用户在触摸传感器180K上进行触摸操作时,相应的硬件中断被发送至操作***层,操作***层将触摸操作加工成原始输入事件,原始输入事件例如包括触摸坐标和触摸操作的时间戳等信息;随后,操作***层识别出原始出入事件对应的控件,并通知该控件对应的应用程序(application,APP)。例如,上述触摸操作为单击操作,上述控件对应的APP 为相机APP,则相机APP可以通过API调用后台服务,将控制指令传输至逻辑端口管理模块,通过逻辑端口管理模块控制摄像头193进行拍摄。
相机APP在运行时,与相机APP相关的数据可以暂时存放在内存中,等待处理器调用。若内存资源不足,则处理器可能需要等待一段时间才能获取相机APP的数据,因此,内存资源的使用情况与相机APP运行情况(如启动速率)存在关联关系。
为了提高内存资源利用率,需要对内存资源的使用情况进行管理。可以通过调节内存配置参数来管理内存资源,下面介绍适用于本申请的两种内存配置参数。
1、额外空闲内存配置参数(extra_free_kbytes)。
extra_free_kbytes的配置方式可以是/proc/sys/vm/extra_free_kbytes,其意义是在不改变最小水线(min watermark)的前提下,提高低水线(low watermark)和高水线(high watermark)的数值。
extra_free_kbytes的值与内核保留的内存大小正相关,即,extra_free_kbytes的值越大,内核保留的内存越大,相应地,第三方APP(如相机APP)可以使用的内存越小。当extra_free_kbytes的值较大时,内存整理功能kswapd/kcompactd会被更频繁的触发,内存回收功能lowmemorykiller也会被更频繁的触发,为内核保留更多的内存。当extra_free_kbytes的值较小时,第三方APP能够使用更多的内存,但是内存分配时出现直接回收(direct reclaim)或者I/O阻塞的概率会增大。
2、内存交换参数(swappiness)。
swappiness的配置方式可以是/proc/sys/vm/swappiness。内核在运行时会尝试把运行时内存交换到zRAM,或者通过删除***缓存中的内存页来获得更多内存,swappiness用于平衡这两种方式的使用频率。swappiness的值越大,内核就会更积极的把运行时内存交换到zRAM;swappiness的值越小,内核就更偏向于删除***缓存中的内存页。
通过设置内存配置参数的值,可以控制内核管理内存的方式。若内存配置参数的值设置不合适,则会导致***性能下降,例如,当swappiness的值较小时,若当前存在大量的文件读入任务,则***会陷入缓存颠簸状态(即,内存不足导致文件页频繁重复读入释放的状态),即使当前zRAM有大量的剩余空间也无法利用,从而导致***I/O高负载。
下面,将详细介绍本申请提供的调节内存的方法。
本申请提供的调节内存的方法能够应用于图3所示的***。该***包括PSI压力注册采集模块、内存信息采集模块、应用场景监控模块和***压力决策模块。
PSI压力注册采集模块用于从PSI群组时间采集器(PSI group time collector)采集各种类型的PSI,PSI群组时间采集器用于统计各个分组的任务所处状态的累计时间,如CPU运行时间(CPU running time)、内存回收时间(memory reclaim time)和I/O等待时间(I/O waiting time),其中,CPU运行时间即CPU PSI,反映了***的运算压力;内存回收时间即内存回收PSI,反映了***的内存回收压力;I/O等待时间即I/O PSI,反映了***的I/O压力。
例如,CPU可以处理多个任务,该多个任务包括内存回收任务,该CPU完成该多个任务所耗费的时间即CPU运行时间,其中,CPU完成内存回收任务的时间即内存回 收时间。此外,上述多个任务从磁盘(disk)读出和写入所耗费的时间即I/O等待时间。
内存信息采集模块用于通过prof fs文件***读取/prof/meminfo,/prof/meminfo例如是可用内存(memory available)、可用交换空间(swap free)和匿名页数量(anon pages)。
swap free反映了zRAM的剩余容量,anon pages反映了能够输入zRAM的数据的数据量,当swap free较低并且anon pages较低时,zRAM的使用收益不大,可以减小zRAM的使用频率;当swap free较高并且anon pages较高时,zRAM的使用收益较大,可以提高zRAM的使用频率。调整内存配置参数会消耗运算资源,因此,当可用内存(物理内存)较大时,无需调整内存配置参数;当可用内存较小时,可以对内存配置参数进行调整。
应用场景监控模块用于采集APP启动和APP切换等场景信息,例如,可以通过***服务中的活动管理器服务(activity manager service,AMS)获取场景信息。
***压力决策模块可以获取压力阈值和调整参数,其中,压力阈值可以是统计PSI的时间窗口大小、不同压力的上报阈值、zRAM空间剩余量的阈值、anon page大小的阈值等;调整参数可以是swappiness调整的上限、下限、预设值等。***压力决策模块还可以根据压力阈值、调整参数、PSI压力注册采集模块、内存信息采集模块和应用场景监控模块采集的信息做出内存调整决策。例如,可以通过proc fs文件***调整swappiness和extra_free_kbytes。
下面将详细介绍PSI压力注册采集模块、内存信息采集模块、应用场景监控模块和***压力决策模块的工作流程。
PSI压力注册采集模块可以采集多种类型的PSI,例如,CPU PSI、内存回收PSI和I/O PSI。每种类型的PSI可以分为多个等级,例如,CPU PSI按照不同的值可以对应高压力事件、中压力事件和低压力事件。
图4是一种单类型PSI的采集流程。
PSI压力注册采集模块开始工作后,可以注册内存压力监听,并设置初始压力状态为无压力。随后,PSI压力注册采集模块基于epoll_wait机制等待内核上报压力事件。
若当前压力状态为无压力,则PSI压力注册采集模块在阻塞模式中等待压力上报。随后,若等待压力上报期间收到压力事件,则PSI压力注册采集模块基于压力事件设置压力;若等待压力上报期间未收到压力事件,则PSI压力注册采集模块继续等待压力事件上报。
若当前压力状态为有压力,则PSI压力注册采集模块可以基于压力上报周期设置超时时间,并判断超时前是否有压力上报。
若超时前有压力上报,则PSI压力注册采集模块可以基于压力事件设置压力;若超时前没有压力上报,则PSI压力注册采集模块可以设置压力状态为无压力。
需要说明的是,S401中的“当前无压力”指的是PSI压力注册采集模块基于上个压力上报周期收集的信息做出的判断,S403和S404则是PSI压力注册采集模块基于当前压力上报周期收集的信息做出的判断。
执行S403或S404后,PSI压力注册采集模块可以重复执行S401。
对于同一类型的压力,PSI压力注册采集模块只向外暴露语义最大的那个。例如,当内核向PSI压力注册采集模块上报了高压力事件和低压力事件时,PSI压力注册采 集模块只向***压力决策模块展示高压力事件。
若PSI压力注册采集模块注册了多种类型的压力监听,则内核独立上报每种压力的事件。例如,PSI压力注册采集模块可以注册CPU压力监听、内存回收压力监听和I/O压力监听;随后,内核向PSI压力注册采集模块分别上报CPU压力事件、内存回收压力事件和I/O压力事件。
下面介绍一个PSI压力注册采集模块工作的具体示例。
设置一个1s的时间窗口,在该时间窗口内,内核会不停地统计CPU处理各个任务的时间、内存回收时间和I/O等待时间。
以多核CPU的处理时间为例,内核收集到多核CPU的处理时间后,可以通过加权平均算法将多个CPU核的处理时间折算为单核CPU的处理时间。
可以预设处理时间达到400ms时CPU压力为低压力,处理时间达到500ms时CPU压力为中压力,处理时间达到600ms时CPU压力为高压力。当内核统计的CPU处理时间小于400ms时,内核不上报CPU压力事件;当内核统计的CPU处理事件大于等于400ms且小于500ms时,内核上报CPU低压力事件;当内核统计的CPU处理事件大于等于500ms且小于600ms时,内核上报CPU中压力事件;当内核统计的CPU处理事件大于等于600ms时,内核上报CPU高压力事件。
上述CPU压力事件上报过程中,各个压力事件是独立上报的,即,PSI压力注册采集模块在一个时间窗口内可能收到多个压力事件。多个压力事件的语义大小排序为:高压力事件>中压力事件>低压力事件>无压力事件,若PSI压力注册采集模块在一个时间窗口内收到多个压力事件,只需向***压力决策模块展示语义最大的那个事件。
需要说明的是,无压力事件不是内核上报的事件,而是PSI压力注册采集模块生成的事件。当内核在一个时间窗口内未上报任何压力事件时,PSI压力注册采集模块生成无压力事件。
在处理时间统计过程中,由于时间窗口是持续滑动的,那么到了下一个时间窗口,所有的信息都要重新统计,内核可以按照下述方法统计下一个时间窗口的处理时间,以提高统计效率。
例如,时间窗口1和时间窗口2是两个相邻的时间窗口,时长均为1s;时间窗口1中CPU处理时间是800ms,时间窗口2到达300ms时内核统计的CPU处理时间为50ms,则内核可以根据公式(1)预测时间窗口2的CPU处理时间为610ms。
T2=(T1/T)*Tn+Tm(1);
公式(1)中,T2为预测的当前时间窗口内的CPU处理时间,T1为上一个时间窗口内的CPU处理时间,T为时间窗口的时长,Tn为当前时间窗口的剩余时长,Tm为当前时间窗口实际统计的CPU处理时间。
在上述示例中,T1=800ms,T=1s,Tn=700ms,Tm=50ms,将这些数字代入公式(1)可得T2=610ms。
图5是本申请提供的一种内存信息采集模块的工作流程的示意图。
内存信息采集模块开始工作后,可以通过prof fs文件***读取/prof/meminfo,/prof/meminfo即内存信息,/prof/meminfo可以包括memory available、swap free和anon pages,其中,swap free和anon pages是指示zRAM使用频率的内存信息。
由于调整内存配置参数会消耗运算资源,记录当前读取的内存信息后,内存信息采集模块可以根据memory available判断是否启动***压力决策模块。当memory available低于内存阈值时,说明可用内存较少,此时启动***压力决策模块能够取得较大的收益,可以启动启动***压力决策模块,下文会详述***压力决策模块根据swap free和anon pages等信息调整内存配置参数的方法;memory available高于内存阈值时,说明可用内存较多,此时启动***压力决策模块不能取得较大的收益,内存信息采集模块可以休眠一段时间(例如2s),随后再读取/prof/meminfo。
可选地,内存信息采集模块可以在开始工作由注册启动场景监听,休眠后可以由应用场景(如,应用冷启动)触发进入苏醒状态,随后再读取/prof/meminfo。
图6是本申请提供的一种应用场景监控模块的工作流程的示意图。
Activity启动后,应用场景监控模块可以在AMS应用生命周期核心回调函数前插桩,监控应用场景。上述AMS应用生命周期核心回调函数可以包括图6所示的创建函数(onCreate)、开始函数(onStart)、恢复函数(onResume)、暂停函数(onPause)、停止函数(onStop)、关闭函数(onDestroy)和重启函数(onRestart)。每种函数对应一种应用场景,通过在这些函数前插桩,应用场景监控模块能够获取各种场景信息。
上文详细描述了PSI压力注册采集模块、内存信息采集模块和应用场景监控模块的工作流程,下面,将详细介绍***压力决策模块的工作流程。
如图7所示,***压力决策模块初始化后加载图3所示的压力阈值和调整参数,随后注册PSI压力注册采集模块、内存信息采集模块和应用场景监控模块,从这三个模块分别获取PSI、内存信息和场景信息。
当memavailable的值低于memavailable水线(图7中的虚线)时,可用内存已处于紧张状态,***压力决策模块启动内存调整功能能够获得较大的***收益;当memavailable的值低于memavailable水线时,可用内存处于宽松状态,***压力决策模块继续调整内存的***收益已不大,可以退出内存调整功能。
可选地,可以根据物理内存的大小设置内存阈值的大小。终端设备的物理内存较大时,可以将内存阈值设置为一个占比较低的数值;终端设备的物理内存较小时,可以将内存阈值设置为一个占比较高的数值。
例如,终端设备A的物理内存为12GB,终端设备B的物理内存为6GB,终端设备A的memavailable水线可以设置为物理内存的三分之一,即4GB;终端设备B的memavailable水线可以设置为物理内存的二分之一,即3GB。这样,物理内存较大的终端设备(终端设备A)在保证充足的可用内存的同时,可以减少内存调整对运算资源的消耗;物理内存较小的终端设备(终端设备B)可以提前调整内存,减小内存不足等问题发生的概率。
图8是***压力决策模块的工作流程的示意图。
***压力决策模块开始工作(即,初始化)后,若可用内存低于内存阈值(即,memavailable的值低于memavailable水线),则判断内存压力是否较高。
例如,内存回收任务所需时间(即,内存PSI指示的时间)指示内存需求压力,当内存回收任务所需时间大于第三时间阈值时,说明当前内存回收任务较多,第三方APP对内存的需求较大,***压力决策模块可以减小extra_free_kbytes以便于为第三 方APP保留更多的内存;当内存回收任务所需时间小于第三时间阈值时,说明当前内存回收任务较少,第三方APP对内存的需求较小,***压力决策模块可以增大extra_free_kbytes以便于为内核保留更多的内存。
调整extra_free_kbytes之后,***压力决策模块可以调整swappiness。
***压力决策模块首先判断当前APP运行场景是否符合预设场景,若当前APP运行场景符合预设场景,则***压力决策模块可以下发预设场景对应的swappiness。例如,预设场景是应用启动场景,当前APP运行场景也是应用启动场景,则***压力决策模块可以判断当前APP运行场景是否符合预设场景;应用启动场景的各种资源需求比较固定,按照预设的swappiness调整内存即可实现***性能最优,无需再收集PSI、swap free和anon pages等信息进行运算,从而减小了内存调整的复杂度。
若当前APP运行场景不符合预设场景,则***压力决策模块可以基于PSI、swap free和anon pages等信息调整swappiness,调整方式如表1所示。
表1
I/O PSI CPU PSI swap free&anon pages swappiness
N/A
N/A
N/A
N/A 平衡值
N/A 平衡值
表1中,N/A表示该参数当前不适用。I/O PSI与I/O压力正相关,I/O PSI越大,I/O压力越大;CPU PSI与运算压力正相关,CPU PSI越大,运算压力越大。
对于表1中第一行的判断方式,当处理时间(CPU PSI指示的时间)小于第二时间阈值时,说明运算压力较小,可以提高zRAM的使用频率来换取更大的可用内存。当swap free较高并且anon pages较高时,zRAM的使用收益较大,可以提高zRAM的使用频率。综合考虑CPU PSI、anon pages和swap free,可以增大swappiness的值以提高zRAM的使用频率,从而实现***性能最优,提高管理内存的效果。
对于表1中第二行的判断方式,当处理时间(CPU PSI指示的时间)大于第二时间阈值时,说明运算压力较大,可以减小zRAM的使用频率以以减小运算资源需求。当I/O时间(I/O PSI指示的时间)小于第一时间阈值时,说明当前I/O压力较小,对内存的需求较小,可以减小zRAM的使用频率,综合考虑I/O PSI和CPU PSI,可以减小swappiness的值以降低zRAM的使用频率,从而实现***性能最优,提高管理内存的效果。
对于表1中第三行的判断方式,当I/O时间(I/O PSI指示的时间)小于第一时间阈值时,说明当前I/O压力较小,对内存的需求较小,可以减小zRAM的使用频率。当swap free较低并且anon pages较低时,zRAM的使用收益较小,可以减小zRAM的使用频率。综合考虑I/O PSI、anon pages和swap free,可以减小swappiness的值以降低zRAM的使用频率,从而实现***性能最优,提高管理内存的效果。
对于表1中第四行的判断方式,当处理时间(CPU PSI指示的时间)大于第二时间阈值时,说明运算压力较大,可以减小zRAM的使用频率以以减小运算资源需求。 当I/O时间(I/O PSI指示的时间)大于第一时间阈值时,说明当前I/O压力较大,对内存的需求较大,应当增大zRAM的使用频率来换取更大的可用内存。综合考虑I/O PSI和CPU PSI,可以将swappiness设置一个合适的值(如,预设的平衡值)以平衡运算资源需求与内存需求,从而实现***性能最优,提高管理内存的效果。
对于表1中第五行的判断方式,当I/O时间(I/O PSI指示的时间)大于第一时间阈值时,说明当前I/O压力较大,对内存的需求较大,应当增大zRAM的使用频率。当swap free较低并且anon pages较低时,zRAM的使用收益较小,应当减小zRAM的使用频率。综合考虑I/O PSI、swap free和anon pages,可以将swappiness设置一个合适的值(如,预设的平衡值)以平衡内存需求与zRAM的使用收益,从而实现***性能最优,提高管理内存的效果。
上述五种调整swappiness的方式是本申请提供的一些实施例,基于上述调整思想,还可以扩展出更多的调整方式,本申请不再一一列举。此外,上述第一时间阈值、第二时间阈值可以是预设的值,如图3中***压力决策模块获取的阈值所示。
若***压力决策模块获取的PSI、swap free和anon pages不满足表1所示的条件,则***压力决策模块可以不调整swappiness。无论swappiness是否被调整,***压力决策模块在根据表1做出判断处理之后均可以休眠一段时间,以减小运算资源和内存资源的消耗。
在内存为2GB、***为EMUI11.0 lite的华为手机上应用上述方法后,相机APP在***高负载的情况(如,连续启动30个APP)下的启动时间相比于未应用上述方法的启动时间减少了50ms,可用内存提升了80MB。
上述实施例中,***压力决策模块首先调整了extra_free_kbytes,随后又调整了swappiness;在调整swappiness的过程中,***压力决策模块首先基于应用场景调整swappiness,又基于PSI、swap free和anon pages调整swappiness。需要说明的是,这些调整步骤的先后顺序是可以交换的,本申请对此不做限定。
例如,***压力决策模块可以先调整swappiness再调整extra_free_kbytes;在调整swappiness的过程中,***压力决策模块可以先基于PSI、swap free和anon pages调整swappiness,再基于应用场景调整swappiness。
上文详细介绍了本申请提供的调整内存的方法的示例。可以理解的是,相应的装置为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请可以根据上述方法示例对调整内存的装置进行功能单元的划分,例如,可以将各个功能划分为各个功能单元,也可以将两个或两个以上的功能集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。需要说明的是,本申请中对单元的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
图9是本申请提供的一种调整内存的装置的结构示意图。该装置900包括处理单元910和输入单元920,其中,输入单元920能够在处理单元910的控制下执行获取步骤。例如:
所述输入单元920用于:获取多个资源压力,所述多个资源压力用于指示对内存压缩的多种需求;
所述处理单元910用于:根据所述多个资源压力调整内存配置参数,所述内存配置参数与所述多个资源压力之间存在预设的对应关系。
可选地,所述内存配置参数包括内存交换参数,所述多个资源压力包括输入/输出压力和内存交换空间压力,所述处理单元910具体用于:当所述输入/输出压力减小时,并且,当所述内存交换空间压力减小时,减小所述内存交换参数;或者,当所述输入/输出压力增大时,并且,当所述内存交换空间压力减小时,将所述内存交换参数调整为预设值。
可选地,所述内存配置参数包括内存交换参数,所述多个资源压力包括处理器压力和内存交换空间压力,所述处理单元910具体用于,包括:当所述处理器压力减小时,并且,当所述内存交换空间压力增大时,增大所述内存交换参数。
可选地,所述内存交换空间压力的大小与匿名页数量正相关。
可选地,所述内存交换空间压力的大小与可用交换空间的大小正相关。
可选地,所述内存配置参数包括内存交换参数,所述多个资源压力包括处理器压力和输入/输出压力,所述处理单元910具体用于:当所述输入/输出压力减小时,并且,当所述处理器压力增大时,减小所述内存交换参数;或者,当所述输入/输出压力增大时,并且,当所述处理器压力增大时,将所述内存交换参数调整为预设值。
可选地,所述处理单元910具体用于:当场景信息指示的当前应用运行场景不符合预设场景时,根据所述多个资源压力调整所述内存配置参数。
可选地,所述处理单元910还用于:当内存回收压力增大时,减小额外空闲内存配置参数;或者,当内存回收压力减小时,增大额外空闲内存配置参数。
可选地,所述处理单元910具体用于:当可用内存小于内存阈值时,根据所述多个资源压力调整所述内存配置参数。
装置900执行调整内存的方法的具体方式以及产生的有益效果可以参见方法实施例中的相关描述。
图10示出了本申请提供的一种电子设备的结构示意图。图10中的虚线表示该单元或该模块为可选的。设备1000可用于实现上述方法实施例中描述的方法。设备1000可以是终端设备或服务器或芯片。
设备1000包括一个或多个处理器1001,该一个或多个处理器1001可支持设备1000实现方法实施例中的方法。处理器1001可以是通用处理器或者专用处理器。例如,处理器1001可以是中央处理器(central processing unit,CPU)、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件,如分立门、晶体管逻辑器件或分立硬件组件。
处理器1001可以用于对设备1000进行控制,执行软件程序,处理软件程序的数 据。设备1000还可以包括通信单元1005,用以实现信号的输入(接收)和输出(发送)。
例如,设备1000可以是芯片,通信单元1005可以是该芯片的输入和/或输出电路,或者,通信单元1005可以是该芯片的通信接口,该芯片可以作为终端设备或服务器或其他电子设备的组成部分。
又例如,设备1000可以是终端设备或服务器,通信单元1005可以是该终端设备或该服务器的收发器,或者,通信单元1005可以是该终端设备或该服务器的收发电路。
设备1000中可以包括一个或多个存储器1002,其上存有程序1004,程序1004可被处理器1001运行,生成指令1003,使得处理器1001根据指令1003执行上述方法实施例中描述的方法。可选地,存储器1002中还可以存储有数据。可选地,处理器1001还可以读取存储器1002中存储的数据(如表1),该数据可以与程序1004存储在相同的存储地址,该数据也可以与程序1004存储在不同的存储地址。
处理器1001和存储器1002可以单独设置,也可以集成在一起,例如,集成在终端设备的***级芯片(system on chip,SOC)上。
设备1000还可以包括天线1006。通信单元1005用于通过天线1006实现设备1000的收发功能。
本申请还提供了一种计算机程序产品,该计算机程序产品被处理器1001执行时实现本申请中任一方法实施例所述的方法。
该计算机程序产品可以存储在存储器1002中,例如是程序1004,程序1004经过预处理、编译、汇编和链接等处理过程最终被转换为能够被处理器1001执行的可执行目标文件。
本申请还提供了一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被计算机执行时实现本申请中任一方法实施例所述的方法。该计算机程序可以是高级语言程序,也可以是可执行目标程序。
该计算机可读存储介质例如是存储器1002。存储器1002可以是易失性存储器或非易失性存储器,或者,存储器1002可以同时包括易失性存储器和非易失性存储器。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。
本领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的装置和设备的具体工作过程以及产生的技术效果,可以参考前述方法实施例中对应的过程和技术效果,在此不再赘述。
在本申请所提供的几个实施例中,所揭露的***、装置和方法,可以通过其他方式实现。例如,以上所描述的方法实施例的一些特征可以忽略,或不执行。以上所描述的装置实施例仅仅是示意性的,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,多个单元或组件可以结合或者可以集成到另一个***。另外,各单元之间的耦合或各个组件之间的耦合可以是直接耦合,也可以是间接耦合,上述耦合包括电的、机械的或其他形式的连接。
应理解,在本申请的各种实施例中,各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请的实施例的实施过程构成任何限定。
另外,本文中术语“***”和“网络”在本文中常被可互换使用。本文中的术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。
总之,以上所述仅为本申请技术方案的较佳实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (12)

  1. 一种调整内存配置参数的方法,其特征在于,包括:
    获取多个资源压力,所述多个资源压力用于指示对内存压缩的多种需求;
    根据所述多个资源压力调整内存配置参数,所述内存配置参数与所述多个资源压力之间存在预设的对应关系。
  2. 根据权利要求1所述的方法,其特征在于,所述内存配置参数包括内存交换参数,所述多个资源压力包括输入/输出压力和内存交换空间压力,
    所述根据所述多个资源压力调整内存配置参数,包括:
    当所述输入/输出压力减小时,并且,当所述内存交换空间压力减小时,减小所述内存交换参数;或者,
    当所述输入/输出压力增大时,并且,当所述内存交换空间压力减小时,将所述内存交换参数调整为预设值。
  3. 根据权利要求1所述的方法,其特征在于,所述内存配置参数包括内存交换参数,所述多个资源压力包括处理器压力和内存交换空间压力,
    所述根据所述多个资源压力调整内存配置参数,包括:
    当所述处理器压力减小时,并且,当所述内存交换空间压力增大时,增大所述内存交换参数。
  4. 根据权利要求2或3所述的方法,其特征在于,所述内存交换空间压力的大小与匿名页数量正相关。
  5. 根据权利要求2至4中任一项所述的方法,其特征在于,所述内存交换空间压力的大小与可用交换空间的大小正相关。
  6. 根据权利要求1所述的方法,其特征在于,所述内存配置参数包括内存交换参数,所述多个资源压力包括处理器压力和输入/输出压力,
    所述根据所述多个资源压力调整内存配置参数,包括:
    当所述输入/输出压力减小时,并且,当所述处理器压力增大时,减小所述内存交换参数;或者,
    当所述输入/输出压力增大时,并且,当所述处理器压力增大时,将所述内存交换参数调整为预设值。
  7. 根据权利要求1至6中任一项所述的方法,其特征在于,所述根据所述多个资源压力调整内存配置参数,包括:
    当场景信息指示的当前应用运行场景不符合预设场景时,根据所述多个资源压力调整所述内存配置参数。
  8. 根据权利要求1至7中任一项所述的方法,其特征在于,还包括:
    当内存回收压力增大时,减小额外空闲内存配置参数;或者,
    当内存回收压力减小时,增大额外空闲内存配置参数。
  9. 根据权利要求1至8中任一项所述的方法,其特征在于,所述根据所述多个资源压力调整内存配置参数,包括:
    当可用内存小于内存阈值时,根据所述多个资源压力调整所述内存配置参数。
  10. 根据权利要求9所述的方法,其特征在于,所述内存阈值与物理内存的比值与 所述物理内存的大小负相关。
  11. 一种调整内存配置参数的装置,其特征在于,包括处理器和存储器,所述处理器和存储器耦合,所述存储器用于存储计算机程序,当所述计算机程序被所述处理器执行时,使得所述装置执行权利要求1至10中任一项所述的方法。
  12. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,当所述计算机程序被处理器执行时,使得所述处理器执行权利要求1至10中任一项所述的方法。
PCT/CN2021/116838 2020-09-10 2021-09-07 调整内存配置参数的方法和装置 WO2022052897A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP21865951.4A EP4130969B1 (en) 2020-09-10 2021-09-07 Method and device for adjusting memory configuration parameter
US17/924,287 US11995317B2 (en) 2020-09-10 2021-09-07 Method and apparatus for adjusting memory configuration parameter

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202010949797 2020-09-10
CN202010949797.5 2020-09-10
CN202011574300.2A CN114168065B (zh) 2020-09-10 2020-12-25 调整内存配置参数的方法和装置
CN202011574300.2 2020-12-25

Publications (1)

Publication Number Publication Date
WO2022052897A1 true WO2022052897A1 (zh) 2022-03-17

Family

ID=80476235

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/116838 WO2022052897A1 (zh) 2020-09-10 2021-09-07 调整内存配置参数的方法和装置

Country Status (4)

Country Link
US (1) US11995317B2 (zh)
EP (1) EP4130969B1 (zh)
CN (1) CN114168065B (zh)
WO (1) WO2022052897A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116048769A (zh) * 2022-08-11 2023-05-02 荣耀终端有限公司 内存回收方法、装置和终端设备
CN117130952A (zh) * 2023-01-10 2023-11-28 荣耀终端有限公司 预读方法和预读装置

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024076068A1 (ko) * 2022-10-06 2024-04-11 삼성전자주식회사 복수의 프로세스들의 릴리즈를 제어하기 위한 전자 장치 및 그 방법
CN116680142B (zh) * 2022-11-15 2024-05-07 荣耀终端有限公司 内存资源监测方法、电子设备、程序产品及介质
CN118093150A (zh) * 2022-11-22 2024-05-28 中兴通讯股份有限公司 内存管理方法、计算机设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704290A (zh) * 2017-10-11 2018-02-16 郑州云海信息技术有限公司 一种动态调节操作***参数的方法及工具
US20180109469A1 (en) * 2016-10-17 2018-04-19 International Business Machines Corporation Systems and methods for controlling process priority for efficient resource allocation
CN109313604A (zh) * 2016-06-27 2019-02-05 英特尔公司 压缩虚拟存储器的动态配置
CN110704189A (zh) * 2019-09-27 2020-01-17 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN110727606A (zh) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN111581119A (zh) * 2020-05-07 2020-08-25 Oppo(重庆)智能科技有限公司 页面回收方法及装置

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7958289B2 (en) * 2002-08-08 2011-06-07 International Business Machines Corporation Method and system for storing memory compressed data onto memory compressed disks
US9524233B2 (en) * 2013-03-05 2016-12-20 Vmware, Inc. System and method for efficient swap space allocation in a virtualized environment
JP6203937B2 (ja) * 2014-03-04 2017-09-27 株式会社日立製作所 計算機およびメモリ制御方法
US9703713B2 (en) * 2015-02-27 2017-07-11 International Business Machines Corporation Singleton cache management protocol for hierarchical virtualized storage systems
JP2017201481A (ja) * 2016-05-06 2017-11-09 富士通株式会社 情報処理装置、情報処理装置の制御方法および情報処理装置の制御プログラム
CN109213539B (zh) * 2016-09-27 2021-10-26 华为技术有限公司 一种内存回收方法及装置
CN106557436A (zh) * 2016-11-17 2017-04-05 乐视控股(北京)有限公司 终端的内存压缩功能使能方法及装置
CN109144714A (zh) * 2017-06-19 2019-01-04 中兴通讯股份有限公司 内存管理方法及装置
CN111382087A (zh) * 2018-12-28 2020-07-07 华为技术有限公司 一种内存管理方法及电子设备
CN110764906B (zh) * 2019-09-27 2022-06-17 Oppo(重庆)智能科技有限公司 内存回收处理方法、装置、电子设备以及存储介质
CN111615207B (zh) * 2020-05-11 2022-11-08 Oppo广东移动通信有限公司 资源映射方法、装置及存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109313604A (zh) * 2016-06-27 2019-02-05 英特尔公司 压缩虚拟存储器的动态配置
US20180109469A1 (en) * 2016-10-17 2018-04-19 International Business Machines Corporation Systems and methods for controlling process priority for efficient resource allocation
CN107704290A (zh) * 2017-10-11 2018-02-16 郑州云海信息技术有限公司 一种动态调节操作***参数的方法及工具
CN110704189A (zh) * 2019-09-27 2020-01-17 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN110727606A (zh) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN111581119A (zh) * 2020-05-07 2020-08-25 Oppo(重庆)智能科技有限公司 页面回收方法及装置

Non-Patent Citations (1)

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

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116048769A (zh) * 2022-08-11 2023-05-02 荣耀终端有限公司 内存回收方法、装置和终端设备
CN116048769B (zh) * 2022-08-11 2023-11-21 荣耀终端有限公司 内存回收方法、装置和终端设备
CN117130952A (zh) * 2023-01-10 2023-11-28 荣耀终端有限公司 预读方法和预读装置

Also Published As

Publication number Publication date
CN114168065B (zh) 2024-05-31
EP4130969A4 (en) 2023-10-04
CN114168065A (zh) 2022-03-11
US11995317B2 (en) 2024-05-28
EP4130969B1 (en) 2024-07-10
EP4130969A1 (en) 2023-02-08
US20230195309A1 (en) 2023-06-22

Similar Documents

Publication Publication Date Title
WO2021169337A1 (zh) 屏下指纹显示方法及电子设备
WO2020259452A1 (zh) 一种移动终端的全屏显示方法及设备
WO2022052897A1 (zh) 调整内存配置参数的方法和装置
WO2021213164A1 (zh) 应用界面交互方法、电子设备和计算机可读存储介质
CN114443277A (zh) 内存管理方法、装置、电子设备以及计算机可读存储介质
WO2020093988A1 (zh) 一种图像处理方法及电子设备
WO2021147396A1 (zh) 图标管理方法及智能终端
WO2022127787A1 (zh) 一种图像显示的方法及电子设备
WO2022199509A1 (zh) 应用执行绘制操作的方法及电子设备
WO2021218429A1 (zh) 应用窗口的管理方法、终端设备及计算机可读存储介质
WO2021052070A1 (zh) 一种帧率识别方法及电子设备
WO2022078105A1 (zh) 内存管理方法、电子设备以及计算机可读存储介质
WO2022001258A1 (zh) 多屏显示方法、装置、终端设备及存储介质
WO2022095744A1 (zh) Vr显示控制方法、电子设备及计算机可读存储介质
CN114461589B (zh) 读取压缩文件的方法、文件***及电子设备
CN115333941A (zh) 获取应用运行情况的方法及相关设备
CN111524528B (zh) 防录音检测的语音唤醒方法及装置
CN115904297A (zh) 屏幕显示检测方法、电子设备及存储介质
CN111381996B (zh) 内存异常处理方法及装置
CN112437341B (zh) 一种视频流处理方法及电子设备
CN116048831B (zh) 一种目标信号处理方法和电子设备
CN111880661A (zh) 手势识别方法及装置
WO2023051094A1 (zh) 内存回收方法、装置、电子设备及可读存储介质
WO2021129453A1 (zh) 一种截屏方法及相关设备
CN115206308A (zh) 一种人机交互的方法及电子设备

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: 21865951

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021865951

Country of ref document: EP

Effective date: 20221026

NENP Non-entry into the national phase

Ref country code: DE