Procházet zdrojové kódy

ft: 代码修改

master
SisMaker před 3 roky
rodič
revize
affb8238c0
18 změnil soubory, kde provedl 67 přidání a 78 odebrání
  1. +12
    -12
      README.md
  2. +2
    -0
      include/eTpf.hrl
  3. +4
    -4
      rebar.config
  4. +0
    -0
      src/callgrind/tpCallgrind.erl
  5. +1
    -1
      src/eTpf_sup.erl
  6. +0
    -0
      src/fileHer/tpFileReader.erl
  7. +0
    -0
      src/flame/tpFlame.erl
  8. +3
    -1
      src/messages/tpMessages.erl
  9. +3
    -1
      src/messages/tpMessagesSeqdiag.erl
  10. +0
    -59
      src/profile/tpRabbitHole.erl
  11. +0
    -0
      src/tracer/tpFileTracer.erl
  12. +0
    -0
      src/tracer/tpRawConsoleTracer.erl
  13. +0
    -0
      src/tracer/tpSocketTracer.erl
  14. +0
    -0
      src/tracer/tpTracer.erl
  15. +0
    -0
      src/tracer/tpTracerPool.erl
  16. +42
    -0
      src/utils/tpMsgHole.erl
  17. +0
    -0
      src/utils/tpSocketClient.erl
  18. +0
    -0
      src/utils/tpTerm.erl

+ 12
- 12
README.md Zobrazit soubor

