Compilation optimization method and electronic equipment

By acquiring decision parameters and using a compilation decision model to select a suitable compilation optimization scheme, the problem of excessive compilation time was solved, and the operating performance of electronic devices was improved.

CN120909601AActive Publication Date: 2025-11-07SHANGHAI GLORY SMART TECH DEV CO LTD

Patent Information

Application Number
CN202511387569.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-26
Publication Date
2025-11-07
Estimated Expiration
2045-09-26

AI Technical Summary

Technical Problem

In electronic devices, as the usage time of applications increases, the number of hot functions increases, leading to longer compilation and optimization times and affecting device performance.

Method used

By acquiring multiple decision parameters, the execution time of full compilation optimization schemes and incremental compilation optimization schemes is evaluated using a compilation decision model. The compilation optimization scheme with shorter execution time is selected for compilation optimization, including a method for determining the target compilation optimization scheme.

Benefits of technology

It optimizes compilation time, improves the performance of electronic devices, and reduces the impact of compilation on device operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120909601A_ABST
    Figure CN120909601A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a compilation optimization method and electronic equipment, the method is executed by the electronic equipment, and the method comprises the steps that under the condition that starting of compilation optimization of an application is triggered, a plurality of decision parameters are obtained, and the decision parameters are related to execution time of compilation optimization; based on the multiple decision parameters, a target compiling optimization scheme adopted for compiling optimization is determined, and the target compiling optimization scheme comprises a full-amount compiling optimization scheme or an incremental compiling optimization scheme; and performing compilation optimization based on the target compilation optimization scheme. Therefore, when the electronic equipment starts compiling optimization of the application, the multiple decision parameters are obtained to comprehensively evaluate the target compiling optimization scheme adopted for compiling optimization, and the compiling optimization scheme with short execution time is selected to execute the compiling optimization task, so that the compiling time is optimized, and the running performance of the electronic equipment is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of electronics, in particular to a compilation optimization method and an electronic device. BACKGROUND

[0002] Currently, if an application is optimized or upgraded during the running of various applications of an electronic device, the application needs to be recompiled to run normally. In order to reduce the compilation power consumption and reduce the application freezing phenomenon caused in the compilation process, the electronic device can perform compilation optimization on the application in advance. For example, the electronic device performs compilation optimization on the hot functions executed by the application in an idle scenario.

[0003] However, as the use time of the application increases, the number of hot functions executed also increases accordingly, which leads to longer compilation optimization time of the electronic device, affecting the running performance of the electronic device. SUMMARY

[0004] The present application provides a compilation optimization method and an electronic device, which can optimize the compilation time and improve the running performance of the electronic device.

[0005] In a first aspect, the present application provides a compilation optimization method, which is executed by an electronic device and includes: in a case where it is triggered to start compilation optimization of an application, obtaining a plurality of decision parameters, the plurality of decision parameters being related to the execution time of the compilation optimization; based on the plurality of decision parameters, determining a target compilation optimization scheme to be adopted for the compilation optimization, the target compilation optimization scheme including a full compilation optimization scheme or an incremental compilation optimization scheme; and based on the target compilation optimization scheme, performing the compilation optimization.

[0006] In the related art, when it is triggered to start the compilation optimization of the application, the electronic device usually fixedly selects a certain compilation optimization scheme, for example, selects the full compilation optimization scheme or the incremental compilation optimization scheme. However, since the full compilation optimization scheme needs to compile all the hot functions contained in the application, the compilation time may be long, and the incremental compilation optimization scheme needs to load the oat file generated by the last compilation and merge the oat file, which may have a long additional processing time. Therefore, if a fixed compilation optimization scheme is selected, the compilation execution time may not be optimal. Therefore, in the compilation optimization method of the present application, when the electronic device starts the compilation optimization of the application, a plurality of decision parameters are obtained to comprehensively evaluate the target compilation optimization scheme to be adopted for the compilation optimization, and a compilation optimization scheme with shorter execution time is selected to perform the compilation optimization task, so as to optimize the compilation time and improve the running performance of the electronic device.

[0007] In some implementations of the first aspect, the plurality of decision parameters include at least one of a number of newly added hot functions and classes of the application from a last compilation to the current compilation, a total number of hot functions and classes contained in the application at a time when the last compilation is completed, a size of an oat file generated by the last compilation, a type of the compilation optimization performed last time, a number of classes contained in an application APK, a number of methods contained in the application APK, and an execution time of the last compilation.

[0008] In some implementations of the first aspect, the plurality of decision parameters include at least one of a number of newly added hot functions and classes of the application from a last compilation to the current compilation, a total number of hot functions and classes contained in the application at a time when the last compilation is completed, a size of an oat file generated by the last compilation, a type of the compilation optimization performed last time, a number of classes contained in an application APK, a number of methods contained in the application APK, and an execution time of the last compilation.

[0009] In some implementations of the first aspect, determining the target compilation optimization scheme for the compilation optimization based on the plurality of decision parameters includes inputting the plurality of decision parameters into a compilation decision model to determine the target compilation optimization scheme for the compilation optimization.

[0010] In some implementations of the first aspect, the plurality of decision parameters include at least one of a number of newly added hot functions and classes of the application from a last compilation to the current compilation, a total number of hot functions and classes contained in the application at a time when the last compilation is completed, a size of an oat file generated by the last compilation, a type of the compilation optimization performed last time, a number of classes contained in an application APK, a number of methods contained in the application APK, and an execution time of the last compilation.

[0011] In some implementations of the first aspect, determining the target compilation optimization scheme for the compilation optimization based on the plurality of decision parameters includes inputting the plurality of decision parameters into a compilation decision model to determine the target compilation optimization scheme for the compilation optimization.

[0012] In the implementation, if the quantization result output by the compilation decision model is greater than a preset threshold (such as 80 points), it is determined that the change range between the current compilation and the last compilation is small, and the incremental compilation optimization scheme is suitable; if the quantization result output by the compilation decision model is not greater than the preset threshold, it is determined that the change range between the current compilation and the last compilation is large, and the full-amount compilation optimization scheme is suitable. Thus, the electronic device determines the target compilation optimization scheme to be used by the output result of the compilation decision model, to optimize the execution time of the compilation optimization.

[0013] With reference to the first aspect, in some implementations of the first aspect, the inputting the plurality of decision parameters into the compilation decision model and determining the target compilation optimization scheme to be used for the compilation optimization comprises: inputting the plurality of decision parameters into the compilation decision model, performing weighted calculation through the weight coefficients corresponding to the plurality of decision parameters, to obtain a first predicted time consumption corresponding to the execution of the full-amount compilation optimization scheme and a second predicted time consumption corresponding to the execution of the incremental compilation optimization scheme; in the case that the first predicted time consumption is less than the second predicted time consumption, taking the full-amount compilation optimization scheme as the target compilation optimization scheme; in the case that the first predicted time consumption is not less than the second predicted time consumption, taking the incremental compilation optimization scheme as the target compilation optimization scheme.

