Application program lag data acquisition method and device, equipment and storage medium

By caching trace information and generating trace files in user space, the application stuttering problem caused by kernel-mode I/O operations is resolved, improving smoothness and the efficiency of stuttering data analysis.

CN114691399BActive Publication Date: 2025-12-12BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011621930.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-31
Publication Date
2025-12-12
Estimated Expiration
2041-06-13

AI Technical Summary

Technical Problem

In existing technologies, latency issues caused by applications performing I/O operations in kernel mode can lead to stuttering and affect smoothness.

Method used

In user space, trace information is cached and trace files are generated through an asynchronous thread, avoiding kernel-space I/O operations. Hook functions are used to intercept write operations and store the information in a circular buffer. The asynchronous thread sends the information to the user-space buffer, and finally generates a trace file and uploads it to the server.

Benefits of technology

It reduces latency caused by kernel-mode I/O operations, improves application smoothness, and ensures effective analysis and localization of lag data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691399B_ABST
    Figure CN114691399B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide an application program lag data acquisition method and device, equipment and a storage medium, by acquiring tracking information of an application program, the tracking information is used to represent time-consuming information related to the application program in the running process of the application program; the tracking information is cached to a preset position through an asynchronous thread in a user mode to generate a tracking file, wherein the tracking file is used for lag analysis of the application program; the tracking file is uploaded to a server to remotely acquire lag data in a terminal device for analyzing the application program lag. Since the tracking information is cached to the preset position in the user mode when the tracking file is acquired, the time delay problem caused by I / O operation caching of the tracking information in the kernel mode can be avoided, thereby improving the smoothness of the application program running.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present disclosure relate to the technical field of computer and network communication, and particularly relate to an application program lag data acquisition method and device, equipment and a storage medium. BACKGROUND

[0002] For an application program (APP) product, the smoothness of program running is an important factor for evaluating the quality of the APP product. In the process of continuous upgrading and version iteration of the APP product, the product developer will collect and locate data for the lag problem in the APP product, so as to find the lag phenomenon of the terminal device running the APP product.

[0003] In the prior art, the APP product developer will monitor the lag of the application program through the terminal device, collect relevant tracking information for analysis. However, the terminal device processes the information based on the abnormal processing mode after collecting the tracking information, so the collected tracking information needs to be written in the kernel state.

[0004] However, there is a delay problem in the input / output (I / O) operation of the thread running the application program in the kernel state, which will cause the application program to lag. SUMMARY

[0005] Embodiments of the present disclosure provide an application program lag data acquisition method, device, equipment and storage medium to overcome the lag problem in monitoring the lag of the application program.

[0006] In a first aspect, embodiments of the present disclosure provide an application program lag data acquisition method, comprising:

[0007] obtaining tracking information of an application program, the tracking information being used to represent time-consuming information related to the application program in the running process of the application program;

[0008] storing the tracking information in a preset location through an asynchronous thread in a user state to generate a tracking file, wherein the tracking file is used for lag analysis of the application program;

[0009] uploading the tracking file to a server.

[0010] In a second aspect, embodiments of the present disclosure provide an application program lag data acquisition device, comprising:

[0011] an obtaining unit, configured to obtain tracking information of an application program, the tracking information being used to represent time-consuming information related to the application program in the running process of the application program;

[0012] A cache unit is configured to cache the tracking information to a preset location through an asynchronous thread in a user mode to generate a tracking file, wherein the tracking file is used for analyzing the application program.

[0013] A transceiving unit is configured to upload the tracking file to a server.

[0014] In a third aspect, an electronic device is provided, which includes at least one processor and a memory.

[0015] The memory stores computer-executable instructions.

[0016] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the application program stall data acquisition method according to the first aspect and various possible designs of the first aspect.

[0017] In a fourth aspect, a computer-readable storage medium is provided, which stores computer-executable instructions. When a processor executes the computer-executable instructions, the application program stall data acquisition method according to the first aspect and various possible designs of the first aspect is implemented.

[0018] The application program stall data acquisition method, device, electronic device and storage medium provided by the embodiments of the present disclosure acquire tracking information of an application program, wherein the tracking information is used to represent time-consuming information related to the application program during the running of the application program. The tracking information is cached to a preset location through an asynchronous thread in a user mode to generate a tracking file, wherein the tracking file is used for analyzing the application program. The tracking file is uploaded to a server to remotely acquire stall data for analyzing the stall of the application program in a terminal device. Since the tracking information is cached to the preset location in the user mode to acquire the tracking file, the time delay caused by I / O operation in the kernel mode to cache the tracking information is avoided, so that the fluency of the application program during running is improved. BRIEF DESCRIPTION OF DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure or the prior art, the drawings needed in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor.

[0020] Figure 1 An application scenario provided by the embodiments of the present disclosure is shown in a schematic diagram.

[0021] Figure 2 FIG. 1 is an example diagram of a process for obtaining frame freezing data in the prior art;