@ -212,14 +212,14 @@ end.
当出于分析目的而跟踪文件时,您很可能不关心某些事件,例如链接的进程。要禁用任何不必要的事件分析,请传递mode选项:
```
1> lg:trace('_', lg_file_tracer, "traces.lz4", #{mode => profile}).
1> lg:trace('_', lg_file_tracer, "traces.lz4", #{mode => utils}).
```
[[tracing_running]]
您还可以通过启用选项来获得仅对配置文件有用的额外事件。 该running选项将启用事件,这些事件指示何时安排进出流程。 启用它通常会很有用,因为它可以启用其他统计信息,但会占用大量资源,因此默认情况下未启用:
```
1> lg:trace('_', lg_file_tracer, "traces.lz4", #{mode => profile, running => true}).
1> lg:trace('_', lg_file_tracer, "traces.lz4", #{mode => utils, running => true}).
```
[[tracing_send]]
@ -241,7 +241,7 @@ events_per_frame。这两个选项使您可以控制文件写入或旋转的频
以下示例将文件大小限制为100MB:
```
1> eTpf:trace('_', lg_file_tracer, #{filename_prefix => "traces.lz4", max_size => 100000000}, #{mode => profile, running =>true}).
1> eTpf:trace('_', lg_file_tracer, #{filename_prefix => "traces.lz4", max_size => 100000000}, #{mode => utils, running =>true}).
```
在测试此功能期间,目前实施的轮换似乎很昂贵,因此您应注意不要设置太低的值。
@ -267,16 +267,16 @@ $ qcachegrind callgrind.out
它将自动检测并打开所有与该callgrind.out.*模式匹配的文件。
Profiling one file 您可以通过调用函数来分析一个文件 `tpCallgrind:profile/2,3`。它包含跟踪文件名,输出文件名和一个可选的选项映射:
Profiling one file 您可以通过调用函数来分析一个文件 `tpCallgrind:utils/2,3`。它包含跟踪文件名,输出文件名和一个可选的选项映射:
```
1> tpCallgrind:profile("traces.lz4.1", "callgrind.out.1").
1> tpCallgrind:utils("traces.lz4.1", "callgrind.out.1").
```
它还接受以下选项:
```
1> tpCallgrind:profile("traces.lz4.1", "callgrind.out.1", #{running => true}).
1> tpCallgrind:utils("traces.lz4.1", "callgrind.out.1", #{running => true}).
```
Profiling many files 便利功能可用于一次分析许多文件:`tpCallgrind:profile_many/2,3`, 它以通配符模式作为第一个参数,并以文件名前缀作为第二个参数:
@ -351,7 +351,7 @@ eTpf只负责提供输出,然后可以使用常规工具(不附带)将其
要分析一个文件:
```
1> lg_flame:profile("traces.lz4.1", "output").
1> lg_flame:utils("traces.lz4.1", "output").
```
这将创建一个名为'output'的中间文件。
@ -377,9 +377,9 @@ eTpf也可以根据它们发送的消息来分析Erlang进程。它可以帮助
然后,一个跟踪会话的输出可用于callgrind和消息概要分析。
分析一个文件 您可以通过调用函数来分析一个文件 lg_messages:profile/1。它使用跟踪文件名并打印出分析结果。
分析一个文件 您可以通过调用函数来分析一个文件 lg_messages:utils/1。它使用跟踪文件名并打印出分析结果。
1> lg_messages:profile("traces.lz4.1").
1> lg_messages:utils("traces.lz4.1").
它还将创建一个GraphViz文件,当前将其硬编码为“ digraph.gv”,并打印使用说明。
@ -468,7 +468,7 @@ edge [arrowhead=none, labelfontsize=12.0, minlen=3];
要查看一个文件:
```
1> lg_messages_seqdiag:profile("traces.lz4.1",
1> lg_messages_seqdiag:utils("traces.lz4.1",
["<7788.381.0>", "<7788.382.0>", "<7774.383.0>",
"<7774.384.0>", "<7774.386.0>"]).
```
@ -509,9 +509,9 @@ Glass将不可避免地将此消息记录在跟踪文件中,识别出目标为
当然,该过程仅在Looking Glass运行时可用,这意味着我们不能直接发送消息。以下作品:
is_pid(whereis(lg)) andalso (lg ! Info). 当然,这可以做成一个宏:
is_pid(whereis('$eTpfHole')) andalso ('$eTpfHole' ! Info). 当然,这可以做成一个宏:
%%启用消息跟踪时,将元数据存储在跟踪文件中。 -define(LG_INFO(Info), is_pid(whereis(lg)) andalso (lg ! Info)). 然后可以这样使用:
%%启用消息跟踪时,将元数据存储在跟踪文件中。 -define(LG_INFO(Info), is_pid(whereis('$eTpfHole')) andalso ('$eTpfHole' ! Info)). 然后可以这样使用:
?LG_INFO(#{process_type => reader}). 该消息必须始终是地图。否则,将无法读取跟踪文件。process_type在对消息交换进行概要分析时,Looking Glass仅识别该字段,
并将其用作标签来标识进程。您可以自由定义地图中需要的任何其他值。

+ 2
- 0
include/eTpf.hrl Zobrazit soubor

@ -0,0 +1,2 @@
%% Ignore Msg Hole Name
-define(eTpfHole, '$eTpfHole').

+ 4
- 4
rebar.config Zobrazit soubor

@ -10,7 +10,7 @@
{apps, [eTpf]}
]}.
{pre_hooks,
[{"", compile, "escript c_src/eNpc compile"}]}.
{post_hooks,
[{"", clean, "escript c_src/eNpc clean"}]}.
% {pre_hooks,
% [{"", compile, "escript c_src/eNpc compile"}]}.
% {post_hooks,
% [{"", clean, "escript c_src/eNpc clean"}]}.

src/profile/tpCallgrind.erl → src/callgrind/tpCallgrind.erl Zobrazit soubor


+ 1
- 1
src/eTpf_sup.erl Zobrazit soubor

@ -31,5 +31,5 @@ start_link() ->
init([]) ->
SupFlags = #{strategy => one_for_one, intensity => 5, period => 10},
ChildSpecs = [?ChildSpec(tpRabbitHole, worker)],
ChildSpecs = [?ChildSpec(tpMsgHole, worker)],
{ok, {SupFlags, ChildSpecs}}.

src/profile/tpFileReader.erl → src/fileHer/tpFileReader.erl Zobrazit soubor


src/profile/tpFlame.erl → src/flame/tpFlame.erl Zobrazit soubor


src/profile/tpMessages.erl → src/messages/tpMessages.erl Zobrazit soubor

