LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0486-cdv-Speed-up-reading-of-dump-with-many-processes.patch of Package erlang (Project home:Ledest:erlang:20)

From 896b367ad01ffa27637567af8fb722b9a379b972 Mon Sep 17 00:00:00 2001
From: Siri Hansen <siri@erlang.org>
Date: Mon, 29 Oct 2018 12:00:07 +0100
Subject: [PATCH 1/2] [cdv] Speed up reading of dump with many processes

Eliminate an ets:select per process, which was used for reading
position data needed for progress reporting. Now this data is stored
in dictionary along with the last tag and id instead.
---
 lib/observer/src/crashdump_viewer.erl | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/lib/observer/src/crashdump_viewer.erl b/lib/observer/src/crashdump_viewer.erl
index 2a5c3bb1f9..41a569c2bf 100644
--- a/lib/observer/src/crashdump_viewer.erl
+++ b/lib/observer/src/crashdump_viewer.erl
@@ -580,9 +580,9 @@ truncated_here(Tag) ->
     case get(truncated) of
 	true ->
 	    case get(last_tag) of
-		Tag -> % Tag == {TagType,Id}
+		{Tag,_Pos} -> % Tag == {TagType,Id}
 		    true;
-		{Tag,_Id} ->
+		{{Tag,_Id},_Pos} ->
 		    true;
 		_LastTag ->
 		    truncated_earlier(Tag)
@@ -837,8 +837,8 @@ do_read_file(File) ->
                             case check_dump_version(Id) of
                                 {ok,DumpVsn} ->
                                     reset_tables(),
-                                    insert_index(Tag,Id,N1+1),
-                                    put_last_tag(Tag,""),
+                                    insert_index(Tag,Id,Pos=N1+1),
+                                    put_last_tag(Tag,"",Pos),
                                     DecodeOpts = get_decode_opts(DumpVsn),
                                     indexify(Fd,DecodeOpts,Rest,N1),
                                     end_progress(),
@@ -906,12 +906,10 @@ indexify(Fd,DecodeOpts,Bin,N) ->
                 _ ->
                     insert_index(Tag,Id,NewPos)
             end,
-	    case put_last_tag(Tag,Id) of
-                {?proc_heap,LastId} ->
-                    [{_,LastPos}] = lookup_index(?proc_heap,LastId),
+	    case put_last_tag(Tag,Id,NewPos) of
+                {{?proc_heap,LastId},LastPos} ->
                     ets:insert(cdv_heap_file_chars,{LastId,N+Start+1-LastPos});
-                {?literals,[]} ->
-                    [{_,LastPos}] = lookup_index(?literals,[]),
+                {{?literals,[]},LastPos} ->
                     ets:insert(cdv_heap_file_chars,{literals,N+Start+1-LastPos});
                 _ -> ok
             end,
@@ -954,10 +952,10 @@ tag(Fd,<<>>,N,Gat,Di,Now) ->
 
 check_if_truncated() ->
     case get(last_tag) of
-	{?ende,_} ->
+	{{?ende,_},_} ->
 	    put(truncated,false),
 	    put(truncated_proc,false);
-        {?literals,[]} ->
+        {{?literals,[]},_} ->
             put(truncated,true),
             put(truncated_proc,false),
             %% Literals are truncated. Make sure we never
@@ -965,7 +963,7 @@ check_if_truncated() ->
             %% references literals will show markers for
             %% incomplete heaps, but will otherwise work.)
             delete_index(?literals, []);
-	TruncatedTag ->
+	{TruncatedTag,_} ->
 	    put(truncated,true),
 	    find_truncated_proc(TruncatedTag)
     end.
@@ -3213,13 +3211,13 @@ tag_to_atom(UnknownTag) ->
 
 %%%-----------------------------------------------------------------
 %%% Store last tag for use when truncated, and reason if aborted
-put_last_tag(?abort,Reason) ->
+put_last_tag(?abort,Reason,_Pos) ->
     %% Don't overwrite the real last tag, and don't return it either,
     %% since that would make the caller of this function believe that
     %% the tag was complete.
     put(truncated_reason,Reason);
-put_last_tag(Tag,Id) ->
-    put(last_tag,{Tag,Id}).
+put_last_tag(Tag,Id,Pos) ->
+    put(last_tag,{{Tag,Id},Pos}).
 
 %%%-----------------------------------------------------------------
 %%% Fetch next chunk from crashdump file
-- 
2.16.4