CN105677550A - Performance acquisition-analysis method, device and system based on Linux system - Google Patents

Performance acquisition-analysis method, device and system based on Linux system Download PDF

Info

Publication number
CN105677550A
CN105677550A CN201511023611.9A CN201511023611A CN105677550A CN 105677550 A CN105677550 A CN 105677550A CN 201511023611 A CN201511023611 A CN 201511023611A CN 105677550 A CN105677550 A CN 105677550A
Authority
CN
China
Prior art keywords
performance
file
address
target process
function
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201511023611.9A
Other languages
Chinese (zh)
Inventor
母天石
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Huaduo Network Technology Co Ltd
Original Assignee
Guangzhou Huaduo Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Huaduo Network Technology Co Ltd filed Critical Guangzhou Huaduo Network Technology Co Ltd
Priority to CN201511023611.9A priority Critical patent/CN105677550A/en
Publication of CN105677550A publication Critical patent/CN105677550A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a performance acquisition-analysis method, device and system based on the Linux system. The technical problem that performance collection is carried out through google-PerfTools conventionally at present, during the duplication-eliminating compiling process and before the performance collection process, the environment variables need to be set, and therefore the performance collection and analysis operation is tedious is solved. The performance acquisition is carried out through dynamic injection, and the performance acquisition-analysis method comprises that a process to be injected and subjected to performance analysis of a selected target host is determined; the dlopen function entry address of a corresponding target process is found out in dependence on the process to be injected; through a ptrace function attached to the target process and the dlopen function entry address, a profiler.so file used for dynamic performance analysis is loaded in the target process; and the google-PerfTools calls the profiler.so file to carry out performance acquisition to the target process, and obtains a corresponding performance analysis result.

Description

A kind of based on the method for performance collection analysis of linux system, Apparatus and system
Technical field
The present invention relates to field of computer technology, particularly relate to a kind of based on the method for performance collection analysis of linux system, Apparatus and system.
Background technology
Memory overflow, also referred to as " storage seepage ", the space dynamically opened up with dynamic memory partition function, does not discharge after using, results in and occupy this internal storage location always. Until EP (end of program). (being exactly plainly that the use of this memory headroom is complete in fact not reclaim afterwards) i.e. so-called memory overflow. The metaphor of memory overflow image is " operating system is provided to the memory space of all processes and is drained by certain process ", final result is that program runtime is more long, taking memory space to get more and more, finally use up whole memory space, whole system is collapsed. So " memory overflow " is the angle from operating system. Here memory space does not imply that physical memory, and refers to virtual memory size.
Performance collection is required over for RAM leakage, the overall performance of assessment software runtime system, navigate to cpu performance focus, specifically navigate to is which section code, which function are consuming time bigger, the collection of current Properties Analysis is collected particular by google-PerfTools and analyzes, it is through the mode of sampling, " portrait " is carried out to the service condition of cpu in program, by it export as a result, it is possible to each function in program (call relation obtaining between function) situation consuming time is very clear. When program is done performance optimization, first good for several operation optimizations the most consuming time, the overall performance of program promotes fairly obvious, is also that the principle the most basic doing performance optimization first optimizes the most consuming time.
But, at present conventional carry out performance collection by google-PerfTools, when duplicate removal compiles, before performance collection, need to carry out the setting of environmental variable, thus result in performance collection and the loaded down with trivial details technical problem of analysis operation.
Summary of the invention
It is a kind of based on the method for performance collection analysis of linux system, Apparatus and system that the embodiment of the present invention provides, what solve current routine carries out performance collection by google-PerfTools, when duplicate removal compiles, before performance collection, need to carry out the setting of environmental variable, and the performance collection caused and the loaded down with trivial details technical problem of analysis operation.
The method of a kind of performance collection analysis based on linux system that the embodiment of the present invention provides, including:
Determine that the process to be implanted of performance evaluation treated by the destination host of selection;
The dlopen function entrance address of the target process of correspondence is found according to described process to be implanted;
By the ptrace function enclosed in described target process, in conjunction with described dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into described target process;
Call described profiler.so file by google-PerfTools and described target process is carried out performance collection, and obtain the results of performance analysis of correspondence.
Optionally it is determined that the destination host selected treats that the process to be implanted of performance evaluation specifically includes:
Determine the IP address of the destination host of selection, and be attached;
Determine that destination host carries out the injection of the described process to be implanted treating performance evaluation of correspondence.
Alternatively, the dlopen function entrance address finding the target process of correspondence according to described process to be implanted specifically includes:
Libc.so file is called by running random procedure;
Agent process when described random procedure runs is by calling the first absolute address during dlsym function acquisition dlopen function operation;
At the described libc.so file of the in-process loading of described agent, to determine the first initial address;
Described dlopen function side-play amount in described libc.so file is determined by described first initial address and described first absolute address;
Determine, by described libc.so file, the initial address that the described process of the injection being carried in dynamic base is corresponding according to described process to be implanted;
Obtaining absolute address according to described initial address and described offset addition, described absolute address is the described dlopen function entrance address of described destination address;
The described process injected is called described ptrace function and is loaded into described target process.
Alternatively, by the ptrace function enclosed in described target process, in conjunction with described dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into described target process and specifically includes:
By transmitting the title of described dlopen function entrance address and described profiler.so file to depositor;
In target process, the described profiler.so file for Dynamic Performance Analysis is loaded by described ptrace function call dlopen function.
Alternatively, call described profiler.so file by google-PerfTools and described target process carried out performance collection, and the results of performance analysis obtaining correspondence specifically includes:
By adding a new function in described profiler.so file, and described new function is registered two signals for allowing described target process receptivity analyze start and stop;
Call described profiler.so file to described target process by google-PerfTools, and carry out the performance collection of preset collection duration;
The results of performance analysis carrying out correspondence according to the performance evaluation type selected in advance is shown, described performance evaluation type includes cpu performance evaluation and/or heap performance evaluation and/or RAM leakage inspection.
The device of a kind of performance collection analysis based on linux system that the embodiment of the present invention provides, including:
Determine unit, for determining that the process to be implanted of performance evaluation treated by the destination host of selection;
Target process positioning unit, for finding the dlopen function entrance address of the target process of correspondence according to described process to be implanted;
Performance evaluation file loading unit, for the ptrace function by enclosing in described target process, is loaded into described target process in conjunction with described dlopen function entrance address by the profiler.so file being used for Dynamic Performance Analysis;
Performance collection analysis unit, carries out performance collection for calling described profiler.so file by google-PerfTools, and obtains the results of performance analysis of correspondence described target process.
Optionally it is determined that unit specifically includes:
First determines subelement, for determining the IP address of the destination host of selection, and is attached;
Second determines subelement, for determining that destination host carries out the injection of the described process to be implanted treating performance evaluation of correspondence.
Alternatively, target process positioning unit specifically includes:
Call subelement, for calling libc.so file by operation random procedure;
First absolute address obtains subelement, and agent process when running for described random procedure is by calling the first absolute address during dlsym function acquisition dlopen function operation;
First initial address determines subelement, at the described libc.so file of the in-process loading of described agent, to determine the first initial address;
Side-play amount determines subelement, for determining described dlopen function side-play amount in described libc.so file by described first initial address and described first absolute address;
Initial address determines subelement, for determining, by described libc.so file, the initial address that the described process of the injection being carried in dynamic base is corresponding according to described process to be implanted;
Absolute address computing unit, for obtaining absolute address according to described initial address and described offset addition, described absolute address is the described dlopen function entrance address of described destination address;
Ptrace function adds subelements, and the described process for injecting is called described ptrace function and is loaded into described target process.
Alternatively, performance evaluation file loading unit specifically includes:
Transmission subelement, is used for by the title transmitting described dlopen function entrance address and described profiler.so file to depositor;
Profiler.so file adds subelements, for loading the described profiler.so file for Dynamic Performance Analysis in target process by described ptrace function call dlopen function.
Alternatively, performance collection analysis unit specifically includes:
Signal registration subelement, is used for by adding a new function in described profiler.so file, and described new function is registered two signals for allowing described target process receptivity analyze start and stop;
Performance gathers subelement, for calling described profiler.so file to described target process by google-PerfTools, and carries out the performance collection of preset collection duration;
Performance evaluation subelement, the results of performance analysis for carrying out correspondence according to the performance evaluation type selected in advance is shown, described performance evaluation type includes cpu performance evaluation and/or heap performance evaluation and/or RAM leakage inspection.
The system of a kind of performance collection analysis based on linux system that the embodiment of the present invention provides, it is characterised in that including:
Backstage agent, TcpProxy, and the device of any one the described performance collection analysis based on linux system mentioned in the present embodiment;
The device of the described performance collection analysis based on linux system is connected with described backstage agent by described TcpProxy;
Destination host is carried out injecting the collection of the performance after target carries out by described backstage agent by getting the instruction of the device coming from the described performance collection analysis based on linux system, and feeds back to the device of the described performance collection analysis based on linux system.
As can be seen from the above technical solutions, the embodiment of the present invention has the advantage that
It is a kind of based on the method for performance collection analysis of linux system, Apparatus and system that the embodiment of the present invention provides, and wherein, the method being carried out performance collection by Dynamic injection comprises determining that the process to be implanted of performance evaluation treated by the destination host of selection, the dlopen function entrance address of the target process of correspondence is found according to process to be implanted, by the ptrace function enclosed in target process, in conjunction with dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into target process, call profiler.so file by google-PerfTools and target process is carried out performance collection, and obtain the results of performance analysis of correspondence. in the present embodiment, by finding the dlopen function entrance address of the target process of correspondence according to process to be implanted, then pass through the ptrace function enclosed in target process, in conjunction with dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into target process, call profiler.so file finally by google-PerfTools and target process is carried out performance collection, achieve the performance collection analysis based on linux system, what solve current routine carries out performance collection by google-PerfTools, when duplicate removal compiles, before performance collection, need to carry out the setting of environmental variable, and the performance collection caused and the loaded down with trivial details technical problem of analysis operation.
Accompanying drawing explanation
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, the accompanying drawing used required in embodiment or description of the prior art will be briefly described below, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, under the premise not paying creative work, it is also possible to obtain other accompanying drawing according to these accompanying drawings.
The schematic flow sheet of one embodiment of the method for a kind of performance collection analysis based on linux system that Fig. 1 provides for the embodiment of the present invention;
The schematic flow sheet of another embodiment of the method for a kind of performance collection analysis based on linux system that Fig. 2 provides for the embodiment of the present invention;
The structural representation of one embodiment of the device of a kind of performance collection analysis based on linux system that Fig. 3 provides for the embodiment of the present invention;
The structural representation of another embodiment of the device of a kind of performance collection analysis based on linux system that Fig. 4 provides for the embodiment of the present invention;
The structural representation of one embodiment of the system of a kind of performance collection analysis based on linux system that Fig. 5 provides for the embodiment of the present invention;
Fig. 6 is the schematic diagram of target process location injection process;
Fig. 7 is the schematic diagram of application examples corresponding to Fig. 2 embodiment.
Detailed description of the invention
It is a kind of based on the method for performance collection analysis of linux system, Apparatus and system that the embodiment of the present invention provides, what solve current routine carries out performance collection by google-PerfTools, when duplicate removal compiles, before performance collection, need to carry out the setting of environmental variable, and the performance collection caused and the loaded down with trivial details technical problem of analysis operation.
For making the goal of the invention of the present invention, feature, the advantage can be more obvious and understandable, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, the embodiments described below are only a part of embodiment of the present invention, and not all embodiment. Based on the embodiment in the present invention, all other embodiments that those of ordinary skill in the art obtain under not making creative work premise, broadly fall into the scope of protection of the invention.
Referring to Fig. 1, an embodiment of the method for a kind of performance collection analysis based on linux system that the embodiment of the present invention provides includes:
101, determine that the process to be implanted of performance evaluation treated by the destination host of selection;
In the present embodiment, when destination host is carried out Dynamic injection performance evaluation by needs, it is necessary first to determine that the process to be implanted of performance evaluation treated by the destination host of selection.
102, the dlopen function entrance address of the target process of correspondence is found according to process to be implanted;
After the process to be implanted of performance evaluation treated by the destination host determining selection, it is necessary to find the dlopen function entrance address of the target process of correspondence according to process to be implanted.
103, the ptrace function by enclosing in target process, is loaded into target process in conjunction with dlopen function entrance address by the profiler.so file being used for Dynamic Performance Analysis;
After find the dlopen function entrance address of target process of correspondence according to process to be implanted, require over the ptrace function enclosed in target process, in conjunction with dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into target process.
104, call profiler.so file by google-PerfTools and target process is carried out performance collection, and obtain the results of performance analysis of correspondence.
When the ptrace function by enclosing in target process, after in conjunction with dlopen function entrance address the profiler.so file being used for Dynamic Performance Analysis being loaded into target process, require over google-PerfTools to call profiler.so file target process carries out performance collection, and obtain the results of performance analysis of correspondence.
In the present embodiment, by finding the dlopen function entrance address of the target process of correspondence according to process to be implanted, then pass through the ptrace function enclosed in target process, in conjunction with dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into target process, call profiler.so file finally by google-PerfTools and target process is carried out performance collection, achieve the performance collection analysis based on linux system, what solve current routine carries out performance collection by google-PerfTools, when duplicate removal compiles, before performance collection, need to carry out the setting of environmental variable, and the performance collection caused and the loaded down with trivial details technical problem of analysis operation.
The process that the above is the method to the performance collection analysis based on linux system is described in detail, the detailed process of each step will be described in detail below, referring to Fig. 2, a kind of another embodiment based on the method for the performance collection analysis of linux system that the embodiment of the present invention provides includes:
201, determine the IP address of the destination host of selection, and be attached;
In the present embodiment, when destination host is carried out Dynamic injection performance evaluation by needs, it is necessary first to determine the IP address of the destination host of selection, and be attached.
202, determine that destination host carries out the injection of the process to be implanted treating performance evaluation of correspondence;
When the IP address of the destination host determining selection, and after being attached, it is thus necessary to determine that destination host carries out the injection of the process to be implanted treating performance evaluation of correspondence.
203, libc.so file is called by operation random procedure;
After determining the injection of process to be implanted treating performance evaluation that destination host carries out correspondence, it is necessary to call libc.so file by running random procedure.
204, agent process when random procedure runs is by calling the first absolute address during dlsym function acquisition dlopen function operation;
After calling libc.so file by operation random procedure, it is necessary to agent process when random procedure runs is by calling the first absolute address during dlsym function acquisition dlopen function operation.
205, at agent in-process loading libc.so file, to determine the first initial address;
After the first absolute address when agent process when random procedure runs is by calling dlsym function acquisition dlopen function operation, it is necessary at agent in-process loading libc.so file, to determine the first initial address.
206, dlopen function side-play amount in libc.so file is determined by the first initial address and the first absolute address;
When at agent in-process loading libc.so file, after determining the first initial address, it is necessary to determine dlopen function side-play amount in libc.so file by the first initial address and the first absolute address.
207, determine, by libc.so file, the initial address that the process of the injection being carried in dynamic base is corresponding according to process to be implanted;
After determining dlopen function side-play amount in libc.so file by the first initial address and the first absolute address, it is necessary to determine, by libc.so file, the initial address that the process of the injection being carried in dynamic base is corresponding according to process to be implanted.
It should be noted that process PID has a maps data recordation dynamic base initial address.
208, obtaining absolute address according to initial address and offset addition, absolute address is the dlopen function entrance address of destination address;
After the initial address that the process being determined the injection being documented in dynamic base by libc.so file is corresponding, need to obtain absolute address according to initial address and offset addition, absolute address is the dlopen function entrance address of destination address, absolute address can be through constant side-play amount in conjunction with libc.so document analysis, and the acquisition of absolute address can be as shown in Figure 6.
209, the process injected is called ptrace function and is loaded into target process;
When obtaining absolute address according to initial address and offset addition, absolute address is after the dlopen function entrance address of destination address, it is necessary to the process of injection is called ptrace function and is loaded into target process.
It should be noted that aforesaid step 203 is as follows to 209:
1) because the operation of random procedure is required for calling libc.so, this is the java standard library of all routine calls, and place is at present procedure, and namely agent process also can call libc, so;
2) absolute address when dlopen runs, dlopen_entry=dlsym (NULL, " _ _ libc_dlopen_mode ") are obtained in current agent process by calling dlsym; Namely absolute address P when dlopen runs in present procedure space can be obtained;
3) situation that libc.so loads in the current agent process space, wherein in red boxes, r-xp section is the libc.so initial address Q at application heap;
4) dlopen function side-play amount M in libc.so is obtained by Q P;
5) in process to be implanted, know lib.so start-stop address Q2 in this process space again by proc/pid/maps file, obtain the absolute address Q2 in dlopen function application heap in target process by Q2+M;
6) carry out injecting libprofile.so to Q2 address by ptrace, reach the purpose of Dynamic injection. 210, by the title of transmission dlopen function entrance address and profiler.so file to depositor;
When the process injected is called after ptrace function is loaded into target process, it is necessary to by transmitting the title of dlopen function entrance address and profiler.so file to depositor.
211, in target process, the profiler.so file for Dynamic Performance Analysis is loaded by ptrace function call dlopen function;
After by the title of transmission dlopen function entrance address and profiler.so file to depositor, it is necessary to load the profiler.so file for Dynamic Performance Analysis in target process by ptrace function call dlopen function.
212, by adding a new function in profiler.so file, and new function is registered two signals for allowing target process receptivity analyze start and stop;
After loaded the profiler.so file for Dynamic Performance Analysis in target process by ptrace function call dlopen function, require over one new function of addition in profiler.so file, and new function is registered two signals for allowing target process receptivity analyze start and stop.
213, call profiler.so file to target process by google-PerfTools, and carry out the performance collection of preset collection duration;
When passing through to add a new function in profiler.so file, and to new function register two for allow target process receptivity analyze start and stop signal after, require over google-PerfTools and call profiler.so file to target process, and carry out the performance collection of preset collection duration.
214, the results of performance analysis displaying of correspondence is carried out according to the performance evaluation type selected in advance.
When calling profiler.so file to target process by google-PerfTools, and after carrying out the performance collection of preset collection duration, needing the results of performance analysis carrying out correspondence according to the performance evaluation type selected in advance to show, performance evaluation type includes cpu performance evaluation and/or heap performance evaluation and/or RAM leakage inspection.
It should be noted that after gathering a plurality of performance data, data are processed by the in-house tool of google-PerfTools, are analyzed by google-PerfTools.
Step 203 can be the steps of to 211:
A) injection process to find the entry address of the dlopen function of target process.
B) injection process calls ptrace function attach to target process T.
C) by transmitting dlopen function entrance address and profiler.so title to depositor, call dlopen by ptrace in target process, load the profiler.so for Dynamic Performance Analysis.
D) in profielr.so, a new function is added. This function is able to receive that the signal of performance evaluation start and stop by registering two signal functions by target process.
E) collection of Properties Analysis is collected particular by googlePerfTools and analyzes, and this block is increased income, so no longer elaborating.
Operation interface as shown in Figure 7, application examples corresponding to Fig. 2 embodiment includes:
Step1. destination host is selected;
Step2. select the process needing to be injected into, namely need the target process of analyzed performance and RAM leakage;
Step3. select the time needing performance to gather, give tacit consent to 5/10/15 minute, it is also possible to self-defined duration;
Step4. select to need Properties Analysis option of operation, it is possible to be cpu performance evaluation/heap performance evaluation/RAM leakage inspection;
Step5. results of performance analysis mobile phone and displaying.
In the present embodiment, by finding the dlopen function entrance address of the target process of correspondence according to process to be implanted, then pass through the ptrace function enclosed in target process, in conjunction with dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into target process, call profiler.so file finally by google-PerfTools and target process is carried out performance collection, achieve the performance collection analysis based on linux system, what solve current routine carries out performance collection by google-PerfTools, when duplicate removal compiles, before performance collection, need to carry out the setting of environmental variable, and the performance collection caused and the loaded down with trivial details technical problem of analysis operation, achieve a kind of general in Dynamic injection method, realize the Properties Analysis to c++ program, without recompilating program and logging in production environment machine, the result dissected can accurately be used for positioning cpu performance focus and RAM leakage, also bring option flexibly for user simultaneously, abundant operative configuration.
Referring to Fig. 3, one embodiment of device of a kind of performance collection analysis based on linux system provided in the embodiment of the present invention includes:
Determine unit 301, for determining that the process to be implanted of performance evaluation treated by the destination host of selection;
Target process positioning unit 302, for finding the dlopen function entrance address of the target process of correspondence according to process to be implanted;
Performance evaluation file loading unit 303, for the ptrace function by enclosing in target process, is loaded into target process in conjunction with dlopen function entrance address by the profiler.so file being used for Dynamic Performance Analysis;
Performance collection analysis unit 304, carries out performance collection for calling profiler.so file by google-PerfTools, and obtains the results of performance analysis of correspondence target process.
In the present embodiment, found the dlopen function entrance address of the target process of correspondence according to process to be implanted by target process positioning unit 302, then the performance evaluation file loading unit 303 ptrace function by enclosing in target process, in conjunction with dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into target process, last performance collection analysis unit 304 calls profiler.so file by google-PerfTools and target process is carried out performance collection, achieve the performance collection analysis based on linux system, what solve current routine carries out performance collection by google-PerfTools, when duplicate removal compiles, before performance collection, need to carry out the setting of environmental variable, and the performance collection caused and the loaded down with trivial details technical problem of analysis operation.
The each unit that the above is the device to the performance collection analysis based on linux system is described in detail, each subelement will be described in detail below, referring to Fig. 4, another embodiment of device of a kind of performance collection analysis based on linux system provided in the embodiment of the present invention includes:
Determine unit 401, for determining that the process to be implanted of performance evaluation treated by the destination host of selection;
Determine that unit 401 specifically includes:
First determines subelement 4011, for determining the IP address of the destination host of selection, and is attached;
Second determines subelement 4012, for determining that destination host carries out the injection of the process to be implanted treating performance evaluation of correspondence.
Target process positioning unit 402, for finding the dlopen function entrance address of the target process of correspondence according to process to be implanted;
Target process positioning unit 402 specifically includes:
Call subelement 4021, for calling libc.so file by operation random procedure;
First absolute address obtains subelement 4022, and agent process when running for random procedure is by calling the first absolute address during dlsym function acquisition dlopen function operation;
First initial address determines subelement 4023, at agent in-process loading libc.so file, to determine the first initial address;
Side-play amount determines subelement 4024, for determining dlopen function side-play amount in libc.so file by the first initial address and the first absolute address;
Initial address determines subelement 4025, for determining, by libc.so file, the initial address that the process of the injection being carried in dynamic base is corresponding according to process to be implanted;
Absolute address computing unit 4026, for obtaining absolute address according to initial address and offset addition, absolute address is the dlopen function entrance address of destination address;
Ptrace function adds subelements 4027, and the process for injecting is called ptrace function and is loaded into target process. Performance evaluation file loading unit 403, for the ptrace function by enclosing in target process, is loaded into target process in conjunction with dlopen function entrance address by the profiler.so file being used for Dynamic Performance Analysis;
Performance evaluation file loading unit 403 specifically includes:
Transmission subelement 4031, for by the title of transmission dlopen function entrance address and profiler.so file to depositor;
Profiler.so file adds subelements 4032, for loading the profiler.so file for Dynamic Performance Analysis in target process by ptrace function call dlopen function.
Performance collection analysis unit 404, carries out performance collection for calling profiler.so file by google-PerfTools, and obtains the results of performance analysis of correspondence target process.
Performance collection analysis unit 404 specifically includes:
Signal registration subelement 4041, is used for by adding a new function in profiler.so file, and new function is registered two signals for allowing target process receptivity analyze start and stop;
Performance gathers subelement 4042, for calling profiler.so file to target process by google-PerfTools, and carries out the performance collection of preset collection duration;
Performance evaluation subelement 4043, the results of performance analysis for carrying out correspondence according to the performance evaluation type selected in advance is shown, performance evaluation type includes cpu performance evaluation and/or heap performance evaluation and/or RAM leakage inspection.
In the present embodiment, found the dlopen function entrance address of the target process of correspondence according to process to be implanted by target process positioning unit 402, then the performance evaluation file loading unit 403 ptrace function by enclosing in target process, in conjunction with dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into target process, last performance collection analysis unit 404 calls profiler.so file by google-PerfTools and target process is carried out performance collection, achieve the performance collection analysis based on linux system, what solve current routine carries out performance collection by google-PerfTools, when duplicate removal compiles, before performance collection, need to carry out the setting of environmental variable, and the performance collection caused and the loaded down with trivial details technical problem of analysis operation, achieve a kind of general in Dynamic injection method, realize the Properties Analysis to c++ program, without recompilating program and logging in production environment machine, the result dissected can accurately be used for positioning cpu performance focus and RAM leakage, also bring option flexibly for user simultaneously, abundant operative configuration.
Referring to Fig. 5, an embodiment of the system of a kind of performance collection analysis based on linux system provided in the embodiment of the present invention includes:
Backstage agent51, TcpProxy52, and the device 53 of the performance collection analysis based on linux system of embodiment as shown in Figure 3 and Figure 4, can be the terminal of web front-end based on the device 53 of the performance collection analysis of linux system;
Device 53 based on the performance collection analysis of linux system is connected with backstage agent51 by TcpProxy52;
Destination host is carried out injecting the collection of the performance after target carries out by backstage agent51 by getting the instruction of the device 53 coming from the performance collection analysis based on linux system, and is fed back to the device 53 of the performance collection analysis based on linux system by TcpProxy52.
TcpProxy52, for being deployed in the machine room that can connect different operators network, as the routing node on backstage and front end communication. Because the real machine room disposed includes telecommunications, UNICOM, education three macroreticular operator. Network of computer room intercommunication between each operator is second-rate, in order to solve the network interworking problem of agent and web front-end, arranges proxy and carrys out transparent data and meet intercommunication problem.
In the present embodiment, by finding the dlopen function entrance address of the target process of correspondence according to process to be implanted, then pass through the ptrace function enclosed in target process, in conjunction with dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into target process, call profiler.so file finally by google-PerfTools and target process is carried out performance collection, achieve the performance collection analysis based on linux system, solve and current carry out performance collection by google-PerfTools, duplicate removal compiling needs the profiler in the storehouse of the upper google of band just can carry out performance collection, the performance collection caused and the loaded down with trivial details technical problem of analysis operation, achieve a kind of general in Dynamic injection method, realize the Properties Analysis to c++ program, without recompilating program and logging in production environment machine, the result dissected can accurately be used for positioning cpu performance focus and RAM leakage, also bring option flexibly for user simultaneously, abundant operative configuration.
Those skilled in the art is it can be understood that arrive, for convenience and simplicity of description, the system of foregoing description, the specific works process of device and unit, it is possible to reference to the corresponding process in preceding method embodiment, do not repeat them here.
In several embodiments provided herein, it should be understood that disclosed system, apparatus and method, it is possible to realize by another way. Such as, device embodiment described above is merely schematic, such as, the division of described unit, being only a kind of logic function to divide, actual can have other dividing mode when realizing, for instance multiple unit or assembly can in conjunction with or be desirably integrated into another system, or some features can ignore, or do not perform. Another point, shown or discussed coupling each other or direct-coupling or communication connection can be through INDIRECT COUPLING or the communication connection of some interfaces, device or unit, it is possible to be electrical, machinery or other form.
The described unit illustrated as separating component can be or may not be physically separate, and the parts shown as unit can be or may not be physical location, namely may be located at a place, or can also be distributed on multiple NE. Some or all of unit therein can be selected according to the actual needs to realize the purpose of the present embodiment scheme.
It addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it is also possible to be that unit is individually physically present, it is also possible to two or more unit are integrated in a unit. Above-mentioned integrated unit both can adopt the form of hardware to realize, it would however also be possible to employ the form of SFU software functional unit realizes.
If described integrated unit is using the form realization of SFU software functional unit and as independent production marketing or use, it is possible to be stored in a computer read/write memory medium. Based on such understanding, part or all or part of of this technical scheme that prior art is contributed by technical scheme substantially in other words can embody with the form of software product, this computer software product is stored in a storage medium, including some instructions with so that a computer equipment (can be personal computer, server, or the network equipment etc.) perform all or part of step of method described in each embodiment of the present invention. And aforesaid storage medium includes: USB flash disk, portable hard drive, read only memory (ROM, Read-OnlyMemory), the various media that can store program code such as random access memory (RAM, RandomAccessMemory), magnetic disc or CD.
The above, above example only in order to technical scheme to be described, is not intended to limit; Although the present invention being described in detail with reference to previous embodiment, it will be understood by those within the art that: the technical scheme described in foregoing embodiments still can be modified by it, or wherein portion of techniques feature is carried out equivalent replacement; And these amendments or replacement, do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.

Claims (11)

1. the method based on the performance collection analysis of linux system, it is characterised in that including:
Determine that the process to be implanted of performance evaluation treated by the destination host of selection;
The dlopen function entrance address of the target process of correspondence is found according to described process to be implanted;
By the ptrace function enclosed in described target process, in conjunction with described dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into described target process;
Call described profiler.so file by google-PerfTools and described target process is carried out performance collection, and obtain the results of performance analysis of correspondence.
2. the method for the performance collection analysis based on linux system according to claim 1, it is characterised in that determine that the destination host of selection treats that the process to be implanted of performance evaluation specifically includes:
Determine the IP address of the destination host of selection, and be attached;
Determine that destination host carries out the injection of the described process to be implanted treating performance evaluation of correspondence.
3. the method for the performance collection analysis based on linux system according to claim 2, it is characterised in that find the dlopen function entrance address of the target process of correspondence to specifically include according to described process to be implanted:
Libc.so file is called by running random procedure;
Agent process when described random procedure runs is by calling the first absolute address during dlsym function acquisition dlopen function operation;
At the described libc.so file of the in-process loading of described agent, to determine the first initial address;
Described dlopen function side-play amount in described libc.so file is determined by described first initial address and described first absolute address;
Determine, by described libc.so file, the initial address that the described process of the injection being carried in dynamic base is corresponding according to described process to be implanted; Obtaining absolute address according to described initial address and described offset addition, described absolute address is the described dlopen function entrance address of described destination address;
The described process injected is called described ptrace function and is loaded into described target process.
4. the method for the performance collection analysis based on linux system according to claim 3, it is characterized in that, by the ptrace function enclosed in described target process, in conjunction with described dlopen function entrance address, the profiler.so file being used for Dynamic Performance Analysis is loaded into described target process and specifically includes:
By transmitting the title of described dlopen function entrance address and described profiler.so file to depositor;
In target process, the described profiler.so file for Dynamic Performance Analysis is loaded by described ptrace function call dlopen function.
5. the method for the performance collection analysis based on linux system according to claim 4, it is characterized in that, call described profiler.so file by google-PerfTools and described target process carried out performance collection, and the results of performance analysis obtaining correspondence specifically includes:
By adding a new function in described profiler.so file, and described new function is registered two signals for allowing described target process receptivity analyze start and stop;
Call described profiler.so file to described target process by google-PerfTools, and carry out the performance collection of preset collection duration;
The results of performance analysis carrying out correspondence according to the performance evaluation type selected in advance is shown, described performance evaluation type includes cpu performance evaluation and/or heap performance evaluation and/or RAM leakage inspection.
6. the device based on the performance collection analysis of linux system, it is characterised in that including:
Determine unit, for determining that the process to be implanted of performance evaluation treated by the destination host of selection;
Target process positioning unit, for finding the dlopen function entrance address of the target process of correspondence according to described process to be implanted;
Performance evaluation file loading unit, for the ptrace function by enclosing in described target process, is loaded into described target process in conjunction with described dlopen function entrance address by the profiler.so file being used for Dynamic Performance Analysis;
Performance collection analysis unit, carries out performance collection for calling described profiler.so file by google-PerfTools, and obtains the results of performance analysis of correspondence described target process.
7. the device of the performance collection analysis based on linux system according to claim 6, it is characterised in that determine that unit specifically includes:
First determines subelement, for determining the IP address of the destination host of selection, and is attached;
Second determines subelement, for determining that destination host carries out the injection of the described process to be implanted treating performance evaluation of correspondence.
8. the device of the performance collection analysis based on linux system according to claim 7, it is characterised in that target process positioning unit specifically includes:
Call subelement, for calling libc.so file by operation random procedure;
First absolute address obtains subelement, and agent process when running for described random procedure is by calling the first absolute address during dlsym function acquisition dlopen function operation;
First initial address determines subelement, at the described libc.so file of the in-process loading of described agent, to determine the first initial address;
Side-play amount determines subelement, for determining described dlopen function side-play amount in described libc.so file by described first initial address and described first absolute address;
Initial address determines subelement, for determining, by described libc.so file, the initial address that the described process of the injection being carried in dynamic base is corresponding according to described process to be implanted;
Absolute address computing unit, for obtaining absolute address according to described initial address and described offset addition, described absolute address is the described dlopen function entrance address of described destination address;
Ptrace function adds subelements, and the described process for injecting is called described ptrace function and is loaded into described target process.
9. the device of the performance collection analysis based on linux system according to claim 8, it is characterised in that performance evaluation file loading unit specifically includes:
Transmission subelement, is used for by the title transmitting described dlopen function entrance address and described profiler.so file to depositor;
Profiler.so file adds subelements, for loading the described profiler.so file for Dynamic Performance Analysis in target process by described ptrace function call dlopen function.
10. the device of the performance collection analysis based on linux system according to claim 8, it is characterised in that performance collection analysis unit specifically includes:
Signal registration subelement, is used for by adding a new function in described profiler.so file, and described new function is registered two signals for allowing described target process receptivity analyze start and stop;
Performance gathers subelement, for calling described profiler.so file to described target process by google-PerfTools, and carries out the performance collection of preset collection duration;
Performance evaluation subelement, the results of performance analysis for carrying out correspondence according to the performance evaluation type selected in advance is shown, described performance evaluation type includes cpu performance evaluation and/or heap performance evaluation and/or RAM leakage inspection.
11. the system based on the performance collection analysis of linux system, it is characterised in that including:
Backstage agent, TcpProxy, and the device of the performance collection analysis based on linux system as described in any one in claim 6 to 10;
The device of the described performance collection analysis based on linux system is connected with described backstage agent by described TcpProxy;
Destination host is carried out injecting the collection of the performance after target carries out by described backstage agent by getting the instruction of the device coming from the described performance collection analysis based on linux system, and feeds back to the device of the described performance collection analysis based on linux system.
CN201511023611.9A 2015-12-29 2015-12-29 Performance acquisition-analysis method, device and system based on Linux system Pending CN105677550A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201511023611.9A CN105677550A (en) 2015-12-29 2015-12-29 Performance acquisition-analysis method, device and system based on Linux system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201511023611.9A CN105677550A (en) 2015-12-29 2015-12-29 Performance acquisition-analysis method, device and system based on Linux system