@ -14,6 +14,8 @@
-module(tpMessages).
-include("eTpf.hrl").
-export([profile/1]).
-export([profile_many/1]).
@ -42,7 +44,7 @@ profile_many(Wildcard) ->
%% @todo Later we may want to look at the latency of gen_server call/reply.
%% @todo Later we may want to look at particular messages, have some sort of callback.
handle_event({send, From, _, Info, lg}, State = #state{meta = Meta0}) ->
handle_event({send, From, _, Info, ?eTpfHole}, State = #state{meta = Meta0}) ->
Meta = case Meta0 of
#{From := Info0} -> Meta0#{From => maps:merge(Info0, Info)};
_ -> Meta0#{From => Info}

src/profile/tpMessagesSeqdiag.erl → src/messages/tpMessagesSeqdiag.erl Zobrazit soubor

@ -14,6 +14,8 @@
-module(tpMessagesSeqdiag).
-include("eTpf.hrl").
-export([profile/2]).
-export([profile_many/2]).
@ -38,7 +40,7 @@ profile_many(Wildcard, Pids) ->
end, #state{pids = prepare_pids(Pids)}, Files),
flush(FinalState).
handle_event({send, From, _, Info, lg}, State = #state{meta = Meta0}) ->
handle_event({send, From, _, Info, ?eTpfHole}, State = #state{meta = Meta0}) ->
Meta = case Meta0 of
#{From := Info0} -> Meta0#{From => maps:merge(Info0, Info)};
_ -> Meta0#{From => Info}

+ 0
- 59
src/profile/tpRabbitHole.erl Zobrazit soubor

@ -1,59 +0,0 @@
%% Copyright (c) 2017-Present Pivotal Software, Inc. All rights reserved.
%%
%% This package, Looking Glass, is double-licensed under the Mozilla
%% Public License 1.1 ("MPL") and the Apache License version 2
%% ("ASL"). For the MPL, please see LICENSE-MPL-RabbitMQ. For the ASL,
%% please see LICENSE-APACHE2.
%%
%% This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
%% either express or implied. See the LICENSE file for specific language governing
%% rights and limitations of this software.
%%
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
%% The purpose of this process is to be the target of messages
%% sent by traced processes. The messages contain metadata that
%% we want to log when we are tracing and later use when profiling
%% the sending of messages. This process does not need them, it
%% just needs to exist, and therefore it discards everything.
-module(tpRabbitHole).
-behaviour(gen_server).
%% API.
-export([start_link/0]).
%% gen_server.
-export([init/1]).
-export([handle_call/3]).
-export([handle_cast/2]).
-export([handle_info/2]).
-export([terminate/2]).
-export([code_change/3]).
%% API.
-spec start_link() -> {ok, pid()}.
start_link() ->
gen_server:start_link({local, lg}, ?MODULE, [], []).
%% gen_server.
init([]) ->
{ok, undefined}.
handle_call(_Request, _From, State) ->
{reply, ignored, State}.
handle_cast(_Msg, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.

src/profile/tpFileTracer.erl → src/tracer/tpFileTracer.erl Zobrazit soubor


src/profile/tpRawConsoleTracer.erl → src/tracer/tpRawConsoleTracer.erl Zobrazit soubor


src/profile/tpSocketTracer.erl → src/tracer/tpSocketTracer.erl Zobrazit soubor


src/profile/tpTracer.erl → src/tracer/tpTracer.erl Zobrazit soubor


src/profile/tpTracerPool.erl → src/tracer/tpTracerPool.erl Zobrazit soubor


+ 42
- 0
src/utils/tpMsgHole.erl Zobrazit soubor

@ -0,0 +1,42 @@
-module(tpMsgHole).
-behaviour(gen_srv).
-include("eTpf.hrl").
% 使
% 西
-export([
start_link/0
]).
-export([
init/1
, handleCall/3
, handleCast/2
, handleInfo/2
, terminate/2
, code_change/3
]).
-spec start_link() -> {ok, pid()}.
start_link() ->
gen_srv:start_link({local, ?eTpfHole}, ?MODULE, [], []).
init(_Args) ->
{ok, undefined}.
handleCall(_Msg, _State, _FROM) ->
{reply, ignored}.
handleCast(_Msg, _State) ->
kpS.
handleInfo(_Msg, _State) ->
kpS.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.

src/profile/tpSocketClient.erl → src/utils/tpSocketClient.erl Zobrazit soubor


src/profile/tpTerm.erl → src/utils/tpTerm.erl Zobrazit soubor


Načítá se…
Zrušit
Uložit