[0014] In the implementation, the first predicted time consumption corresponding to the execution of the full-amount compilation optimization scheme and the second predicted time consumption corresponding to the execution of the incremental compilation optimization scheme can be respectively predicted through the compilation decision model, and then the first predicted time consumption and the second predicted time consumption are compared, and the compilation optimization scheme with shorter time consumption is taken as the target compilation optimization scheme. Thus, the electronic device can optimize the execution time of the compilation optimization.

[0015] With reference to the first aspect, in some implementations of the first aspect, the weight coefficient corresponding to the first decision parameter in the plurality of decision parameters is greater than the weight coefficient corresponding to the second decision parameter; the first decision parameter comprises the number of newly added hot functions and classes of the application from the last compilation to the current compilation, and the size of the oat file generated by the last compilation; and the second decision parameter comprises the total number of hot functions and classes contained in the application at the time of the last compilation, the type of the last executed compilation optimization, the number of classes contained in the application APK, the number of methods contained in the application APK, and the execution time of the last compilation.

[0016] In the plurality of decision parameters, the plurality of decision parameters can be divided into core parameters and auxiliary parameters based on the influence degree of the decision parameters on the execution time of the compilation optimization, and the weight coefficient corresponding to the decision parameter as the core parameter is greater than the weight coefficient corresponding to the decision parameter as the auxiliary parameter. For example, the first decision parameter in the implementation manner is the core parameter, the second decision parameter is the auxiliary parameter, and the weight coefficient corresponding to the first decision parameter is greater than the weight coefficient corresponding to the second decision parameter. Thus, by dividing the influence degree of the decision parameters and adaptively assigning the corresponding weight coefficients, the accuracy of the determined target compilation optimization scheme can be improved.

[0017] In combination with the first aspect, in some implementation manners of the first aspect, the triggering of the compilation optimization of the application includes: triggering the compilation optimization of the application in a case where the electronic device is in an idle state.

[0018] The condition of triggering the compilation optimization can be that the electronic device is in an idle state, for example, the electronic device is in a charging state and the screen is off for half an hour, or the electronic device is in a charging state and the screen is off for half an hour and the battery power is greater than 95%, and the like. The compilation optimization is performed in the idle state, which can greatly reduce the influence on the operation of the electronic device, that is, reduce the running power consumption, and further improve the running performance.

[0019] In combination with the first aspect, in some implementation manners of the first aspect, the compilation optimization based on the target compilation optimization scheme includes: in a case where the target compilation optimization scheme is an incremental compilation optimization scheme, compiling the hotspot function newly added to the application from the last compilation to the current compilation to obtain an oat file, merging the oat file with the oat file obtained by the last compilation to generate a new oat file; and in a case where the target compilation optimization scheme is a full-amount compilation optimization scheme, compiling all the hotspot functions included in the application to generate a new oat file.

[0020] In general, after the electronic device determines whether to execute the full-amount compilation optimization scheme or the incremental compilation optimization scheme, the virtual machine can be called to execute the corresponding compilation optimization scheme. In a case where the full-amount compilation optimization scheme is executed, the virtual machine needs to recompile all the hotspot functions corresponding to the application, and the compilation result is integrated into a new oat file to replace the oat file obtained by the last compilation. In a case where the incremental compilation optimization scheme is executed, the virtual machine needs to compile the hotspot function newly added to the application from the last compilation to the current compilation, and the compilation result obtains an oat file. Then, the oat file obtained by the last compilation is loaded, and the two oat files are merged to generate a new oat file. Thus, the electronic device can implement a dynamic compilation optimization scheme to optimize the compilation time and improve the running performance of the electronic device.

[0021] In some implementations of the first aspect, the electronic device includes a compilation parameter collection module, an execution module, a big data framework, a performance analysis module, an oat file generation module, and a compilation file module. The obtaining of the plurality of decision parameters includes: the compilation parameter collection module sending an obtaining instruction of a compilation parameter to the execution module and sending an obtaining instruction of an execution time of a last compilation to the big data framework, the plurality of decision parameters including the compilation parameter and the execution time of the last compilation; the execution module sending a first instruction to the performance analysis module to obtain a total number of hot functions and classes included in the application at the time of the last compilation; the execution module sending a second instruction to the performance analysis module to obtain a number of newly added hot functions and classes of the application during a period from the last compilation to the present compilation; the execution module sending a third instruction to the oat file generation module to obtain a size of an oat file generated by the last compilation; the execution module sending a fourth instruction to the oat file generation module to obtain a compilation optimization type of the last execution; the execution module sending a fifth instruction to the compilation file module to obtain a number of classes and methods included in an APK of the application; the execution module returning the obtained compilation parameter to the compilation parameter collection module; and the big data framework sending the execution time of the last compilation to the compilation parameter collection module.

[0022] In some implementations of the first aspect, the electronic device further includes a compilation decision module, and the determining of a target compilation optimization scheme for the compilation optimization based on the plurality of decision parameters includes: the compilation parameter collection module sending the plurality of decision parameters to the compilation decision module; and the compilation decision module determining the target compilation optimization scheme for the compilation optimization based on the plurality of decision parameters.

[0023] In the above implementations, the electronic device can divide a plurality of processing modules, and the compilation parameter collection module (dexopter module) collects compilation parameters from the performance analysis module (‌profman module), the oat file generation module (oat_file_assistant module), and the compilation file module (dexfile module) through the execution module (artd module), and can also collect an execution time of a last compilation from the big data framework. Then, the compilation parameter collection module sends the collected decision parameters to the compilation decision module to determine a compilation optimization scheme for the present compilation, so as to improve the running performance of the electronic device.

[0024] In a second aspect, the present application provides an apparatus, which is included in an electronic device, and the apparatus has functions to implement the above-mentioned first aspect and the behaviors of the electronic device in the possible implementation manners of the above-mentioned first aspect. The functions can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above-mentioned functions. For example, a receiving module or unit, a processing module or unit, and the like.

[0025] In a third aspect, the present application provides an electronic device, which includes one or more processors, and a memory; The memory is coupled to the one or more processors, and the memory is configured to store computer program codes, the computer program codes including computer instructions, and the one or more processors are configured to invoke the computer instructions to cause the electronic device to perform any of the methods in the first aspect.

[0026] In a fourth aspect, the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are configured to invoke computer instructions to cause the electronic device to perform the methods in the first aspect and any of the possible implementation manners thereof.

[0027] Optionally, the chip system further includes a memory, and the memory is connected to the processor through a circuit or a wire.