[0022] Figure 3 FIG. 1 is an example diagram of a process for obtaining frame freezing data in the prior art; Figure 1

[0023] Figure 4 FIG. 1 is an example diagram of a process for obtaining frame freezing data in the prior art; Figure 3 FIG. 1 is an example diagram of a process for obtaining frame freezing data in the prior art;

[0024] Figure 5 FIG. 1 is an example diagram of a process for obtaining frame freezing data in the prior art;

[0025] Figure 6 FIG. 1 is an example diagram of a process for obtaining frame freezing data in the prior art; Figure 2

[0026] Figure 7 FIG. 1 is an example diagram of a process for obtaining frame freezing data in the prior art;

[0027] Figure 8 FIG. 1 is an example diagram of a process for obtaining frame freezing data in the prior art; DETAILED DESCRIPTION

[0028] In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure clearer, the following will combine the drawings for the embodiments of the present disclosure to clearly and completely describe the technical solutions of the embodiments of the present disclosure. Obviously, the described embodiments are some but not all of the embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present disclosure.

[0029] First, the terms involved in the present application are explained:

[0030] Trace information, i.e., trace information, is information tracked and traced by an operating system to a corresponding process when an application program has an exception. The information records the stack of the process and some state information of the virtual machine when the exception occurs. The operating system saves such trace information to form a trace file, for example, the traces.txt file in the Android system, which records the relevant information of the current process when an Application Not Responding (ANR) event occurs. According to the trace information recorded in the trace file, the analysis and positioning of the frame freezing problem of the application program can be realized to optimize the running fluency of the application program.

[0031] ​​Kernel mode and user mode, kernel mode and user mode are two running levels of an operating system, the kernel mode has high permission, and the user mode has low permission, through the kernel mode and the user mode, the permission grading and data isolation of a central processing unit (CPU) can be effectively realized, the process corresponding to the kernel mode is a kernel process, and the process corresponding to the user mode is a user process, for safety consideration, the user process is restricted, and the user process cannot access and acquire resources at will. The kernel process is responsible for managing and allocating resources, and has the highest permission, and the user process uses the allocated resources. When the CPU executes a program running in the user mode, some unpredictable exceptions occur, at this time, switching from the current running process to a kernel-related process for processing the exception is triggered, that is, switching to the kernel mode.

[0032] The application scenario of the embodiment of the present disclosure is explained as follows:

[0033] Figure 1 An application scenario diagram provided by the embodiment of the present disclosure is shown in FIG. 1. Figure 1 The application program lag data acquisition method provided by the embodiment of the present disclosure can be applied to a terminal device, for example, a smart phone. The terminal device is installed and runs an application program (APP) client. In order to improve the smoothness of the application program running and provide a better use experience for the application user of the application program, the server connected in communication with the application program client collects the lag data uploaded by the client for recording the lag of the application program. Specifically, for example, the application program client can upload the lag data to the server according to the preset plan information, or upload the lag data to the server according to the received instruction information. The development user of the application program analyzes and locates the reason for the lag of the application program through the lag data in the server, so as to optimize the application program, reduce the lag, and improve the smoothness of the application program running.

[0034] Figure 2 An example diagram of a process for acquiring lag data in the prior art is shown in FIG. 2. Figure 2In the prior art, the application program is analyzed for the reason of the application program being stuck by obtaining the calling time of the function related to the application program in the running process of the application program to determine the function with long calling time, so as to locate the reason of the application program being stuck. Therefore, the information representing the calling time of the function related to the application program is included in the stuck data. Taking the Android system as an example, the information representing the calling time of each function in the application program is atrace information. In the prior art, the process of obtaining the stuck data needs to call the write system (write) function to write the atrace information into the preset trace mark description (trace_mark_fd) file, so as to generate the stuck data. The process needs to switch the thread to the kernel state to complete, and in the process of switching to the kernel state to perform the I / O operation, the read-write delay occurs for the device with poor performance, and then the flow of the application program is affected, and the application program is stuck. The application program stuck data obtaining method provided by the embodiment of the present disclosure solves the above problems.

[0035] Reference Figure 3 , Figure 3 The application program stuck data obtaining method provided by the embodiment of the present disclosure is shown in the flowchart Figure 1 The method of the embodiment can be applied in a terminal device. The application program stuck data obtaining method comprises the following steps.

[0036] Step S101: Obtain the trace information of the application program. The trace information is used to represent the time consumption information related to the application program in the running process of the application program.

[0037] Taking the Android system as an example, the trace information is, for example, the stack information when the ANR event of the application program occurs, and more specifically, the atrace information. The atrace information refers to the time consumption information related to the application program in the native layer of the Android system, which is obtained by the atrace function. By configuring different execution parameters for the atrace function, the corresponding atrace information can be obtained. The use method of the atrace function and the specific obtaining method of the atrace information are not described herein.

[0038] Taking the Android system as an example, the trace information is, for example, the stack information when the ANR event of the application program occurs, and more specifically, the atrace information. The atrace information refers to the time consumption information related to the application program in the native layer of the Android system, which is obtained by the atrace function. By configuring different execution parameters for the atrace function, the corresponding atrace information can be obtained. The use method of the atrace function and the specific obtaining method of the atrace information are not described herein.

[0039] Step S102: Cache the trace information to a preset position through an asynchronous thread in the user state to generate a trace file, wherein the trace file is used to analyze the reason of the application program being stuck.

[0040] Taking the Android system as an example, the trace information is, for example, the stack information when the ANR event of the application program occurs, and more specifically, the atrace information. The atrace information refers to the time consumption information related to the application program in the native layer of the Android system, which is obtained by the atrace function. By configuring different execution parameters for the atrace function, the corresponding atrace information can be obtained. The use method of the atrace function and the specific obtaining method of the atrace information are not described herein. Figure 4As shown, step S102 includes the following three specific implementation steps:

[0041] S1021, intercepting the cache operation of the application program, wherein the cache operation is used to represent that the application program stores the trace information by executing the kernel code.

[0042] Specifically, the trace information is the stack information at the time of the exception of the application program. In the prior art, the trace information is cached as a trace file. The way is to switch to the kernel state, write to a preset file trace_mark_fd by executing the kernel code, and generate a trace file. In the embodiment, the cache operation of the application program is intercepted during the process of storing the trace information as a trace file, that is, without switching to the kernel state, but saving the trace information in a preset position under the user state. More specifically, the process can intercept the input data of the write function through the hook function, so as to avoid switching to the kernel state to process the trace information.

[0043] S1022, sending the trace information to the preset user state cache area through an asynchronous thread.

[0044] Further, after intercepting the trace information, the trace information is sent to the preset user state cache area. The process can be implemented under the user state without switching to the kernel state. Exemplarily, a ring buffer is provided in the terminal device. The intercepted trace information is first sent to the ring buffer. Different trace information is sequentially written into the ring buffer until the cache data in the ring buffer reaches a preset quantity level. Then, the data in the ring buffer is sent as a whole. Since the process always runs under the user state, frequent calling of the kernel thread is avoided, and the waste of kernel resources is reduced.

[0045] Further, after the trace information cached in the ring buffer reaches a preset data quantity, the data in the ring buffer is sent to the user state cache area through an asynchronous thread for caching. Exemplarily, the user state cache area is implemented through an ofstream class in the Android system.

[0046] Exemplarily, before being sent to the preset user state buffer area through the asynchronous thread, the method further comprises: obtaining input / output interface information and lock information, the input / output interface information being used to represent the input / output state of the thread to the trace_marker_fd file; and the lock information being used to represent the holding state of the thread to the trace_marker_fd file. Exemplarily, the method further comprises: obtaining trace information in a sleep state, wherein the trace information in the sleep state refers to trace information that causes the thread to be in a sleep state due to I / O time consumption, Binder time consumption, and the like in the atrace.

[0047] Correspondingly, the I / O interface information, the lock information, and the trace information in the sleep state are sent to the user state buffer area through the asynchronous thread. In the step of the embodiment, the I / O interface information, the lock information, and the trace information in the sleep state are obtained, so as to further enrich the trace information used to locate the application program freezing problem, so that the generated trace file contains more information used to indicate the freezing problem, and the effectiveness of the data is improved.

[0048] S1023, when it is determined that the data write amount of the user state buffer area is greater than or equal to the preset buffer threshold, writing the data in the user state buffer area to a preset position to generate a trace file.

[0049] When the data write amount of the user state buffer area is greater than or equal to the preset buffer threshold, for example, greater than or equal to 90% of the maximum write amount of the buffer area, the data in the user state buffer area is saved in a preset local storage position, at this time, the write function needs to be called to generate a corresponding trace file.

[0050] In the prior art, in the process of generating a trace file by switching to a kernel state and executing kernel code to write a preset file trace_mark_fd, when multiple threads perform I / O read / write operations on a regular file that describes the properties of the trace_mark_fd file, the threads hold a position lock, that is, an f_pos_lock lock, of the regular file, and the position lock is used to ensure the order of writing trace information by the threads. In a low memory working condition, the delay of the I / O read / write operation is high, so that once a certain thread cannot complete the corresponding I / O read / write operation in time, other threads must wait, therefore, if a user interface (UI) thread needs to operate the same file at this time, a contention for the f_pos_lock lock occurs, and thus the program freezes. Figure 5For the implementation process of step S102 in the embodiments of the present disclosure, refer to Figure 5 In the step of the present application, the trace information is intercepted and written to trace_mark_fd by the application program, and the trace information is cached in the ringbuffer and written to the user buffer area through the ringbuffer, so as to generate a separate trace file, that is, the stall data, reduce the time consumption of the write operation, improve the efficiency of the system in processing the trace information, and reduce the stall phenomenon of the application program.

[0051] Step S103, uploading the trace file to the server.

[0052] Exemplarily, after the terminal device generates the trace file locally, the trace file can be uploaded to the server for the development user of the application program to analyze the trace file, so as to realize the positioning of the application program stall problem.

[0053] In a possible implementation, the terminal device can upload the trace file to the server according to a preset configuration parameter, for example, once a day or once a week. The terminal device can also upload the corresponding trace file to the server after determining that the application program has a stall phenomenon.

[0054] In another possible implementation, the terminal device sends the trace file to the server after receiving an upload instruction. The upload instruction can be directly input by the user to the terminal device, generated by the application program according to a preset rule, or sent by the server to the terminal device, which is not limited here.

[0055] In the present embodiment, the trace information of the application program is obtained, and the trace information is used to represent the time-consuming information related to the application program in the running process of the application program. The trace information is cached to a preset position through an asynchronous thread in the user state to generate a trace file, wherein the trace file is used for stall analysis of the application program. The trace file is uploaded to the server to realize remote acquisition of the stall data in the terminal device for analyzing the stall of the application program. Since the trace file is obtained by caching the trace information to the preset position in the user state, the time delay problem caused by I / O operation caching of the trace information through the kernel state can be avoided, so as to improve the smoothness of the application program running.

[0056] Reference Figure 6 , Figure 6 The application program stall data acquisition method provided in the embodiments of the present disclosure is shown in the flowchart Figure 2 The process of obtaining the trace information of the application program is described in detail in the present embodiment. The application program stall data acquisition method comprises:

[0057] S201, receiving a calling instruction, the calling instruction is used to instruct the terminal device to start collecting trace information of an application.

[0058] Exemplarily, the calling instruction is an instruction for starting the function of collecting trace information of the application. Specifically, when the terminal device does not receive the calling instruction, the trace information of the application is not collected, so as to reduce the load of the system and save the computing resource. When the terminal device receives the calling instruction, the trace information of the application is collected. Further, the calling instruction can be input by a user through the terminal device directly, or be sent by the application to the terminal device according to the need, or be sent by a server to the terminal device. The function of generating the frame freezing data is controlled to be started or stopped through the calling instruction. In a more specific embodiment, the calling instruction includes an execution script, through which the atrace_enabled_tags item is found from the libcutils.so library through the dlopen mode, and the value of the atrace_enabled_tags item is set to 1, so as to start the function of collecting the trace information.

[0059] S202, after receiving the calling instruction, first state information and second state information are collected, wherein the first state information represents the calling time consumption of the function of the application, and the second state information represents the calling time consumption of the function in the operating system.

[0060] Exemplarily, the first state information is the trace information of the function in the application, for example, the calling time consumption of the function a and the calling time consumption of the function b. Through the calling time consumption of each function in the application, the program frame freezing can be located. Specifically, in a possible implementation, the method for collecting the first state information can include:

[0061] S2021: the start time and the end time of each function during the running of the application are collected through dynamic instrumentation in the application.

[0062] S2022: the first state information is determined according to the start time and the end time of each function.

[0063] Specifically, through dynamic instrumentation in the application, when the program runs to the instrumentation function, a corresponding time information can be obtained to describe the start time and the end time of the corresponding function. Through the calculation of the time interval of the start time and the end time, the running time consumption of the corresponding function, that is, the first state information, can be determined.

[0064] Exemplarily, the second state information is system-level trace information, which can be collected by a system performance tracking tool, such as a systrace program. The systrace program is a performance data sampling and analysis tool newly added in Android 4.1. It can help developers collect running information of an Android key subsystem, thereby helping developers more intuitively analyze system bottlenecks and improve performance. Details of the principle and use method of the systrace are not described herein.

[0065] Specifically, in a possible implementation, the method for obtaining the second state information can include:

[0066] S2023, collecting preset custom information and input / output interface information by using a system performance tracking tool.

[0067] S2024, generating the second state information according to the custom information and the input / output interface information.

[0068] The custom information refers to trace information that is set by a user according to needs, for example, I / O operation of a system, a kernel work queue, CPU load, and running status of each Android subsystem, which is not specifically limited herein. The input / output interface information, namely, I / O information, is used to represent I / O-related trace information. The above information can be obtained by collecting the information by using a system performance tracking tool program. Then, the collected custom information and input / output interface information are determined as the second state information, which is used to determine the calling time of a function in a standard operating system.

[0069] S203, intercepting the first state information and the second state information written by an application program to a trace_marker_fd file by using a hook function preset at a write system call position, and writing the first state information and the second state information to a ring memory buffer.

[0070] Exemplarily, according to a system preset exception handling method, when an application program obtains trace information including the first state information and the second state information, a thread enters a kernel state, and the write function is used to write the trace information to the trace_marker_fd file. In this embodiment, by setting the hook function, the system call of the write function is hooked when the application program writes the first state information and the second state information to the trace_marker_fd file, the flow of data is changed, the first state information and the second state information are written to a preset ringbuffer, and I / O, lock-related, and other trace information are additionally collected for analyzing the sleep state, and the I / O, lock-related, and other trace information are collectively cached into the ringbuffer.

