CN116521180B - Compiling optimization method, electronic equipment and storage medium - Google Patents

Compiling optimization method, electronic equipment and storage medium Download PDF

Info

Publication number
CN116521180B
CN116521180B CN202310769339.7A CN202310769339A CN116521180B CN 116521180 B CN116521180 B CN 116521180B CN 202310769339 A CN202310769339 A CN 202310769339A CN 116521180 B CN116521180 B CN 116521180B
Authority
CN
China
Prior art keywords
function
hotspot
scene
target application
functions
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202310769339.7A
Other languages
Chinese (zh)
Other versions
CN116521180A (en
Inventor
路来承
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
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 Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202310769339.7A priority Critical patent/CN116521180B/en
Publication of CN116521180A publication Critical patent/CN116521180A/en
Application granted granted Critical
Publication of CN116521180B publication Critical patent/CN116521180B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a compiling optimization method, electronic equipment and a storage medium, relates to the field of compiling optimization, and can improve the running speed of an application program in an important scene and improve the use experience of a user. The method comprises the following steps: the electronic equipment acquires application scene information of a target application program and determines a target application scene where the target application program is located based on the application scene information; under the condition that the target application scene belongs to an important scene set, the electronic equipment determines all functions executed by the target application program in the target application scene as first hot spot functions so as to obtain first hot spot function information of the target application program in the target application scene; the first hotspot function information includes: function identifiers of all first hotspot functions and identifiers of important scenes; the important scene set comprises a plurality of important scenes; and the electronic equipment generates a hot spot function compiling file based on all the first hot spot function information of the target application program.

Description

Compiling optimization method, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of compilation optimization, and in particular, to a compilation optimization method, an electronic device, and a storage medium.
Background
With the widespread use of application programs (which may be simply referred to as applications) on electronic devices, the variety and development means of application programs are increasing. In order to increase the installation and starting speed of the application when it is first started or installed, the electronic device may install and start the application in an interpreted execution manner when the application is installed, without pre-compiling (AOT) intermediate code files (e.g., dex files) in an installation package of the application. After the application program is used for a certain period of time, the electronic equipment can record the hot spot function through the configuration file (profile file) and compile the recorded hot spot function, so that when the hot spot function is used in the running process of the subsequent application program, the corresponding compiled file is operated, and the operating efficiency of the application program is improved.
However, in the prior art, a function whose execution number (derived from the number of calls and/or the number of called times) is greater than a certain threshold is determined as a hotspot function. However, some important functions are not identified as hot functions, so that when the application program is in an application scene corresponding to the important functions or performs services related to the important functions, the important functions need to be interpreted and executed, which reduces the running efficiency of the application program and makes the use experience of the user poor.
Disclosure of Invention
The embodiment of the application provides a compiling optimization method, which can improve the running speed of an application program in an important scene and improve the use experience of a user.
In order to achieve the above purpose, the embodiments of the present application adopt the following technical solutions:
in a first aspect, the present application provides a compiling optimization method applied to an electronic device. The method comprises the following steps: the electronic equipment acquires application scene information of a target application program and determines a target application scene where the target application program is located based on the application scene information; under the condition that the target application scene belongs to an important scene set, the electronic equipment determines all functions executed by the target application program in the target application scene as first hot spot functions so as to obtain first hot spot function information of the target application program in the target application scene; the first hotspot function information includes: function identifiers of all first hotspot functions and identifiers of important scenes; the important scene set comprises a plurality of important scenes; and the electronic equipment generates a hot spot function compiling file based on all the first hot spot function information of the target application program.
In practice, important scenes are generally important scenes for users, and the relation between the running speed of the corresponding application program in the scenes and the use experience of the users is more important. If some functions with lower use frequency in the important scene are not identified as hot spot functions and compiled, the running speed of the application program in the important scene can be reduced, and the use experience of a user is reduced. Therefore, based on the technical scheme provided by the embodiment, all the functions executed or called in the important scene can be identified as hot spot functions and compiled, so that the running speed of the application program in the important scene can be greatly improved, and the use experience of a user is improved.
In one possible design manner of the first aspect, the generating, by the electronic device, a hotspot function compilation file based on all first hotspot function information of the target application program includes: the electronic equipment generates a configuration file based on all first hotspot function information of the target application program; the electronic device compiles all the first hot spot functions based on the function identifications of the first hot spot functions corresponding to different important scenes in the configuration file so as to obtain a hot spot function compiling file.
In practice, when compiling a target application program, if a predetermined hotspot function exists in the electronic device, in a compiling manner, a configuration file needs to be generated based on the hotspot function first and then compiled. Therefore, based on the scheme, the compiling of the hot spot function can be successfully completed.
In one possible design manner of the first aspect, the electronic device generates a configuration file based on all first hotspot function information of the target application program, including: the electronic equipment classifies and aggregates the function identifications of the first hot spot functions corresponding to different important scenes based on the identifications of the important scenes in all the first hot spot function information of the target application program so as to generate a configuration file.
Based on the technical scheme, because the splitting and aggregation of the first hot spot functions corresponding to different important scenes in the configuration file are performed, the electronic equipment sequentially aggregates the machine codes of the hot spot functions corresponding to the same important scene in the hot spot function compiling file generated based on the matching file into the machine code segments corresponding to the important scene in the same area. In this way, when the subsequent electronic device runs the target application program, if the hotspot function corresponding to a certain important scene needs to be executed, the hotspot functions of all important scenes can be obtained from the hotspot function compiling file as soon as possible, so that the running efficiency of the target application program is improved.
In one possible design manner of the first aspect, the electronic device, based on the identifiers of important scenes in all the first hotspot function information of the target application, aggregates the function identifiers of the first hotspot functions corresponding to different important scenes to generate a configuration file, including: the electronic equipment classifies and aggregates the function identifications of the first hot spot functions corresponding to different important scenes based on the identifications of the important scenes in all the first hot spot function information of the target application program to obtain a first hot spot function aggregation result corresponding to the different important scenes; the electronic equipment adjusts the positions of function identifications of the first hotspot functions in the first hotspot function aggregation result corresponding to the first important scene by adopting a preset rule based on the calling relation of different first hotspot functions in the first hotspot function information corresponding to the first important scene; the first important scene is any one of a plurality of important scenes corresponding to the target application program; the preset rules comprise: the positions of the two first hotspot functions with higher affinity in the first hotspot function aggregation result are more similar; the more the calling times or called times between any two first hot spot functions, the higher the affinity of any two first hot spot functions; and the electronic equipment generates a configuration file based on the first hotspot function aggregation results corresponding to the adjusted different important scenes.
Based on the technical scheme, the affinity of different first hot functions can be reflected in the configuration file, so that the machine code of the first hot function with higher affinity can be placed more similar based on the affinity when the subsequent electronic equipment compiles the file based on the hot functions generated by the configuration file. Therefore, when the subsequent electronic equipment runs the target application program and needs to execute the hot spot function, the loading times of loading the content of the compiling file of the hot spot function in the memory can be reduced, and the times of cache miss and cache jitter are reduced. And further, the running efficiency of the target application program in the electronic equipment is improved, and the use experience of a user is improved.
In one possible design manner of the first aspect, the compiling, by the electronic device, all the first hotspot functions based on the function identifications of the first hotspot functions corresponding to different important scenes in the configuration file, to obtain a hotspot function compiled file includes: the electronic equipment compiles all the first hot spot functions based on the function identifications of the first hot spot functions corresponding to different important scenes in the configuration file, and compiles the first hot spot functions corresponding to the same important scene in the same machine code segment in the hot spot function compiling file.
Based on the technical scheme, the electronic equipment can set the machine code of the first hot spot function of the same important scene in the same machine code segment, and if the follow-up electronic equipment needs to execute the hot spot function corresponding to a certain important scene when running the target application program, the hot spot functions of all the important scenes can be acquired from the hot spot function compiling file as soon as possible, so that the running efficiency of the target application program is improved.
In one possible design manner of the first aspect, the compiling, by the electronic device, all the first hotspot functions based on the function identifications of the first hotspot functions corresponding to different important scenes in the configuration file, to obtain a hotspot function compiled file includes: the electronic equipment determines affinities of different first hotspot functions according to the position relations of the different first hotspot functions in all the first hotspot functions corresponding to each important scene in the configuration file; the electronic equipment compiles according to the affinities among the first hot spot functions corresponding to each important scene to obtain a machine code segment corresponding to each important scene; the machine code segment corresponding to any important scene comprises machine codes of all first hot spot functions corresponding to any important scene, and the positions between the machine codes of the two first hot spot functions with higher affinity are more similar; the electronic equipment generates a hot spot function compiling file based on the machine code segments corresponding to each important scene.
Based on the technical scheme, the electronic equipment can generate the hot spot function compiling file on the basis of fully considering the affinities of different hot spot functions. The affinity of different hotspot functions, i.e. the closer the distance before the machine code of the hotspot function with higher affinity, can be reflected in the hotspot function compilation file. Therefore, when the subsequent electronic equipment runs the target application program and needs to execute the hot spot function, the loading times of loading the content of the compiling file of the hot spot function in the memory can be reduced, and the times of cache miss and cache jitter are reduced. And further, the running efficiency of the target application program in the electronic equipment is improved, and the use experience of a user is improved.
In one possible design manner of the first aspect, the method further includes: under the condition that the target application scene does not belong to the important scene set, the electronic equipment determines a second hot spot function based on the execution times of the function executed by the target application program in the target application scene so as to obtain second hot spot function information; the second hotspot function information includes: function identification of all second hotspot functions; the electronic device generates a hotspot function compiling file based on all first hotspot function information of the target application program, and the hotspot function compiling file comprises the following components: and the electronic equipment generates a hotspot function compiling file based on all the first hotspot function information and all the second hotspot function information of the target application program.
Based on the scheme, the electronic equipment can identify and obtain the hot spot function which is not in an important scene, and further compile and obtain a more perfect hot spot function compiling file.
In one possible design manner of the first aspect, the determining, by the electronic device, the second hotspot function based on the number of executions of the function executed by the target application program in the target application scenario includes: and the electronic equipment determines a function of which the execution times of the target application program in the target application scene is greater than a preset threshold value as a second hot spot function.
Based on the scheme, the electronic equipment can more accurately identify the hot spot function in the scene which is not important, and further compiles the hot spot function compiling file to obtain the more perfect hot spot function compiling file.
In a second aspect, the present application provides an electronic device, comprising: the acquisition module is used for acquiring application scene information of the target application program and determining a target application scene where the target application program is located based on the application scene information; the processing module is used for determining all functions executed by the target application program in the target application scene as first hot spot functions under the condition that the target application scene determined by the acquisition module belongs to the important scene set so as to obtain first hot spot function information of the target application program in the target application scene; the first hotspot function information includes: function identifiers of all first hotspot functions and identifiers of important scenes; the important scene set comprises a plurality of important scenes; and the compiling module is used for generating a hot spot function compiling file based on all the first hot spot function information of the target application program.
In a third aspect, the present application provides an electronic device, comprising: a memory and one or more processors; the memory is coupled with the processor; wherein the memory has stored therein computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform the compilation optimization method as provided in the first aspect and any of its possible designs.
In a fourth aspect, the present application provides a computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform a compilation optimization method as provided in the first aspect and any one of its possible designs.
In a fifth aspect, the present application provides a computer program product comprising executable instructions which, when run on an electronic device, cause the electronic device to perform a compilation optimization method as provided in the first aspect and any one of its possible designs.
In a sixth aspect, there is provided an apparatus (e.g. the apparatus may be a system-on-a-chip) comprising a processor for supporting an electronic device to implement the functionality referred to in the second aspect above. In one possible design, the apparatus further includes a memory for storing program instructions and data necessary for the electronic device. When the device is a chip system, the device can be formed by a chip, and can also comprise the chip and other discrete devices.
It should be appreciated that the advantages of the second to sixth aspects may be referred to in the description of the first aspect, and are not described herein.
Drawings
Fig. 1 is a schematic diagram of a compiling optimization method according to an embodiment of the present application;
fig. 2 is a schematic hardware architecture of an electronic device according to an embodiment of the present application;
fig. 3 is a schematic software architecture of an electronic device according to an embodiment of the present application;
fig. 4 is a schematic flow chart of a compiling optimization method according to an embodiment of the present application;
fig. 5 is a second flowchart of a compiling optimization method according to an embodiment of the present application;
fig. 6 is a flowchart of a compiling optimization method according to an embodiment of the present application;
fig. 7 is a flowchart of a compiling optimization method according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a configuration file provided in an embodiment of the present application;
fig. 9 is a second schematic structural diagram of a configuration file according to an embodiment of the present application;
fig. 10 is a flowchart of a compilation optimization method according to an embodiment of the present application;
fig. 11 is a schematic structural diagram III of a configuration file according to an embodiment of the present application;
Fig. 12 is a schematic structural diagram of a configuration file according to an embodiment of the present application;
fig. 13 is a flowchart of a compilation optimization method according to an embodiment of the present application;
fig. 14 is a schematic flow chart of compiling a hotspot function by an electronic device according to an embodiment of the present application;
fig. 15 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The terminology used in the following embodiments of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms as well, unless the context clearly indicates to the contrary. It should also be understood that "/" means or, e.g., A/B may represent A or B; the text "and/or" is merely an association relation describing the associated object, and indicates that three relations may exist, for example, a and/or B may indicate: a exists alone, A and B exist together, and B exists alone.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly understand that the embodiments described herein may be combined with other embodiments.
The terms "first", "second" in the following embodiments of the present application are used for descriptive purposes only and are not to be construed as implying or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature, and in the description of embodiments of the present application, unless otherwise indicated, the meaning of "a plurality" is two or more.
In order to facilitate the clear description of the technical solutions of the embodiments of the present application, the following simply describes some terms and techniques related to the embodiments of the present application:
(1) Android Runtime (ART): android runtime may also be referred to as ART virtual machine. The ART virtual machine is a virtual machine technology in an Android operating system, and replaces the previous Dalvik virtual machine in Android version 5.0 and above. One Of the major improvements In ART over Dalvik is the use Of precompiled (AOT) rather than Just-In-Time (JIT), which means that an application can precompiled the native machine code to improve performance when it is first installed, but requires more memory.
The Art virtual machine has the greatest characteristics that when the application program is installed, all dex files of the application program are precompiled and local machine codes are generated for subsequent execution, so that the running speed of the application is increased. Compared with the Dalvik virtual machine, the Art virtual machine has higher performance, higher starting speed and smaller application occupation space, and meanwhile, the safety of the Android application is improved to a certain extent. In general, the Art virtual machine may improve the running efficiency and user experience of the application.
In addition, ART brings better garbage collection mechanism and new characteristics of supporting instrumentation and the like so as to strengthen the stability and safety of application programs and provide basic support for new Android functions.
In addition, in practice, in order to increase the installation efficiency and the starting speed of the application program when the application program is to be started and for the first time, the ART virtual machine may install the application program in an interpreted execution manner and start the application program. In this case, the ART virtual machine does not compile the dex file in advance, but records the hot spot function through the profile file after the application program is used for a certain period of time, and compiles the recorded hot spot function, so that when the hot spot function is used in the running process of the subsequent application program, the corresponding compiling file is operated, and the running efficiency of the application program is improved.
(2) Precompiled (AOT): in programming languages, it is generally classified into two types, interpretation execution and compilation execution. And AOT is to compile the codes into local machine codes before the program runs, so that the performance loss in the interpretation and execution process is avoided, and the execution speed and efficiency of the program are improved. In the Android system, the ART (Android RunTime) engine adopts an AOT compiling mode, namely, an application program is compiled into a local machine code in advance when being installed, so that the starting speed and the execution efficiency of the application program are increased, and the method is also one reason for obviously improving the performance of the Android system after being upgraded.
(3) Interpretation execution: interpretation execution refers to the way in which the electronic device directly runs the source code of the application program, interpreting execution row by row. In this mode, each time a program is executed, the source code needs to be parsed and translated into an executable instruction sequence. Since interpretation and translation are required each time of execution, the speed of interpretation execution is relatively slow.
(4) Cache (cache) jitter: cache jitter refers to the phenomenon of cache replacement caused by frequent access to different data due to the small cache size. When the data accessed by the program exceeds the capacity of the cache, the cache needs to replace a portion of the already cached data to make room for new data. If the program repeatedly accesses data having a size exceeding the cache capacity, a large number of cache replacement operations are caused, thereby degrading the performance of the program.
(5) Cache miss: a cache miss refers to data that is not needed in the cache, and the data needs to be reloaded from main memory into the cache. When data accessed by an application is not found in the cache, the cache cannot provide the corresponding data, which must be read from main memory and saved to the cache, known as a cache miss. Cache misses typically result in longer latencies due to slower interaction speeds between main memory and the CPU, thereby degrading program performance.
In the prior art, after determining and compiling the post-hot functions, the electronic device stores the post-hot functions in the hard disk with high probability according to the sequence or random disorder among the hot functions in the source code of the application program. When the electronic device needs to use a certain first hot-spot function when running the application program, the first hot-spot function and a part of hot-spot functions (particularly, related data of the hot-spot functions) adjacent to and close to the storage position of the first hot-spot function are loaded into the memory from the hard disk. And then, putting the first hot spot function and the hot spot function adjacent to or close to the hot spot function in the memory into a cache for running an application program by the electronic equipment. At this time, if the electronic device executes the first hotspot function, and the next hotspot function to be executed is not a hotspot function that is put into the cache together with the first hotspot function, a cache miss condition may occur. Then, the electronic device needs to empty the cache and re-grab the hot spot function from the memory, so as to generate cache jitter.
(6) Intermediate representation (Intermediate Representation, IR): for an electronic device that actually runs an application, it can directly execute object code (or referred to as machine code) that is composed of machine language, while the code of the application is high-abstraction and cannot be directly executed. Based on this, the application program requires a compiler (or interpreter) to compile the source code of the application program before being installed in the electronic device, thereby generating object code composed of machine language. In the process of converting the source code into the target code, the source code is firstly converted into the intermediate representation, and then the compiler can complete the steps of register allocation, instruction selection, code scheduling, code optimization and the like according to the intermediate representation, so that the intermediate representation is converted into the target code. In the embodiment of the present application, the intermediate representation (or may be called as intermediate code) may include a dex (dalvik executable, darwink executable file) file, where the dex file may specifically be an intermediate representation file of the java code.
(7) OAT file: the OAT is a file format in the Android operating system, which is collectively called an "optimized ART (Android run time) file" and can be understood as an optimized Android Runtime file. OAT files are optimized dex files that contain efficient compiler code and operating system specific binary code, which makes it faster to run than the original dex file. In the Android system, after an application program is installed, the Android operating system can convert a dex file (Dalvik Executable) in the APK into an OAT file, so that the starting speed and the running efficiency of the application program can be improved.
In order to improve the installation and starting speed of the application program when the application program is started or installed for the first time, currently, when the application program is installed, the electronic device installs and starts the application program by using a virtual machine in an interpretation and execution mode, and does not pre-compile intermediate code files in an installation package of the application program. After the application program is used for a certain period of time, the electronic equipment can record the hot spot function through the configuration file and compile the recorded hot spot function, so that when the hot spot function is used in the running process of the subsequent application program, the corresponding compiling file is operated, and the running efficiency of the application program is improved. However, the algorithm for determining the hotspot function in the prior art determines the hotspot function based on the execution times of the function. Specifically, in the prior art, a function whose execution number (obtained by the number of calls and/or the number of called times) is greater than a certain threshold is determined as a hotspot function. For some important scenarios (e.g., take a photograph, sweep a code, etc.) where some users often use an application, the use of some important functions in their travel path is not very frequent. Therefore, the important functions of the important scenes are not compiled in advance, so that when the application program is in the application scene corresponding to the important functions or the service related to the important functions is executed, the important functions need to be interpreted and executed, the running efficiency of the application program is reduced, and the use experience of a user is poor.
In view of the above problems, referring to fig. 1, the present application provides a compiling optimization solution applied in an electronic device. In the technical scheme, the scene monitoring module in the electronic equipment can monitor all behaviors of the application program or all executed services, so as to determine the current application scene of the electronic equipment (or the application scene generated by the current running of a certain application program by the electronic equipment). And the scene monitoring module can inform the virtual machine in time when determining that the application scene belongs to a predefined important scene. By way of example, important scenarios may include: a starting scene, a code scanning scene, a photographing scene, a live broadcast scene and the like; the virtual machine may be an ART (android run time) virtual machine in the android system. Specifically, when the important scene starts (or the important scene is in a starting state), the scene monitoring module can inform the virtual machine of starting to count the functions used (or called) in the application process while running the tasks or services required to be executed by the corresponding application program under the important scene, and identify the counted functions as hot spot functions. The scene monitoring module can also inform the virtual machine to stop counting the functions used in the process of running the application program when the important scene is over. When the ART virtual machine determines that the important scene is over, all the functions counted under the important scene can be determined as hot spot functions and written into a configuration file (for example, a profile file). The compiling module in the ART virtual machine may then compile based on the hotspot functions in the profile file, and generate a compiled file (e.g., OAT file) corresponding to the hotspot functions.
In practice, important scenes are generally important scenes for users, and the relation between the running speed of the corresponding application program in the scenes and the use experience of the users is more important. If some functions with lower use frequency in the important scene are not identified as hot spot functions and compiled, the running speed of the application program in the important scene can be reduced, and the use experience of a user is reduced. Therefore, based on the technical scheme provided by the application, all the functions executed or called in the important scene can be identified as hot spot functions and compiled, so that the running speed of the application program in the important scene can be greatly improved, and the use experience of a user is improved.
The following describes in detail the technical solutions provided in the embodiments of the present application with reference to the accompanying drawings.
The technical scheme provided by the embodiment of the application can be applied to the electronic equipment capable of installing and running the application program. In this application, the electronic device may be a cell phone, tablet, wearable device, in-vehicle device, augmented reality (augmented reality, AR)/Virtual Reality (VR) device, notebook, ultra-mobile personal computer (ultra-mobile personal computer, UMPC), netbook, personal digital assistant (personal digital assistant, PDA), wireless terminal in industrial control (industrial control), wireless terminal in unmanned (self driving), wireless terminal in teleoperation (remote medical surgery), wireless terminal in smart grid (smart grid), wireless terminal in transportation security (transportation safety), wireless terminal in smart city (smart home), cellular telephone, cordless telephone, session initiation protocol (session initiation protocol, SIP) telephone, wireless local loop (wireless local loop, WLL) station, handheld device with wireless communication function, computing device or other processing device connected to wireless modem, wireless terminal in a vehicle-mounted device, wearable device, and terminal in 5G or future evolution of the network (PLMN) without limiting the communication to this application, mobile network (public land mobile network).
Take the example of the electronic device being a cell phone. Fig. 2 shows a schematic structural diagram of the middle-electronic device provided by the application.
Referring to fig. 2, the electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a display 193, a subscriber identity module (subscriber identification module, SIM) card interface 194, a camera 195, and the like. The sensor module 180 may include, among other things, a pressure sensor, a gyroscope sensor, a barometric sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The controller may be a neural hub and command center of the electronic device. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, and/or a universal serial bus (universal serial bus, USB) interface, among others.
The charge management module 140 is configured to receive a charge input from a power supply device (e.g., a charger, notebook power, etc.). The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charge management module 140 may receive a charging input of a wired charger through the USB interface 130. In some wireless charging embodiments, the charge management module 140 may receive wireless charging input through a wireless charging coil of the electronic device. The charging management module 140 may also supply power to the electronic device through the power management module 141 while charging the battery 142. The battery 142 may specifically be a battery formed by connecting a plurality of batteries in series. The power management module 141 is used for connecting the battery 142, and the charge management module 140 and the processor 110.
The power management module 141 receives input from the battery 142 and/or the charge management module 140 and provides power to the processor 110, the internal memory 121, the display 193, the camera 195, the wireless communication module 160, and the like. The power management module 141 may also be configured to monitor battery capacity, battery cycle number, battery health (leakage, impedance) and other parameters. In other embodiments, the power management module 141 may also be provided in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may also be disposed in the same device, for example, the power management module 141 and the charging management module 140 may be different functional modules in the same power management chip.
The external memory interface 120 may be used to connect external non-volatile memory to enable expansion of the memory capabilities of the electronic device. The external nonvolatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and video are stored in an external nonvolatile memory.
The internal memory 121 may include one or more random access memories (random access memory, RAM) and one or more non-volatile memories (NVM). The random access memory may be read directly from and written to by the processor 110, may be used to store executable programs (e.g., machine instructions) for an operating system or other on-the-fly programs, may also be used to store data for users and applications, and the like. The nonvolatile memory may store executable programs, store data of users and applications, and the like, and may be loaded into the random access memory in advance for the processor 110 to directly read and write.
Touch sensors, also known as "touch devices". The touch sensor may be disposed on the display screen 193, and the touch sensor and the display screen 193 form a touch screen, which is also called a "touch screen". The touch sensor is used to monitor touch operations acting on or near it. The touch sensor may communicate the monitored touch operation to the application processor to determine the touch event type. Visual output related to the touch operation may be provided through the display 193. In other embodiments, the touch sensor may also be disposed on a surface of the electronic device other than where the display 193 is located.
The pressure sensor is used for sensing a pressure signal and can convert the pressure signal into an electric signal. In some embodiments, the pressure sensor may be provided on the display 193. Pressure sensors are of many kinds, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. When a touch operation is applied to the display screen 193, the electronic apparatus monitors the intensity of the touch operation according to the pressure sensor. The electronic device may also calculate the location of the touch based on the monitoring signal of the pressure sensor. In some embodiments, touch operations that act on the same touch location, but at different touch operation strengths, may correspond to different operation instructions. For example: and executing an instruction for checking the short message when the touch operation with the touch operation intensity smaller than the first pressure threshold acts on the short message application icon. And executing an instruction for newly creating the short message when the touch operation with the touch operation intensity being greater than or equal to the first pressure threshold acts on the short message application icon.
The electronic device implements display functions through a GPU, a display screen 193, an application processor, and the like. The GPU is a microprocessor for image editing, and is connected to the display 193 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 change display information.
The electronic device may implement photographing functions through an ISP, a camera 195, a video codec, a GPU, a display screen 193, an application processor, and the like.
The ISP is used to process the data fed back by the camera 195. For example, when photographing, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the optical signal is converted into an electric signal, and the camera photosensitive element transmits the electric signal to the ISP for processing and is converted into an image visible to naked eyes. ISP can also perform algorithm optimization on noise and brightness of the image. The ISP can also optimize parameters such as exposure, color temperature and the like of a shooting scene. In some embodiments, the ISP may be located in the camera 195. The camera 195 is used to capture still images or video. In some embodiments, the electronic device may include 1 or N cameras, N being a positive integer greater than 1. The camera 195 may be a front camera or a rear camera.
The digital signal processor is used for processing digital signals, and can process other digital signals besides digital image signals. For example, when the electronic device selects a frequency bin, the digital signal processor is used to fourier transform the frequency bin energy, and so on.
The display 193 is used to display images, videos, and the like. The display 193 includes a display panel. The display panel may employ a liquid crystal display (liquid crystal display, LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (flex), a mini, a Micro-OLED, a quantum dot light-emitting diode (quantum dot light emitting diodes, QLED), or the like. In some embodiments, the electronic device may include 1 or N display screens 193, N being a positive integer greater than 1.
In embodiments of the present application, the display 193 may be used to display an interface (e.g., a camera preview interface, a video preview interface, a film preview interface, etc.) of an electronic device and display images captured from any one or more cameras 195 in the interface.
The wireless communication function of the electronic device may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem, a baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device may be used to cover a single or multiple communication bands. Different antennas may also be multiplexed to improve the utilization of the antennas.
The mobile communication module 150 may provide a solution for wireless communication including 2G/3G/4G/5G, etc. applied on an electronic device. The mobile communication module 150 may receive electromagnetic waves from the antenna 1, perform processes such as filtering, amplifying, and the like on the received electromagnetic waves, and transmit the processed electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 can amplify the signal modulated by the modem processor, and convert the signal into electromagnetic waves through the antenna 1 to radiate. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be provided in the same device as at least some of the modules of the processor 110.
The wireless communication module 160 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc. for application on an electronic device. The wireless communication module 160 may be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the electromagnetic wave signals, filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, frequency modulate it, amplify it, and convert it to electromagnetic waves for radiation via the antenna 2.
The SIM card interface 194 is used to connect to a SIM card. The SIM card may be inserted into the SIM card interface 194, or removed from the SIM card interface 194 to effect contact and separation with the electronic device. The electronic device may support one or more SIM card interfaces. The SIM card interface 194 may support a Nano SIM card, micro SIM card, etc. The same SIM card interface 194 may be used to insert multiple cards simultaneously. The SIM card interface 194 may also be compatible with external memory cards. The electronic equipment interacts with the network through the SIM card, so that the functions of communication, data communication and the like are realized. One SIM card corresponds to one subscriber number.
It should be understood that the connection relationship between the modules illustrated in the embodiments of the present invention is only illustrative, and does not limit the structure of the electronic device. In other embodiments of the present application, the electronic device may also use different interfacing manners in the foregoing embodiments, or a combination of multiple interfacing manners.
It will be understood, of course, that the above illustration of fig. 2 is merely exemplary of the case where the electronic device is in the form of a cellular phone. If the electronic device is a tablet computer, a handheld computer, a PC, a PDA, a wearable device (e.g., a smart watch, a smart bracelet), etc., the electronic device may include fewer structures than those shown in fig. 2, or may include more structures than those shown in fig. 2, which is not limited herein.
It will be appreciated that implementation of the functionality of the electronic device requires software in addition to hardware support.
The software system of the electronic device may employ a layered architecture, an event driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In the embodiment of the application, the Android system with a layered architecture is taken as an example, and the software structure of the electronic equipment is illustrated.
Fig. 3 is a schematic diagram of a layered architecture of a software system of an electronic device according to an embodiment of the present application. The layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate with each other through a software interface (e.g., API).
In some examples, referring to fig. 3, in the embodiment of the present application, the software of the electronic device is divided into four layers, namely, an application layer, a framework layer (or referred to as an application framework layer), a system library and android run time (HAL layer (hardware abstraction layer), a hardware abstraction layer) and a driver layer (or referred to as a kernel layer) from top to bottom.
The application layer may include a series of applications, among others. As shown in fig. 3, the application layer may include camera, gallery, calendar, map, WLAN, bluetooth, music, video, short message, call, contact, live, etc. Applications (APP). The call application and the contact person can be preset in the factory of the electronic equipment, and can also be a third party application for user call provided by the application market.
The framework layer provides an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. The application framework layer includes a number of predefined functions. For example, the application framework layer may include an activity manager, a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc., which embodiments of the present application do not impose any limitations.
The window manager is used for managing window programs. The window manager can acquire the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
The content provider is used to store and retrieve data and make such data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebooks, etc.
The view system includes visual controls, such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications. The display interface may be composed of one or more views. For example, a display interface including a text message notification icon may include a view displaying text and a view displaying a picture.
The telephony manager is for providing communication functions of the electronic device. For example, the telephony manager may manage the call state (including initiate, connect, hang-up, etc.) of the call application.
The resource manager provides various resources for the application program, such as localization strings, icons, pictures, layout files, video files, and the like.
The notification manager allows the application to display notification information in a status bar, can be used to communicate notification type messages, can automatically disappear after a short dwell, and does not require user interaction. Such as notification manager is used to inform that the download is complete, message alerts, etc. The notification manager may also be a notification in the form of a chart or scroll bar text that appears on the system top status bar, such as a notification of a background running application, or a notification that appears on the screen in the form of a dialog window. For example, a text message is prompted in a status bar, a prompt tone is emitted, the electronic device vibrates, and an indicator light blinks, etc.
In an embodiment of the present application, a scene monitoring service (or referred to as a scene monitoring module) may be included in the framework layer. The scene monitoring service can monitor the specific application scene where the electronic equipment is currently located, and timely inform the ART virtual machine of the starting information and the ending information of the important scene when the important scene is monitored, so that the ART virtual machine determines functions executed (or called) by the electronic equipment running the application program corresponding to the important scene in a time period corresponding to the important scene as hot spot functions, and compiles the hot spot functions. In this way, when the subsequent electronic device is in the important scene again, the compiled files of all the hotspot functions corresponding to the important scene can be used for running, the running speed is faster, and the user experience is better.
The system library may include a plurality of functional modules. For example: surface manager (surface manager), media library (Media Libraries), openGL ES, SGL, etc. The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications. Media libraries support a variety of commonly used audio, video format playback and recording, still image files, and the like. The media library may support a variety of audio video encoding formats, such as: MPEG4, h.264, MP3, AAC, AMR, JPG, PNG, etc. OpenGL ES is used to implement three-dimensional graphics drawing, image rendering, compositing, and layer processing, among others. SGL is the drawing engine for 2D drawing.
Android runtime (android run) includes a core library and an ART virtual machine. android run is responsible for scheduling and management of android systems. The core library consists of two parts: one part is a function which needs to be called by java language, and the other part is a core library of android. The application layer and the application framework layer run in an ART virtual machine. The ART virtual machine executes java files of the application program layer and the application program framework layer into binary files. The ART virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
In the embodiment of the application, when receiving the information provided by the scene monitoring service and indicating the start of the important scene, the ART virtual machine starts to identify all functions executed (or called) by the application program corresponding to the important scene as hot spot functions until receiving the information provided by the scene monitoring service and indicating the end of the important scene. The ART virtual machine is also used for storing all the hotspot functions into the profile file and compiling to obtain an OAT file. When the subsequent ART virtual machine is in an important scene of the electronic equipment, the binary codes of the corresponding hotspot functions can be extracted from the OAT file, so that the running speed of the corresponding application program is faster, and the use experience of a user is improved.
The HAL layer is an interface layer between the operating system kernel and the hardware circuitry that aims at abstracting the hardware. The hardware interface details of a specific platform are hidden, a virtual hardware platform is provided for an operating system, so that the operating system has hardware independence, and can be transplanted on various platforms. The HAL layer provides a standard interface to display device hardware functionality to a higher level Java API framework (i.e., framework layer). The HAL layer contains a plurality of library modules, each of which implements an interface for a particular type of hardware component, such as: an audio HAL module, a blue HAL Bluetooth module, a camera HAL module, and a sensors HAL sensor module (or called Isensor service).
The kernel layer is a layer between hardware and software. The inner core layer at least comprises display drive, camera drive, audio drive, sensor drive and the like, and the application is not limited.
Based on the hardware architecture and the software structure, the information display method provided in the embodiment of the application is described below by taking the electronic device as an example of the electronic device using the android system.
Referring to fig. 4, a compiling optimization method provided in an embodiment of the present application may be applied to an electronic device, and the method may include S401 to S404:
s401, the electronic equipment acquires application scene information of a target application program and determines a target application scene where the target application program is located based on the application scene information.
In the embodiment of the present application, the target application may be an application installed on the electronic device and currently running, and the type and function of the application are not specifically limited in this application. The technical solution provided in the embodiments of the present application is to determine that the electronic device is in an important scene, and the function related to the important scene is identified as a hotspot function and compiled, so that S401 needs to be executed first to determine a target application scene generated by a target application program currently operated by the electronic device.
In practice, when the target application program uses different functions, the electronic device is triggered to start different activity activities, and different application scenes, such as a code scanning scene, a call making scene, a video scene, and the like, are generated. Based on this, the application scenario information of the target application may include activity that the target application currently starts, or may include instruction information that can instruct the target application to currently start. Based on the application scene information, the electronic device can determine a target application scene generated by the operation of the target application program, and further provide data support for the subsequent electronic device to determine a hot spot function in an important scene (part of application scenes in all application scenes).
In the embodiment of the present application, as shown in fig. 3, S401 may be implemented by a scene monitoring module in an electronic device. Referring to fig. 5, a target application in an electronic device may start a target function and generate corresponding application scenario information in response to a user operation to start the target function. The scene monitoring module may then determine a target application scene (corresponding to the target function) in which the target application program is located based on the application scene information. In some embodiments, the target function of the target application program may be automatically closed, or the target application program in the electronic device may close the target function and generate corresponding application scenario information in response to the user operation of closing the target function. How the specific target function is closed depends on the specific content of the target function, which is not particularly limited in this application.
In addition, the application scenario information when the target application program is just in a certain application scenario and the application scenario information when the target application is about to exit the application scenario may be different, and the scenario monitoring module may determine whether the application scenario is currently in a start state or an end state based on the different application scenario information. For example, application scenario information when a target application program just starts entering a certain application scenario (e.g., a target application scenario) may include application scenario start information, and application scenario information when a target application program just starts exiting a certain application scenario may include application scenario end information.
In some possible implementations, the scene monitoring module may be iAware.
For example, taking a target application program as an application program with a function of scanning a code (scanning a two-dimensional code or a bar code, etc.), the application scene information includes activity, the scene monitoring module is iAware, and the target application scene is a code scanning scene, as shown in fig. 6, when the target application program in the electronic device responds to a code scanning operation of a user, the scanning activity is started.
At this time, if the iAware monitors the scan activity, the iAware determines that the target application scene is the scan scene based on the scan activity, and determines that the scan scene is in the start state. Specifically, iAware may monitor the scan activity through an activity management service in the framework layer.
In addition, when the target application finishes scanning by using the scanning function, the exit scanning activity is started. At this time, the iAware monitors the exit scan activity, and determines that the scan scene is in the exit state based on the exit scan activity.
In the embodiment of the present application, S401 may be performed in real time by the electronic device or periodically performed with a shorter time as a period duration, so as to ensure that a target application scenario where a target application program is located may be identified in time, and determine whether the target application scenario where the target application program is located is a start state, a process or an end state, so that hotspot function information of the target application program in each important scenario may be counted in time.
In the embodiment of the present application, there may be a plurality of target application programs, and the application scenario information also corresponds to the number of the target application programs, and there may be a plurality of target application scenarios. For example, when the electronic device runs the music application and the instant messaging application at the same time, the playing song activity is started by using the music application, and the instant messaging activity is started by using the instant messaging application to perform instant chat, the target application scene may include a music playing scene corresponding to the playing song activity and a chat scene corresponding to the instant messaging activity. The number of target application programs, the number of application scene information and the number of target application scenes are not particularly limited. Since the actions performed on the application scenario information of each target application program are the same, only an example of one target application scenario is described in the embodiment of the present application, and the present application is not limited to the actual implementation.
S402, under the condition that the target application scene belongs to an important scene set, the electronic device determines all functions executed by the target application program in the target application scene as first hot spot functions so as to obtain first hot spot function information of the target application program in the target application scene.
In this embodiment, the important scene set is a plurality of application scenes predefined by a manufacturer or a developer of the electronic device according to usage data of each function of each application program by a user. For example, the set of important scenes may include: a plurality of important scenes such as a starting scene, a code scanning scene, a photographing scene, a live broadcast scene and the like. The important scenes which can be generated or entered by each application program are different, for example, a payment application can generate important scenes such as an opening scene, a code scanning scene and a shooting scene, for example, an instant messaging application can generate important scenes such as an opening scene, a code scanning scene and a shooting scene, and for example, a live broadcast application can generate important scenes such as an opening scene, a code scanning scene, a shooting scene and a live broadcast scene.
Wherein the first hotspot function information includes: the function identification of all the first hotspot functions and the identification of important scenes (namely, important scenes to which the target application scene belongs).
By way of example, the function identification may be used to indicate a specific function, and may specifically be a function name, such as main, printf, strlen, strcpy, strcmp, malloc, free, open, read, write, close, org.
The identification of the important scene is used for indicating the type of the important scene (such as a code scanning scene, a shooting scene and the like) to which the target application scene belongs, and distinguishing the important scene from other important scenes. The specific implementation may be in any feasible manner, for example, the identification of the important scene may be a character string, a number, etc.
In one implementation, referring to fig. 5 in conjunction with fig. 3, S402 may be performed by a scene monitoring module and a virtual machine in the electronic device. The scene monitoring module may determine whether the target application scene belongs to an important scene after determining the target application scene in which the target application program is located. If the scene monitoring module determines that the target application scene belongs to an important scene, whether the target application scene is in a starting state or an ending state or not can be determined according to the application scene information, namely whether the target application scene is just started or is ready to end is determined.
And when the scene monitoring module determines that the target application scene is just started, the virtual machine is notified. Referring specifically to fig. 5, the scene monitoring module may send first indication information to the virtual machine, where the first indication information is used to indicate that the target application scene is just started or indicate that the target application program starts to enter the target application scene. When the virtual machine determines that the target application scene is just started, the virtual machine can mark the starting of the target application scene so as to be convenient for defining the scene to which the first hot spot function belongs and starting to count all executed functions in the target application program as hot spot functions when the first hot spot function in the target application scene is counted later. Specifically, the virtual machine may specifically set the value of the environment variable for the important scene to the value of the corresponding target application scene.
And when the scene monitoring module determines that the preparation of the target application scene is finished, the virtual machine is also notified. Referring specifically to fig. 5, the scene monitoring module may send second indication information to the virtual machine, where the second indication information is used to indicate that the target application scene is ready to end or indicate that the target application program starts to exit the target application scene. When the virtual machine determines that the preparation of the target application scene is finished, the end of the target application scene can be marked, so that when the first hot spot function in the target application scene is counted later, the scene to which the first hot spot function belongs is defined, and the time for counting all executed functions in the target application program as the hot spot function is stopped. Specifically, the virtual machine may specifically set the value of the environment variable for the important scene to null.
Referring to fig. 5, an execution subject that receives the first indication information and the second indication information and adjusts the value of the environment variable may be a scene indication module in the virtual machine.
The hotspot function management module in the virtual machine for determining the hotspot function can determine the function executed by the target application program as the hotspot function when the target application scene is in a starting state and an ending state (i.e. when the target application program is in the target application scene), and record the identification or type of the important scene to which the target application scene belongs. In particular, the hotspot function management module may determine whether to directly determine the function performed by the target application as a hotspot function based on the value of the environmental variable for the important scenario.
It should be noted that, in the design of the existing electronic device, the hotspot function management module of the virtual machine needs to determine whether all functions are hotspot functions, so that in addition to determining all functions executed by the target application program in the important scene as hotspot functions required by the implementation of the application, the function executed by the target application program not in the important scene needs to be determined whether the functions are hotspot functions. Based on this, referring to fig. 5, when the target application program is in the target application scene and the first function is executed, the hotspot function management module in the virtual machine may first acquire an environment variable for indicating the scene, and determine, based on the environment variable, whether the target application scene in which the target application program is currently located is an important scene.
If the current target application scene of the target application program is determined to be an important scene based on the environment variable, the hotspot function management module determines all functions executed by the target application program in the target application scene as first hotspot functions, and further obtains first hotspot function information. In this case, the value of the environment variable is not null, and the value of the environment variable corresponds to one important scene.
If it is determined that the current target application scenario of the target application program is not an important scenario based on the environment variable, the hotspot function management module may determine the hotspot function based on the execution times of the function executed by the target application program in the target application scenario. Specifically, the hotspot function management module may determine the execution times (may be referred to as hotness) of each function, and if the execution times of a certain function is greater than a preset threshold, determine the function as a second hotspot function, so as to obtain second hotspot function information. The second hotspot function information includes a function identifier (e.g., a function name) of each second hotspot function. The preset threshold may be any feasible value preset by the designer of the electronic device according to the user usage data or usage requirements. In this case, the value of the environment variable is null or the value of the environment variable is not null but the value of the environment variable does not correspond to any one important scene.
If the scene monitoring module determines that the target application scene does not belong to an important scene, the scene monitoring module does not execute any action or operation. In this case, the hotspot function management module in the virtual machine may determine the hotspot function based on the execution times of the function executed by the target application program, so as to obtain the second hotspot function information. The specific implementation manner is as described in the previous paragraph, and is not repeated here.
Based on the above expression, the compiling optimization method provided in the embodiment of the application further includes: and under the condition that the target application scene does not belong to an important scene, the electronic equipment determines a second hot spot function based on the execution times of each function executed by the target application program in the target application scene so as to obtain second hot spot function information of the target application program. Specifically, the electronic device may determine, as the second hotspot function, a function whose execution number is greater than a preset threshold, from all functions executed by the target application program in the target application scene, and acquire second hotspot function information.
Taking the target application program as an application program with a function of scanning codes (scanning two-dimensional codes or bar codes and the like), the application scene information comprises activity, the scene monitoring module is iAware, the target application scene is an important scene of the type of scanning code scene, the virtual machine is an ART virtual machine, and the specific implementation of S402 can be as shown in fig. 6:
The iAware can judge whether the code scanning scene belongs to an important scene or not after determining the code scanning scene of the target application program. If the iAware determines that the code scanning scene belongs to an important scene, whether the code scanning scene is in a starting state or an ending state can be determined according to the content of the activity, namely whether the code scanning scene is just started or is ready to be ended is determined.
In the case that the activity is specifically the start scanning activity, the iAware determines that the code scanning scene is just started, and notifies the ART virtual machine (specifically, may be a scene indication module in the virtual machine). The first indication information may specifically include any content indicating the start of the code scanning scene. When the ART virtual machine determines that the code scanning scene is just started, the start of the code scanning scene can be marked, and particularly, the environment variable env aiming at the important scene is set to be a value corresponding to the code scanning scene.
In the case that the activity is specifically the exit scanning activity, the iAware determines that the code scanning scene preparation is finished, and notifies the ART virtual machine (specifically, may be a scene indication module in the virtual machine). The second indication information may specifically include any content indicating the end of the code scanning scene. When determining that the code scanning scene is ready to be ended, the ART virtual machine can mark the end of the code scanning scene, and particularly sets an environment variable env for an important scene to be null.
And a hotspot function management module used for determining the hotspot function in the ART virtual machine can execute a first function to start the hotspot function determination processing when the target application program is in the code scanning scene.
Firstly, a hotspot function management module acquires env, and judges whether a code scanning scene where a target application program is currently located is an important scene or not based on the env.
If the code scanning scene where the target application program is currently located is determined to be an important scene based on env, the hot spot function management module determines all functions executed by the target application program in the code scanning scene as first hot spot functions, and further obtains first hot spot function information. In this case, the value of env is not null, and corresponds to the code scanning scene.
If it is determined that the code scanning scene where the target application program is currently located is not an important scene based on env, the hotspot function management module may determine the hotspot function based on the execution times of the function executed by the target application program in the code scanning scene. Specifically, the hotspot function management module may determine the execution times of each function, and if the execution times of a certain function are greater than a preset threshold, determine the function as a second hotspot function, so as to obtain second hotspot function information. The second hotspot function information includes a function identifier (e.g., a function name) of each second hotspot function. In this case, the value of env is null or the value of env is not null but the value of env does not correspond to any one important scene.
In practice, the value of env is not changed after the ART virtual machine is set under normal conditions, that is, the ART virtual machine is not changed with a high probability when it is determined that the target application is in the scan scene and the exit is not finished. In some special cases, such as ART virtual machine running errors, result in changes to the value of env, where because ART itself is running error, it may also be erroneous if all functions executed by the target application in the target application scenario are identified as hot spot functions directly in the case where env is not empty. Therefore, in the embodiment of the application, the hotspot function management module determines whether the target application scene is an important scene based on env, and besides the identification and determination of the hotspot function in the non-important scene can be successfully completed, the function of the target application program in the target application scene can not be determined to be the hotspot function in time under special conditions, so that the situation that the function which is not supposed to belong to the hotspot function due to the special conditions is prevented from being determined to be the hotspot function. (e.g., the ART virtual machine would not normally run the function of the target application to cause it to execute, and would cause it to execute in special cases).
If the iAware determines that the target application program is not in the code scanning scene based on the application scene information of the target application program, or the code scanning scene does not belong to an important scene, the iAware does not execute any action or operation. In this case, the hotspot function management module may determine the hotspot function based on the execution times of the function executed by the target application program, and further obtain the second hotspot function information. The specific implementation manner is as described in the previous paragraph, and is not repeated here.
S403, the electronic equipment generates a configuration file based on all first hot spot function information of the target application program.
In the embodiment of the present application, the configuration file may be a profile file.
In practice, taking an operating system of an electronic device as an android system as an example, when a compiling module in a virtual machine of the electronic device compiles a file of an application program (may specifically be a file in an installation package of the application program), if a predetermined hotspot function exists, a compiling mode adopted is a speed-profile compiling mode based on a profile file (i.e. a configuration file). The compiling mode needs to be completed based on the profile file. Therefore, in the embodiment of the present application, the electronic device needs to generate the configuration file based on the multiple hotspot function information of the target application program, and then can perform subsequent compiling.
It should be noted that, because the functions executed by the target application program may be different in different usage situations even in the same scenario, all functions executed by the target application program in important scenarios are obtained more comprehensively. S403 may be implemented after S401 and S402 are continuously performed for a certain period of time. The certain duration may be according to actual requirements, for example, the certain duration may be any feasible time length such as one week. In addition, a positive correlation relationship exists between a preset threshold value of the second hotspot function and the certain duration.
In the present embodiment, S403 (including subsequent S403A, S4031A-S4033A) may be implemented by a hotspot function management module in the virtual machine of the electronic device.
S404, the electronic equipment compiles all the first hot functions based on the function identifications of the first hot functions corresponding to different important scenes in the configuration file so as to obtain a hot function compiling file.
Illustratively, the hotspot function compilation file may be an OAT file.
Specifically, the electronic device may select, from code files of the target application program, a code file (e.g., a dex file) corresponding to the first hotspot function based on the function identification of the first hotspot function corresponding to different important scenes in the configuration file, and compile the code file.
In order to enable the subsequent electronic equipment to execute the hot spot function corresponding to a certain important scene when the target application program is run, the hot spot functions of all important scenes can be obtained from the hot spot function compiling file as soon as possible, and the running efficiency of the target application program is improved. The machine codes of the hot spot functions corresponding to the same important scene in the hot spot function compiling file are required to be aggregated in the same area to form a machine code segment corresponding to the important scene. Based on this, when the electronic device compiles the first hotspot function, the electronic device may compile the first hotspot function corresponding to the same important scene in the same machine code segment. That is, only the machine code segment of the first hot function corresponding to the important scene is included in the machine code segment of the hot function compiled file corresponding to the same important scene.
In order to enable the electronic device to smoothly compile the first hot spot function corresponding to the same important scene in the same machine code segment. Referring to fig. 7 in conjunction with fig. 4, S403 may be S403A:
S403A, the electronic device classifies and aggregates the function identifications of the first hot spot functions corresponding to different important scenes based on the identifications of the important scenes in all the first hot spot function information of the target application program so as to generate a configuration file.
By way of example, taking a configuration file as an example, the configuration file may be as shown in fig. 7, where the plurality of important scenes corresponding to the target application include a start scene (a scene corresponding to the target application start procedure), a scan scene (a scene corresponding to the target application using the scan function), and a photo scene (a scene corresponding to the target application using the photo function). Referring to fig. 8, first hotspot functions corresponding to different scenes are disposed in different areas in an aggregation manner. The data specifically stored in the configuration file, such as the first hotspot function 11, the first hotspot function 12, the first hotspot function 21, the first hotspot function 22, the first hotspot function 31, the first hotspot function 32, etc., may be a function identifier (e.g. a function name) of the corresponding function. The data specifically stored in the configuration file, such as the startup scene, the scanning scene, the photographing scene and the like, are identifiers of corresponding scenes.
In addition, in addition to the first hotspot function executed by the target application program in the important scene, the second hotspot function executed by the target application program in the non-important scene for times greater than the preset threshold is also a function to be compiled. Based on this, in some embodiments, when the electronic device generates the configuration file, all the second hotspot function information needs to be based on in addition to the identification of the important scene in the first hotspot function information. That is, the electronic device needs to generate a configuration file based on all the first hotspot function information and all the second hotspot function information of the target application. By way of example, taking a configuration file as an example, where the multiple important scenes corresponding to the target application program include a start scene, a scan scene, and a photo scene, the structure of the configuration file in this case is combined with fig. 7, which may be shown in fig. 9. Referring to fig. 9, the second hotspot functions in all non-important scenarios may be aggregated within the same region. Wherein, the data stored in the configuration file specifically by the second hotspot function 41, the second hotspot function 42, and the like may be a function identification (e.g., a function name) of the corresponding function. The data specifically stored in the configuration file for the non-important scene is a specific identification indicating the non-important scene.
Further, in executing S404, in addition to the functions executed by the target application program in the important scene, the second hot spot function, in which the number of times the target application program is executed in the non-important scene is greater than the preset threshold, is also a function that needs to be compiled. Based on the above, when the electronic device generates the hotspot function compiling file, function identification based on all second hotspot functions in the configuration file is needed in addition to the first hotspot function information based on corresponding different important scenes in the configuration file. That is, the electronic device needs to compile the first hotspot function and the second hotspot function to obtain the hotspot function compiled file by configuring the function identifier of the first hotspot function corresponding to different important scenes and the function identifiers of all the second hotspot functions corresponding to non-important scenes in the file. That is, the hot-spot function compiling file includes the machine code of the second hot-spot function in addition to the machine code of the first hot-spot function.
In practice, important scenes are generally important scenes for users, and the relation between the running speed of the corresponding application program in the scenes and the use experience of the users is more important. If some functions with lower use frequency in the important scene are not identified as hot spot functions and compiled, the running speed of the application program in the important scene can be reduced, and the use experience of a user is reduced. Therefore, based on the technical scheme provided by the application, all the functions executed or called in the important scene can be identified as hot spot functions and compiled, so that the running speed of the application program in the important scene can be greatly improved, and the use experience of a user is improved.
After the electronic device obtains all the hotspot functions, if different hotspot functions are placed in the configuration file only according to the obtained sequence or random disorder, the large probability can make the machine code distance of a plurality of hotspot functions with very close execution sequence or time be far away in the final configuration file compiling-based hotspot function compiling file. In practice, the electronic device extracts data of a hotspot function from the hotspot function compiling file in the hard disk to extract data of a fixed size (e.g. 4 k) from the content each time during the process of running the target application. When the electronic device needs to execute a certain hotspot function a, a fixed-size data set including the data of the hotspot function a is firstly extracted from a hotspot function compiling file of the hard disk to execute. Then, if the next hot spot function B needs to be executed, since the data of the hot spot function B and the data of the hot spot function a are far apart in the hot spot function compiling file, the electronic device needs to extract the data set with the fixed size including the data of the hot spot function B from the hot spot function compiling file again for execution. Thus, the running efficiency of the target application program is reduced.
Furthermore, the data in the memory in actual execution is also loaded into the cache to facilitate the call of the electronic device, but based on the above problem, because the storage space of the cache is smaller, if the data of two hot functions to be continuously called and executed are not adjacent or similar in the hot function compiled file, then the data storage positions of the two hot functions are not adjacent or similar when the data are extracted into the memory. Therefore, after the electronic device accesses the data of one of the hot spot functions from the cache and executes the data, the data of the other hot spot function cannot exist in the cache with high probability, and the electronic device needs to reload the data of the other hot spot function from the memory, so that the problems of cache miss and cache jitter are generated, and the running efficiency of the electronic device on the application program and the use experience of a user are reduced. Thus, in generating the configuration file, the function identification of the first hotspot function corresponding to the different important scene is placed in the same region in the configuration file, except as mentioned in the previous embodiment. It is also desirable to store function identities of first hotspot functions with higher affinity closer together based on the calling relationship between different first hotspot functions. For example, if the number of times that the first hotspot function a calls the first hotspot function B is greater than the number of times that the first hotspot function a calls the first hotspot function C, the affinity between the first hotspot function a and the first hotspot function B is higher, and the function identifier of the first hotspot function a and the function identifier of the first hotspot function B are stored more recently in the configuration file. In practice, two first hotspot functions with higher affinity may indicate a greater probability that the two first hotspot functions are executed consecutively.
Based on this, in some embodiments, the first hotspot function information obtained in S402 further includes a calling relationship between different first hotspot functions. The call relationships between different first hotspot functions may include call relationships in which each first hotspot function calls other first hotspot functions, and/or called relationships in which each first hotspot function is called by other first hotspot functions. The calling relationship may include a function name and a number of times of calling of each callee (other hotspot function), and the called relationship may include a function name and a number of times of calling of each caller (other hotspot function). In some possible implementations, the call relationships between different first hotspot functions may be stored in the target hotspot function information in a hash table. In the examples shown in fig. 5 and fig. 6, when determining all the functions executed by the target application program in the target application scenario (in fig. 6, the code scanning scenario) as the first hotspot functions, the hotspot function management module further obtains the calling relations between different first hotspot functions, so as to obtain the first hotspot function information.
In addition, the second hotspot function information obtained in the foregoing embodiment may also include a calling relationship between different second hotspot functions. The calling relations between the different second hotspot functions can refer to the expression of the calling relations between the different second hotspot functions and the first hotspot functions, and the description is omitted here.
Further, referring to fig. 10 in conjunction with fig. 7, S403A may specifically be S4031A-S4033A:
S4031A, the electronic device classifies and aggregates the function identifications of the first hot spot functions corresponding to different important scenes based on the identifications of the important scenes in all the first hot spot function information of the target application program, and obtains a first hot spot function aggregation result corresponding to the different important scenes.
The hotspot function aggregation result corresponding to any important scene comprises function identifications of all first hotspot functions corresponding to any important scene and calling relations between each first hotspot function corresponding to any important scene and other first hotspot functions.
In addition, the hotspot functions of the target application program determined by the electronic device include, in addition to the first hotspot functions, second hotspot functions in non-important scenes. Therefore, in some embodiments, when the electronic device executes S4031A, the electronic device may further aggregate the function identifiers of all the second hotspot functions corresponding to the non-important scene, to obtain a second hotspot function aggregation result. The second hotspot function aggregation result comprises a function identifier of each second hotspot function and a calling relationship of different second hotspot functions.
S4032A, the electronic device adjusts the position of the function identifier of the first hotspot function in the first hotspot function aggregation result corresponding to the first important scene by adopting a preset rule based on the calling relation of different first hotspot functions in the first hotspot function information corresponding to the first important scene.
The first important scene is any one of a plurality of important scenes corresponding to the target application program. The preset rules comprise: the more closely two first hotspot functions with higher affinities are located in the first hotspot function aggregation result. The more calls or invocations between two first hotspot functions, the higher the affinity of the two first hotspot functions. For example, if three first hotspot functions A, B and C exist in the first important scene, the number of times that the first hotspot function a calls the first hotspot function B is greater than the number of times that the first hotspot function a calls the first hotspot function C, the positions of the first hotspot function a and the first hotspot function B are closer, and the positions of the first hotspot function a and the first hotspot function C are further. In the embodiments of the present application, the specific value of the affinity may be set in any feasible manner, which is not specifically limited in this application. For example, the affinity of two first hotspot functions (or second hotspot functions) may be the number of calls or the number of times that are called between the two first hotspot functions.
In addition, the hotspot functions of the target application program determined by the electronic device include, in addition to the first hotspot functions, second hotspot functions in non-important scenes. Therefore, in some embodiments, when the electronic device executes S4032A, the electronic device may further adjust the location of the function identifier of the second hotspot function in the second hotspot function aggregation result by using a preset rule based on the calling relationship of the different second hotspot functions. The specific implementation may refer to the implementation of adjustment of the aggregation result of the first hotspot function, which is not described herein.
It should be noted that, the electronic device may implement S4032A described above with each important scene of the target application program as the first important scene.
S4033A, the electronic equipment generates a configuration file based on the first hotspot function aggregation results corresponding to the adjusted different important scenes.
By way of example, taking the example of multiple important scenarios of the target application, including a start scenario, a scan scenario, and a photo scenario, the resulting configuration file may be as shown in fig. 11. Wherein the first hotspot function of each important scene is stored together. In the storage area corresponding to each important scene, the first hotspot functions with higher affinity are positioned closer. For example, in the storage area corresponding to the startup scenario, the caller 111 closest to the first hotspot function 11 is the caller (other first hotspot function that calls the first hotspot function 11) having the highest affinity with the first hotspot function 11, and the callee 112 closest to the first hotspot function 11 is the callee (other first hotspot function that calls the first hotspot function 11) having the highest affinity with the first hotspot function 11. The first hotspot function 12 may be the first hotspot function (which may be a caller or a callee) having the highest affinity with the first hotspot function 11. In addition, the storage area of each caller (e.g., caller 111) in fig. 11 may further include the number of times the caller is called a corresponding first hotspot function (e.g., the corresponding first hotspot function of caller 111 is first hotspot function 11), and the storage area of the callee (e.g., callee 112) should further include the number of times the callee is called a corresponding first hotspot function (e.g., the corresponding first hotspot function of callee 112 is first hotspot function 11).
In addition, the hotspot functions of the target application program determined by the electronic device include, in addition to the first hotspot functions, second hotspot functions in non-important scenes. So S4033A may specifically be: the electronic equipment generates a configuration file based on the first hotspot function aggregation results corresponding to the adjusted different important scenes and the second hotspot function aggregation results after adjustment. For example, referring to fig. 12 in conjunction with fig. 11, the configuration file further includes a storage area of the non-important scene, where the storage area of the non-important scene includes function identifiers of all the second hotspot functions (e.g., the second hotspot function 41). The storage relationship of the function identifier of the second hotspot function in the storage area of the non-important scene may refer to the first hotspot function, which is not described herein.
Of course, in some embodiments, the electronic device may further generate the configuration file directly according to the first hotspot function aggregation result and the second hotspot function aggregation result corresponding to different important scenes. Because the first hotspot function aggregation result and the second hotspot function aggregation result of the configuration file comprise the calling relations of different first hotspot functions and the calling relations of different second hotspot functions, when the subsequent electronic equipment compiles based on the configuration file, the affinity between the different first hotspot functions and the affinity between the different second hotspot functions can be determined according to the calling relations, and further, the hotspot function compiling file capable of improving the running efficiency of the target application program is generated based on the affinity between the different first hotspot functions and the affinity between the different second hotspot functions. In the hotspot function compiling file, the closer the distance between the machine codes of the first hotspot function with higher affinity is, the closer the distance between the machine codes of the second hotspot function with higher affinity is.
Based on the technical scheme, the electronic equipment can generate the configuration file capable of reflecting the affinities of different hot spot functions, and the subsequent electronic equipment can reflect the affinities of the different hot spot functions based on the configuration file in the hot spot function compiling file obtained by compiling the configuration file, namely, the closer the distance before the machine code of the hot spot function with higher affinity is. Therefore, when the subsequent electronic equipment runs the target application program and needs to execute the hot spot function, the loading times of loading the content of the compiling file of the hot spot function in the memory can be reduced, and the times of cache miss and cache jitter are reduced. And further, the running efficiency of the target application program in the electronic equipment is improved, and the use experience of a user is improved.
In some embodiments, in order to obtain a hotspot function compiling file capable of reflecting affinities of different hotspot functions, when compiling the hotspot functions, the electronic device needs to determine the affinities of the different hotspot functions according to contents in the configuration file, and then compile the hotspot functions. Based on this, referring to fig. 13 in conjunction with fig. 10, S404 may specifically include S4041-S4043:
s4041, the electronic device determines affinities of different first hotspot functions according to the position relations of the different first hotspot functions in all the first hotspot functions corresponding to each important scene in the configuration file.
Specifically, the closer the first hotspot function is located, the greater the affinity. In particular, the value of affinity may be any feasible value, for example, the affinity of two first hotspot functions may be the number of calls or the number of called times between the two first hotspot functions.
In addition, the electronic device needs to compile the first hotspot function and compile the second hotspot function, so S4041 is executed, and the electronic device may determine affinities of different second hotspot functions according to the positional relationships of the different second hotspot functions in the storage area corresponding to the non-important scene in the configuration file.
In some embodiments, if the electronic device directly generates the configuration file according to the first hotspot function aggregation result and the second hotspot function aggregation result corresponding to different important scenarios, the positional relationship of different first hotspot functions in the configuration file cannot reflect the affinity, and S4041 may be that when the electronic device compiles the hotspot functions (the first hotspot function and the second hotspot function) based on the configuration file, the affinity of different hotspot functions may be determined directly according to the calling relationship between different hotspot functions in the configuration file.
S4042, the electronic device compiles according to the affinities among the first hot spot functions corresponding to each important scene to obtain the machine code segments corresponding to each important scene.
The machine code segment corresponding to any important scene comprises machine codes of all first hot spot functions corresponding to any important scene, and the positions of the machine codes of the two first hot spot functions with higher affinity are more similar. For example, if a certain important scenario includes three first hotspot functions A, B and C, and affinity of a and B is greater than a and C, then in the machine code segment of the important scenario for a beverage, the machine code of a is followed by the machine code of B, and the machine code of B is followed by the machine code of C.
In addition, the electronic device needs to compile the second hotspot functions in addition to the first hotspot functions, so S4042 is executed, and at the same time, the electronic device may compile all the second hotspot functions according to affinities between different second hotspot functions, to obtain machine code segments corresponding to non-important scenes.
S4043, the electronic equipment generates a hot spot function compiling file based on the machine code segments corresponding to each important scene in a combined mode.
In the hot spot function compiling file, the positional relationship between machine code segments between different important scenes may be any feasible situation, and the application is not particularly limited.
In addition, the electronic device needs to compile the first hotspot function and compile the second hotspot function, so S4043 may specifically be that the electronic device generates the hotspot function compilation file based on a combination of the machine code segment corresponding to each important scene and the machine code segment of the non-important scene.
In order to more clearly illustrate the flow of compiling the first hotspot function by the electronic device in the embodiment of the present application, the following description is provided with reference to fig. 14. Referring to fig. 14, the flow of compiling the first hotspot function by the electronic device is as follows:
after compiling starts, the electronic device first reads the configuration file, and reads the code file (e.g., dex file) of the hotspot function from the code file of the target application program based on the function identifications of all the hotspot functions (the first hotspot function and the second hotspot function) in the configuration file.
The electronic device may then traverse all the scenes (including each important scene and non-important scene) in the configuration file one by one to obtain a list of hotspot functions in each scene until all the scene traversals are completed. The list of hot spot functions for any one scene may include function identifications of all hot spot functions in the any one scene.
Then, traversing the hot spot functions in the hot spot function list in each scene one by one, and sorting based on the calling relation and the called relation among different hot spot functions, namely determining the affinity. In the ranking result, the closer the distance between two hotspot functions with higher affinity. In addition, in the sorting result, the hotspot functions in the first order may be hotspot functions in the corresponding scene, which are not called by other hotspot functions.
And compiling the hot spot function in each scene according to the sequencing result of each scene, and generating a hot spot function compiling file (such as oat file) based on the compiling results corresponding to all the scenes.
Specific implementation of the above process may refer to the relevant description in the foregoing embodiments, and will not be repeated here.
Based on the technical scheme, the electronic equipment can generate the hot spot function compiling file on the basis of fully considering the affinities of different hot spot functions. The affinity of different hotspot functions, i.e. the closer the distance before the machine code of the hotspot function with higher affinity, can be reflected in the hotspot function compilation file. Therefore, when the subsequent electronic equipment runs the target application program and needs to execute the hot spot function, the loading times of loading the content of the compiling file of the hot spot function in the memory can be reduced, and the times of cache miss and cache jitter are reduced. And further, the running efficiency of the target application program in the electronic equipment is improved, and the use experience of a user is improved.
It will be appreciated that, in order to achieve the above-mentioned functions, the electronic device includes corresponding hardware structures and/or software modules for performing the respective functions. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present application.
The embodiment of the application may divide the functional modules of the electronic device according to the method example, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated modules may be implemented in hardware or in software functional modules. It should be noted that, in the embodiment of the present invention, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation.
In the case of dividing each functional module by corresponding each function, referring to fig. 15, an embodiment of the present application provides an electronic device, which can implement the compilation optimization method provided in the foregoing embodiment. The electronic device may include: an acquisition module 151, a processing module 152 and a compiling module 153.
Specifically, the acquiring module 151 is configured to acquire application scenario information of a target application program, and determine a target application scenario where the target application program is located based on the application scenario information; the processing module 152 is configured to determine, when the target application scenario determined by the obtaining module 151 belongs to the important scenario set, all functions executed by the target application program in the target application scenario as first hotspot functions, so as to obtain first hotspot function information of the target application program in the target application scenario; the first hotspot function information includes: function identifiers of all first hotspot functions and identifiers of important scenes; the important scene set comprises a plurality of important scenes; the compiling module 153 is configured to generate a hotspot function compiling file based on all the first hotspot function information of the target application program.
With respect to the electronic apparatus in the above-described embodiments, a specific manner in which each module performs an operation has been described in detail in the embodiments of the information display method in the foregoing embodiments, and will not be specifically described herein. The related beneficial effects of the method can also refer to the related beneficial effects of the information display method, and are not repeated here.
The embodiment of the application also provides electronic equipment, which comprises: a display screen, a memory, and one or more processors; the display screen and the memory are coupled with the processor; wherein the memory has stored therein computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform a compilation optimization method as provided by the foregoing embodiments. The specific structure of the electronic device may refer to the structure of the electronic device shown in fig. 2.
The present embodiments also provide a computer readable storage medium comprising computer instructions that, when executed on an electronic device, cause the electronic device to perform a compilation optimization method as provided by the foregoing embodiments.
Embodiments of the present application also provide a computer program product containing executable instructions that, when run on an electronic device, cause the electronic device to perform a compilation optimization method as provided by the previous embodiments.
It will be apparent to those skilled in the art from this description that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus/devices and methods may be implemented in other ways. For example, the apparatus/device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and the parts displayed as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a readable storage medium. Based on such understanding, the technical solution of the embodiments of the present application may be essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including several instructions for causing a device (may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read Only Memory (ROM), a random access memory (random access memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely a specific embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered in the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (7)

1. A compilation optimization method applied to an electronic device, the method comprising:
the electronic equipment acquires application scene information of a target application program and determines a target application scene where the target application program is located based on the application scene information;
under the condition that the target application scene belongs to an important scene set, the electronic equipment determines all functions executed by the target application program in the target application scene as first hot spot functions so as to obtain first hot spot function information of the target application program in the target application scene; the first hotspot function information includes: function identifiers of all first hotspot functions and identifiers of important scenes; the set of important scenes comprises a plurality of important scenes;
the electronic equipment generates a hotspot function compiling file based on all the first hotspot function information of the target application program;
the electronic device generates a hotspot function compiling file based on all the first hotspot function information of the target application program, and the hotspot function compiling file comprises:
the electronic equipment classifies and aggregates the function identifications of the first hot spot functions corresponding to different important scenes based on the identifications of the important scenes in all the first hot spot function information of the target application program to obtain a first hot spot function aggregation result corresponding to different important scenes;
The electronic equipment adjusts the position of the function identifier of the first hotspot function in the first hotspot function aggregation result corresponding to the first important scene by adopting a preset rule based on the calling relation of different first hotspot functions in the first hotspot function information corresponding to the first important scene; the first important scene is any one of a plurality of important scenes corresponding to the target application program; the preset rule comprises the following steps: the positions of the two first hotspot functions with higher affinity in the first hotspot function aggregation result are more similar; the more the calling times or called times between any two first hot spot functions, the higher the affinity of the any two first hot spot functions;
the electronic equipment generates a configuration file based on the first hotspot function aggregation results corresponding to the adjusted different important scenes;
and compiling all the first hot spot functions by the electronic equipment based on the function identifications of the first hot spot functions corresponding to different important scenes in the configuration file so as to obtain a hot spot function compiling file.
2. The method of claim 1, wherein the compiling all the first hotspot functions by the electronic device based on the function identifications of the first hotspot functions corresponding to different important scenes in the configuration file to obtain a hotspot function compiled file includes:
And compiling all the first hot spot functions by the electronic equipment based on the function identifications of the first hot spot functions corresponding to different important scenes in the configuration file, and compiling the first hot spot functions corresponding to the same important scene in the same machine code segment in the hot spot function compiling file.
3. The method of claim 1, wherein the compiling all the first hotspot functions by the electronic device based on the function identifications of the first hotspot functions corresponding to different important scenes in the configuration file to obtain a hotspot function compiled file includes:
the electronic equipment determines affinities of different first hotspot functions according to the position relations of the different first hotspot functions in all first hotspot functions corresponding to each important scene in the configuration file;
the electronic equipment compiles according to the affinities among the first hot spot functions corresponding to each important scene to obtain machine code segments corresponding to each important scene; the machine code segment corresponding to any important scene comprises machine codes of all first hot spot functions corresponding to any important scene, and the positions between the machine codes of the two first hot spot functions with higher affinity are more similar;
And the electronic equipment generates a hot spot function compiling file based on the machine code segments corresponding to each important scene in a combined mode.
4. A method according to any one of claims 1-3, wherein the method further comprises:
under the condition that the target application scene does not belong to an important scene set, the electronic equipment determines a second hot spot function based on the execution times of the function executed by the target application program in the target application scene so as to obtain second hot spot function information; the second hotspot function information includes: function identification of all second hotspot functions;
the electronic device generates a hotspot function compiling file based on all the first hotspot function information of the target application program, and the hotspot function compiling file comprises:
and the electronic equipment generates a hotspot function compiling file based on all the first hotspot function information and all the second hotspot function information of the target application program.
5. The method of claim 4, wherein the electronic device determining a second hotspot function based on the number of executions of the function executed by the target application in the target application scenario comprises:
and the electronic equipment determines a function, of which the execution times of the target application program in the target application scene are larger than a preset threshold, as the second hot spot function.
6. An electronic device comprising a memory and one or more processors; the memory is coupled with the processor; wherein the memory has stored therein computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform the compilation optimization method of any of claims 1-5.
7. A computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the compilation optimization method of any of claims 1-5.
CN202310769339.7A 2023-06-28 2023-06-28 Compiling optimization method, electronic equipment and storage medium Active CN116521180B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310769339.7A CN116521180B (en) 2023-06-28 2023-06-28 Compiling optimization method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310769339.7A CN116521180B (en) 2023-06-28 2023-06-28 Compiling optimization method, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116521180A CN116521180A (en) 2023-08-01
CN116521180B true CN116521180B (en) 2024-03-08

Family

ID=87397952

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310769339.7A Active CN116521180B (en) 2023-06-28 2023-06-28 Compiling optimization method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116521180B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103713933A (en) * 2013-12-31 2014-04-09 华为技术有限公司 Method, device and system for converging hotspot functions and variables in computer programs
CN109241633A (en) * 2018-09-12 2019-01-18 西安交通大学 Fluid machinery parallel simulation program process mapping method based on genetic algorithm
CN112948026A (en) * 2019-11-26 2021-06-11 Oppo广东移动通信有限公司 Hotspot code processing method and device, server, electronic equipment and storage medium
CN115827006A (en) * 2022-12-08 2023-03-21 北京小米移动软件有限公司 Application installation method and device, electronic equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7765534B2 (en) * 2004-04-30 2010-07-27 International Business Machines Corporation Compiler with cache utilization optimizations
US8959495B2 (en) * 2012-09-14 2015-02-17 Oracle International Corporation Unifying static and dynamic compiler optimizations in source-code bases

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103713933A (en) * 2013-12-31 2014-04-09 华为技术有限公司 Method, device and system for converging hotspot functions and variables in computer programs
CN109241633A (en) * 2018-09-12 2019-01-18 西安交通大学 Fluid machinery parallel simulation program process mapping method based on genetic algorithm
CN112948026A (en) * 2019-11-26 2021-06-11 Oppo广东移动通信有限公司 Hotspot code processing method and device, server, electronic equipment and storage medium
CN115827006A (en) * 2022-12-08 2023-03-21 北京小米移动软件有限公司 Application installation method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种监测函数语义信息访存地址序列的方法;陈荔城等;计算机研究与发展(05);全文 *

Also Published As

Publication number Publication date
CN116521180A (en) 2023-08-01

Similar Documents

Publication Publication Date Title
CN113568634B (en) Processing method and processing device for application optimization
CN112988213B (en) Program data updating method, electronic equipment and computer storage medium
WO2021185352A1 (en) Version upgrade method and related apparatus
CN112817634B (en) COTA package downloading method and device
WO2021104117A1 (en) Method for constructing application program resource packet, construction apparatus, and terminal device
CN115333941B (en) Method for acquiring application running condition and related equipment
WO2022247446A1 (en) Performance optimization method and related device
CN116156044A (en) Equipment cooperation method and related device
CN113656089B (en) Class verification method and device in application program
CN116483734B (en) Pile inserting method and system based on compiler and related electronic equipment
CN116643778B (en) Application program optimization method and electronic equipment
CN116521180B (en) Compiling optimization method, electronic equipment and storage medium
CN117130617A (en) Compiling method and device of application program
CN113885928B (en) Program updating method and electronic device
CN117093315B (en) Upgrade content display method, electronic equipment and storage medium
CN116027933B (en) Method and device for processing service information
CN116719556B (en) System upgrading method and electronic equipment
CN114996078B (en) Method and device for compiling control of dex file
CN115767602B (en) Automatic error correction method for equipment protocol subsystem abnormality and electronic equipment
CN117009023B (en) Method for displaying notification information and related device
CN115952564B (en) Data writing method and terminal equipment
CN116048629B (en) System service switching method, control device, electronic equipment and storage medium
CN116719398B (en) Temperature control method, electronic equipment and storage medium
CN117707755A (en) Thread identifier distribution method, electronic equipment and storage medium
CN117950677A (en) Software distribution method, electronic equipment and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant