Skip to content

Perfetto plugin - Memory optimizations and table renaming#48

Merged
KyleStorck merged 4 commits intomicrosoft:developfrom
KyleStorck:user/kylsto/memory_opt
Sep 21, 2021
Merged

Perfetto plugin - Memory optimizations and table renaming#48
KyleStorck merged 4 commits intomicrosoft:developfrom
KyleStorck:user/kylsto/memory_opt

Conversation

@KyleStorck
Copy link
Copy Markdown
Collaborator

Made some memory optimizations to help improve the sluggishness in WPA when viewing large traces. Memory optimizations reduce memory usage by about 50%. UI is more responsive now. Optimizations include

  • Used string interning on the high-count string fields
  • Switched the variable length argument fields from List to string[]
  • Changed bunch of longs to ints. These are mostly ID fields. Confirmed they are int or smaller within Perfetto

Table renaming

  • Removed redundant "Perfetto" from all tables and column config names
  • Added column configs that graph by StartTime instead of duration for GenericEvents

@KyleStorck KyleStorck requested a review from ivberg September 20, 2021 23:17

public static string StringIntern(string str)
{
return str != null ? string.Intern(str) : string.Empty;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok with not releasing the memory if the trace is closed ? (per the MSDN article on string.Intern) or will just punt this for later?

A HashTable might just work for this and be free-able?

https://docs.microsoft.com/en-us/dotnet/api/system.string.intern?view=net-5.0
Performance Considerations
If you are trying to reduce the total amount of memory your application allocates, keep in mind that interning a string has two unwanted side effects. First, the memory allocated for interned String objects is not likely to be released until the common language runtime (CLR) terminates. The reason is that the CLR's reference to the interned String object can persist after your application, or even your application domain, terminates. Second, to intern a string, you must first create the string.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not found a way to "close" a trace. Pressing "X" on the trace in graph explorer doesn't really close it. All the events stay in memory. So unless there really is a way to close a trace I think string.Intern is fine for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - this does seem to be the case for ETL as well at least from the UI. Closing graph explorer does indeed seem to leave everything in memory and you can re-open graph explorer from the Trace Menu. Keep in mind that this eventually may be used in-process C# Only DataLayer (no UI) with a processing harness, where the expectation would be to free memory after unloading the trace; so we should keep this in mind for later.

@KyleStorck KyleStorck merged commit 1e2a9a7 into microsoft:develop Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants