Add additional filter capabilities to dotnet-pgo tool. (#89853)
authorJohan Lorensson <lateralusx.github@gmail.com>
Thu, 10 Aug 2023 11:06:11 +0000 (13:06 +0200)
committerGitHub <noreply@github.com>
Thu, 10 Aug 2023 11:06:11 +0000 (13:06 +0200)
commit6d9baea7c228dfbb11833ae08137bba6a0d262ac
tree80951da7e1aed7066686e7e8c8effdc46ed0bd72
parent4aea2aa559a66432cd22e07e028f38bff50c7889
Add additional filter capabilities to dotnet-pgo tool. (#89853)

Mono adopted PGO in .net7 as a replacement for a
solution called profiled AOT in mono/mono used by Android
SDK. In the replaced solution there was a concept of
a stop trigger, meaning that the user could collect methods
up to a stop trigger (a method name) meaning that the
profiled AOT image would only include methods up to that point.

When using EventPipe and nettrace there is limited ability to
get the same fine grained control over what methods that ends
up in the nettrace file. dotnet-monitor includes ways to stop
tracing if it hits for example a specific method, but due to the
nature of EventPipe, there could still be additional methods added
to the trace when closing session. dotnet-trace currently don't offer
any ability to do something similar, but if implemented, it
would probably come with the same limitations as dotnet-monitor.

Adding better filter capabilities to dotnet-pgo would add additional
capabilities, giving users more control on what methods that gets
included into the generated mibc file. That would give Mono's
profiled AOT better control to include methods up to a stop trigger.

dotnet-pgo alread had capabilities to include events based on timestamp
interval. This commit extends that to select the lower/upper timestamp
based on a regular expression matching methods. This commit also
adds capabilities to add a method include/exclude filters using regular
expression, giving users fine grained control on what methods to
include/exclude in the generated mibc file.

The additional filter capabilities could be used by Android SDK to
for example create a mibc file including all methods up to Main,
replacing the stop trigger features used in old profiled AOT solution.

---------

Co-authored-by: mdh1418 <mitchhwang1418@gmail.com>
src/coreclr/tools/dotnet-pgo/PgoRootCommand.cs
src/coreclr/tools/dotnet-pgo/Program.cs