Add streaming support for EventPipe env trace file. (#52443)
* Add streaming support for EventPipe env trace file.
Using EventPipeOutputPath and EventPipeConfig it is possible to setup
an EventPipe file session running during complete runtime execution.
There was however no logic that would flush this session, so if number
of events included in file exceeded max buffer all subsequent events
would be lost. Depeding on use case (like startup profiling) that could
be acceptable, unless rundown events where needed, since they would
likely be lost unless buffer size was way biffer than default limit (1MB).
Adding ability to run a streaming thread (similar to IPC) together with
file sessions would greatly increase usage of the default file session
and could then be real useful in cases where regular diagnostic
tooling won't work or increase the complexity of the profilig task.
In order to preserve old behavior, a new EventPipeSessionType has been
introduced, EP_SESSION_TYPE_FILESTREAM and that will work similar to
existing EP_SESSION_TYPE_FILE, but also start a streaming thread,
making sure buffer content is periodically flushed into file, reduce
risk of getting a flooded buffer manager triggering lost events.
For the default trace file, old behavior is kept and there is a new env
variable, COMPlus_EventPipeOutputStreaming that can be used to enable
using EP_SESSION_TYPE_FILESTREAM instead of EP_SESSION_TYPE_FILE for the
default file session.