Task processing method and device for point-of-sale equipment, electronic equipment and storage medium
By performing hot spot instant compilation and local program performance compilation of the task subroutine of point-of-sale equipment, the target local machine code is generated, and the problem of inefficient task processing in the existing technology is solved and more efficient task processing is achieved.
Patent Information
- Application Number
- CN202510188175.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-06-27
AI Technical Summary
The task processing efficiency of existing point-of-sale devices is low, mainly because ART needs to verify every method function call of the application, resulting in inefficiency.
A task processing method for point-of-sale equipment is proposed. By responsive to task processing requests, the target task application is obtained, the task subroutine is compiled in a hot spot, the hot spot subroutine is generated, and it is stored in the local compilation cache space and program performance analysis file. Then, the local program performance compiles the hot-spot subprogram, generates the target local machine code, and directly calls the machine code to perform task operations.
It significantly improves the task processing efficiency of point-of-sale equipment, avoids verification of the application during each task processing, and directly calls local machine code to perform task operations, improving processing speed and efficiency.
Smart Images

Figure CN120216057A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a method and apparatus for task processing of a point-of-sale device, an electronic device, and a storage medium. Background Art
[0002] Currently, the task processing of point-of-sale devices usually relies on ART (Android Runtime) to optimize the performance of the application using the verify compilation method, that is, the bytecode of the application is verified every time it is executed, but not compiled into machine code. For example, when a Pos (Point of Sale) machine needs to process a customer's checkout request, under the default compilation policy, when the Pos machine receives a product scanning instruction and the input transaction information, after ART verifies the function of calculating the total price of the transaction application program called by the Pos machine, the product price is calculated after verification. However, this method requires ART to perform verification every time a method function of the application program is called, resulting in low efficiency of task processing of point-of-sale devices. Therefore, how to improve the task processing efficiency of point-of-sale devices has become an urgent problem to be solved. Summary of the Invention
[0003] The main purpose of the embodiments of this application is to propose a method and apparatus for task processing of a point-of-sale device, an electronic device, and a storage medium, aiming to improve the task processing efficiency of the point-of-sale device.
[0004] To achieve the above object, the first aspect of the embodiments of this application proposes a method for task processing of a point-of-sale device, the method including:
[0005] In response to a task processing request of a point-of-sale device, obtain a target task application program of the point-of-sale device; wherein, the task processing request carries a device task operation; the target task application program includes a plurality of task subroutines;
[0006] Perform hotspot just-in-time compilation on the task subroutines to obtain hotspot subroutines;
[0007] Store the hotspot subroutines in a preset local compilation cache space;
[0008] Extract the hotspot subroutines from the local compilation cache space and store the hotspot subroutines in a preset program performance analysis file;
[0009] In response to a compilation request of the program performance analysis file, call the hotspot subroutines in the program performance analysis file and perform local program performance compilation on the hotspot subroutines to generate target native machine code;
[0010] Invoke the target native machine code to execute the device task operation.
[0011] In some embodiments, the hot spot subroutine includes a hot spot method subroutine and a hot spot class subroutine;
[0012] Storing the hot spot subroutine into a preset program performance analysis file includes:
[0013] In response to a storage request for storing the hot spot subroutine into the program performance analysis file, perform class program trigger screening on the hot spot class subroutine to obtain a target class subroutine;
[0014] Perform method program trigger screening on the hot spot method subroutine to obtain a target method subroutine;
[0015] Store the target class subroutine and the target method subroutine into the program performance analysis file.
[0016] In some embodiments, performing native program performance compilation on the hot spot subroutine to generate target native machine code includes:
[0017] Based on the hot spot subroutine, configure trigger compilation conditions for the point-of-sale device to obtain trigger compilation conditions;
[0018] Use the trigger compilation conditions to perform native performance compilation on the hot spot subroutine to generate target native machine code.
[0019] In some embodiments, based on the hot spot subroutine, configuring trigger compilation conditions for the point-of-sale device to obtain trigger compilation conditions includes:
[0020] Obtain the program execution frequency of the hot spot subroutine;
[0021] Obtain the program execution urgency of the hot spot subroutine;
[0022] According to the program execution frequency and the program execution urgency, set background compilation conditions for the point-of-sale device to obtain the trigger compilation conditions.
[0023] In some embodiments, invoking the target native machine code to execute the device task operation of the task processing request includes:
[0024] Obtain the device target task of the task processing request;
[0025] Load the target native machine code to obtain a task processing application program that matches the device target task;
[0026] Execute the device target task based on the task processing application program.
[0027] In some embodiments, extracting the hot subroutine from the local compilation cache space includes:
[0028] In response to a program extraction request for extracting the hot subroutine from the local compilation cache space, obtaining the device state of the point-of-sale device;
[0029] Based on the device state of the point-of-sale device, identifying the running state of the hot subroutine to obtain the program running state;
[0030] Obtaining an initial sleep time interval, and adjusting the sleep time of the initial sleep time interval based on the program running state to obtain a pre-adjusted sleep time interval;
[0031] Extracting the hot subroutine from the local compilation cache space according to the pre-adjusted sleep time interval.
[0032] In some embodiments, performing hot just-in-time compilation on the task subroutine to obtain a hot subroutine includes:
[0033] Obtaining the task processing requirements of the point-of-sale device, obtaining the device task category based on the task processing requirements, and obtaining the category task application program of the device task category;
[0034] Obtaining the category hot definition threshold corresponding to the category task application program, and obtaining the target hot definition threshold corresponding to the target task application program from the category hot definition thresholds;
[0035] Identifying a hot program for the task subroutine according to the target hot definition threshold to obtain an initial hot subroutine;
[0036] Performing just-in-time compilation on the initial hot subroutine to obtain the hot subroutine.
[0037] To achieve the above object, a second aspect of the embodiments of the present application proposes a task processing device for a point-of-sale device, and the device includes:
[0038] A task program acquisition module, configured to obtain a target task application program of the point-of-sale device in response to a task processing request of the point-of-sale device; wherein, the task processing request carries a device task operation; the target task application program includes a plurality of task subroutines;
[0039] A hot compilation module, configured to perform hot just-in-time compilation on the task subroutine to obtain a hot subroutine;
[0040] A local storage module, configured to store the hot subroutine in a preset local compilation cache space;
[0041] A file storage module, configured to extract the hot subroutine from the local compilation cache space and store the hot subroutine in a preset program performance analysis file;
[0042] A local program performance compilation module, configured to, in response to a compilation request of the program performance analysis file, call the hot subroutine in the program performance analysis file and perform local program performance compilation on the hot subroutine to generate target native machine code;
[0043] A task processing module, configured to call the target native machine code to execute the device task operation.
[0044] To achieve the above object, a third aspect of the embodiments of the present application provides an electronic device, where the electronic device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect above is implemented.
[0045] To achieve the above object, a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect above is implemented.
[0046] The task processing method and device, electronic device, and storage medium for a point-of-sale device proposed in this application obtain a target task application program for the point-of-sale device by responding to a task processing request of the point-of-sale device; wherein, the task processing request carries a device task operation; the target task application program includes multiple task subroutines; perform hotspot just-in-time compilation on the task subroutines to obtain hotspot subroutines; store the hotspot subroutines in a preset local compilation cache space; extract the hotspot subroutines from the local compilation cache space and store the hotspot subroutines in a preset program performance analysis file; in response to a compilation request of the program performance analysis file, call the hotspot subroutines in the program performance analysis file and perform local program performance compilation on the hotspot subroutines to generate target native machine code; call the target native machine code to execute the device task operation. In the embodiments of this application, first, perform hotspot just-in-time compilation on the task subroutines to obtain hotspot subroutines, which can quickly locate the hotspot code and preliminarily compile it into hotspot subroutines; secondly, store the hotspot subroutines extracted from the local compilation cache space in a preset program performance analysis file, which can improve the efficiency of storing the hotspot subroutines in the program performance analysis file and still retain the hotspot subroutines after the point-of-sale device restarts; finally, perform local program performance compilation on the hotspot subroutines to generate target native machine code, further realizing retaining the hotspot subroutines as native code, so that when executing device tasks, there is no need to verify each application program, and the native code can be directly called, significantly improving the task processing efficiency of the point-of-sale device. Description of the Drawings
[0047] Figure 1 is a flowchart of the task processing method for a point-of-sale device provided by an embodiment of this application;
[0048] Figure 2 is Figure 1 a flowchart of step S102 in
[0049] Figure 3 is Figure 1 a flowchart of step S104 in
[0050] Figure 4 is Figure 1 another flowchart of step S104 in
[0051] Figure 5 is Figure 1 a flowchart of step S105 in
[0052] Figure 6 is Figure 5 a flowchart of step S501 in
[0053] Figure 7 is Figure 1 a flowchart of step S106 in
[0054] Figure 8 is a schematic structural diagram of a task processing device for a point-of-sale device provided by an embodiment of the present application;
[0055] Figure 9 is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0056] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0057] It should be noted that although functional module division is performed in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order from the module division in the device or the order in the flowchart. Terms such as "first" and "second" in the description, claims and the above-mentioned drawings are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0059] Based on this, embodiments of the present application provide a task processing method and device for a point-of-sale device, an electronic device and a storage medium, aiming to improve the task processing efficiency of the point-of-sale device.
[0060] The task processing method and device for a point-of-sale device, an electronic device and a storage medium provided by embodiments of the present application are specifically described through the following embodiments. First, the task processing method for a point-of-sale device in embodiments of the present application is described.
[0061] The task processing method for a point-of-sale device provided by an embodiment of this application relates to the field of computer technology. The task processing method for a point-of-sale device provided by an embodiment of this application can be applied to a terminal, can also be applied to a server side, or can be software running on a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, can also be configured as a server cluster or a distributed system composed of multiple physical servers, or can also be configured as a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the task processing method for a point-of-sale device, etc., but is not limited to the above forms.
[0062] This application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet-type devices, multi-processor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and so on. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This application can also be practiced in a distributed computing environment, where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0063] Figure 1 is an optional flowchart of the task processing method for a point-of-sale device provided by an embodiment of this application, Figure 1 The method in may include but is not limited to steps S101 to S106.
[0064] Step S101, in response to a task processing request of the point-of-sale device, obtain the target task application program of the point-of-sale device; wherein, the task processing request carries a device task operation; the target task application program includes multiple task subprograms.
[0065] Step S102, perform hot-spot just-in-time compilation on the task subprograms to obtain hot-spot subprograms.
[0066] Step S103, store the hot-spot subprograms in a preset local compilation cache space.
[0067] Step S104: Extract the hot subroutine from the local compilation cache space and store the hot subroutine in a preset program performance analysis file.
[0068] Step S105: In response to the compilation request of the program performance analysis file, call the hot subroutine in the program performance analysis file and perform local program performance compilation on the hot subroutine to generate the target native machine code.
[0069] Step S106: Call the target native machine code to execute the device task operation.
[0070] Steps S101 to S106 illustrated in the embodiments of the present application obtain the target task application program of the point-of-sale device by responding to the task processing request of the point-of-sale device; wherein, the task processing request carries the device task operation; the target task application program includes multiple task subroutines; perform hot just-in-time compilation on the task subroutines to obtain hot subroutines; store the hot subroutines in a preset local compilation cache space; extract the hot subroutines from the local compilation cache space and store the hot subroutines in a preset program performance analysis file; in response to the compilation request of the program performance analysis file, call the hot subroutines in the program performance analysis file and perform local program performance compilation on the hot subroutines to generate the target native machine code; call the target native machine code to execute the device task operation. In the embodiments of the present application, first, perform hot just-in-time compilation on the task subroutines to obtain hot subroutines, which can quickly locate the hot code and preliminarily compile it into hot subroutines; second, store the hot subroutines extracted from the local compilation cache space in a preset program performance analysis file, which can improve the efficiency of storing the hot subroutines in the program performance analysis file and still retain the hot subroutines after the point-of-sale device restarts; finally, perform local program performance compilation on the hot subroutines to generate the target native machine code, further realizing the retention of the hot subroutines as native code, so that when executing the device task, there is no need to verify each application program, and the native code can be directly called, significantly improving the task processing efficiency of the point-of-sale device.
[0071] In step S101 of some embodiments, specifically, the point-of-sale device may be a Pos (Point of Sale) machine, which is an integrated terminal device with multiple functions and is used to complete functions such as commodity transaction payment, commodity inventory management, or receipt printing.
[0072] Specifically, the task processing request of the point-of-sale device carries the device task operation.
[0073] For example, the device task operation may be a Pos machine cash register operation, a Pos machine commodity management operation, or a Pos machine receipt printing operation, etc.
[0074] Specifically, the target task application refers to an application package that responds to the task processing request of a point-of-sale device, and the application package includes multiple task subroutines, which are Java codes.
[0075] For example, if the task processing request of the point-of-sale device is a transaction task request, the target task application can be a Pos machine transaction application package, and the task subroutines are applications such as calculating the total price, selecting a payment method, or processing payment transactions; if the task processing request of the point-of-sale device is a commodity management request, the target task application can be a Pos machine commodity management application package, and the task subroutines are applications such as entering commodity names, entering prices, or increasing or decreasing inventory.
[0076] Furthermore, since Java code cannot be directly run on the CPU and needs to be interpreted by a virtual machine into machine code before it can be directly run on the CPU, subsequent hotspot just-in-time compilation and native program performance compilation are required.
[0077] Please refer to Figure 2 , in some embodiments, step S102 includes but is not limited to steps S201 to S204:
[0078] Step S201, obtain the task processing requirements of the point-of-sale device, and based on the task processing requirements, obtain the device task category, and obtain the category task application corresponding to the device task category.
[0079] Step S202, obtain the category hotspot definition threshold corresponding to the category task application, and obtain the target hotspot definition threshold corresponding to the target task application from the category hotspot definition threshold.
[0080] Step S203, identify the hotspot program for the task subroutine according to the target hotspot definition threshold to obtain the initial hotspot subroutine.
[0081] Step S204, perform just-in-time compilation on the initial hotspot subroutine to obtain the hotspot subroutine.
[0082] In step S201 of some embodiments, specifically, the point-of-sale device faces various task processing requirements during daily operation, such as task requirements like Pos machine cash register operation, Pos machine commodity management operation, or Pos machine receipt printing operation. The task processing requirements of the point-of-sale device determine the task category that the Pos machine needs to execute.
[0083] Specifically, the category task application refers to the application corresponding to the device task category. For example, if the Pos machine task category is calculating the total price, the application is the program for calculating the total price.
[0084] In step S202 of some embodiments, specifically, the category hot-spot definition threshold is used to determine whether a method or code segment of a task subroutine is hot-spot code during runtime.
[0085] Specifically, the category hot-spot definition threshold includes, but is not limited to, the execution times, execution time, or resource consumption of the method of the task subroutine, etc. For different categories of task applications, the category hot-spot definition threshold is also different.
[0086] Specifically, by setting corresponding category hot-spot definition thresholds for different categories of task applications, it is possible to dynamically identify frequently executed method programs during task processing on a point-of-sale device, and reduce the warmup_threshold threshold of this method program to trigger subsequent just-in-time compilation earlier, thereby improving the efficiency of subsequent just-in-time compilation.
[0087] Furthermore, the category hot-spot definition threshold can be the set warmup_threshold threshold, that is, the counter threshold. When the value of the counter reaches or exceeds the set warmup_threshold threshold, this method will be considered a hot-spot method.
[0088] For example, during the processing of the transaction task and the commodity management task of a POS machine, since the method of the transaction task of the POS machine is called more frequently than the method of the commodity management task, the warmup_threshold threshold corresponding to the application program of the transaction task is lower than that of the application program of the commodity management. And since the method of calculating the total price in the transaction task is called more frequently than the method of printing the transaction voucher, the warmup_threshold threshold of the method of calculating the total price is further lower than that of the method of printing the transaction voucher.
[0089] In this embodiment, by obtaining the category hot-spot definition threshold corresponding to the category task application program, it is possible to match the corresponding hot-spot definition threshold for application programs of different categories of tasks, and for frequently called application programs, trigger subsequent just-in-time compilation earlier, thereby improving the efficiency of subsequent just-in-time compilation.
[0090] In step S203 of some embodiments, specifically, the initial hot-spot subroutine refers to a task subroutine that reaches or exceeds the target hot-spot definition threshold.
[0091] Specifically, after the task application of the point-of-sale device is started, all method programs are initially in the verify state, that is, the bytecode verification and interpretation execution stage. In this stage, whenever a method program is called, the counter will increase the execution times of this method program until this method program reaches the target hot-spot definition threshold, and this method program is used as the initial hot-spot subroutine.
[0092] For example, if the task application is to calculate the total price, the method for calculating the total price is calculateTotalPrice(). If the warmup_threshold for this method is 45,000 times, when the execution times of calculateTotalPrice() ≥ 45,000 times, the method program for calculating the total price is regarded as a hot program.
[0093] In this embodiment, by identifying hot programs for task subroutines according to the target hot boundary threshold, the initial hot subroutines are obtained, which can accurately locate the task subroutines with frequent execution or large resource consumption, facilitating subsequent conversion of the hot subroutines into more efficient machine code through just-in-time compilation, thereby improving the execution speed of the program.
[0094] In step S204 of some embodiments, specifically, the hot subroutine refers to a program in the form of machine code.
[0095] Specifically, the initial hot subroutine is compiled in real time through a JIT (Just-In-Time Compiler) to compile the initial hot subroutine into initial native machine code.
[0096] Specifically, in the traditional JIT compilation process, if there is a method program with a loop count of 100,000 times, even if JIT compilation is triggered when it reaches the 50,000th time, the generated initial native machine code cannot be used immediately. Because after compilation is completed, the current execution still needs to continue to complete the remaining iterations until the entire method call ends, and the compiled machine code can be used only when it is called the next time. This solution also combines OSR (On-Stack Replacement) compilation to replace the stack frame in the execution stack of the method program at the 50,001st time with a stack frame pointing to the native machine code compiled by OSR. Since the stack frame replacement process is seamless and does not interrupt the execution of the loop, after replacement, the remaining iterations of the loop (i.e., from the 50,001st time to the 100,000th time) will directly execute using the initial native machine code compiled by OSR instead of continuing to execute the interpreted bytecode.
[0097] In this embodiment, by performing just-in-time compilation on the initial hot subroutine to obtain the hot subroutine, the program can be compiled into initial native machine code, so that when the program of the POS machine runs, the hot subroutine can be dynamically compiled into efficient native code. When the hot subroutine is called again, it can directly execute the compiled initial native machine code without the need for re-interpreted execution or just-in-time compilation, thereby improving the task processing efficiency of subsequent point-of-sale devices.
[0098] In step S103 of some embodiments, specifically, the local compilation cache space can be jit_code_cach (Just-In-Time compilation code cache).
[0099] In this embodiment, by storing the hot subroutines in a preset local compilation cache space, the initial native machine code after JIT compilation can be directly executed without having to perform JIT compilation again every time it is called, which helps improve the task processing efficiency of subsequent point-of-sale devices. Also, the initial native machine code can be repeatedly executed, reducing the need to repeatedly compile the same code and further saving CPU resources.
[0100] Please refer to Figure 3 , in some embodiments, step S104 includes but is not limited to steps S301 to S304:
[0101] Step S301, in response to a program extraction request for extracting a hot subroutine from the local compilation cache space, obtain the device status of the point-of-sale device.
[0102] Step S302, based on the device status of the point-of-sale device, identify the running status of the hot subroutine to obtain the program running status.
[0103] Step S303, obtain the initial sleep time interval, and based on the program running status, adjust the sleep time interval of the initial sleep time interval to obtain a pre-adjusted sleep time interval.
[0104] Step S304, extract the hot subroutine from the local compilation cache space according to the pre-adjusted sleep time interval.
[0105] In step S301 of some embodiments, specifically, although the JIT compiler has compiled the hot code into the initial native machine code and stored it in jit_code_cache, these compiled codes will not be retained after the application is restarted. Therefore, in order to quickly load and execute the initial native machine code when the application is started next time, it is necessary to store the hot methods and hot class subroutines in the profile file.
[0106] Specifically, the device status of the point-of-sale device refers to the CPU usage rate of the device, the memory usage, the battery status, etc.
[0107] In step S302 of some embodiments, specifically, the program running status can be the active state (foreground running state) or the background running state.
[0108] Specifically, based on the device status of the point-of-sale device, the system will identify the running status of the hot-spot subroutines to determine their running efficiency in the current environment, so as to determine which hot-spot subroutines can be further optimized or adjusted under the current device status.
[0109] For example, if the CPU load of the device is high, the hot-spot subroutines will run in the background.
[0110] In step S303 of some embodiments, specifically, the initial sleep time interval is used to control the frequency of extracting hot-spot subroutines from the local compilation cache space.
[0111] Furthermore, if the CPU usage of the point-of-sale device is high or the memory is insufficient, and the hot-spot subroutines are in the background running state, the sleep time interval can be extended to reduce the occupation of system resources while ensuring that the hot-spot code can still be recorded; if the CPU and memory resources of the point-of-sale device are sufficient and the battery status is good, and the hot-spot subroutines are in the foreground running state, the sleep time interval can be shortened to speed up the recording and optimization of the hot-spot code.
[0112] In this embodiment, the sleep time is adjusted based on the program running state to obtain the pre-adjusted sleep time interval, which can understand the resource consumption of the point-of-sale device and ensure that the hot-spot subroutines can be effectively utilized without increasing the burden on the point-of-sale device. Further, by reasonably adjusting the sleep time, it can be ensured that the hot-spot code can be recognized and recorded faster, which helps to improve the task processing efficiency of the point-of-sale device in the future.
[0113] In step S304 of some embodiments, specifically, the extraction process of extracting hot-spot subroutines from the local compilation cache space according to the pre-adjusted sleep time interval is dynamic and can be adjusted in real time according to the actual running situation and performance requirements of the point-of-sale device, so that the point-of-sale device can ensure that when processing transaction requests, it always uses the most optimized code, and there is no need for the JIT compiler to re-identify the hot-spot methods and compile them every time the application starts, which helps to improve the task processing efficiency of the point-of-sale device in the future.
[0114] Please refer to Figure 4 , in some embodiments, step S104 further includes but is not limited to steps S401 to S403:
[0115] Step S401, in response to the storage request of the hot-spot subroutines stored in the program performance analysis file, perform class program trigger screening on the hot-spot class subroutines to obtain the target class subroutines.
[0116] Step S402, perform method program trigger screening on the hot-spot method subroutines to obtain the target method subroutines.
[0117] Step S403: Store the target class subroutine and the target method subroutine into the program performance analysis file.
[0118] In step S401 of some embodiments, specifically, the hot subroutines include hot method subroutines and hot class subroutines.
[0119] Specifically, the target class subroutine refers to a class program that meets the standard for storage in the profile file.
[0120] Specifically, the hot class subroutines can be screened for class program triggering through a preset class program threshold, so as to record the hot class subroutines that meet the class program threshold into the profile file. Among them, the class program threshold means that only when the number of times a class program is frequently called reaches or exceeds the class program threshold, will this class program be considered a hot class.
[0121] In step S402 of some embodiments, the target method subroutine refers to a method program that meets the standard for storage in the profile file.
[0122] Specifically, the hot method subroutines can be screened for method program triggering through a preset method program threshold, so as to record the hot method subroutines that meet the method program threshold into the profile file. Among them, the method program threshold means that only when the number of times a method program is frequently called reaches or exceeds the method program threshold, will this method program be considered a hot class.
[0123] In step S403 of some embodiments, the Profile file is a file that records the hot programs during the runtime of the application.
[0124] Specifically, the Profile file includes but is not limited to hot class subroutines, hot method subroutines, the execution frequency of each hot method and class subroutine, the execution time of the hot method subroutine, the CPU occupancy, etc.
[0125] Specifically, although the JIT compiler has compiled the hot methods into native machine code and stored it in the jit_code_cache, these compiled native machine codes will not be retained after the application restarts. Therefore, in order to quickly load and execute the optimized code when the application is started next time, it is necessary to store the hot method subroutines and hot class subroutines into the profile file.
[0126] Specifically, first, it is determined whether the application package name corresponding to the hot subroutine matches the preset optimized target package name. If they match, the thresholds of the class program and the method program are adjusted. Since there are fewer application programs on the POS machine, these thresholds can be lowered. For example, if the original thresholds of the class program and the method program are 1000 and 5000 calls respectively, then the threshold of the class program is lowered to 500 calls, and the threshold of the method program is lowered to 2000 calls. When the hot subroutine simultaneously meets the thresholds of the method program and the class program, the operation of storing the hot code information into the profile file can be easily triggered when the execution frequency of the hot code or the number of methods or class programs involved is small.
[0127] In this embodiment, by storing the target class subroutine and the target method subroutine into the program performance analysis file, the efficiency of storing the hot subroutine from the local compilation cache space into the program performance analysis file is improved, providing richer data support for subsequent local program performance compilation, thereby further improving the running efficiency of the POS machine application program.
[0128] Please refer to Figure 5 , in some embodiments, step S105 includes but is not limited to steps S501 to S502:
[0129] Step S501, configuring the trigger compilation condition for the point-of-sale device based on the hot subroutine to obtain the trigger compilation condition.
[0130] Step S502, locally performing performance compilation on the hot subroutine using the trigger compilation condition to generate the target native machine code.
[0131] Please refer to Figure 6 , in some embodiments, step S501 includes but is not limited to steps S601 to S603:
[0132] Step S601, obtaining the program execution frequency of the hot subroutine.
[0133] Step S602, obtaining the program execution urgency of the hot subroutine.
[0134] Step S603, setting the background compilation condition for the point-of-sale device according to the program execution frequency and the program execution urgency to obtain the trigger compilation condition.
[0135] In step S601 of some embodiments, specifically, the program execution frequency refers to the number of times the hot subroutine is called within a certain period of time.
[0136] In step S602 of some embodiments, specifically, the program execution urgency refers to the response time of the hot subroutine.
[0137] For example, during the task processing of a point-of-sale device, the application for processing payments is more urgent than the application for merchandise management.
[0138] In step S603 of some embodiments, specifically, the triggering compilation conditions include the battery power condition and the screen-off static time condition of the point-of-sale device. The triggering compilation conditions are used to perform local program performance compilation on the hot spot subroutines that meet the triggering compilation conditions, and the triggering compilation conditions are dynamically determined based on the execution frequency and the execution urgency.
[0139] Specifically, the status of the point-of-sale device can be monitored in the background, including the screen status, battery power, and static time. When the point-of-sale device's screen is off and the battery power is higher than 30%, the timing starts, and after reaching the static time of 15 minutes, the background is triggered to perform the local program performance compilation task.
[0140] For example, for transaction tasks with a higher execution frequency, when the Pos machine's screen is off and the battery power is higher than 30%, the compilation task can be triggered after waiting for 15 minutes; while for low-frequency tasks, when the Pos machine's screen is off and the battery power is higher than 30%, the compilation task can only be triggered after waiting for 30 minutes.
[0141] Specifically, for local program performance compilation, the status of the Pos machine (such as screen-off, static time, battery power, etc.) can be detected through JobScheduler and the compilation task can be triggered.
[0142] Specifically, when adjusting the triggering compilation conditions, in the implementation of JobScheduler, the code for detecting the screen status and static time of the point-of-sale device can be detected, and the screen status and static time code can be adjusted.
[0143] Specifically, when adjusting the triggering condition of the battery power, the battery power setting code can be found and adjusted by listening to the battery status broadcast (such as Intent.ACTION_BATTERY_CHANGED).
[0144] In this embodiment, the background compilation conditions of the point-of-sale device are set according to the program execution frequency and the program execution urgency to obtain the triggering compilation conditions, which can adjust the triggering compilation conditions based on the real-time status of the point-of-sale device and the hot spot application program, and can dynamically trigger the compilation task, which helps to improve the efficiency of subsequent local program performance compilation.
[0145] In step S502 of some embodiments, specifically, local program performance compilation refers to speed-profile compilation. Through the triggering compilation conditions, the profile file storing the hot spot subroutines can be subjected to speed-profile compilation to further generate the target native machine code.
[0146] Specifically, the target native machine code refers to the machine code that can be directly run on the CPU. The difference between it and the initial native machine code generated after hot-spot just-in-time compilation is that the initial native machine code will disappear after the application is restarted and the JIT compilation needs to be executed again, while the target native machine code still exists after the application is restarted and there is no need to recompile.
[0147] In this embodiment, by performing local program performance compilation on the hot-spot subroutine to generate the target native machine code, the hot-spot subroutine can be retained as native code, so that when executing the device task, it is not necessary to verify each application, and the native code can be directly called, significantly improving the task processing efficiency of the point-of-sale device.
[0148] Please refer to Figure 7 , in some embodiments, step S106 includes but is not limited to steps S701 to S703:
[0149] Step S701, obtain the device target task of the task processing request.
[0150] Step S702, load the target native machine code to obtain a task processing application program that matches the device target task.
[0151] Step S703, execute the device target task based on the task processing application program.
[0152] In step S701 of some embodiments, specifically, the device target task can be a transaction processing task of a Pos machine, a receipt printing task, a refund task, a commodity inventory entry task, etc.
[0153] In step S702 of some embodiments, specifically, the task processing application program refers to the target native machine code that can execute the device target task.
[0154] Specifically, read the target native machine code that can execute the device task from the profile file, verify the integrity of the target native machine code, and load the target native machine code into the CPU for execution.
[0155] For example, if the device target task is the total price calculation task of a Pos machine, then the task processing application program is the native machine code corresponding to the method program for calculating the total price.
[0156] In this embodiment, by loading the target native machine code to obtain a task processing application program that matches the device target task, it can ensure that the loaded target native machine code matches the target task, so as to avoid executing the wrong application program and improve the task processing efficiency of the point-of-sale device.
[0157] In step S703 of some embodiments, specifically, the POS machine interacts with the user instruction, collects necessary input information (such as transaction amount, payment method, etc.), and generates corresponding outputs (such as receipts, transaction confirmations, etc.).
[0158] In the embodiment of the present application, in response to a task processing request of a point-of-sale device, a target task application program of the point-of-sale device is obtained; wherein, the task processing request carries a device task operation; the target task application program includes multiple task subprograms; the task subprograms are subjected to hot-spot just-in-time compilation to obtain hot-spot subprograms; the hot-spot subprograms are stored in a preset local compilation cache space; the hot-spot subprograms are extracted from the local compilation cache space and stored in a preset program performance analysis file; in response to a compilation request of the program performance analysis file, the hot-spot subprograms in the program performance analysis file are called, and the hot-spot subprograms are subjected to local program performance compilation to generate target native machine codes; the target native machine codes are called to execute the device task operation. In the embodiment of the present application, first, the task subprograms are subjected to hot-spot just-in-time compilation to obtain hot-spot subprograms, which can quickly locate the hot-spot code and initially compile it into hot-spot subprograms; secondly, the hot-spot subprograms extracted from the local compilation cache space are stored in a preset program performance analysis file, which can improve the efficiency of storing the hot-spot subprograms in the program performance analysis file and still retain the hot-spot subprograms after the point-of-sale device is restarted; finally, the hot-spot subprograms are subjected to local program performance compilation to generate target native machine codes, further realizing retaining the hot-spot subprograms as native codes, so that when executing device tasks, it is not necessary to verify each application program, and the native codes can be directly called, significantly improving the task processing efficiency of the point-of-sale device.
[0159] Please refer to Figure 8 , the embodiment of the present application also provides a task processing device for a point-of-sale device, which can implement the above-mentioned task processing method of the point-of-sale device. The device includes:
[0160] A task program acquisition module, configured to obtain a target task application program of the point-of-sale device in response to a task processing request of the point-of-sale device; wherein, the task processing request carries a device task operation; the target task application program includes multiple task subprograms;
[0161] A hot-spot compilation module, configured to perform hot-spot just-in-time compilation on the task subprograms to obtain hot-spot subprograms;
[0162] A local storage module, configured to store the hot-spot subprograms in a preset local compilation cache space;
[0163] A file storage module, configured to extract the hot-spot subprograms from the local compilation cache space and store the hot-spot subprograms in a preset program performance analysis file;
[0164] A local program performance compilation module, which is used to respond to a compilation request of a program performance analysis file, call a hot subroutine in the program performance analysis file, and perform local program performance compilation on the hot subroutine to generate target native machine code;
[0165] A task processing module, which is used to call the target native machine code to execute device task operations.
[0166] The specific implementation manner of the task processing device of this point-of-sale device is basically the same as the specific embodiment of the task processing method of the above point-of-sale device, and will not be elaborated here.
[0167] An embodiment of this application also provides an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the task processing method of the above point-of-sale device. This electronic device can be any intelligent terminal including a tablet computer, an in-vehicle computer, etc.
[0168] Please refer to Figure 9 , Figure 9 , which schematically shows the hardware structure of an electronic device in another embodiment. The electronic device includes:
[0169] A processor 901, which can be implemented by using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided by the embodiments of this application;
[0170] A memory 902, which can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM), etc. The memory 902 can store a processing system and other application programs. When implementing the technical solutions provided by the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 902, and the processor 901 is used to call and execute the task processing method of the point-of-sale device of the embodiments of this application;
[0171] An input / output interface 903, which is used to implement information input and output;
[0172] A communication interface 904, which is used to implement communication interaction between this device and other devices, and can implement communication through a wired manner (such as USB, network cable, etc.) or through a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0173] A bus 905 that transmits information between various components of the device, such as a processor 901, a memory 902, an input / output interface 903, and a communication interface 904;
[0174] Among them, the processor 901, the memory 902, the input / output interface 903, and the communication interface 904 are communicatively connected to each other inside the device through the bus 905.
[0175] An embodiment of the present application also provides a computer-readable storage medium that stores a computer program, and when the computer program is executed by a processor, it implements the task processing method of the above-mentioned point-of-sale device.
[0176] As a non-transitory computer-readable storage medium, the memory can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory may optionally include a memory remotely located relative to the processor, and these remote memories can be connected to the processor through a network. Examples of the above-mentioned network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0177] The task processing method of a point-of-sale device, the task processing device of a point-of-sale device, an electronic device, and a storage medium provided by an embodiment of the present application obtain a target task application program of the point-of-sale device by responding to a task processing request of the point-of-sale device; wherein, the task processing request carries a device task operation; the target task application program includes multiple task subroutines; perform hotspot just-in-time compilation on the task subroutines to obtain hotspot subroutines; store the hotspot subroutines in a preset local compilation cache space; extract the hotspot subroutines from the local compilation cache space and store the hotspot subroutines in a preset program performance analysis file; in response to a compilation request of the program performance analysis file, call the hotspot subroutines in the program performance analysis file and perform local program performance compilation on the hotspot subroutines to generate target native machine code; call the target native machine code to execute the device task operation. In the embodiment of the present application, first, perform hotspot just-in-time compilation on the task subroutines to obtain hotspot subroutines, which can quickly locate the hotspot code and preliminarily compile it into hotspot subroutines; secondly, store the hotspot subroutines extracted from the local compilation cache space in a preset program performance analysis file, which can improve the efficiency of storing the hotspot subroutines in the program performance analysis file and still retain the hotspot subroutines after the point-of-sale device is restarted; finally, perform local program performance compilation on the hotspot subroutines to generate target native machine code, further realizing retaining the hotspot subroutines as native code, so that when executing device tasks, there is no need to verify each application program, and the native code can be directly called, significantly improving the task processing efficiency of the point-of-sale device.
[0178] The embodiments described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art know that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
[0179] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or combine some steps, or different steps.
[0180] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0181] Those of ordinary skill in the art can understand that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices can be implemented as software, firmware, hardware, and their appropriate combinations.
[0182] In the description of this application and the above-mentioned drawings, the terms "first", "second", "third", "fourth", etc. (if any) are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0183] It should be understood that in this application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects and indicates that three relationships can exist. For example, "A and / or B" can mean: only A exists, only B exists, and both A and B exist at the same time. Among them, A and B can be singular or plural. The character " / " generally means that the associated objects before and after are in an "or" relationship. "At least one (one) of the following" or its similar expression refers to any combination of these items, including any combination of single items (ones) or plural items (ones). For example, at least one (one) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0184] In several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the above-mentioned division of units is only a logical function division, and there can 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. The displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of devices or units can be in electrical, mechanical or other forms.
[0185] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0186] In addition, in each embodiment of the present application, the functional units may be integrated into one processing unit, or each unit may exist physically alone, 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 a software functional unit.
[0187] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product. The computer software product is stored in a storage medium and includes multiple instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of the present application. The aforementioned storage medium includes: various storage media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store programs.
[0188] The preferred embodiments of the embodiments of the present application have been described above with reference to the accompanying drawings. However, this does not limit the scope of the rights of the embodiments of the present application. Any modifications, equivalent replacements, and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall fall within the scope of the rights of the embodiments of the present application.
Claims
1. A task processing method for a point-of-sale device, characterized in that: The method comprises: In response to a task processing request of a point-of-sale device, obtaining a target task application of the point-of-sale device; wherein the task processing request carries a device task operation; and the target task application includes a plurality of task subroutines; Performing hot spot just-in-time compilation on the task subroutine to obtain a hot spot subroutine; Storing the hotspot subroutine in a preset local compilation cache space; Extracting the hot subroutine from the local compilation cache space, and storing the hot subroutine in a preset program performance analysis file; In response to a compilation request of the program performance analysis file, calling the hotspot subroutine in the program performance analysis file, and performing local program performance compilation on the hotspot subroutine to generate a target local machine code; The target native machine code is called to execute the device task operation.
2. The method according to claim 1, characterized in that The hotspot subprogram includes a hotspot method subprogram and a hotspot class subprogram; The step of storing the hotspot subroutine in a preset program performance analysis file includes: In response to a storage request for storing the hotspot subprogram in the program performance analysis file, performing class program trigger screening on the hotspot class subprogram to obtain a target class subprogram; Performing method program trigger screening on the hot method subprogram to obtain a target method subprogram; The target class subroutine and the target method subroutine are stored in the program performance analysis file.
3. The method according to claim 1, characterized in that The performing local program performance compilation on the hotspot subroutine to generate a target local machine code includes: Based on the hotspot subroutine, trigger compilation condition configuration is performed on the point-of-sale device to obtain trigger compilation condition; The trigger compilation condition is used to perform local performance compilation on the hotspot subroutine to generate a target local machine code.
4. The method according to claim 3, characterized in that The configuring the trigger compilation condition of the point of sale device based on the hotspot subroutine to obtain the trigger compilation condition includes: Obtaining the program execution frequency of the hotspot subroutine; Obtaining the execution urgency of the hot subroutine; The background compilation condition is set for the point-of-sale device according to the program execution frequency and the program execution urgency to obtain the trigger compilation condition.
5. The method according to claim 1, characterized in that The device task operation of calling the target native machine code to execute the task processing request includes: Obtain the device target task of the task processing request; Loading the target local machine code to obtain a task processing application that matches the target task of the device; The device target task is executed based on the task processing application.
6. The method according to any one of claims 1 to 5, characterized in that: The extracting the hotspot subroutine from the local compilation cache space includes: Responding to a program extraction request to extract the hot subroutine from the local compilation cache space, obtaining a device status of the point-of-sale device; Identify the running state of the hotspot subprogram based on the device state of the point-of-sale device to obtain the program running state; Acquire an initial sleep time interval, and adjust the sleep time of the initial sleep time interval based on the program running state to obtain a pre-adjusted sleep time interval; The hot subroutine is extracted from the local compilation cache space according to the pre-adjusted sleep time interval.
7. The method according to any one of claims 1 to 5, characterized in that: The hot spot real-time compilation of the task subroutine to obtain the hot spot subroutine includes: Obtaining a task processing requirement of the point-of-sale device, and obtaining a device task category based on the task processing requirement, and obtaining a category task application of the device task category; Obtaining a category hotspot definition threshold corresponding to the category task application, and obtaining a target hotspot definition threshold corresponding to the target task application from the category hotspot definition threshold; Perform hotspot program identification on the task subprogram according to the target hotspot definition threshold to obtain an initial hotspot subprogram; The initial hotspot subroutine is compiled in real time to obtain the hotspot subroutine.
8. A task processing device for a point-of-sale device, characterized in that: The device comprises: A task program acquisition module, for acquiring a target task application program of the point-of-sale device in response to a task processing request of the point-of-sale device; wherein the task processing request carries a device task operation; and the target task application program includes a plurality of task subprograms; A hotspot compilation module, used for performing hotspot real-time compilation on the task subroutine to obtain a hotspot subroutine; A local storage module, used for storing the hotspot subroutine in a preset local compilation cache space; A file storage module, used for extracting the hot subroutine from the local compilation cache space and storing the hot subroutine in a preset program performance analysis file; A local program performance compiling module, for responding to a compiling request of the program performance analysis file, calling the hotspot subroutine in the program performance analysis file, and performing local program performance compiling on the hotspot subroutine to generate a target local machine code; The task processing module is used to call the target local machine code to execute the device task operation.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the task processing method of a point of sale device according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the task processing method of the point of sale device according to any one of claims 1 to 7 is implemented.