Publications (1)

Publication Number Publication Date
CN105677550A true CN105677550A (en) 2016-06-15

Family

ID=56298160

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201511023611.9A Pending CN105677550A (en) 2015-12-29 2015-12-29 Performance acquisition-analysis method, device and system based on Linux system

Country Status (1)

Country Link
CN (1) CN105677550A (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106407103A (en) * 2016-07-20 2017-02-15 平安科技(深圳)有限公司 Abnormal signal processing method and apparatus
CN106557424A (en) * 2016-11-18 2017-04-05 腾讯科技(深圳)有限公司 Internal storage testing method, measured terminal, test client and system
CN106775671A (en) * 2016-11-30 2017-05-31 武汉虹信通信技术有限责任公司 A kind of hot patch restorative procedure in the linux environment for communication system
CN106959860A (en) * 2017-03-30 2017-07-18 山东超越数控电子有限公司 The implementation method and device of a kind of kernel Dynamic Execution network based on acceptance of the bid kylin operating system
CN107066390A (en) * 2017-04-24 2017-08-18 许继集团有限公司 A kind of Dram leakage detection method and system
CN108073489A (en) * 2016-11-15 2018-05-25 丰田自动车株式会社 Ensure the method for the operation of calculator
CN108228448A (en) * 2016-12-22 2018-06-29 中国移动通信集团公司 A kind of code tracking method and device
CN108595218A (en) * 2018-04-17 2018-09-28 网宿科技股份有限公司 A kind of method and apparatus of loading system dynamic base
CN109325343A (en) * 2018-09-17 2019-02-12 北京深思数盾科技股份有限公司 Java applet executes method and device
CN109992328A (en) * 2019-03-14 2019-07-09 北京椒图科技有限公司 A kind of function reorientation method and device
CN109992468A (en) * 2017-12-29 2019-07-09 中国移动通信集团黑龙江有限公司 A kind of process performance analysis method, device, system and computer storage medium
CN110908882A (en) * 2019-11-14 2020-03-24 北京无限光场科技有限公司 Performance analysis method and device of application program, terminal equipment and medium
CN114266037A (en) * 2021-12-16 2022-04-01 北京安天网络安全技术有限公司 Sample detection method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101271402A (en) * 2007-03-20 2008-09-24 华为技术有限公司 Method and system for calling function
CN102681940A (en) * 2012-05-15 2012-09-19 兰雨晴 Method for carrying out performance test on memory management subsystem of Linux operation system
CN103379481A (en) * 2012-04-26 2013-10-30 腾讯科技(深圳)有限公司 Method for achieving safety protection and firewall
CN103838662A (en) * 2012-11-23 2014-06-04 三星电子株式会社 Dynamic library profiling method and dynamic library profiling system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101271402A (en) * 2007-03-20 2008-09-24 华为技术有限公司 Method and system for calling function
CN103379481A (en) * 2012-04-26 2013-10-30 腾讯科技(深圳)有限公司 Method for achieving safety protection and firewall
US20150033320A1 (en) * 2012-04-26 2015-01-29 Tencent Technology (Shenzhen) Company Limited Safety Protection Method, Firewall, Terminal Device and Computer-Readable Storage Medium
CN102681940A (en) * 2012-05-15 2012-09-19 兰雨晴 Method for carrying out performance test on memory management subsystem of Linux operation system
CN103838662A (en) * 2012-11-23 2014-06-04 三星电子株式会社 Dynamic library profiling method and dynamic library profiling system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ARROW: "使用ptrace向已运行进程中注入.so并执行相关函数", 《HTTPS:/BLOG.CSDN.NET/MYARROW/ARTICLE/DETAILS-9630377》 *
冯文龙: "使用google-perftools剖析程序性能瓶颈", 《HTTPS://WWW.IBM.COM/DEVELOPERWORKS/CN/LINUX/L-CN-GOOGLEPERF/》 *

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106407103A (en) * 2016-07-20 2017-02-15 平安科技(深圳)有限公司 Abnormal signal processing method and apparatus
CN108073489A (en) * 2016-11-15 2018-05-25 丰田自动车株式会社 Ensure the method for the operation of calculator
CN106557424A (en) * 2016-11-18 2017-04-05 腾讯科技(深圳)有限公司 Internal storage testing method, measured terminal, test client and system
CN106557424B (en) * 2016-11-18 2019-12-10 腾讯科技(深圳)有限公司 Memory test method, tested terminal, test client and system
CN106775671A (en) * 2016-11-30 2017-05-31 武汉虹信通信技术有限责任公司 A kind of hot patch restorative procedure in the linux environment for communication system
CN108228448A (en) * 2016-12-22 2018-06-29 中国移动通信集团公司 A kind of code tracking method and device
CN108228448B (en) * 2016-12-22 2021-03-26 中国移动通信集团公司 Code tracking method and device
CN106959860A (en) * 2017-03-30 2017-07-18 山东超越数控电子有限公司 The implementation method and device of a kind of kernel Dynamic Execution network based on acceptance of the bid kylin operating system
CN107066390A (en) * 2017-04-24 2017-08-18 许继集团有限公司 A kind of Dram leakage detection method and system
CN107066390B (en) * 2017-04-24 2020-01-17 许继集团有限公司 Dynamic memory leak detection method and system
CN109992468A (en) * 2017-12-29 2019-07-09 中国移动通信集团黑龙江有限公司 A kind of process performance analysis method, device, system and computer storage medium
CN109992468B (en) * 2017-12-29 2023-09-19 中国移动通信集团黑龙江有限公司 Process performance analysis method, device and system and computer storage medium
CN108595218A (en) * 2018-04-17 2018-09-28 网宿科技股份有限公司 A kind of method and apparatus of loading system dynamic base
CN108595218B (en) * 2018-04-17 2021-08-27 网宿科技股份有限公司 Method and device for loading dynamic library of system
CN109325343A (en) * 2018-09-17 2019-02-12 北京深思数盾科技股份有限公司 Java applet executes method and device
CN109992328A (en) * 2019-03-14 2019-07-09 北京椒图科技有限公司 A kind of function reorientation method and device
CN109992328B (en) * 2019-03-14 2023-05-12 北京椒图科技有限公司 Function redirection method and device
CN110908882A (en) * 2019-11-14 2020-03-24 北京无限光场科技有限公司 Performance analysis method and device of application program, terminal equipment and medium
CN114266037A (en) * 2021-12-16 2022-04-01 北京安天网络安全技术有限公司 Sample detection method and device, electronic equipment and storage medium
CN114266037B (en) * 2021-12-16 2024-05-17 北京安天网络安全技术有限公司 Sample detection method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN105677550A (en) Performance acquisition-analysis method, device and system based on Linux system
CN101976209B (en) Adapting configuration for incompatible application programs
CN111061484A (en) Code compiling method, device, server, user terminal and readable medium
CN1614555A (en) Apparatus and method for autonomic hardware assisted thread stack tracking
CN103718159B (en) Image processing software development approach, image processing software development device
CN105204985A (en) Vulnerability detection method and device
CN102369511B (en) Resource removing method, device and system
CN110414236A (en) A kind of detection method and device of malicious process
CN105893311A (en) Universal serial bus interface drive configuration method and device
CN105678168A (en) Method and apparatus for detecting Shellcode based on stack frame abnormity
CN115617687A (en) Program instrumentation method, apparatus, device and storage medium
CN104268193A (en) Advertisement webpage intercepting method and device
CN113127314B (en) Method and device for detecting program performance bottleneck and computer equipment
CN112782567A (en) Chip testing system, method, device, medium and equipment
US20210263835A1 (en) Code coverage method for embedded system on chip
CN102789417B (en) Program detecting system and method based on directional symbol execution on mobile intelligent terminal
CN114510723B (en) Intelligent contract authority management vulnerability detection method and device
CN104572482A (en) Process variable storage method and device
CN113821486B (en) Method and device for determining dependency relationship between pod libraries and electronic equipment
CN108628744A (en) Method for diagnosing faults, device and electronic equipment
CN114675822A (en) AUTOSAR software component development method, device, equipment and storage medium
CN114840418A (en) Fuzzy test method and device
CN105677559A (en) Detection method and device
CN104424096A (en) Automatic testing system and method for Android platform based device
CN112486497A (en) Compiling configuration file generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 511442 floor 28 floor B1 of Wanda Plaza, Panyu District South Village, Guangzhou City, Guangdong

Applicant after: Guangzhou Huaduo Network Technology Co., Ltd.

Address before: 510665, Guangzhou, Whampoa Avenue, No. 2, creative industrial park, building 3-08,

Applicant before: Guangzhou Huaduo Network Technology Co., Ltd.

CB02 Change of applicant information
RJ01 Rejection of invention patent application after publication

Application publication date: 20160615

RJ01 Rejection of invention patent application after publication