[0028] Further optionally, the chip system further includes a communication interface.

[0029] In a fifth aspect, the present application provides a computer-readable storage medium, which includes instructions, and when the instructions are run on an electronic device, the instructions cause the electronic device to perform any of the methods in the first aspect.

[0030] In a sixth aspect, the present application provides a computer program product, which includes computer program codes, and when the computer program codes are run on an electronic device, the computer program codes cause the electronic device to perform any of the methods in the first aspect. BRIEF DESCRIPTION OF DRAWINGS

[0031] Figure 1 is a schematic diagram of an overall process of an electronic device performing a compilation optimization provided by an embodiment of the present application; Figure 2 is a schematic diagram of a structure of an electronic device provided by an embodiment of the present application; Figure 3 is a software structure block diagram of an electronic device provided by an embodiment of the present application; Figure 4 is a signaling interaction flowchart of a compilation optimization method provided by an embodiment of the present application; Figure 5 is an example of a correspondence between multiple decision parameters and different weight coefficients provided by an embodiment of the present application; Figure 6 is a flowchart of a compilation optimization method provided by an embodiment of the present application. DETAILED DESCRIPTION

[0032] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, “ / ” represents or, for example, A / B can represent A or B; “and / or” in this document only describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent three cases of A alone, A and B together, and B alone. In addition, in the description of the embodiments of the present application, “multiple” means two or more than two.

[0033] Hereinafter, the terms “first”, “second”, “third” are only used for description purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with “first”, “second”, “third” can explicitly or implicitly include one or more of the features.

[0034] In order to make the following embodiments clear and simple, first, a brief introduction of related concepts or technologies is given: Interpreted execution: a programming language execution mode that translates source code line by line into machine code and executes immediately. The language of interpreted execution needs to be translated into code at runtime, which means that the interpreter needs to read the source code line by line and convert it into instructions that electronic devices can recognize at runtime.

[0035] Just-in-time compilation (JIT): a compilation mode that translates bytecode into machine code and executes immediately at runtime. During program execution, hot functions are calculated according to the algorithm, and then real-time compilation is performed, which requires runtime resources and can cause process lag.

[0036] Ahead-of-time compilation (AOT): opposite to JIT compilation, it is a compilation mode that converts bytecode into machine code before program execution, which can improve runtime efficiency.

[0037] dex2oat (dalvik excutable file to optimized art file): a program for compiling and optimizing dex files, used to convert the bytecode of dex files into native executable machine code. The storage location in an Android device is / system / bin / dex2oat, and the corresponding process after startup is dex2oat.

[0038] dex file: a Dalvik bytecode file, an executable file that can be recognized by the virtual machine in an electronic device.

[0039] oat file: a file generated after dex files are compiled and optimized based on dex2oat, storing executable machine code.

[0040] profile file: a configuration file recording the index information of hot functions and classes in the compilation and optimization process of an electronic device, which can be continuously updated.

[0041] With the continuous optimization of electronic technology, electronic devices will perform application upgrades or optimizations at irregular intervals. In general, after application upgrades or optimizations, recompilation is required for normal operation.

[0042] Compilation refers to the process of generating a target program from a source program written in a source language using a compiler. It can be the process of translating a program written in a certain programming language into an equivalent program in another language. Generally, the Android application package (APK) and JAR (Java archive) package downloaded in electronic devices (such as mobile phones running the Android system) are written based on the Java language. If you want to run these program packages on an electronic device, you need to compile them and convert them into a language that the electronic device can recognize. When Java language code is compiled into an APK, it is simply translated into bytecode that runs across platforms. This bytecode can be stored in a dex file and can be recognized by the virtual machine (Android runtime, ART) in different platforms (or electronic devices). However, after the virtual machine recognizes it, the bytecode needs to be compiled into platform-adapted machine code according to the platform on which the virtual machine runs, so that it can be executed by the central processing unit (CPU).

[0043] For the early compilation process, after the Java language code is translated into bytecode, the virtual machine compiles the bytecode, which adopts JIT compilation or interpretation execution, that is, the bytecode is translated into machine code at runtime and then executed by the CPU, and the operation of translating bytecode into machine code is required every time at runtime, which undoubtedly increases the compilation power consumption and the application running lag phenomenon caused by compilation. To solve this problem, the developers developed the AOT compilation optimization method, that is, the bytecode of the frequently used functions (or hot functions) in APK is translated into machine code in advance and stored, for example, stored as an oat file, for use next time the application runs, thereby reducing the compilation amount and compilation power consumption and improving the running efficiency. As shown in Figure 1 illustrated, in the compilation phase, for the bytecode translated after the Java language code, if there is an oat file corresponding to the compilation optimization, the CPU can directly execute it, and if there is no corresponding oat file, the virtual machine needs to compile the bytecode by JIT.

[0044] The currently adopted compilation optimization method can be the optimization operation of background compilation by the virtual machine in the idle scene during daily operation, that is, when the electronic device is in an idle state, for example, the electronic device is in a charging state and the screen is off for half an hour, the hot functions in the profile file are compiled, and the compilation result (oat file) is stored for subsequent execution of the functions directly, here the virtual machine can adopt the dex2oat mechanism during the background compilation. It can be understood that the hot functions in the profile file can be the functions frequently executed during the application running.

[0045] In the related art, the background compilation optimization performed by the electronic device in the idle scenario is usually to recompile all the hotspot functions corresponding to the application, and replace the oat file generated by the last compilation. This compilation optimization method can also be referred to as a full compilation optimization scheme. However, as the use time of the application increases, the number of hotspot functions executed also increases, and the number of hotspot functions that need to be compiled increases, which leads to longer compilation optimization time of the electronic device, affecting the running performance of the electronic device. Based on this, the developers also proposed an incremental compilation optimization scheme, that is, in the compilation optimization stage, only the newly added hotspot functions of the application from the last compilation to the current compilation are compiled, and then the compilation result (oat file) is merged with the oat file of the last compilation, thereby reducing the number of hotspot functions in each compilation optimization, to reduce the compilation optimization time. However, the incremental compilation optimization scheme still has some problems. Although it can reduce the number of hotspot functions in the compilation optimization, it increases the time of loading the oat file of the last compilation before compilation and the time of merging the oat file of the current compilation with the oat file of the last compilation. If the size of the oat file continues to increase, the loading time and the merging time will also continue to increase, and the corresponding compilation time will also become longer.

[0046] Therefore, the embodiment of the present application provides a compilation optimization method. When the compilation optimization is triggered, the execution time of the full compilation optimization scheme and the incremental compilation optimization scheme in the idle scenario can be evaluated, and the compilation optimization scheme with shorter execution time is selected to perform the compilation optimization task, so as to optimize the compilation time and improve the running performance of the electronic device. It should be noted that the compilation optimization method provided by the embodiment of the present application can be applied to mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, notebook computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA) and other electronic devices that can perform compilation optimization. The embodiment of the present application does not limit the specific type of the electronic device.