[0071] S204, mapping the preset to-be-written file to the user buffer corresponding to the ofstream class.

[0072] Exemplarily, ofstream is a class for writing data in memory to disk. Specifically, a file output stream object file, i.e., a to-be-written file, is first constructed by a constructor of the ofstream class, and the file is set in the corresponding user buffer, thereby completing the mapping process of the to-be-written file.

[0073] S205, writing the trace information in the ring memory buffer to the user buffer through an asynchronous thread, and when the data write amount of the user buffer is greater than or equal to a preset buffer threshold, flushing the data in the user buffer to the corresponding to-be-written file to generate a trace file.

[0074] Exemplarily, when the trace information in the ring buffer reaches a preset amount, the data in the ring buffer is written into the user buffer of the ofstream through an asynchronous thread (async thread) at one time, and when the data write amount of the user buffer of the ofstream is greater than or equal to a preset buffer threshold, for example, greater than 90% of the maximum storage amount of the user buffer, the data in the user buffer is flushed to the to-be-written file constructed above, thereby achieving the purpose of writing the trace information to the disk.

[0075] S206, uploading the trace file to a server.

[0076] In the step of this embodiment, the implementation manner of step S206 is the same as that of step S103 in the embodiment shown in Figure 3 , and the detailed description is referred to the description of step S103, which will not be repeated here.

[0077] Corresponding to the application program lag data acquisition method of the above embodiment, Figure 7 a structural block diagram of an application program lag data acquisition device provided by the embodiment of the present disclosure. For ease of illustration, only parts related to the embodiment of the present disclosure are shown. For details, refer to the description of the above embodiment. Figure 7 The application program lag data acquisition device 3 comprises:

[0078] The acquisition unit 31 is configured to acquire trace information of an application program, and the trace information is used to represent time-consuming information related to the application program during the running of the application program.

[0079] The cache unit 32 is configured to cache the trace information to a preset position through an asynchronous thread in a user state to generate a trace file, wherein the trace file is used for lag analysis of the application program.

[0080] The transceiving unit 33 is configured to upload the tracking file to a server.

[0081] In an embodiment of the present disclosure, the caching unit 32 is specifically configured to: intercept a caching operation of the application program, where the caching operation is used to represent that the application program stores tracking information by executing the kernel code; send the tracking information to a preset user-mode cache area through an asynchronous thread; and when it is determined that a data write amount of the user-mode cache area is greater than or equal to a preset cache threshold, write data in the user-mode cache area to a preset location to generate a tracking file.

[0082] In an embodiment of the present disclosure, when the caching unit 32 intercepts the operation of the application program storing the tracking information by executing the kernel code, the caching unit 32 is specifically configured to: intercept the tracking information written to the trace_marker_fd file by the application program through a hook function preset at a write system call location, and write the tracking information to a ring memory cache area; and send the tracking information to the preset user-mode cache area through the asynchronous thread, including: writing the tracking information in the ring memory cache area to the user-mode cache area through the asynchronous thread.

[0083] In an embodiment of the present disclosure, the user-mode cache area is implemented through an ofstream class, and when the caching unit 32 determines that the data write amount of the user-mode cache area is greater than or equal to the preset cache threshold, the caching unit 32 writes the data in the user-mode cache area to the preset location to generate the tracking file, and the caching unit 32 is specifically configured to: map a preset to-be-written file to a user-mode buffer area corresponding to the ofstream class; and when the data write amount of the user-mode buffer area is greater than or equal to the preset cache threshold, flush the data in the user-mode buffer area to the corresponding to-be-written file to generate the tracking file.

[0084] In an embodiment of the present disclosure, the obtaining unit 31 is further configured to: obtain input-output interface information and lock information, where the input-output interface information is used to represent an input-output state of the thread to the trace_marker_fd file, and the lock information is used to represent a holding state of the thread to the trace_marker_fd file; and the caching unit 32 is further configured to: send the input-output interface information and the lock information to the user-mode cache area through the asynchronous thread.

[0085] In an embodiment of the present disclosure, the tracking information includes first state information representing a calling time consumption of a function of the application program, and the obtaining unit 31 is specifically configured to: obtain start times and end times of each function of the application program at runtime by dynamically inserting a probe in the application program; and determine the first state information according to the start times and the end times corresponding to each function.

[0086] In an embodiment of the present disclosure, the tracking information further comprises second state information, the second state information representing a calling time consumption of a function in the operating system, the obtaining unit 31 is specifically configured to: collect preset custom information and input / output interface information through a system performance tracking tool; and generate the second state information according to the custom information and the input / output interface information.

[0087] In an embodiment of the present disclosure, the transceiving unit 33 is further configured to: receive a calling instruction, the calling instruction being used to instruct the terminal device to start real-time obtaining of the tracking information of the application program; and the obtaining unit 31 is specifically configured to: after receiving the calling instruction, real-time obtain the tracking information of the application program.

