A JVM system problem location method and device
By creating snapshot threads in the JVM system, collecting stack trace data and startup time affecting parameters, the problem of long startup time of Java applications is solved, and rapid identification and optimization of performance bottlenecks is achieved.
Patent Information
- Application Number
- CN202410457237.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-16
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-04-16
AI Technical Summary
Existing APM tools are difficult to effectively locate the problem of long-term Java application startup time, especially in JVM systems. Frequent object allocation and garbage collection lead to performance degradation and lack of effective analysis methods.
Create a snapshot thread in the JVM system, perform stack trace and periodic data collection on the application at startup, obtain parameters that affect the startup time, and perform problem positioning analysis based on these data until the snapshot thread is stopped when the preset conditions are met.
It realizes effective positioning of the problem of long startup time of Java applications. By collecting stack trace data and startup time affecting parameters, it can quickly identify performance bottlenecks and optimize application startup performance.
Smart Images

Figure CN118193272B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of application performance management, and in particular to a method for locating problems in a JVM system. Background Art
[0002] APM is the abbreviation of Application Performance Management, which is a practice and collection of tools to improve application performance and availability by monitoring and managing software application performance. APM is designed to help developers and system administrators identify and resolve performance issues in applications to ensure that applications can run quickly and efficiently and provide a good user experience. APM is an important practice that can help organizations ensure that their applications maintain high performance and stability in an ever-changing technology environment.
[0003] Among them, the application can be run in the JVM (Java Virtual Machine) system, and the running process of the application can be monitored through the JVM. The JVM has a high-rate object allocation problem, which refers to the situation where objects are frequently created and destroyed in Java applications, resulting in high memory management overhead. This situation may cause the performance of the application to degrade, because frequent object allocation and garbage collection operations will take up a lot of CPU (Central Processing Unit) time, and will cause all application threads to suspend execution, increase application response time, reduce application throughput, and increase unnecessary memory overhead.
[0004] Currently, general APM probes are used to locate requests. They use the pre-embedded point method to analyze the problem of long execution time of certain methods such as web (network) requests. However, there is basically no method or means to locate the long startup time of the application. Summary of the invention
[0005] In order to solve the problems of the prior art, the embodiments of the present application provide a method and device for locating problems of a JVM system, which can locate the problem of a long startup time of a Java application. The technical solution is as follows:
[0006] According to one aspect of the present application, a method for locating a problem of a JVM system is provided, the method comprising:
[0007] In the Java virtual machine JVM system, create a snapshot thread;
[0008] Whenever the JVM system starts a target application, starting the snapshot thread;
[0009] During the startup of the target application: performing a stack tracing operation on the target application based on the snapshot thread to obtain stack tracing data during the startup of the target application; periodically obtaining startup time influencing parameters of the target application;
[0010] Whenever a preset snapshot thread stopping condition is met, the snapshot thread is stopped;
[0011] Determining target stack trace data of the target application based on the stack trace data currently cached by the snapshot thread;
[0012] Based on the target stack tracing data and the startup time influencing parameters, a problem location analysis is performed on the target application.
[0013] According to another aspect of the present application, a problem location device for a JVM system is provided, the device comprising:
[0014] The thread creation module is used to create snapshot threads in the Java virtual machine JVM system;
[0015] A data acquisition module is used to start the snapshot thread whenever the JVM system starts the target application; during the startup process of the target application: perform a stack tracing operation on the target application based on the snapshot thread to obtain stack tracing data during the startup process of the target application; periodically obtain startup time influencing parameters of the target application; and stop the snapshot thread whenever a preset snapshot thread stop condition is met;
[0016] A data aggregation module, configured to determine target stack tracing data of the target application based on the stack tracing data currently cached by the snapshot thread;
[0017] The problem locating module is used to perform problem locating analysis on the target application based on the target stack tracing data and the startup time influencing parameters.
[0018] According to another aspect of the present application, there is provided an electronic device, including:
[0019] Processor; and
[0020] Memory for storing programs,
[0021] The program includes instructions, which, when executed by the processor, enable the processor to perform the problem location of the JVM system.
[0022] According to another aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to perform the problem location of the above-mentioned JVM system.
[0023] This application can achieve the following beneficial effects:
[0024] During the startup process of the target application, stack trace data is collected through the snapshot thread, and the startup time influencing parameters of the target application are periodically obtained. Based on the stack trace data and the startup time influencing parameters, the problem location analysis of the target application is performed to locate the problem of long startup time of the Java application. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Further details, features and advantages of the present application are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:
[0026] Figure 1 A flowchart of a method for locating a problem in a JVM system provided according to an exemplary embodiment of the present application is shown;
[0027] Figure 2 A flame diagram schematic diagram provided according to an exemplary embodiment of the present application is shown;
[0028] Figure 3 A schematic block diagram of a problem location device for a JVM system provided according to an exemplary embodiment of the present application is shown;
[0029] Figure 4 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present application is shown. DETAILED DESCRIPTION
[0030] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.
[0031] It should be understood that the various steps described in the method implementation of the present application can be performed in different orders and / or performed in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.
[0032] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0033] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0034] The names of the messages or information exchanged between multiple devices in the embodiments of the present application are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0035] The present application provides a method for locating a problem in a JVM system, which can be performed by a terminal, a server and / or other devices with processing capabilities. The method provided in the embodiment of the present application can be performed by any of the above devices, or by multiple devices together.
[0036] The following will refer to Figure 1 The problem location method of the JVM system shown in the figure is introduced.
[0037] Step 101: Create a snapshot thread in a Java virtual machine JVM system.
[0038] In a possible implementation, a snapshot (dump) thread may be created in a Java Agent of a JVM system. Java Agent is a mechanism provided by the JVM that allows the bytecode of an application to be modified or enhanced by an agent when the application is started. This mechanism is often used to implement various types of code injection, performance monitoring, logging, AOP (aspect-oriented programming) and other functions.
[0039] Java Agent allows developers to intercept and modify the bytecode of a class during the process of class loading in an application. This requires analyzing, modifying, and regenerating the bytecode. To achieve this, bytecode manipulation libraries are usually used, such as ASM, ByteBuddy, etc. These libraries provide high-level APIs that make it relatively easy to operate at the bytecode level.
[0040] The Java class loader is responsible for loading classes from the class path into memory. Java Agent uses the class loader's delegation mechanism to intervene in the class loading process and implement dynamic modification of classes. This intervention is usually implemented through Java's Instrumentation interface, which provides the ability to perform bytecode conversion before and after class loading.
[0041] The Java Agent functionality is implemented through a special JAR file that contains a predefined premain or agentmain method. The premain method is called before the main application is started, while the agentmain method can load new agents at runtime after the main application has been started. These methods are used to initialize the agent, set bytecode conversion rules, etc.
[0042] Java Agent allows the modification of bytecodes when classes are loaded, thereby changing the behavior of classes. This mechanism is widely used for various purposes, including performance optimization, monitoring, logging, security enhancement, etc.
[0043] The application scenarios of Java Agent include performance analysis tools (such as JProfiler), AOP frameworks (such as AspectJ), code injection tools (such as bytecode instrumentation tools), monitoring tools (such as New Relic), security enhancement tools, etc. Through Java Agent, developers can perform various types of enhancements to applications without modifying the original code.
[0044] In short, Java Agent is a powerful mechanism provided by the Java virtual machine that allows developers to modify and enhance applications at the bytecode level, which makes it possible to implement various innovative functions and tools.
[0045] Step 102: Whenever the JVM system starts the target application, a snapshot thread is started.
[0046] In a possible implementation, when the target application is started, the snapshot thread may be started in a Java Agent.
[0047] Step 103, during the startup process of the target application: performing a stack tracing operation on the target application based on the snapshot thread to obtain stack tracing data during the startup process of the target application; and periodically obtaining startup time influencing parameters of the target application.
[0048] In a possible implementation, in order to analyze the problem of long application startup time, two types of data may be collected during the startup process of the target application. The first type refers to stack trace data, and the second type refers to startup time influencing parameters.
[0049] The following is an introduction to the process of collecting stack trace data.
[0050] In the snapshot thread, the stack data of the target application during startup can be photographed by regularly tracing the stack data, that is, the data at the time of photographing is obtained as the stack tracing data, and the stack tracing data is cached according to the photographing time.
[0051] Optionally, a timed multiplication strategy can be used to reduce the number of photos taken and reduce the impact on the application. The specific processing can be as follows:
[0052] Obtain the preset initial photo-taking time interval and initial snapshot weight;
[0053] After the target application starts to start, based on the initial photo-taking time interval and the initial snapshot weight, stack trace data of the target number of target applications is obtained;
[0054] Perform the following snapshot adjustment processing: adjust the current photographing time interval and the current snapshot weight based on a preset multiple, and obtain the stack trace data of the target number of target applications again based on the adjusted photographing time interval and snapshot weight;
[0055] The snapshot adjustment process is repeatedly executed until a preset snapshot thread stop condition is met, and then the snapshot adjustment process is stopped.
[0056] As an example, the preset initial photo-taking time interval and snapshot weight can be read in the configuration file. This interval determines how often the application takes photos after it starts running.
[0057] After reading the photo-taking time interval, photos can be taken at this interval. This process can be repeated 10 times (i.e., target data), i.e., 10 stack trace data are obtained.
[0058] After completing the first round of 10 photos, you can modify the photo interval. The new photo interval can be twice the previous photo interval (i.e. the preset multiple), and the weight of the newly taken snapshot will be twice the weight of the previous snapshot.
[0059] After modifying the photo-taking interval, take photos again at the new interval. This process will be repeated 10 times.
[0060] After completing the second round of 10 photos, the photo interval is changed again to twice the previous one, and the weight of the newly taken snapshot will be twice the weight of the previous snapshot.
[0061] Then, take pictures again at the new interval, and this process will be repeated until the preset snapshot thread stop condition is met, the snapshot thread stops running, and the photo taking process will also stop accordingly.
[0062] The following is an introduction to the collection process of parameters affecting the startup time.
[0063] The process of periodically obtaining the parameters affecting the startup time of the target application may be as follows:
[0064] In the JVM system, create an MBean object;
[0065] Based on the MBean object, periodically obtain the parameters affecting the startup time of the target application;
[0066] Whenever the reporting period is reached, the startup time impact parameters currently cached by the reporting MBean object are reported.
[0067] The startup time influencing parameters may include any one or more of the following: garbage collection time, safe point time, number of class loads, and class loading time.
[0068] In one possible implementation, a JMX (Java Management Extensions) listener can be used to report the garbage collection time per unit time, the safe point time, and the number of class loads. By adding a Transformer, the class loading process can be monitored to analyze the class loader, the URL (uniform resource location) of the class file, the jar (java archive) package to which it belongs, and the class loading time.
[0069] Specifically, an MBean object is a Java object that can be managed by the JMX API. You can create an MBean object to obtain and store the above startup time-influencing parameters. Register the MBean object in the MBeanServer so that you can access the MBean object through the JMX API (Application Programming Interface). In the MBean object, you can use java.lang.management.GarbageCollectorMXBean and java.lang.management.ThreadMXBean to obtain garbage collection time and safe point time, and use java.lang.management.ClassLoadingMXBean to obtain the number of class loaders.
[0070] You can create a scheduled task that regularly updates the information in the MBean object and reports the information to the monitoring system.
[0071] Specifically, the data format for uploading class loading time can be as follows:
[0072] {
[0073] time: class loading time
[0074] className: class name
[0075] classLoaderName: class loader name
[0076] classLoaderHashCode: HashCode of class loader
[0077] classresource: URL of the class file (the jar package it belongs to)
[0078] }
[0079] During the running of a Java application, some specific events may cause the entire JVM to stop or pause, so that all application threads will be paused, thus affecting the performance of the application.
[0080] The specific events mentioned above include:
[0081] Garbage Collection (GC): When the JVM starts to perform garbage collection, in order to ensure that memory and objects are cleaned up correctly, all threads need to pause execution to perform global garbage collection operations;
[0082] Initialization at JVM startup: During the JVM startup process, some initialization work will be performed, such as loading classes, initializing the virtual machine, etc. These operations may require stopping all threads for initialization;
[0083] Thread safety checkpoint (safepoint): In some cases, the JVM needs to ensure that all threads are in a safe state to perform certain operations or checks. These operations may include thread state transitions, internal state modifications, etc.
[0084] In Java, programmers do not need to manage memory manually because Java's garbage collector is responsible for managing memory automatically. When a Java application runs, it creates objects in the heap memory. Over time, these objects may no longer be used by the program, so they become garbage objects (i.e. objects that are no longer referenced). The JVM's garbage collector periodically scans the heap memory, finds objects that are no longer referenced, and reclaims the memory space occupied by these objects. Generally, the garbage collection process stops the world, and other threads cannot work normally.
[0085] "Stop the world" is a descriptive term that means that when these events occur, the entire JVM execution is temporarily stopped. This pause can cause performance issues for some applications, because threads being suspended for too long can affect the responsiveness and throughput of the application.
[0086] In order to reduce the impact of "Stop the world", JVM developers will continue to optimize garbage collection algorithms, improve the performance of garbage collectors, and minimize the frequency and pause time of garbage collection. When designing applications, developers can also reduce the impact of garbage collection on applications through reasonable memory management and resource usage.
[0087] Safepoint is an important mechanism for JVM management and optimization, but in some cases, safepoint may cause the application to pause for a long time, affecting the performance of the application. Therefore, when optimizing and adjusting Java applications, developers need to consider the impact of safepoint on application performance and make targeted adjustments and optimizations.
[0088] When the JVM is running, there are usually many safepoints, but not all safepoints will cause all threads to be suspended. For example, garbage collection requires all threads to be suspended, while other types of safepoints may only require some threads to be suspended.
[0089] This embodiment collects startup time influencing parameters, and locates and analyzes the problem of long application startup time based on the startup time influencing parameters, so that developers can optimize the startup time of the application.
[0090] Step 104: whenever a preset snapshot thread stopping condition is met, the snapshot thread is stopped.
[0091] The preset snapshot thread stop condition may include one or more of the following:
[0092] The first condition is that the startup time of the target application reaches the preset time value;
[0093] The second condition is that the target application is initialized successfully;
[0094] The third condition is that the first access request of the target application is successfully completed.
[0095] In a possible implementation, for the first condition, the preset time value may be read from a configuration file, and the startup time of the target application may be monitored. Whenever the startup time of the target application reaches the preset time value, the snapshot thread may be stopped.
[0096] For the second condition mentioned above, you can embed the port initialization method of different Web containers. When the port is set successfully, an event notification is issued and the snapshot thread is stopped. Among them, the Web container is a software environment for hosting and running Web applications. It provides an operating environment in which developers can deploy, run and manage their Web applications. The Web container is usually used as part of a Web server to execute the code of the Web application, process HTTP requests and responses, and provide the ability to interact with other systems and services. The startup time of the Web container refers to the time required from the start command to the time when the container is fully ready to process the request. This includes operations such as loading configuration, initializing applications, and preparing database connections.
[0097] For the third condition above, after the target application successfully completes the first access request, an event notification may be issued to stop the snapshot thread.
[0098] Step 105 : determining target stack trace data of the target application based on the stack trace data currently cached by the snapshot thread.
[0099] In a possible implementation, after the snapshot thread ends, the stack trace data currently cached by the snapshot thread may be obtained and the stack trace data may be aggregated. The corresponding processing may be as follows:
[0100] Whenever the snapshot thread is stopped, the stack trace data currently cached by the snapshot thread is obtained;
[0101] Based on the stored historical stack trace data and the stack trace data currently cached by the snapshot thread, an aggregation operation is performed on the target application to determine the target stack trace data of the target application.
[0102] The specific aggregation operations can be as follows:
[0103] For the stack trace data currently cached by the snapshot thread, create target key data, the target key data including the thread ID and time granularity of the snapshot thread;
[0104] In the stored historical stack trace data, search for historical key data identical to the target key data;
[0105] If there is no target history key data identical to the target key data, determining the target stack trace data of the target application based on the stack trace data currently cached by the snapshot thread;
[0106] If there is target history key data identical to the target key data, the target stack trace data of the target application is determined based on the stack trace data currently cached by the snapshot thread and the history stack trace data corresponding to the target history key data.
[0107] In a possible implementation, a hash map HashMap may be used to store and aggregate StackTraces (ie, stack tracing data) with the same thread ID (ie, thread identification) and the same time granularity.
[0108] First, create a HashMap, the key is a composite key containing thread ID and time granularity (i.e. key data), and the value is a list List, which is used to store StackTrace. Whenever the snapshot thread stops, get the stack trace data currently cached by the snapshot thread as a new StackTrace, and create a composite key for the new StackTrace based on the format of the key data in the HashMap, i.e. the target key data.
[0109] Check whether the target key data already exists in the HashMap. If not, create a new key (the target key data) in the HashMap, add the new StackTrace to a new List, and use the stack trace data in the List as the target stack trace data for the target application. If the target key data already exists in the HashMap, get the List corresponding to the key, add the new StackTrace to the List, and use the stack trace data in the List (including historical stack trace data and new stack trace data) as the target stack trace data for the target application.
[0110] Step 106 : Based on the target stack trace data and the startup time influencing parameters, a problem location analysis is performed on the target application.
[0111] In a possible implementation, both the target stack trace data and the start-up time impact parameters can be reported to the monitoring system. Figure 2 The flame graph shown in the figure. The flame graph is a visualization technique used to display the performance bottlenecks of software or systems. It graphically displays the time consumed by the program during execution, helping developers quickly locate performance problems. Each layer of the flame graph represents a function call, and the width represents the time spent on the startup time of the function. The wider it is, the longer it takes. The order from bottom to top represents the calling relationship of the functions, and the functions below call the functions above. The function at the top is the currently executing function. If its width is very wide, it may be a performance bottleneck. In general, the flame graph is a very effective performance analysis tool that can help developers quickly locate and solve performance problems.
[0112] Combined with the parameters affecting the startup time, we can analyze the factors that may cause the target application to start slowly.
[0113] As a specific example, the following logic can be used to provide an analysis strategy:
[0114] safepointImpact=safepointTime / totalTime*safepointWeight
[0115] gcImpact=gcTime / totalTime*gcWeight
[0116] classLoadImpact=classLoadCount / totalTime*classLoadWeight
[0117] classLoaderImpact=classLoaderCount / totalTime*classLoaderWeight
[0118] flameGraphImpact=flameGraphResult / totalTime*flameGraphWeight
[0119] maxImpact=max(safepointImpact,gcImpact,classLoadImpact,classLoaderImpact,flameGraphImpact)
[0120] Among them, totalTime represents the total startup time of the target application; safepointImpact represents the safety point impact factor, safepointTime represents the safety point time consumption, and safepointWeight represents the safety point weight; gcImpact represents the garbage collection impact factor, gcTime represents the garbage collection time consumption, and gcWeight represents the garbage collection weight; classLoadImpact represents the class loading number impact factor, classLoadCount represents the class loading number, and classLoadWeight represents the class loading number weight; classLoaderImpact represents the class loading time impact factor, classLoaderCount represents the class loading time, and classLoaderWeight represents the class loading time weight; flameGraphImpact represents the stack impact factor, flameGraphResult represents the stack trace time width selected by the flame graph, and flameGraphWeight represents the stack weight; maxImpact represents the maximum possible impact factor.
[0121] Through the above analysis strategy, we can give a factor that is most likely to cause slow application startup. Among them, the above safety point weight, garbage collection weight, class loading quantity weight, class loading time weight and flame graph weight can be adjusted through configuration.
[0122] The embodiments of the present application can achieve the following beneficial effects:
[0123] During the startup process of the target application, stack trace data is collected through the snapshot thread, and the startup time influencing parameters of the target application are periodically obtained. Based on the stack trace data and the startup time influencing parameters, the problem location analysis of the target application is performed to locate the problem of long startup time of the Java application.
[0124] The embodiment of the present application provides a JVM system problem location device, which is used to implement the above-mentioned JVM system problem location method. Figure 3 The schematic block diagram of the problem locating device of the JVM system is shown. The problem locating device 300 of the JVM system includes: a thread creation module 301, a data acquisition module 302, a data aggregation module 303, and a problem locating module 304.
[0125] The thread creation module 301 is used to create a snapshot thread in a Java virtual machine JVM system;
[0126] The data acquisition module 302 is used to start the snapshot thread whenever the JVM system starts the target application; during the startup process of the target application: perform a stack tracing operation on the target application based on the snapshot thread to obtain stack tracing data during the startup process of the target application; periodically obtain the startup time influencing parameters of the target application; and stop the snapshot thread whenever a preset snapshot thread stop condition is met;
[0127] A data aggregation module 303 is used to determine the target stack tracing data of the target application based on the stack tracing data currently cached by the snapshot thread;
[0128] The problem locating module 304 is used to perform problem locating analysis on the target application based on the target stack tracing data and the startup time influencing parameters.
[0129] Optionally, the data acquisition module 302 is used to:
[0130] Obtain the preset initial photo-taking time interval and initial snapshot weight;
[0131] After the target application starts to start, based on the initial photographing time interval and the initial snapshot weight, obtaining a target number of stack trace data of the target application;
[0132] Performing the following snapshot adjustment processing: adjusting the current photographing time interval and the current snapshot weight based on a preset multiple, and acquiring the stack tracing data of the target application of the target number again based on the adjusted photographing time interval and snapshot weight;
[0133] The snapshot adjustment process is repeatedly executed until the preset snapshot thread stop condition is met, and then the snapshot adjustment process is stopped.
[0134] Optionally, the preset snapshot thread stopping condition includes one or more of the following:
[0135] The startup time of the target application reaches a preset time value;
[0136] The target application is initialized successfully;
[0137] The first access request of the target application is successfully completed.
[0138] Optionally, the data aggregation module 303 is used to:
[0139] Whenever the snapshot thread is stopped, the stack trace data currently cached by the snapshot thread is obtained;
[0140] Based on the stored historical stack tracing data and the stack tracing data currently cached by the snapshot thread, an aggregation operation is performed on the target application to determine the target stack tracing data of the target application.
[0141] Optionally, the data aggregation module 303 is used to:
[0142] For stack trace data currently cached by the snapshot thread, create target key data, the target key data including a thread identifier and a time granularity of the snapshot thread;
[0143] Searching for historical key data identical to the target key data in the stored historical stack trace data;
[0144] If there is no target history key data identical to the target key data, determining the target stack trace data of the target application based on the stack trace data currently cached by the snapshot thread;
[0145] If there is target history key data identical to the target key data, the target stack tracing data of the target application is determined based on the stack tracing data currently cached by the snapshot thread and the history stack tracing data corresponding to the target history key data.
[0146] Optionally, the data acquisition module 302 is used to:
[0147] In the JVM system, creating an MBean object;
[0148] Based on the MBean object, periodically obtain the startup time influencing parameters of the target application;
[0149] Whenever a reporting cycle is reached, the startup time influencing parameter currently cached by the MBean object is reported.
[0150] Optionally, the startup time influencing parameters include any one or more of the following: garbage collection time, safe point time, class loading quantity, and class loading time.
[0151] The embodiments of the present application can achieve the following beneficial effects:
[0152] During the startup process of the target application, stack trace data is collected through the snapshot thread, and the startup time influencing parameters of the target application are periodically obtained. Based on the stack trace data and the startup time influencing parameters, the problem location analysis of the target application is performed to locate the problem of long startup time of the Java application.
[0153] The exemplary embodiment of the present application also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and the computer program is used to cause the electronic device to perform the method according to the embodiment of the present application when executed by the at least one processor.
[0154] The exemplary embodiment of the present application further provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform a method according to an embodiment of the present application.
[0155] The exemplary embodiments of the present application further provide a computer program product, including a computer program, wherein when the computer program is executed by a processor of a computer, it is used to enable the computer to execute the method according to the embodiment of the present application.
[0156] refer to Figure 4 , the structural block diagram of the electronic device 400 that can be used as the server or client of the present application will now be described, which is an example of the hardware device that can be applied to various aspects of the present application. The electronic device is intended to represent various forms of digital electronic computer equipment, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples, and are not intended to limit the implementation of the present application described and / or required herein.
[0157] like Figure 4 As shown, the electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0158] A plurality of components in the electronic device 400 are connected to the I / O interface 405, including: an input unit 406, an output unit 407, a storage unit 408, and a communication unit 409. The input unit 406 may be any type of device capable of inputting information to the electronic device 400, and the input unit 406 may receive input digital or character information, and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 407 may be any type of device capable of presenting information, and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 408 may include, but is not limited to, a disk, an optical disk. The communication unit 409 allows the electronic device 400 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks, and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0159] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above. For example, in some embodiments, the problem location method of the above-mentioned JVM system may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 400 via the ROM 402 and / or the communication unit 409. In some embodiments, the computing unit 401 may be configured to execute the problem location method of the above-mentioned JVM system by any other appropriate means (e.g., by means of firmware).
[0160] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0161] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0162] As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0163] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0164] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0165] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
Claims
1. A method for locating a problem in a JVM system, characterized in that: The method comprises: In the Java virtual machine JVM system, create a snapshot thread; Whenever the JVM system starts a target application, starting the snapshot thread; During the startup of the target application: performing a stack tracing operation on the target application based on the snapshot thread to obtain stack tracing data during the startup of the target application; periodically obtaining startup time influencing parameters of the target application; Whenever a preset snapshot thread stopping condition is met, the snapshot thread is stopped; Based on the stored historical stack tracing data and the stack tracing data currently cached by the snapshot thread, performing an aggregation operation on the target application to determine target stack tracing data of the target application; Based on the target stack tracing data and the startup time influencing parameters, a problem location analysis is performed on the target application.
2. The method according to claim 1, characterized in that The step of performing a stack tracing operation on the target application based on the snapshot thread during the startup of the target application to obtain stack tracing data during the startup of the target application includes: Obtain the preset initial photo-taking time interval and initial snapshot weight; After the target application starts to start, based on the initial photographing time interval and the initial snapshot weight, obtaining a target number of stack trace data of the target application; Performing the following snapshot adjustment processing: adjusting the current photographing time interval and the current snapshot weight based on a preset multiple, and acquiring the stack tracing data of the target application of the target number again based on the adjusted photographing time interval and snapshot weight; The snapshot adjustment process is repeatedly executed until the preset snapshot thread stop condition is met, and then the snapshot adjustment process is stopped.
3. The method according to claim 1, characterized in that: The preset snapshot thread stopping condition includes one or more of the following: The startup time of the target application reaches a preset time value; The target application is initialized successfully; The first access request of the target application is successfully completed.
4. The method according to claim 1, characterized in that Whenever the snapshot thread is stopped, the stack trace data currently cached by the snapshot thread is obtained, so as to perform an aggregation operation on the target application based on the stored historical stack trace data and the stack trace data currently cached by the snapshot thread to determine the target stack trace data of the target application.
5. The method according to claim 1, characterized in that The performing an aggregation operation on the target application based on the stored historical stack tracing data and the stack tracing data currently cached by the snapshot thread to determine the target stack tracing data of the target application includes: For stack trace data currently cached by the snapshot thread, create target key data, the target key data including a thread identifier and a time granularity of the snapshot thread; Searching for historical key data identical to the target key data in the stored historical stack trace data; If there is no target history key data identical to the target key data, determining the target stack trace data of the target application based on the stack trace data currently cached by the snapshot thread; If there is target history key data identical to the target key data, the target stack tracing data of the target application is determined based on the stack tracing data currently cached by the snapshot thread and the history stack tracing data corresponding to the target history key data.
6. The method according to claim 1, characterized in that The periodically obtaining the startup time influencing parameter of the target application includes: In the JVM system, creating an MBean object; Based on the MBean object, periodically obtain the startup time influencing parameters of the target application; Whenever a reporting cycle is reached, the startup time influencing parameter currently cached by the MBean object is reported.
7. The method according to claim 6, characterized in that The startup time influencing parameters include any one or more of the following: garbage collection time, safe point time, class loading quantity, and class loading time.
8. A JVM system problem location device, characterized in that: The device comprises: The thread creation module is used to create snapshot threads in the Java virtual machine JVM system; A data acquisition module is used to start the snapshot thread whenever the JVM system starts the target application; during the startup process of the target application: perform a stack tracing operation on the target application based on the snapshot thread to obtain stack tracing data during the startup process of the target application; periodically obtain startup time influencing parameters of the target application; and stop the snapshot thread whenever a preset snapshot thread stop condition is met; A data aggregation module, configured to perform an aggregation operation on the target application based on the stored historical stack tracing data and the stack tracing data currently cached by the snapshot thread, and determine the target stack tracing data of the target application; The problem locating module is used to perform problem locating analysis on the target application based on the target stack tracing data and the startup time influencing parameters.
9. An electronic device, comprising: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to make a computer execute the method according to any one of claims 1-7.