[0047] For example, Figure 2Fig. 1 is a structural schematic diagram of an electronic device 100 provided by an embodiment of the present application. Taking the electronic device 100 as a mobile phone for example, the electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identity module (SIM) card interface 195, etc. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric 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, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0048] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units can be independent devices or integrated in one or more processors.

[0049] The charging management module 140 is configured to receive charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input through a wireless charging coil of the electronic device 100. The charging management module 140 can charge the battery 142 and supply power to the electronic device through the power management module 141.

[0050] The power management module 141 is configured to connect the battery 142 and the charging management module 140 to the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160, etc. The power management module 141 can also be configured to monitor parameters such as the battery capacity, the number of battery cycles, the battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 can also be disposed in the same device.

[0051] The wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, etc.

[0052] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc. applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrated with at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive signals to be sent from the processor 110, perform frequency modulation, amplification, and convert them into electromagnetic wave radiation via the antenna 2.

[0053] The electronic device 100 implements the display function by the GPU, the display 194, and the application processor, etc. The GPU is a microprocessor for image processing, connected to the display 194 and the application processor. The GPU is configured to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs that execute program instructions to generate or change display information.

[0054] The display screen 194 is configured to display images, videos, and the like. The 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 flex light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light emitting diodes (QLED), or the like. In some embodiments, the electronic device 100 can include one or N display screens 194, where N is a positive integer greater than 1.

[0055] The camera 193 is configured to capture still images or videos. An object generates an optical image through a lens and projects the optical image to a photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to an ISP to convert the electrical signal into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into an image signal in a standard format, such as RGB, YUV, or the like. In some embodiments, the electronic device 100 can include one or N cameras 193, where N is a positive integer greater than 1.

[0056] The NPU is a neural-network (NN) computing processor that is configured to quickly process input information by imitating the structure of a biological neural network, such as the transmission mode between neurons in the human brain, and is also configured to continuously self-learn. Through the NPU, the electronic device 100 can implement intelligent cognitive applications, such as image recognition, face recognition, voice recognition, text understanding, and the like.

[0057] The internal memory 121 can be used to store computer executable program codes, the executable program codes including instructions. The processor 110 performs various function applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. The program storage area can store an operating system, application programs required by at least one function (such as a sound playing function, an image playing function, etc.), and the like. The data storage area can store data (such as audio data, a phone book, etc.) created during use of the electronic device 100, and the like. In addition, the internal memory 121 can include a high-speed random access memory, and can further include a non-volatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.

[0058] The fingerprint sensor 180H is used to collect a fingerprint. The electronic device 100 can implement fingerprint unlocking, access to an application lock, fingerprint photographing, fingerprint answering a call, and the like by using the collected fingerprint characteristics.

[0059] The touch sensor 180K, also referred to as a “touch panel”. The touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also referred to as a “touch panel”. The touch sensor 180K is used to detect a touch operation acting on or near the touch sensor 180K. The touch sensor 180K can transmit the detected touch operation to the application processor to determine a touch event type. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0060] The keys 190 include a power-on key, a volume key, and the like. The keys 190 can be mechanical keys. They can also be touch keys. The electronic device 100 can receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.

[0061] The indicator 192 can be an indicator light, which can be used to indicate a charging state, a power change, and can also be used to indicate a message, a missed call, a notification, and the like.

[0062] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than illustrated, or combine certain components, or split certain components, or different component arrangements. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.

[0063] The software system of the electronic device 100 can employ a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. Embodiments of the present application take an Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100.

[0064] Figure 3 is a software structure block diagram of the electronic device 100 of embodiments of the present application. The layered architecture divides the software into several layers, each of which has a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the local service layer, and the kernel layer.

[0065] The application layer can include a series of application packages. As shown in Figure 3 , the application packages can include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, and other applications.

[0066] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications of the application layer. The application framework layer includes some pre-defined functions.

[0067] As shown in Figure 3 , the application framework layer can include a big data framework, a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0068] The big data framework is used to count the execution time of each compilation optimization.

[0069] The window manager is used to manage windows programs. The window manager can acquire the display screen size, determine whether there is a status bar, lock the screen, intercept the screen, etc. The content provider is used to store and acquire data, and make the data accessible to the application program. The data can include video, image, audio, dialed and received phone, browsing history and bookmark, phone book, etc. The view system includes visual controls, such as a control for displaying text, a control for displaying pictures, etc. The view system can be used to build an application program. The display interface can be composed of one or more views. For example, a display interface including a short message notification icon can include a view for displaying text and a view for displaying pictures. The phone manager is used to provide the communication function of the electronic device 100. For example, the management of the call state (including connection, hang-up, etc.). The resource manager provides various resources for the application program, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables the application program to display notification information in the status bar, which can be used to convey the type of message, which can automatically disappear after a short stay, without user interaction. For example, the notification manager is used to inform the completion of the download, message reminder, etc. The notification manager can also be a notification in the form of a chart or a scroll bar text appearing in the top status bar of the system, such as the notification of the application program running in the background, and can also be a notification in the form of a dialogue window appearing on the screen.

[0070] The native layer includes a core library and a virtual machine. The core library includes two parts: one part is the function function required to be called by the java language, and the other part is the core library of Android.

[0071] The application program layer and the application program framework layer run in the virtual machine. The virtual machine executes the java file of the application program layer and the application program framework layer into a binary file. The virtual machine is used to perform the management of the object life cycle, the management of the stack, the management of the thread, the management of the security and the exception, and the garbage collection, etc.

[0072] The virtual machine can include a compilation parameter collection module, a compilation decision module, an execution module, a performance analysis module, an oat file generation module and a compilation file module.

[0073] Wherein, when the electronic device is ready to perform the compilation optimization, the compilation parameter collection module (dexopter module) can collect the compilation parameters from the performance analysis module (‌profman module), the oat file generation module (oat_file_assistant module) and the compilation file module (dexfile module) by executing the module (artd module), and can also collect the execution time of the last compilation from the above-mentioned big data framework, and these compilation parameters usually have a greater impact on the execution time of the compilation optimization. After the compilation parameter collection module collects the compilation parameters, the compilation parameters are passed to the compilation decision module for determining the compilation optimization scheme adopted this time. The performance analysis module (‌profman module) described above is mainly responsible for performance analysis and optimization, and the core functions include monitoring the running performance of the application, collecting runtime data and adjusting the optimization strategy according to the data, etc. The compilation parameters that can be provided include the number of hot functions and classes, including the number of hot functions and classes added by the application from the last compilation to the present compilation, and the total number of hot functions and classes contained by the application when the last compilation is completed. The oat file generation module (oat_file_assistant module) is the core module responsible for handling oat file generation in the virtual machine runtime, and is mainly used for generating oat files, updating oat files and handling dex2oat conversion, etc. The compilation parameters that can be provided include the oat file size generated by the last compilation and the last execution compilation optimization type (full compilation optimization or incremental compilation optimization). The compilation file module (dexfile module) can provide the compilation parameters including the number of classes (class) and methods (method) contained in the application APK.