[0088] In an embodiment of the present disclosure, the transceiving unit 33 is further configured to: receive an uploading instruction, the uploading instruction being used to instruct the terminal device to upload the tracking file to the server.

[0089] The obtaining unit 31, the caching unit 32 and the transceiving unit 33 are connected in sequence. The application program lag data obtaining apparatus 3 provided in the embodiment can execute the technical solution of the method embodiment as shown in Figures 3-5 The implementation principle and technical effects are similar, and will not be repeated here.

[0090] Referring to Figure 8 , a structural diagram of an electronic device 900 suitable for implementing an embodiment of the present disclosure is shown, which can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, personal digital assistants (PDA), tablet computers (PAD), portable media players (PMP), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. Figure 8 The electronic device shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present disclosure.

[0091] As Figure 8As shown, the electronic device 900 can include a processing device (e.g., a central processor, a graphics processor, etc.) 901 that can perform various suitable actions and processes according to programs stored in a Read Only Memory (ROM) 902 or loaded into a Random Access Memory (RAM) 903 from a storage device 908. Various programs and data required by the electronic device 900 for operation are also stored in the RAM 903. The processing device 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. An Input / Output (I / O) interface 905 is also connected to the bus 904.

[0092] Generally, the following devices can be connected to the I / O interface 905: input devices 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 907 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, etc.; storage devices 908 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 909. The communication devices 909 can allow the electronic device 900 to communicate wirelessly or wired with other devices to exchange data. Although Figure 8 The electronic device 900 is shown with various devices, but it should be understood that not all of the shown devices are required to be implemented or present. More or fewer devices can alternatively be implemented or present.

[0093] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication devices 909, or installed from the storage devices 908, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the methods of embodiments of the present disclosure are performed.

[0094] It should be noted that the computer-readable medium in the above disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, 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 above. In the present disclosure, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present disclosure, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or apparatus. The program code contained in the computer-readable medium can be transmitted by any suitable medium, including but not limited to a wire, a cable, an RF (radio frequency) or the like, or any suitable combination of the above.

[0095] The computer-readable medium described above can be contained in the electronic device described above; or can exist separately and not be assembled into the electronic device.

[0096] The computer-readable medium described above carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.

[0097] Computer program code for carrying out operations of the present disclosure can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0098] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may

[0099] The units described in the embodiments of the present disclosure can be implemented by software, or by hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself. For example, the first obtaining unit can also be described as a unit for obtaining at least two Internet protocol addresses.

[0100] The functions described above in the specification of the present disclosure can be performed by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Program-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.

[0101] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0102] In a first aspect, according to one or more embodiments of the present disclosure, an application program lag data acquisition method is provided, comprising: obtaining tracking information of an application program, the tracking information being used to represent time consumption information related to the application program during running of the application program; caching the tracking information to a preset location through an asynchronous thread in a user mode to generate a tracking file, wherein the tracking file is used for lag analysis of the application program; and uploading the tracking file to a server.

[0103] According to one or more embodiments of the present disclosure, the caching of the tracking information to the preset location through the asynchronous thread in the user mode to generate the tracking file comprises: intercepting a caching operation of the application program, wherein the caching operation is used to represent that the application program stores the tracking information by executing kernel code; sending the tracking information to a preset user mode cache area through an asynchronous thread; and when it is determined that a data write amount of the user mode cache area is greater than or equal to a preset cache threshold, writing data in the user mode cache area to the preset location to generate the tracking file.

[0104] According to one or more embodiments of the present disclosure, the intercepting of the operation of the application program for storing the tracking information by executing the kernel code comprises: intercepting, through a hook function preset at a write system call position, tracking information written by the application program to a trace identification description file, and writing the tracking information to a ring memory cache area; and sending the tracking information to a preset user mode cache area through an asynchronous thread, comprising: writing, through the asynchronous thread, the tracking information in the ring memory cache area to the user mode cache area.

[0105] According to one or more embodiments of the present disclosure, the user-mode cache area is implemented by a stream write operation class, and when it is determined that the data write amount of the user-mode cache area is greater than or equal to a preset cache threshold, data in the user-mode cache area is written to a preset position to generate a tracking file, including: mapping a preset to-be-written file to a user-mode buffer area corresponding to the stream write operation class; when the data write amount of the user-mode buffer area is greater than or equal to the preset cache threshold, the data in the user-mode buffer area is flushed to the corresponding to-be-written file to generate the tracking file.

[0106] According to one or more embodiments of the present disclosure, the method further includes: obtaining input / output interface information and lock information, the input / output interface information being used to represent an input / output state of the thread to the trace identification description file; and the lock information being used to represent a holding state of the thread to the trace identification description file; and the method further includes: sending the input / output interface information and the lock information to the user-mode cache area through an asynchronous thread.

[0107] According to one or more embodiments of the present disclosure, the trace information includes first state information, the first state information representing a calling time consumption of a function of the application program, and the obtaining of the trace information of the application program includes: obtaining start times and end times of each function during running of the application program through dynamic insertion of a probe in the application program; and determining the first state information according to the start times and the end times corresponding to each function respectively.

