Method and device for dynamically adjusting JIT size of virtual machine and storage medium
By precompiling and calculating the target application of POS machine, dynamically adjusting the JIT size of the virtual machine, the POS machine's operating efficiency problem caused by mismatch of JIT size parameters is solved, and more efficient operation speed and stability are achieved.
Patent Information
- Application Number
- CN202411477338.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-03-21
AI Technical Summary
Due to the mismatch of JIT size parameters of POS machines, they lead to low operational efficiency and slow response.
By precompiling the target application, calculating its complexity, dynamically adjusting the virtual machine JIT size according to the complexity, storing it in a configuration file, and updating the virtual machine JIT size in real time to match the application's needs.
It improves the running speed of the POS machine, ensures that the virtual machine is always in the most suitable memory state, adapts to high-complex applications, and ensures the normal operation of the virtual machine.
Smart Images

Figure CN119668772A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual machine technology, and in particular to a method, device and storage medium for dynamically adjusting the JIT size of a virtual machine. Background Art
[0002] In the modern business environment, POS machines are key payment tools, and their core function is to efficiently and stably process the payment process between users and merchants. Compared with smartphones, which are highly integrated personal devices, POS machines are designed to focus more on applications in specific business scenarios, especially the speed and stability of payment processing. However, there is a gap in hardware performance between POS machines and smartphones, especially in terms of processor speed and memory management. Most of the POS machines on the market currently use the code base and parameter configuration schemes of smartphones, and preset fixed default values. For example, before compiling the firmware, the POS machine has already preset the current JIT size in the code. The system has been precompiling and executing bytecodes with a fixed JIT size, which ultimately leads to problems such as low operating efficiency and slow response due to mismatched JIT size parameters. Summary of the invention
[0003] In order to solve the above technical problems, the present application provides a method, device and storage medium for dynamically adjusting the JIT size of a virtual machine, so as to improve the operating speed of a POS machine.
[0004] The technical solution provided in this application is described below:
[0005] The first aspect of the present application provides a method for dynamically adjusting the size of a virtual machine JIT, comprising:
[0006] Precompile the target application to obtain the compiled code;
[0007] Calculating the complexity of the target application according to the size of the target application and the encoding and decoding;
[0008] Setting a JIT size corresponding to the target application according to the complexity, wherein the JIT size corresponding to the target application increases as the complexity increases;
[0009] Storing the application package name of the target application and the JIT size corresponding to the target application in a configuration file;
[0010] When an operation instruction of the user for the target application is detected, identifying the application package name of the target application;
[0011] Reading a configuration file of the target application according to the application package name of the target application;
[0012] The virtual machine JIT size is updated according to the JIT size corresponding to the target application in the configuration file.
[0013] Optionally, before precompiling the target application, the method further includes:
[0014] The maximum value of the JIT compilation cache is preset according to the terminal performance of the terminal on which the target application is installed.
[0015] Optionally, precompiling the target application to obtain the compiled code includes:
[0016] The bytecode of the target application is precompiled into machine code, and the machine code is used as the compiled code.
[0017] Optionally, precompiling the bytecode of the target application into machine code includes:
[0018] Acquire a bytecode set of the target application, wherein the bytecode set includes all instructions of the target application;
[0019] By monitoring the usage counts of all instructions in the target application, the bytecodes corresponding to the instructions whose usage counts are greater than a preset count are used as hot bytecodes;
[0020] The heat bytecode is precompiled into machine code.
[0021] Optionally, the calculating the complexity of the target application according to the size of the target application and the encoding and decoding includes:
[0022] Whenever the size of the target application increases by a first preset value, the first complexity increases by one unit;
[0023] Whenever the size of the code increases by a second preset value, the second complexity increases by one unit;
[0024] The first complexity and the second complexity are accumulated to obtain the complexity of the target application.
[0025] Optionally, the configuration file further includes version information of the target application, and after reading the configuration file of the target application according to the application package name of the target application, further includes:
[0026] Detect whether the version information is the latest version;
[0027] If yes, then updating the virtual machine JIT size according to the JIT size corresponding to the target application in the configuration file;
[0028] If not, the complexity of the target application is recalculated and a new configuration file is set after the target application is updated.
[0029] Optionally, after updating the JIT size of the virtual machine according to the JIT size corresponding to the target application in the configuration file, the method further includes:
[0030] Monitor the terminal operation status in real time and obtain monitoring results;
[0031] When the monitoring result indicates that the terminal operation status is overloaded, the complexity of the target application is recalculated according to the maximum value of the JIT compilation cache and a new configuration file is set.
[0032] A second aspect of the present application provides a device for dynamically adjusting the size of a virtual machine JIT, including:
[0033] A pre-compilation unit, used to pre-compile the target application to obtain a compiled code;
[0034] A complexity unit, configured to calculate the complexity of the target application according to the size of the target application and the encoding and decoding;
[0035] A setting unit, configured to set a JIT size corresponding to the target application according to the complexity, wherein the JIT size corresponding to the target application increases as the complexity increases;
[0036] A configuration file unit, used to store the application package name of the target application and the JIT size corresponding to the target application into a configuration file;
[0037] an identification unit, configured to identify an application package name of the target application when an operation instruction of the user for the target application is detected;
[0038] A reading unit, configured to read a configuration file of the target application according to an application package name of the target application;
[0039] An updating unit is used to update the JIT size of the virtual machine according to the JIT size corresponding to the target application in the configuration file.
[0040] A third aspect of the present application provides a device for dynamically adjusting the size of a virtual machine JIT, the device for dynamically adjusting the size of a virtual machine JIT comprising:
[0041] Processor, memory, input-output unit, and bus;
[0042] The processor is connected to the memory, the input and output unit, and the bus;
[0043] The memory stores a program, and the processor calls the program to execute the first aspect and the optional method of dynamically adjusting the JIT size of the virtual machine in any one of the first aspect.
[0044] The fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the method for dynamically adjusting the size of a virtual machine JIT according to the first aspect and any optional item in the first aspect is executed.
[0045] It can be seen from the above technical solutions that this application has the following advantages:
[0046] The present application provides a method for dynamically adjusting the JIT size of a virtual machine, first precompiling the target application to obtain a compiled code; secondly, calculating the complexity of the target application based on the size of the target application and the compiled code; then setting the JIT size corresponding to the target application based on the complexity, and the JIT size corresponding to the target application increases with the increase in complexity; and storing the application package name of the target application and the JIT size corresponding to the target application in a configuration file; when detecting the user's operation instruction for the target application, identifying the application package name of the target application; further reading the configuration file of the target application based on the application package name of the target application; and finally updating the JIT size of the virtual machine based on the JIT size corresponding to the target application in the configuration file. The present application dynamically adjusts the JIT size of the terminal's virtual machine according to the complexity of each target application for different target applications, so that the terminal is always in the most appropriate virtual machine memory state, and even for target applications with higher complexity, adaptive adjustments can be made to ensure the normal operation of the virtual machine and improve the running speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solution in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0048] Figure 1 A flowchart of an embodiment of a method for dynamically adjusting the JIT size of a virtual machine provided in this application;
[0049] Figure 2 A flowchart of another embodiment of the method for dynamically adjusting the JIT size of a virtual machine provided by the present application;
[0050] Figure 3 A flowchart of another embodiment of the method for dynamically adjusting the JIT size of a virtual machine provided by the present application;
[0051] Figure 4 A flowchart of another embodiment of the method for dynamically adjusting the JIT size of a virtual machine provided by the present application;
[0052] Figure 5A flowchart of another embodiment of the method for dynamically adjusting the JIT size of a virtual machine provided by the present application;
[0053] Figure 6 A schematic diagram of the structure of an embodiment of a device for dynamically adjusting the size of a virtual machine JIT provided by the present application;
[0054] Figure 7 A schematic diagram of the structure of another embodiment of the device for dynamically adjusting the JIT size of a virtual machine provided in the present application. DETAILED DESCRIPTION
[0055] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0056] In the description of the present invention, "several" means one or more, "more" means more than two, "greater than", "less than", "exceed" etc. are understood as not including the number itself, and "above", "below", "within" etc. are understood as including the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0057] In the description of the present invention, it should be understood that descriptions involving orientation, such as up, down, left, right, front, back, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.
[0058] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0059] In the description of the present invention, it should be noted that, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention in combination with the specific content of the technical solution. In addition, the identification of specific steps below does not represent a limitation on the order of steps and execution logic, and the execution order and execution logic between each step should be understood and inferred with reference to the contents described in the embodiment.
[0060] The method provided in this application can be applied to a terminal or a system, or a server. For example, the terminal can be a smart phone or a computer, a tablet computer, a portable computer terminal, or a fixed terminal such as a desktop computer. For the convenience of description, the following description is taken as an example of a system applied to a POS machine as the execution subject.
[0061] It should also be noted that the terms "first", "second", etc. in the specification and drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order, sequence or importance.
[0062] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention provides a method, device and storage medium for dynamically adjusting the JIT size of a virtual machine, which are used to improve the operating speed of a POS machine.
[0063] See also Figure 1 , Figure 1 An embodiment of a method for dynamically adjusting a virtual machine JIT size provided in the present application includes:
[0064] Step S101, precompile the target application to obtain a compiled code;
[0065] Step S102, calculating the complexity of the target application according to the size and encoding of the target application;
[0066] Step S103, setting the JIT size corresponding to the target application according to the complexity, and the JIT size corresponding to the target application increases as the complexity increases;
[0067] Step S104: storing the application package name of the target application and the JIT size corresponding to the target application in a configuration file;
[0068] Step S105: when an operation instruction of the user for the target application is detected, identifying the application package name of the target application;
[0069] Step S106: Read the configuration file of the target application according to the application package name of the target application;
[0070] Step S107: Update the JIT size of the virtual machine according to the JIT size corresponding to the target application in the configuration file.
[0071] The method for dynamically adjusting the JIT size of a virtual machine of the present invention first precompiles the target application to obtain a compiled code; secondly, the complexity of the target application is calculated according to the size of the target application and the compiled code; then, the JIT size corresponding to the target application is set according to the complexity, and the JIT size corresponding to the target application increases with the increase in complexity; and the application package name of the target application and the JIT size corresponding to the target application are stored in a configuration file; when an operation instruction of the user for the target application is detected, the application package name of the target application is identified; further, the configuration file of the target application is read according to the application package name of the target application; finally, the JIT size of the virtual machine is updated according to the JIT size corresponding to the target application in the configuration file. This application dynamically adjusts the JIT size of the virtual machine of the terminal according to the complexity of each target application for different target applications, so that the terminal is always in the most appropriate virtual machine memory state, and even for target applications with higher complexity, adaptive adjustments can be made to ensure the normal operation of the virtual machine and improve the operation speed.
[0072] In step S101 of some embodiments, the target application is precompiled to obtain a compiled code. It should be noted that, according to the performance of the terminal (in this embodiment, the terminal refers to the POS machine) on which the target application is carried, the maximum value of the JIT compilation cache, i.e., the dalvik.vm.jitmaxsize value, will be pre-set when the JIT function is started to ensure that the JIT compiler can work normally. The maximum value of the JIT compilation cache is a memory limit used to control how much code the JIT compiler can compile and cache. After the maximum value of the JIT compilation cache is preset, the system of the POS machine will retrieve the target application in the terminal, and pre-compile the target application to obtain the compiled code. The process of obtaining the compiled code is to use a pre-compilation tool to pre-compile the bytecode of the target application into a machine code, and the machine code is the compiled code. Among them, before the bytecode is pre-compiled into the machine code, the bytecode can also be pre-processed, including syntax checking, macro expansion, etc. The bytecode of the target application is pre-compiled into a machine code, and the machine code can be directly executed on the hardware without passing through the interpreter again, which can speed up the startup and operation of the target application.
[0073] Reference Figure 2 According to some embodiments of the present invention, in order to improve the speed and efficiency of precompilation, the precompiled bytecodes may be screened to reduce the precompilation resources occupied by unnecessary bytecodes. That is, the precompilation of the bytecodes of the target application into machine codes mentioned in step S101 may specifically include, but not limited to, the following:
[0074] Step S201, obtaining a bytecode set of a target application, where the bytecode set includes all instructions of the target application;
[0075] Step S202: monitor the usage times of all instructions in the target application, and use the bytecodes corresponding to the instructions whose usage times are greater than a preset number as hot bytecodes;
[0076] Step S203: precompile the heat bytecode into machine code.
[0077] In steps S201 to S203 of some embodiments, the bytecode set of the target application is first obtained, and the bytecode set includes all instructions of the target application. Then, by monitoring the number of times all instructions in the target application are used, the bytecode corresponding to the instruction whose number of times of use is greater than the preset number of times is used as the hot bytecode, and then the hot bytecode is precompiled into machine code. Among them, a complete bytecode set is extracted from the target application using a special tool or framework (such as ASM, Javassist, etc.). The bytecode set contains all instructions executed by the target application. A lightweight monitoring module is integrated in the system, which can capture and record the call status of each bytecode instruction at each execution. After collecting a sufficient amount of execution data, the number of times the monitored bytecode is used is statistically analyzed. According to the preset number of times (such as the preset number of times is set to 70% of the total number of calls, etc.), the bytecode instructions used frequently, namely the hot bytecode, are screened out. The identified hot bytecode is input into the JIT compiler, and the hot bytecode is precompiled into the corresponding machine code. During the precompilation process, the machine code can be further optimized, such as inline expansion, loop optimization, etc., to improve execution efficiency.
[0078] In step S102 of some embodiments, the complexity of the target application is calculated based on the size and encoding of the target application. When calculating the complexity of the target application, multiple aspects can be considered to evaluate its complexity, including but not limited to: the number of source code lines of the target application, the number of methods, cyclic complexity, the number of conditional branches, external library dependencies, etc. When considering multiple factors, weights can also be assigned to different evaluation indicators, and the complexity score of the application can be calculated by weighted summation. In addition, the complexity score can also be adjusted according to specific rules. For example, for target applications that contain a large number of complex algorithms or high-concurrency processing, an additional complexity consideration score can be added; and for applications that use a large number of third-party libraries but have relatively simple logic, the complexity consideration score can be appropriately deducted. The calculation of complexity will affect the update of the JIT size of the virtual machine of the POS machine.
[0079] Reference Figure 3 According to some embodiments of the present invention, calculating the complexity of the target application according to the size and encoding of the target application in step S102 may specifically include, but is not limited to, the following:
[0080] Step S301: Whenever the size of the target application increases by a first preset value, the first complexity increases by one unit;
[0081] Step S302: Whenever the size of the code increases by a second preset value, the second complexity increases by one unit;
[0082] Step S303: accumulate the first complexity and the second complexity to obtain the complexity of the target application.
[0083] In steps S301 to S302 of some embodiments, whenever the size of the target application increases by a first preset value, the first complexity increases by one unit; whenever the size of the code increases by a second preset value, the second complexity increases by one unit; and then the first complexity and the second complexity are accumulated to obtain the complexity of the target application. The first complexity is calculated based on the size of the target application. The first preset value can be set to 10M, that is, for every increase of 10M in the size of the target application, the first complexity is calculated to be 1. For example, if the size of the target application itself is 100M, the first complexity is 10. The second complexity is calculated based on the code. The second preset value can also be set to 10M, that is, for every increase of 10M in the code size, the second complexity is calculated to be 1. For example, if the code size of the target application in the above example is 30M, the second complexity is 3. Therefore, the complexity of the target application obtained by accumulating the first complexity and the second complexity is 13.
[0084] In step S103 of some embodiments, the JIT size corresponding to the target application is set according to the complexity, and the JIT size corresponding to the target application increases as the complexity increases. After the complexity is obtained in step S102, the JIT size that should be set when running the target application is set according to the complexity, that is, the JIT size corresponding to the target application. The JIT size corresponding to the target application can be a specific value; it can also be set to a range first, and then the virtual machine JIT size is dynamically adjusted within the range. It should be noted that if the JIT size corresponding to the target application is a specific value, when switching to run different target applications, the complexity increases, the specific value also increases, and vice versa, when the complexity decreases, the specific value also decreases; if the JIT size corresponding to the target application is set to a range, when the complexity increases, the maximum value or the minimum value of the range increases alone, or both the maximum value and the minimum value increase. It should also be noted that the setting of the JIT size corresponding to the target application should not exceed the maximum value of the JIT compilation cache pre-set in step S101. Therefore, the existence of the complexity of the target application makes it practical to realize the dynamic adjustment of the virtual machine JIT size.
[0085] In step S104 of some embodiments, the application package name of the target application and the JIT size corresponding to the target application are stored in the configuration file. A configuration file (such as Package_complexity.xml) is created in a specific directory of the virtual machine to store the application package name of the target application and the JIT size corresponding to the target application obtained in step S103. It should be noted that the configuration file also includes the complexity of the target application calculated in step S102, and the application package name of the target application can be used as a key, and the complexity and the corresponding JIT size can be used as values, and written into the configuration file in the form of a key-value pair.
[0086] In step S105 of some embodiments, when the virtual machine of the POS machine is running, it continuously detects whether an event occurs in the system, and identifies the application package name of the target application when an operation instruction of the user for the target application is detected. The operation instruction of the user for the target application is, for example, to start the target application or to run a function of the target application, that is, when it is detected that the user has started a target application, the application package name of the target application can be identified by using methods such as callback functions.
[0087] In step S106 of some embodiments, the configuration file of the target application is read according to the application package name of the target application. After the application package name, complexity and corresponding JIT size of the target application are written into the configuration file in the form of key-value pairs in step S104, the association between the key values can be directly used to directly and quickly access and obtain the JIT size corresponding to the target application through the application package name, making the search and retrieval process more efficient.
[0088] Reference Figure 4 , with the update of the target application version, the functional complexity and resource usage pattern of the target application may change. If the virtual machine JIT size remains unchanged, these changes will affect the operating efficiency of the POS terminal. Therefore, it is necessary to adaptively update the virtual machine JIT size according to the target application version update, which may include, but is not limited to, the following:
[0089] Step S401, check whether the version information is the latest version; if so, execute step S402; if not, execute step S403;
[0090] Step S402: Update the JIT size of the virtual machine according to the JIT size corresponding to the target application in the configuration file;
[0091] Step S403: After the target application is updated, the complexity of the target application is recalculated and a new configuration file is set.
[0092] In steps S401 to S403 of some embodiments, it is detected whether the version information is the latest version; if so, the virtual machine JIT size is updated according to the JIT size corresponding to the target application in the configuration file; if not, the complexity of the target application is recalculated and a new configuration file is set. The configuration file also includes version information, and the version information of the target application is obtained by accessing or reading the configuration file. The version information includes a recorded version number or a recorded version update time. The recorded version number is compared with the latest version number provided by the target application provider, or the recorded version update time is compared with the version update time provided by the target application provider, so as to determine whether the version information recorded in the configuration file is the latest version.
[0093] If the version information is the latest version, the virtual machine JIT size is updated according to the JIT size corresponding to the target application in the configuration file to optimize the execution efficiency of the target application. If the version information is not the latest version, the corresponding latest version should be obtained first, the target application should be updated according to the latest version, and then the target application complexity should be recalculated and a new configuration file should be set, and then the virtual machine JIT size should be updated according to the JIT size corresponding to the target application in the new configuration file.
[0094] In step S107 of some embodiments, the JIT size of the virtual machine is updated according to the JIT size corresponding to the target application in the configuration file. The JIT size of the virtual machine is updated or modified according to the JIT size corresponding to the read target application, and the memory allocation of the JIT area can also be adjusted. After the adjustment is completed, the effect of the update or modification can be verified by a performance monitoring tool. If the operating status of the POS machine after the update or modification is as expected, that is, the operating speed of the POS machine remains within the normal range, the adjustment result is retained; otherwise, the complexity should be re-evaluated or the JIT size corresponding to the target application should be set to a new range, and the JIT size of the virtual machine should be dynamically adjusted within the range.
[0095] Reference Figure 5 In order to further ensure that the POS machine is in good operating condition, the operating status of the POS machine can also be monitored in real time and adjusted in time, which may include, but is not limited to, the following:
[0096] Step S501: monitor the terminal operation status in real time and obtain monitoring results;
[0097] Step S502: When the monitoring result shows that the terminal operation status is overloaded, the complexity of the target application is recalculated according to the maximum value of the JIT compilation cache and a new configuration file is set.
[0098] In steps S501 to S502 of some embodiments, the terminal operation status is monitored in real time to obtain monitoring results; when the monitoring result is that the terminal operation status is overloaded, the complexity of the target application is recalculated and a new configuration file is set according to the maximum value of the JIT compilation cache. The terminal operation status is monitored in real time by a monitoring module, and the monitoring module periodically (such as every second or every few minutes) collects monitoring data and records it in real time. The collected monitoring data can be analyzed using an analysis algorithm or a machine learning model to evaluate the current operation status of the terminal. When the monitoring result is that the terminal operation status is overloaded, the complexity of the target application is recalculated and a new configuration file is set within the range allowed by the maximum value of the JIT compilation cache to ensure that the target application can still run in the optimal state when resources are limited.
[0099] The above embodiment describes the method for dynamically adjusting the size of a virtual machine JIT provided by the present application. The following describes the device and storage medium for dynamically adjusting the size of a virtual machine JIT provided by the present application:
[0100] See also Figure 6 The present application provides an embodiment of a device for dynamically adjusting the size of a virtual machine JIT, and the device for dynamically adjusting the size of a virtual machine JIT includes:
[0101] A pre-compilation unit 601 is used to pre-compile the target application to obtain a compiled code;
[0102] A complexity unit 602, used to calculate the complexity of the target application according to the size and encoding of the target application;
[0103] A setting unit 603, used to set the JIT size corresponding to the target application according to the complexity, and the JIT size corresponding to the target application increases as the complexity increases;
[0104] A configuration file unit 604, used to store the application package name of the target application and the JIT size corresponding to the target application into a configuration file;
[0105] An identification unit 605 is used to identify the application package name of the target application when an operation instruction of the user for the target application is detected;
[0106] A reading unit 606 is used to read a configuration file of a target application according to an application package name of the target application;
[0107] The updating unit 607 is used to update the JIT size of the virtual machine according to the JIT size corresponding to the target application in the configuration file.
[0108] Optionally, before the pre-compilation unit 601, it further includes:
[0109] The preset value unit 613 is used to preset the maximum value of the JIT compilation cache according to the terminal performance.
[0110] Optionally, the pre-compilation unit 601 is specifically used for:
[0111] Precompile the bytecode of the target application into machine code, and use the machine code as the compiled code.
[0112] Optionally, the pre-compilation unit 601 is specifically used for:
[0113] Obtaining a bytecode set of a target application, where the bytecode set includes all instructions of the target application;
[0114] By monitoring the usage count of all instructions in the target application, the bytecodes corresponding to the instructions whose usage count is greater than a preset number are regarded as hot bytecodes;
[0115] Precompile the heat bytecode into machine code.
[0116] Optionally, the complexity unit 602 is specifically used for:
[0117] Whenever the size of the target application increases by a first preset value, the first complexity increases by one unit;
[0118] Whenever the size of the code increases by a second preset value, the second complexity increases by one unit;
[0119] The first complexity and the second complexity are accumulated to obtain the complexity of the target application.
[0120] Optionally, the configuration file also includes version information of the target application, and after the reading unit 606, further includes:
[0121] A detection unit 608, used to detect whether the version information is the latest version;
[0122] The current version unit 609 is used to update the virtual machine JIT size according to the JIT size corresponding to the target application in the configuration file if the version information is the latest version;
[0123] The first recalculation unit 610 is used to recalculate the complexity of the target application and set a new configuration file after the target application is updated if the version information is not the current latest version.
[0124] Optionally, after the updating unit 607, the method further includes:
[0125] The monitoring unit 611 is used to monitor the terminal operation status in real time and obtain monitoring results;
[0126] The second recalculation unit 612 is used to recalculate the complexity of the target application and set a new configuration file according to the maximum value of the JIT compilation cache when the monitoring result shows that the terminal operation status is overloaded.
[0127] This application also provides a device for dynamically adjusting the size of the virtual machine JIT, see Figure 7 , the device comprises:
[0128] Processor 701, memory 702, input and output unit 703, bus 704;
[0129] The processor 701 is connected to the memory 702, the input and output unit 703 and the bus 704;
[0130] The memory 702 stores a program, and the processor 701 calls the program to execute the following steps: Figures 1 to 5 A method for monitoring battery safety of a POS terminal as shown in any one of the embodiments.
[0131] The present application also relates to a computer-readable storage medium, on which a program is stored, and when the program is run on a computer, the computer executes the following Figures 1 to 5 A method for monitoring battery safety of a POS terminal as shown in any one of the embodiments.
[0132] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0133] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0134] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0135] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0136] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk, etc. Various media that can store program codes.
Claims
1. A method for dynamically adjusting the JIT size of a virtual machine, characterized in that: The method comprises: Precompile the target application to obtain the compiled code; Calculating the complexity of the target application according to the size of the target application and the encoding and decoding; Setting a JIT size corresponding to the target application according to the complexity, wherein the JIT size corresponding to the target application increases as the complexity increases; Storing the application package name of the target application and the JIT size corresponding to the target application in a configuration file; When an operation instruction of the user for the target application is detected, identifying the application package name of the target application; Reading a configuration file of the target application according to the application package name of the target application; The virtual machine JIT size is updated according to the JIT size corresponding to the target application in the configuration file.
2. The method according to claim 1, characterized in that Before the target application is precompiled, the method further includes: The maximum value of the JIT compilation cache is preset according to the terminal performance of the terminal on which the target application is installed.
3. The method according to claim 1, characterized in that The pre-compiling of the target application to obtain the compiled code includes: The bytecode of the target application is precompiled into machine code, and the machine code is used as the compiled code.
4. The method according to claim 3, characterized in that The precompiling the bytecode of the target application into machine code comprises: Acquire a bytecode set of the target application, wherein the bytecode set includes all instructions of the target application; By monitoring the usage counts of all instructions in the target application, the bytecodes corresponding to the instructions whose usage counts are greater than a preset count are used as hot bytecodes; The heat bytecode is precompiled into machine code.
5. The method according to claim 1, characterized in that The calculating the complexity of the target application according to the size of the target application and the encoding and decoding comprises: Whenever the size of the target application increases by a first preset value, the first complexity increases by one unit; Whenever the size of the code increases by a second preset value, the second complexity increases by one unit; The first complexity and the second complexity are accumulated to obtain the complexity of the target application.
6. The method according to any one of claims 1 to 5, characterized in that The configuration file also includes the version information of the target application, and after reading the configuration file of the target application according to the application package name of the target application, further includes: Detect whether the version information is the latest version; If yes, then updating the virtual machine JIT size according to the JIT size corresponding to the target application in the configuration file; If not, the complexity of the target application is recalculated and a new configuration file is set after the target application is updated.
7. The method according to claim 2, characterized in that After the JIT size of the virtual machine is updated according to the JIT size corresponding to the target application in the configuration file, the method further includes: Monitor the terminal operation status in real time and obtain monitoring results; When the monitoring result indicates that the terminal operation status is overloaded, the complexity of the target application is recalculated according to the maximum value of the JIT compilation cache and a new configuration file is set.
8. A device for dynamically adjusting the size of a virtual machine JIT, characterized in that: Applied to a POS terminal, the device comprises: A pre-compilation unit, used to pre-compile the target application to obtain a compiled code; A complexity unit, configured to calculate the complexity of the target application according to the size of the target application and the encoding and decoding; A setting unit, configured to set a JIT size corresponding to the target application according to the complexity, wherein the JIT size corresponding to the target application increases as the complexity increases; A configuration file unit, used to store the application package name of the target application and the JIT size corresponding to the target application into a configuration file; an identification unit, configured to identify an application package name of the target application when an operation instruction of the user for the target application is detected; A reading unit, configured to read a configuration file of the target application according to an application package name of the target application; An updating unit is used to update the JIT size of the virtual machine according to the JIT size corresponding to the target application in the configuration file.
9. A device for dynamically adjusting the size of a virtual machine JIT, characterized in that: The device comprises: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method for dynamically adjusting the JIT size of a virtual machine according to any one of claims 1 to 7.
10. A computer-readable storage medium having a program stored thereon, wherein when the program is executed on a computer, the method for dynamically adjusting the JIT size of a virtual machine according to any one of claims 1 to 7 is executed.