[0074] The kernel layer is the layer between hardware and software. The kernel layer at least contains display driver, camera driver, audio driver and sensor driver.

[0075] For ease of understanding, the following embodiments of the present application will take an electronic device with the structure shown in Figure 2 and Figure 3 as an example, and the compilation optimization method provided by the embodiments of the present application will be specifically described in combination with the drawings and application scenarios.

[0076] Figure 4 is a signaling interaction flow diagram of an example of the compilation optimization method provided by the embodiments of the present application, applied to the software architecture shown in Figure 3 , the method comprises: S11, in the case of triggering to start the compilation optimization of the application, the dexopter module sends an acquisition instruction of the compilation parameter to the artd module.

[0077] S12, the dexopter module sends an acquisition instruction of the execution time of the last compilation to the big data framework.

[0078] The condition triggering the start of the compiling optimization of the application can be that the electronic device is in an idle state, for example, the electronic device is in a charging state and the screen is off for half an hour, or the electronic device is in a charging state and the screen is off for half an hour and the battery power is greater than 95%, and the like. In the embodiment of the present application, in the case of triggering the start of the compiling optimization, the electronic device will first collect the compiling parameters and the execution time of the last compilation through the dexopter module. For the convenience of description, the compiling parameters and the execution time of the last compilation can be collectively referred to as decision parameters.

[0079] S13, the artd module obtains the corresponding compiling parameters from each module.

[0080] S14, the artd module returns the compiling parameters to the dexopter module.

[0081] S15, the big data framework returns the execution time of the last compilation to the dexopter module.

[0082] That is to say, after the artd module receives the obtaining instruction of the dexopter module, the corresponding compiling parameters can be obtained from each module related to the compilation, and returned to the dexopter module for subsequent compilation decision. In some implementations, each module can include but is not limited to the performance analysis module (profman module), the oat file generation module (oat_file_assistant module) and the compiling file module (dexfile module). At the same time, the big data framework can query the execution time of the last compilation and return it to the dexopter module. Here, the dexopter module can send an obtaining instruction of the execution time of the last compilation to the big data framework through the getCompileTime interface, and the execution time of the last compilation returned by the big data framework can be recorded as last_compilation_time.

[0083] In some embodiments, the decision parameters can include but are not limited to the number of newly added hot functions and classes of the application from the last compilation to the present compilation, the total number of hot functions and classes contained in the application at the time of the last compilation, the size of the oat file generated by the last compilation, the type of the last executed compiling optimization, the number of classes contained in the application APK, the number of methods contained in the application APK, and the execution time of the last compilation. For these decision parameters, the electronic device can add a stub point in multiple modules in the virtual machine, and obtain through the corresponding interface, for example, the dexopter module can send an obtaining instruction to the artd module through different calling interfaces.

[0084] Specifically, continuing to refer to Figure 4The dexopter module sends a first instruction to the artd module to obtain the total number of hot functions and classes contained in the application at the time of the last compilation in S111, which can include the processes of S1111-S1115. S1111, the dexopter module sends a first instruction to the artd module to obtain the index information of the hot functions and classes contained in the application at the time of the last compilation.

[0085] The index information of the hot functions and classes contained in the application at the time of the last compilation can be recorded in the Ref-profile file, and the dexopter module can call the getOrInitReferenceProfile interface to send the first instruction to the artd module to obtain the total number of hot functions and classes contained in the application at the time of the last compilation from the Ref-profile file.

[0086] S112, the dexopter module sends a second instruction to the artd module to obtain the number of newly added hot functions and classes in the application from the last compilation to the current compilation.

[0087] The index information of the hot functions and classes newly added in the application from the last compilation to the current compilation can be recorded in the Cur-profile file, and the dexopter module can call the mergeProfilesToIncrementProfile interface to send the second instruction to the artd module to obtain the number of newly added hot functions and classes in the application from the last compilation to the current compilation from the Cur-profile file.

[0088] S113, the dexopter module sends a third instruction to the artd module to obtain the size of the oat file generated by the last compilation.

[0089] The dexopter module can call the getOatInfo interface to send the third instruction to the artd module to obtain the size of the oat file generated by the last compilation.

[0090] S114, the dexopter module sends a fourth instruction to the artd module to obtain the type of the last executed compilation optimization.

[0091] The dexopter module can call the getBsetInfo interface to send the fourth instruction to the artd module to obtain the type of the last executed compilation optimization.

[0092] S115, the dexopter module sends a fifth instruction to the artd module to obtain the number of classes and methods contained in the application APK.

[0093] The dexopter module can call the getDexInfo interface to send the fifth instruction to the artd module to obtain the number of classes and methods contained in the application APK.

[0094] After the artd module receives the above instruction, the artd module can send an obtaining instruction to the corresponding module to obtain the corresponding compilation parameter. Specifically, continuing to refer to Figure 4 , the artd module obtains the corresponding compilation parameter from each module in S13 can include the processes of S131-S140: S131, the artd module sends a first instruction to the profman module.

[0095] S132, the profman module returns the total number of hot functions and classes contained in the application when the last compilation is completed to the artd module.

[0096] The artd module can call the ProcessProfiles interface to send the first instruction to the profman module to obtain the total number of hot functions and classes contained in the application when the last compilation is completed. The total number of hot functions contained in the application when the last compilation is completed can be denoted as num_of_method_in_ref_prof, and the total number of classes contained in the application when the last compilation is completed can be denoted as num_of_class_in_ref_prof.

[0097] S133, the artd module sends a second instruction to the profman module.

[0098] S134, the profman module returns the number of newly added hot functions and classes of the application from the last compilation to the current compilation to the artd module.

[0099] The artd module can also call the ProcessProfiles interface to send the second instruction to the profman module to obtain the number of newly added hot functions and classes of the application from the last compilation to the current compilation. The number of newly added hot functions of the application from the last compilation to the current compilation can be denoted as num_of_method_in_cur_prof, and the number of newly added classes of the application from the last compilation to the current compilation can be denoted as num_of_class_in_cur_prof.

[0100] S135, the artd module sends a third instruction to the oat_file_assistant module.

[0101] S136, the oat_file_assistant module returns the size of the oat file generated by the last compilation to the artd module.

[0102] The artd module can call the GetOptimizationStatus interface to send a third instruction to the oat_file_assistant module to obtain the size of the oat file generated by the last compilation, and the size of the oat file generated by the last compilation can include size_of_origin_odex and size_of_origin_art.

[0103] S137, the artd module sends a fourth instruction to the oat_file_assistant module.

[0104] S138, the oat_file_assistant module returns the type of the last executed compilation optimization to the artd module.

[0105] The artd module can call the getBestInfo interface to send a fourth instruction to the oat_file_assistant module to obtain the type of the last executed compilation optimization, and the type of the last executed compilation optimization can be denoted as last_compilation_type.

[0106] S139, the artd module sends a fifth instruction to the dexfile module.

[0107] S140, the dexfile module returns the number of classes and methods contained in the application APK to the artd module.

[0108] The artd module can call the NumClassDefs interface and the NumMethodIds interface to send a fifth instruction to the dexfile module to obtain the number of classes and methods contained in the application APK, and the number of classes contained in the application APK can be denoted as num_of_class_in_apk, and the number of methods contained in the application APK can be denoted as num_of_method_in_apk.

[0109] After the above process, the dexopter module can collect various decision parameters, and then the dexopter module can execute the steps of S15 described below. It can be understood that the electronic device can collect the corresponding decision parameters in each idle scene for big data analysis and other operation and maintenance needs.

[0110] S16, the dexopter module sends the various decision parameters to the compilation decision module.

[0111] S17, the compiling decision module determines the target compiling optimization scheme to be used in the current compiling based on the decision parameters.

[0112] That is, the dexopter module passes the collected decision parameters to the compiling decision module, and the compiling decision module determines which compiling optimization scheme to be executed, for example, whether to execute the full-amount compiling optimization scheme or the incremental compiling optimization scheme.

[0113] In some implementations, the compiling decision module can analyze the decision parameters based on a compiling decision model to determine the target compiling optimization scheme to be used in the current compiling. The compiling decision model herein includes the mapping relationship between different decision parameters and different types of compiling optimization schemes, and different decision parameters correspond to different weight coefficients. As a realizable way, the compiling decision module inputs the obtained decision parameters into the compiling decision model, and performs weighted calculation on the decision parameters through different weight coefficients, so as to obtain a quantitative result, for example, a comprehensive score. If the quantitative result is greater than a preset threshold (such as 80 points), it is determined that the change range between the current compiling and the last compiling is small, and the incremental compiling optimization scheme is suitable. If the quantitative result is not greater than the preset threshold, it is determined that the change range between the current compiling and the last compiling is large, and the full-amount compiling optimization scheme is suitable. As another realizable way, the compiling decision module inputs the obtained decision parameters into the compiling decision model, and performs weighted calculation on the decision parameters through different weight coefficients, so as to obtain a first predicted time consumption corresponding to the execution of the full-amount compiling optimization scheme and a second predicted time consumption corresponding to the execution of the incremental compiling optimization scheme. The compiling optimization scheme with shorter time consumption is determined as the target compiling optimization scheme by comparing the first predicted time consumption and the second predicted time consumption. In this implementation, the compiling decision model can also directly output the true value type of the judgment result, for example, true or false, true indicating the execution of the incremental compiling optimization scheme and false indicating the execution of the full-amount compiling optimization scheme.

[0114] For the compilation decision model, when determining the respective weight coefficients, the decision parameters of the full-quantity compilation optimization scheme and the incremental compilation optimization scheme when performing the same for different applications can be systematically collected and analyzed, and a curve fitting method can be used to determine the weight coefficients of the respective decision parameters. Among them, the number of newly added hotspot functions and classes of the application from the last compilation to the present compilation, the total number of hotspot functions and classes contained by the application when the last compilation is completed, the size of the oat file generated by the last compilation, the type of the last executed compilation optimization, the number of classes contained in the application APK, the number of methods contained in the application APK, and the execution time of the last compilation, and other decision parameters, by analyzing the role of each parameter and other factors, it can be determined which decision parameters are the core parameters affecting the compilation execution time, which decision parameters are the auxiliary parameters affecting the compilation execution time, and then the corresponding weight coefficients are determined. For example, the number of newly added hotspot functions and classes of the application from the last compilation to the present compilation can reflect the size of the current runtime hotspot code of the application, and has a greater impact on the compilation execution time, and can be determined as a core parameter; the size of the oat file generated by the last compilation can reflect the size of the last compilation result, and can be used to evaluate the change range of the compilation execution time, for example, the larger the file, the larger the compilation size, and the longer the loading time, which can be determined as a core parameter; the total number of hotspot functions and classes contained by the application when the last compilation is completed is used to compare the difference between the last compilation configuration and the present compilation configuration, which can be determined as an auxiliary parameter; the number of classes and methods contained in the application APK is used to reflect the size of the application code structure and the size of the method quantity, which can be determined as an auxiliary parameter; the execution time of the last compilation is used to evaluate the trend of the increase and decrease of the compilation time, which can be determined as an auxiliary parameter; the type of the last executed compilation optimization is used to record the historical compilation mode, which assists the compilation decision module in making decisions, which can be determined as an auxiliary parameter.

[0115] After the core role or auxiliary role of each decision parameter is determined, the compilation decision module can assign weight coefficients to each decision parameter. In some implementations, the weight coefficient corresponding to the decision parameter as a core parameter is greater than the weight coefficient corresponding to the decision parameter as an auxiliary parameter. For example, as shown in FIG. 6, the weight coefficient of the number of newly added hotspot functions and classes of the application from the last compilation to the present compilation is 0.4, which is greater than the weight coefficient of the total number of hotspot functions and classes contained by the application when the last compilation is completed, which is 0.2. The weight coefficient of the size of the oat file generated by the last compilation is 0.2, which is greater than the weight coefficient of the type of the last executed compilation optimization, which is 0.1. The weight coefficient of the number of classes contained in the application APK is 0.1, which is greater than the weight coefficient of the number of methods contained in the application APK, which is 0.05. The weight coefficient of the execution time of the last compilation is 0.1, which is greater than the weight coefficient of the number of classes contained in the application APK, which is 0.05. Figure 5As shown, the weight coefficient of num_of_method_in_cur_prof is a%, the weight coefficient of num_of_class_in_cur_prof is b%, the weight coefficient of size_of_origin_odex is c%, the weight coefficient of size_of_origin_art is d%, the weight coefficient of num_of_class_in_ref_prof is e%, the weight coefficient of num_of_method_in_ref_prof is f%, the weight coefficient of num_of_method_in_apk is g%, the weight coefficient of num_of_class_in_apk is h%, the weight coefficient of last_compilation_time is m%, and the weight coefficient of last_compilation_type is n%. The four weight coefficients a, b, c, and d can be greater than the other weight coefficients.

[0116] In some implementations, as the number of compilations increases, the related data of performing the compilation optimization can change, and the influence of each decision module on the compilation optimization can also change. In this case, the corresponding weight coefficients can be adaptively updated to adapt to the real-time needs of the compilation optimization.

[0117] After determining whether to perform the full-amount compilation optimization scheme or the incremental compilation optimization scheme based on the above process, the compilation decision module can send the determination result to the virtual machine for the virtual machine to perform the corresponding compilation optimization scheme. In the case of performing the full-amount compilation optimization scheme, the virtual machine needs to recompile all the hot functions of the application, and the compilation result is combined into a new oat file to replace the oat file obtained by the last compilation. In the case of performing the incremental compilation optimization scheme, the virtual machine needs to compile the newly added hot functions of the application from the last compilation to the current compilation, and the compilation result is an oat file. Then, the oat file obtained by the last compilation is loaded, and the two oat files are merged to generate a new oat file.

[0118] The compilation optimization method provided by the embodiments of the present application can be used for the electronic device to obtain multiple decision parameters affecting the compilation time when evaluating the idle scenario, analyze and evaluate based on the decision parameters, determine whether to perform the full-amount compilation optimization scheme or the incremental compilation optimization scheme, greatly reduce the execution time of the compilation optimization, and improve the running performance and resource utilization of the electronic device.

[0119] Based on the process of the above embodiments, Figure 6 A flowchart of a compilation optimization method is also provided, which is applied to an electronic device. The method includes the following steps. S101, in a case where a compilation optimization of an application is triggered to start, a plurality of decision parameters are acquired.

[0120] The condition of triggering the compilation optimization to start can be that the electronic device is in an idle state, and in the case where the compilation optimization is triggered to start, the electronic device starts to collect the plurality of decision parameters. It can be understood that the plurality of decision parameters have a certain degree of influence on the execution time of the compilation optimization of the electronic device, including but not limited to the number of newly added hot functions and classes during the application from the last compilation to the present compilation, the total number of hot functions and classes contained by the application at the time of the last compilation, the size of the oat file generated by the last compilation, the type of the last executed compilation optimization, the number of classes contained in the application APK, the number of methods contained in the application APK, and the execution time of the last compilation.

[0121] S102, based on the plurality of decision parameters, a target compilation optimization scheme adopted by the present compilation is determined.

[0122] That is, the electronic device can determine whether to execute a full-amount compilation optimization scheme or an incremental compilation optimization scheme based on the plurality of decision parameters. It can be understood that the process of determining the target compilation optimization scheme can refer to the description of the above embodiments, which will not be described here.

[0123] Exemplarily, it is assumed that the execution time of the last compilation is 10 minutes, the type of the compilation optimization is a full-amount compilation optimization scheme, the total number of hot functions and classes contained at the time of the compilation completion is 100, the number of newly added hot functions and classes during the application from the last compilation to the present compilation is 10, and the estimated time of loading the oat file generated by the last compilation and the time of merging the file is 5 minutes. Then, in the estimation of the present compilation, if the full-amount compilation optimization scheme is adopted, the execution time is about 11 minutes, and if the incremental compilation optimization scheme is adopted, the execution time is about 6 minutes, and the execution time of the incremental compilation optimization scheme is shorter, so the target compilation optimization scheme can be the incremental compilation optimization scheme.

[0124] S103, based on the target compilation optimization scheme, a compilation optimization is performed.

[0125] After the electronic device determines the target compilation optimization scheme, the compilation optimization can be started in the background. During the compilation optimization, the electronic device can continue to record the generated decision parameters for reference in the next compilation.

[0126] In some embodiments, the electronic device performs the above-mentioned compilation optimization method in an idle state, and if the electronic device changes from the idle state to a working state, the compilation optimization process can be paused, the progress of the compilation is recorded, and the compilation optimization is continued when the electronic device enters the idle state again, so as to reduce the processing power consumption of the electronic device.

[0127] The above-mentioned compilation optimization method, when the electronic device evaluates the idle scene to perform the compilation optimization, can obtain multiple decision parameters affecting the compilation time, determine whether to perform the full-amount compilation optimization scheme or the incremental compilation optimization scheme based on the decision parameters, so that the execution time of the compilation optimization is greatly reduced, and the running performance and resource utilization of the electronic device are improved.

[0128] The above describes the examples of the compilation optimization method provided by the embodiments of the present application in detail. It can be understood that the electronic device includes hardware and / or software modules corresponding to the execution of each function in order to implement the above-mentioned functions. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of the examples described in the embodiments disclosed in the present application, the present application can be realized in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered beyond the scope of the present application.

[0129] The embodiments of the present application can divide the functional modules of the electronic device according to the above-mentioned method examples. For example, each functional module such as a detection unit, a processing unit, a display unit, etc. can be divided corresponding to each function, or two or more functions can be integrated in one module. The above-mentioned integrated module can be realized in the form of hardware or software functional module. It should be noted that the division of the modules in the embodiments of the present application is illustrative, and is only a logical functional division. Actual implementation can have another division manner.

[0130] It should be noted that all related contents of each step involved in the above-mentioned method embodiments can be cited to the functional description of the corresponding functional module, which will not be repeated here.

[0131] The electronic device provided by the embodiments of the present application is used to perform the above-mentioned compilation optimization method, and thus can achieve the same effect as the above-mentioned implementation method.

[0132] In the case of using integrated units, the electronic device can further include a processing module, a storage module, and a communication module. The processing module can be used to control and manage the actions of the electronic device. The storage module can be used to support the electronic device to execute the storage of program codes and data, etc. The communication module can be used to support the communication between the electronic device and other devices.

[0133] The processing module can be a processor or a controller. It can implement or execute various exemplary logical blocks, modules, and circuits described in combination with the disclosure of the present application. The processor can also be a combination of computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, and the like. The storage module can be a memory. The communication module can be a device for interacting with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, and the like.

[0134] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in the embodiment can be a device with the structure shown in the figure. Figure 2

[0135] The embodiment of the present application also provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is executed by a processor, the processor executes the compiling optimization method of any one of the above embodiments. The storage medium can include a U disk, a mobile hard disk, a read only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various storage program codes.

[0136] The embodiment of the present application also provides a computer program product, which, when running on a computer, causes the computer to execute the above related steps to implement the compiling optimization method in the above embodiment.

[0137] In addition, the embodiment of the present application also provides a device, which can be a chip, a component or a module. The device can include a processor and a memory connected to each other. The memory is used to store computer execution instructions. When the device is running, the processor can execute the computer execution instructions stored in the memory to make the chip execute the compiling optimization method in the above method embodiments.

