Bytecode-based program distribution method, system, terminal and storage medium
By using the JVMTI tool to obtain and analyze the bytecode information of Java programs, and rationally allocating Java programs to nodes with matching resources for execution, the problem of low resource utilization of Java programs in the cluster is solved, and the running efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2026-04-14
AI Technical Summary
In a cluster, when multiple Java programs run on a single node, existing technologies cannot effectively utilize the resources of multiple Java programs, resulting in low operating efficiency.
The JVMTI tool is used to instrument Java programs, obtain bytecode information, analyze instruction types, classify them according to instruction types, and allocate Java programs to nodes with matching resources for execution.
This improved the cluster's resource utilization and operational efficiency.
Smart Images

Figure CN116257331B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of program instrumentation technology, and specifically relates to a bytecode-based program allocation method, system, terminal, and storage medium. Background Technology
[0002] In a cluster, multiple Java programs often run on a single node, each with different operational characteristics, such as computation-oriented or storage-oriented programs. Running multiple computation-oriented or storage-oriented programs simultaneously on a single node without considering cluster resource utilization will significantly reduce program efficiency. Therefore, how to rationally combine and run multiple Java programs is a problem that urgently needs to be solved. Summary of the Invention
[0003] This application provides a bytecode-based program allocation method, system, terminal, and storage medium, aiming to at least partially solve one of the aforementioned technical problems in the prior art.
[0004] To address the above problems, this application provides the following technical solution:
[0005] A bytecode-based program allocation method, comprising:
[0006] Use the JVMTI tool to instrument the application and obtain the bytecode information of the functions;
[0007] The acquired bytecode is analyzed to obtain the instruction type of the bytecode, and the application is classified according to the instruction type of the bytecode;
[0008] The application is assigned to a node that matches its resources based on the application classification results.
[0009] The technical solution adopted in this application embodiment also includes: the step of using JVMTI tools to instrument the application and obtain the bytecode information of the function includes:
[0010] Set the event callback interface based on the function name;
[0011] During JVM execution, the callback interface and callback function corresponding to each event are invoked;
[0012] Obtain the bytecode of the corresponding function in the callback function of the event.
[0013] The technical solution adopted in this application embodiment also includes: the instruction types of the bytecode include load and store instructions, arithmetic instructions, type conversion instructions, operand stack management instructions, control transfer instructions, and method call instructions.
[0014] The technical solution adopted in this application embodiment further includes: the classification of applications according to the instruction type of the bytecode specifically includes:
[0015] The instructions in the bytecode are obtained, and the instruction type of the bytecode is identified using a recognition algorithm;
[0016] The number of instructions of each type is counted, and the type of application is determined based on the proportion of the number of each instruction type; the application types include computation-oriented programs and storage-oriented programs.
[0017] The technical solution adopted in this application embodiment further includes: the specific method of allocating the application to a node that matches its resources based on the application classification result is as follows:
[0018] The computation-oriented programs are assigned to nodes with more CPU resources, and the storage-oriented programs are assigned to nodes with a higher I / O ratio.
[0019] The technical solution adopted in this application embodiment also includes: the application program is a Java program.
[0020] Another technical solution adopted in this application embodiment is: a bytecode-based program allocation system, comprising:
[0021] Bytecode Acquisition Module: Used to instrument the application using JVMTI tools to obtain the bytecode information of functions;
[0022] Bytecode analysis module: used to analyze the acquired bytecode, obtain the instruction type of the bytecode, and classify the application according to the instruction type of the bytecode;
[0023] Program allocation module: used to allocate the application to a node that matches its resources based on the application classification results.
[0024] Another technical solution adopted in this application embodiment is: a terminal, the terminal including a processor and a memory coupled to the processor, wherein,
[0025] The memory stores program instructions for implementing the bytecode-based program allocation method;
[0026] The processor is used to execute the program instructions stored in the memory to control bytecode-based program allocation.
[0027] Another technical solution adopted in this application embodiment is: a storage medium storing processor-executable program instructions, the program instructions being used to execute the bytecode-based program allocation method.
[0028] Compared with the prior art, the beneficial effects of the embodiments of this application are as follows: The bytecode-based program allocation method, system, terminal and storage medium of the embodiments of this application use the JVMTI tool to perform instrumentation operations on Java programs, obtain the bytecode information of functions, and analyze the bytecode information to guide the Java program to run reasonably on a single node, thereby improving the resource utilization of the cluster and improving the running efficiency. Attached Figure Description
[0029] Figure 1 This is a flowchart of a bytecode-based program allocation method according to an embodiment of this application;
[0030] Figure 2 This is a schematic diagram of the bytecode-based program allocation system architecture according to an embodiment of this application;
[0031] Figure 3 This is a schematic diagram of the terminal structure according to an embodiment of this application;
[0032] Figure 4 This is a schematic diagram of the structure of the storage medium according to an embodiment of this application. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0034] To address the shortcomings of existing technologies, the bytecode-based program allocation method in this application uses the JVMTI (JVM Tool Interface) tool built into the JVM (Java Virtual Machine) to instrument the application and obtain runtime bytecode information. Statistical analysis of the bytecode information is then performed to calculate the proportion of computational instructions and storage instructions, thereby guiding the application to run in a suitable configuration and improving cluster resource utilization. For ease of explanation, the following embodiments use only a Java program as an example, but it can also be applied to other types of applications.
[0035] Specifically, please refer to Figure 1 This is a flowchart of a bytecode-based program allocation method according to an embodiment of this application. The bytecode-based program allocation method according to an embodiment of this application includes the following steps:
[0036] S10: Use the JVMTI tool to instrument Java programs and obtain bytecode information of functions;
[0037] In this step, JVMTI provides a monitoring and development interface for the JVM virtual machine. This interface allows for real-time monitoring of the Java program's runtime status and control of its execution. Bytecode is a binary file containing an executable program, consisting of a sequence of op code / data pairs; it is a type of intermediate code. This invention uses JVMTI to extract bytecode from Java programs and analyzes the program's performance using the obtained bytecode. JVMTI is event-driven; during event execution, the JVM calls the event callback interface. The callback function allows intervention in the event execution, easily obtaining the bytecode of a specified function without interfering with program execution.
[0038] Specifically, the bytecode acquisition process in this application embodiment includes the following steps:
[0039] S11: Set the callback interface for the event based on the function name;
[0040] S12: During JVM execution, the callback interface and callback function corresponding to each event are called;
[0041] S13: Obtain the bytecode of the corresponding function in the callback function.
[0042] S20: Analyze the acquired bytecode, obtain the instruction type of the bytecode, and classify the Java program according to the instruction type of the bytecode;
[0043] In this step, bytecode analysis specifically includes: first, obtaining the bytecode instructions and identifying the instruction types using an algorithm. Bytecode instruction types include load and store instructions, arithmetic instructions, type conversion instructions, operand stack management instructions, control transfer instructions, method call instructions, and many others. Then, counting the number of instructions of each type and determining the type of Java program based on the proportion of each instruction type. For example, if arithmetic instructions are the most numerous (i.e., have the highest proportion) among all bytecode instructions, the Java program is determined to be arithmetic-oriented; if load and store instructions are the most numerous among all bytecode instructions, the Java program is determined to be storage-oriented.
[0044] S30: Based on the Java program classification results, assign different types of Java programs to nodes that match their resources for execution;
[0045] In this step, the Java programs are allocated as follows: for example, computationally intensive programs are allocated to nodes with more CPU resources, while storage-intensive programs are allocated to nodes with a higher I / O ratio. By rationally allocating Java programs based on their classification, the cluster's resource utilization and operational efficiency are improved.
[0046] Based on the above, the bytecode-based program allocation method of this application uses the JVMTI tool to instrument Java programs, obtain bytecode information of functions, and analyze the bytecode information to guide Java programs to run in a reasonable manner on a single node, thereby improving the resource utilization of the cluster and improving the running efficiency.
[0047] Please see Figure 2 This is a schematic diagram of the bytecode-based program allocation system structure according to an embodiment of this application. The bytecode-based program allocation system 40 according to an embodiment of this application includes:
[0048] Bytecode Acquisition Module 41: This module uses the JVMTI tool to instrument Java programs and obtain bytecode information of functions. JVMTI provides a monitoring and development interface for the JVM virtual machine, allowing real-time monitoring of the Java program's runtime status and control of its execution. Bytecode is a binary file containing an executable program, consisting of a sequence of op code / data pairs; it is a type of intermediate code. This invention uses JVMTI to extract bytecode from Java programs and analyzes the program's performance using the acquired bytecode. JVMTI is event-driven; during event execution, the JVM calls the event callback interface. The callback function can intervene in the event execution, easily obtaining the bytecode of a specified function without interfering with program execution.
[0049] Specifically, the bytecode acquisition module's process for acquiring bytecode includes: setting the event callback interface based on the function name; during JVM execution, calling the callback interface and callback function corresponding to each event; and acquiring the bytecode of the corresponding function within the callback function.
[0050] Bytecode Analysis Module 42: This module analyzes the acquired bytecode, identifies its instruction types, and classifies the Java program based on these instruction types. The bytecode analysis process involves: first, acquiring the bytecode instructions and identifying their types using an algorithm. Bytecode instruction types include load and store instructions, arithmetic instructions, type conversion instructions, operand stack management instructions, control transfer instructions, method call instructions, and more. Then, the number of instructions of each type is counted, and the Java program type is determined based on the proportion of each instruction type. For example, if arithmetic instructions have the highest number (i.e., the largest proportion) among all bytecode instructions, the Java program is classified as a computation-oriented program; if load and store instructions have the highest number, the Java program is classified as a storage-oriented program.
[0051] Program allocation module 43: This module allocates different types of Java programs to nodes that match their available resources based on the Java program classification results. Specifically, the node allocation method for Java programs includes, for example, assigning computationally intensive programs to nodes with more CPU resources, and storage-intensive programs to nodes with higher I / O ratios. By rationally allocating Java programs according to their classification results, the resource utilization of the cluster is improved, and operational efficiency is increased.
[0052] Based on the above, the bytecode-based program allocation system of this application uses the JVMTI tool to instrument Java programs, obtain bytecode information of functions, and analyze the bytecode information to guide Java programs to run in a reasonable manner on a single node, thereby improving the resource utilization of the cluster and improving the running efficiency.
[0053] Please see Figure 3 This is a schematic diagram of the terminal structure according to an embodiment of this application. The terminal 50 includes a processor 51 and a memory 52 coupled to the processor 51.
[0054] The memory 52 stores program instructions for implementing the above-described bytecode-based program allocation method.
[0055] Processor 51 is used to execute program instructions stored in memory 52 to control bytecode-based program allocation.
[0056] The processor 51 can also be referred to as a CPU (Central Processing Unit). The processor 51 may be an integrated circuit chip with signal processing capabilities. The processor 51 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor.
[0057] Please see Figure 4This is a schematic diagram of the structure of the storage medium according to an embodiment of this application. The storage medium of this embodiment stores a program file 61 capable of implementing all the above methods. This program file 61 can be stored in the storage medium in the form of a software product, including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, or terminal devices such as computers, servers, mobile phones, and tablets.
[0058] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A bytecode-based program allocation method, characterized in that, include: Use the JVMTI tool to instrument the application and obtain the bytecode information of the functions; The acquired bytecode is analyzed to obtain the instruction type of the bytecode, and the application is classified according to the instruction type of the bytecode; Based on the application classification results, the application is assigned to a node whose resources match its execution; wherein: The process of using JVMTI tools to instrument the application and obtain function bytecode information includes: Set the event callback interface based on the function name; During JVM execution, the callback interface and callback function corresponding to each event are invoked; Obtain the bytecode of the corresponding function in the callback function of the event.
2. The bytecode-based program allocation method according to claim 1, characterized in that, The bytecode instruction types include load and store instructions, arithmetic instructions, type conversion instructions, operand stack management instructions, control transfer instructions, and method call instructions.
3. The bytecode-based program allocation method according to claim 2, characterized in that, The classification of applications based on the instruction type of the bytecode specifically involves: The instructions in the bytecode are obtained, and the instruction type of the bytecode is identified using a recognition algorithm; The number of instructions of each type is counted, and the type of application is determined based on the proportion of the number of each instruction type; the application types include computation-oriented programs and storage-oriented programs.
4. The bytecode-based program allocation method according to claim 3, characterized in that, The specific steps of assigning the application to a node that matches its resources based on the application classification result are as follows: The computation-oriented programs are assigned to nodes with more CPU resources, and the storage-oriented programs are assigned to nodes with a higher I / O ratio.
5. The bytecode-based program allocation method according to any one of claims 1 to 4, characterized in that, The application is a Java program.
6. A bytecode-based program allocation system utilizing the bytecode-based program allocation method of claim 1, characterized in that, include: Bytecode Acquisition Module: Used to instrument the application using JVMTI tools to obtain the bytecode information of functions; Bytecode analysis module: used to analyze the acquired bytecode, obtain the instruction type of the bytecode, and classify the application according to the instruction type of the bytecode; Program allocation module: used to allocate the application to a node that matches its resources based on the application classification results.
7. A terminal, characterized in that, The terminal includes a processor and a memory coupled to the processor, wherein, The memory stores program instructions for implementing the bytecode-based program allocation method according to any one of claims 1-5; The processor is used to execute the program instructions stored in the memory to control bytecode-based program allocation.
8. A storage medium, characterized in that, The system stores processor-executable program instructions for performing the bytecode-based program allocation method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Automatic attribute setting device and method
CN103763181A
Application identification method and device, electronic device and storage medium
CN107665307A
Resource scheduling method and device, electronic equipment and storage medium
CN112099952A