[0108] According to one or more embodiments of the present disclosure, the trace information further includes second state information, the second state information representing a calling time consumption of a function in an operating system, and the obtaining of the trace information of the application program further includes: collecting preset custom information and input / output interface information through a system performance tracking tool; and generating the second state information according to the custom information and the input / output interface information.

[0109] According to one or more embodiments of the present disclosure, the method further includes: receiving a calling instruction, the calling instruction being used to instruct the terminal device to start real-time obtaining of the trace information of the application program; and the obtaining of the trace information of the application program includes: real-time obtaining of the trace information of the application program after receiving the calling instruction.

[0110] According to one or more embodiments of the present disclosure, the method further includes: receiving an uploading instruction, the uploading instruction being used to instruct the terminal device to upload the tracking file to a server.

[0111] In a second aspect, according to one or more embodiments of the present disclosure, an application program lag data obtaining apparatus is provided, including:

[0112] The obtaining unit is configured to obtain trace information of an application program, the trace information being used to represent time consumption information related to the application program during running of the application program.

[0113] The cache unit is configured to cache the tracking information to a preset location through an asynchronous thread in a user mode to generate a tracking file, where the tracking file is used for frame freezing analysis of the application program.

[0114] The transceiving unit is configured to upload the tracking file to a server.

[0115] According to one or more embodiments of the present disclosure, the cache unit is specifically configured to: intercept a cache operation of the application program, where the cache operation is used to represent that the application program stores tracking information by executing kernel code; send the tracking information to a preset user-mode cache area through an asynchronous thread; and write data in the user-mode cache area to a preset location to generate a tracking file when it is determined that a data write amount of the user-mode cache area is greater than or equal to a preset cache threshold.

[0116] According to one or more embodiments of the present disclosure, when the cache unit intercepts the operation of the application program to store the tracking information by executing the kernel code, the cache unit is specifically configured to: intercept the tracking information written by the application program to a trace identification description file through a hook function preset at a write system call location, and write the tracking information to a ring memory cache area; and send the tracking information to a preset user-mode cache area through an asynchronous thread, including: writing the tracking information in the ring memory cache area to the user-mode cache area through the asynchronous thread.

[0117] According to one or more embodiments of the present disclosure, the user-mode cache area is implemented through a stream write operation class, and when the cache unit writes data in the user-mode cache area to a preset location to generate a tracking file when it is determined that a data write amount of the user-mode cache area is greater than or equal to a preset cache threshold, the cache unit is specifically configured to: map a preset to-be-written file to a user-mode buffer area corresponding to the stream write operation class; and flush data in the user-mode buffer area to the corresponding to-be-written file to generate the tracking file when a data write amount of the user-mode buffer area is greater than or equal to the preset cache threshold.

[0118] According to one or more embodiments of the present disclosure, the obtaining unit is further configured to: obtain input-output interface information and lock information, where the input-output interface information is used to represent an input-output state of the thread to the trace identification description file, and the lock information is used to represent a holding state of the thread to the trace identification description file; and the cache unit is further configured to: send the input-output interface information and the lock information to the user-mode cache area through the asynchronous thread.

[0119] According to one or more embodiments of the present disclosure, the tracking information includes first state information representing a calling time consumption of a function of the application program, and the obtaining unit is specifically configured to: obtain start times and end times of each function of the application program by dynamically inserting a probe into the application program; and determine the first state information according to the start times and the end times corresponding to each function.

[0120] According to one or more embodiments of the present disclosure, the tracking information further comprises second state information, the second state information representing a calling time consumption of the function in the operating system, the obtaining unit is specifically configured to: collect preset custom information and input / output interface information through a system performance tracking tool; and generate the second state information according to the custom information and the input / output interface information.

[0121] According to one or more embodiments of the present disclosure, the transceiving unit is further configured to: receive a calling instruction, the calling instruction being used to instruct the terminal device to start real-time obtaining of the tracking information of the application program; and the obtaining unit is specifically configured to: after receiving the calling instruction, real-time obtain the tracking information of the application program.

[0122] According to one or more embodiments of the present disclosure, the transceiving unit is further configured to: receive an uploading instruction, the uploading instruction being used to instruct the terminal device to upload the tracking file to the server.

[0123] In a third aspect, according to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor and a memory;

[0124] The memory stores computer-executable instructions;

[0125] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the application program lag data obtaining method as described in the first aspect above and various possible designs of the first aspect.

[0126] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, the computer-readable storage medium storing computer-executable instructions, when a processor executes the computer-executable instructions, the application program lag data obtaining method as described in the first aspect above and various possible designs of the first aspect is implemented.

[0127] The above description is merely preferred embodiments of the present disclosure and a description of principles of applied technologies. It should be understood by those skilled in the art that the disclosed scope of the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combinations of the above technical features or equivalent features without departing from the disclosed concept. For example, the above features are replaced with technical features disclosed in the present disclosure (but not limited to) having similar functions to form technical solutions.

