Skip to content

Commit

Permalink
Update TraceTranscoder.cs
Browse files Browse the repository at this point in the history
Improve performance during a MemTrace capture:

- adding an HashSet in the tools code to avoid linear search time (deplinenoise#12)
  • Loading branch information
lastquest committed Jun 19, 2021
1 parent a04cea7 commit 4aaef21
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tool/MemTrace/TraceTranscoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TraceTranscoder
public const uint StreamMagic = 0xbfaf0003;

public TraceMeta MetaData { get; private set; }
public HashSet<ulong> SymbolsHashSet { get; internal set; } = new HashSet<ulong>();

private const uint BufferSize = 128 * 1024;
private const uint RingMask = BufferSize - 1;
Expand Down Expand Up @@ -529,8 +530,12 @@ private bool ReadBackTraceIndex(out int out_index, ref ulong pos)
return false;
}

if (!MetaData.Symbols.Contains(frames[i]))
if (!SymbolsHashSet.Contains(frames[i]))
{
MetaData.Symbols.Add(frames[i]);
SymbolsHashSet.Add(frames[i]);
}

}

++m_SeenStackRollback;
Expand Down

0 comments on commit 4aaef21

Please sign in to comment.