[0138] The electronic device, the computer readable storage medium, the computer program product or the chip provided in the embodiment can be used to execute the corresponding method provided above, and thus the beneficial effects achieved thereby can refer to the beneficial effects of the corresponding method provided above, which will not be described here.

[0139] Through the description of the above embodiments, those skilled in the art can understand that, for the convenience and brevity of description, only the division of the above functional modules is taken as an example for illustration. In actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.

[0140] ​In addition, each of the function units in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.

[0141] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method of compilation optimization, the method being performed by an electronic device, the method comprising: The method comprises: In the case of triggering to start the compilation optimization of the application, a plurality of decision parameters related to the execution time of the compilation optimization are obtained; Based on the plurality of decision parameters, a target compilation optimization scheme for performing the compilation optimization is determined, the target compilation optimization scheme comprising a full-amount compilation optimization scheme or an incremental compilation optimization scheme; Based on the target compilation optimization scheme, the compilation optimization is performed.

2. The method of claim 1, wherein, The plurality of decision parameters comprise at least one of the number of hotspot functions and classes newly added to the application from the last compilation to the present compilation, the total number of hotspot functions and classes contained by the application at the time of completing the last compilation, the oat file size generated by the last compilation, the type of the last executed compilation optimization, the number of classes contained in the application APK, the number of methods contained in the application APK, and the execution time of the last compilation.

3. The method of claim 2, wherein, The determination of the target compilation optimization scheme for performing the compilation optimization based on the plurality of decision parameters comprises: The plurality of decision parameters are input into a compilation decision model to determine the target compilation optimization scheme for performing the compilation optimization.

4. The method of claim 3, wherein, The input of the plurality of decision parameters into the compilation decision model to determine the target compilation optimization scheme for performing the compilation optimization comprises: The plurality of decision parameters are input into the compilation decision model, and a weighting calculation is performed through the weight coefficients corresponding to the plurality of decision parameters to obtain a quantization result; In the case that the quantization result is greater than a preset threshold, the incremental compilation optimization scheme is taken as the target compilation optimization scheme; In the case that the quantization result is not greater than the preset threshold, the full-amount compilation optimization scheme is taken as the target compilation optimization scheme.

5. The method of claim 3, wherein, The input of the plurality of decision parameters into the compilation decision model to determine the target compilation optimization scheme for performing the compilation optimization comprises: The plurality of decision parameters are input into the compilation decision model, and a weighting calculation is performed through the weight coefficients corresponding to the plurality of decision parameters to obtain a first predicted time consumption corresponding to the execution of the full-amount compilation optimization scheme and a second predicted time consumption corresponding to the execution of the incremental compilation optimization scheme; In the case that the first predicted time consumption is less than the second predicted time consumption, the full-amount compilation optimization scheme is taken as the target compilation optimization scheme; In the case that the first predicted time consumption is not less than the second predicted time consumption, the incremental compilation optimization scheme is taken as the target compilation optimization scheme.

6. The method according to claim 4 or 5, characterized in that, The weight coefficient corresponding to a first decision parameter in the plurality of decision parameters is greater than the weight coefficient corresponding to a second decision parameter; The first decision parameter comprises the number of hotspot functions and classes newly added to the application from the last compilation to the present compilation and the oat file size generated by the last compilation; The second decision parameter comprises the total number of hotspot functions and classes contained by the application at the time of completing the last compilation, the type of the last executed compilation optimization, the number of classes contained in the application APK, the number of methods contained in the application APK, and the execution time of the last compilation.

7. The method of claim 1, wherein, The triggering to start the compilation optimization of the application comprises: In a case where the electronic device is in an idle state, triggering to start the compilation optimization of the application.

8. The method of claim 1, wherein, The compilation optimization is performed based on the target compilation optimization scheme, including: In a case where the target compilation optimization scheme is the incremental compilation optimization scheme, compiling the hotspot functions newly added to the application from the last compilation to the present compilation, obtaining an oat file, merging the oat file with the oat file obtained from the last compilation, and generating a new oat file; In a case where the target compilation optimization scheme is the full-amount compilation optimization scheme, compiling all the hotspot functions included in the application, and generating a new oat file.

9. The method of claim 1, wherein, The electronic device includes a compilation parameter collection module, an execution module, a big data framework, a performance analysis module, an oat file generation module, and a compilation file module; The obtaining of the plurality of decision parameters includes: The compilation parameter collection module sends a compilation parameter obtaining instruction to the execution module, and sends a last compilation execution time obtaining instruction to the big data framework, and the plurality of decision parameters include the compilation parameter and the last compilation execution time; The execution module sends a first instruction to the performance analysis module to obtain the total number of hotspot functions and classes included in the application when the last compilation is completed; The execution module sends a second instruction to the performance analysis module to obtain the number of hotspot functions and classes newly added to the application from the last compilation to the present compilation; The execution module sends a third instruction to the oat file generation module to obtain the oat file size generated from the last compilation; The execution module sends a fourth instruction to the oat file generation module to obtain the last execution compilation optimization type; The execution module sends a fifth instruction to the compilation file module to obtain the number of classes and methods included in the application APK; The execution module returns the obtained compilation parameters to the compilation parameter collection module; The big data framework sends the last compilation execution time to the compilation parameter collection module.

10. The method of claim 9, wherein, The electronic device further includes a compilation decision module, and the target compilation optimization scheme for the compilation optimization is determined based on the plurality of decision parameters, including: The compilation parameter collection module sends the plurality of decision parameters to the compilation decision module; The compilation decision module determines the target compilation optimization scheme for the compilation optimization based on the plurality of decision parameters.

11. An electronic device, comprising: The electronic device includes: one or more processors, and a memory; The memory is coupled with the one or more processors, and the memory is configured to store computer program codes, the computer program codes including computer instructions, and the one or more processors are configured to invoke the computer instructions to enable the electronic device to perform the method in any one of claims 1 to 10.

12. A chip system, characterized by The chip system is applied to an electronic device, and the chip system includes one or more processors configured to invoke computer instructions to enable the electronic device to perform the method in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on the electronic device, cause the electronic device to perform the method of any of claims 1-10.

14. A computer program product, characterised in that, The computer program product includes a computer program that, when executed on the electronic device, causes the electronic device to perform the method of any of claims 1-10.

Citation Information

Patent Citations

  • Compiling parameter optimization method and device and electronic equipment

    CN110941424A

  • Agent modeling method for multi-objective compilation optimization sequence selection

    CN112035116A

  • Dex file compiling control method and device

    CN114996078A

  • Automatic parameter adjusting method for compiler

    CN115469851A

  • Code compiling method and device, electronic equipment and storage medium

    CN116991409A

Cited By

  • Incremental compiling method based on intermediate representation

    CN122064324A

  • An incremental compilation method based on intermediate representation

    CN122064324B