[0128] Moreover, while operations are depicted in a particular order, this should not be understood as requiring such an order nor infringing on the scope of the disclosure. Certain of the operations described in the discussion are combinable into a single operation, and certain operations can be separated into several operations. In some embodiments, the operations described in the discussion can be performed in an order different than presented in the discussion. In some embodiments, the operations described in the discussion can be performed concurrently. Also, while several specific implementation details are discussed in the discussion, these should not be interpreted as limiting the scope of the disclosure. Rather, certain features described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable sub-combination.

[0129] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims

1. An application program lag data acquisition method, characterized by, The method comprises the following steps: acquiring tracking information of an application, the tracking information being used to represent time-consuming information related to the application during running of the application; caching the tracking information to a preset location through an asynchronous thread in a user mode to generate a tracking file, wherein the tracking file is used for analyzing frame freezing of the application; uploading the tracking file to a server; caching the tracking information to a preset location through an asynchronous thread in a user mode to generate a tracking file, comprising: intercepting a caching operation of the application, wherein the caching operation is used to represent that the application stores the tracking information by executing kernel code; sending the tracking information to a preset user-mode cache area through an asynchronous thread; when it is determined that a data write amount of the user-mode cache area is greater than or equal to a preset cache threshold, writing data in the user-mode cache area to a preset location to generate a tracking file.

2. The method of claim 1, wherein, intercepting the operation of the application for storing the tracking information by executing kernel code, comprising: intercepting, through a hook function preset at a write system call location, tracking information written by the application to a trace identification description file, and writing the tracking information to a ring memory cache area; sending the tracking information to a preset user-mode cache area through an asynchronous thread, comprising: writing, through an asynchronous thread, the tracking information in the ring memory cache area to the user-mode cache area.

3. The method of claim 2, wherein, The user-mode cache area is implemented through a stream write operation class, and when it is determined that a data write amount of the user-mode cache area is greater than or equal to a preset cache threshold, writing data in the user-mode cache area to a preset location to generate a tracking file, comprising: mapping a preset to-be-written file to a user-mode buffer area corresponding to the stream write operation class; when a data write amount of the user-mode buffer area is greater than or equal to a preset cache threshold, flushing data in the user-mode buffer area to the corresponding to-be-written file to generate the tracking file.

4. The method of claim 1, wherein, The method further comprises: acquiring input-output interface information and lock information, the input-output interface information being used to represent an input-output state of a thread to a trace identification description file, and the lock information being used to represent a holding state of the thread to the trace identification description file; The method further comprises: sending the input-output interface information and the lock information to the user-mode cache area through an asynchronous thread.

5. The method of claim 1, wherein, The tracking information comprises first state information, the first state information representing a calling time-consuming of a function of the application, and acquiring tracking information of an application comprises: acquiring start time and end time of each function during running of the application through dynamic instrumentation in the application; determining the first state information according to the start time and the end time corresponding to each function.

6. The method of claim 5, wherein, The tracking information further comprises second state information, the second state information representing a calling time-consuming of a function in an operating system, and acquiring tracking information of an application further comprises: collecting preset custom information and input-output interface information through a system performance tracking tool; generating second state information according to the custom information and the input-output interface information.

7. The method according to any one of claims 1 to 6, characterized in that, The method further comprises: receiving a calling instruction, the calling instruction being used to instruct the terminal device to start acquiring tracking information of the application program in real time; acquiring tracking information of an application program, comprising: after receiving the calling instruction, acquiring tracking information of the application program in real time.

8. The method according to any one of claims 1 to 6, characterized in that, The method further comprises: receiving an uploading instruction, the uploading instruction being used to instruct the terminal device to upload the tracking file to the server.

9. An application hang data acquisition apparatus, comprising: Comprise: an acquisition unit, configured to acquire tracking information of an application program, the tracking information being used to represent time-consuming information related to the application program during running of the application program; a cache unit, configured to cache the tracking information to a preset position through an asynchronous thread under a user state to generate a tracking file, wherein the tracking file is used to perform stall analysis on the application program; a transceiving unit, configured to upload the tracking file to a server; the cache unit is specifically configured to intercept a cache operation of the application program, wherein the cache operation is used to represent that the application program stores the tracking information by executing kernel code; the cache unit is further configured to send the tracking information to a preset user state cache area through an asynchronous thread; and when it is determined that a data writing amount of the user state cache area is greater than or equal to a preset cache threshold, the cache unit is further configured to write data in the user state cache area to a preset position to generate a tracking file.

10. An electronic device, comprising: Comprise: at least one processor and a memory; the memory stores computer execution instructions; the at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the application program stall data acquisition method according to any one of claims 1 to 8.

11. A computer readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and when the processor executes the computer execution instructions, the application program stall data acquisition method according to any one of claims 1 to 8 is realized.

Citation Information

Patent Citations

  • Distributed tracking system

    CN105224445A

  • A real-time calling chain tracking method based on micro-service

    CN109921927A