Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Early testhost startup performance work #2584

Merged

Conversation

cvpoienaru
Copy link
Member

Description

Early testhost startup performance improvements

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@cvpoienaru cvpoienaru marked this pull request as ready for review October 7, 2020 10:03
@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@cvpoienaru cvpoienaru marked this pull request as draft October 7, 2020 12:44
@cvpoienaru cvpoienaru changed the title Protocol augmentation for early testhost startup Early testhost startup performance work Oct 9, 2020
@cvpoienaru cvpoienaru marked this pull request as ready for review November 4, 2020 16:16
Copy link
Contributor

@Haplois Haplois left a comment

Choose a reason for hiding this comment

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

LGTM with some nit.

src/Microsoft.TestPlatform.Client/TestPlatform.cs Outdated Show resolved Hide resolved
StartTestSessionCriteria testSessionCriteria,
ITestSessionEventsHandler eventsHandler)
{
if (testSessionCriteria == null)
Copy link
Member

Choose a reason for hiding this comment

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

is there any part of the code from CreateTestRunRequest or CreateDiscoveryRequest that's common?
it would be nice if the RunAll() scenario would essentially do PrepareForRunAll() -> Execute()

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, there's indeed a large portion in the beginning that is repeated for both CreateDiscoveryRequest and CreateTestRunRequest.

We can encapsulate this code in a method along the lines of PrepareForRunAll as you suggested, but both CreateDiscoveryRequest and CreateTestRunRequest receive different argument types that don't implement a common interface, i.e. DiscoveryCriteria vs TestRunCriteria. We can introduce a common interface for them to implement, but I'd leave this out of the scope of this PR for now and introduce it with the next PR that will enable testhost sharing.

/// <param name="testHostLauncher">The custom host launcher.</param>
///
/// <returns>A test session info object.</returns>
ITestSession StartTestSession(
Copy link
Member

Choose a reason for hiding this comment

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

under what circumstances do we need to restart sessions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Restarting sessions shouldn't be a thing.

The current PR enables spawning a session that has one or more testhosts attached to it and only one request per session can be served. This is because the default behavior is to terminate the testhost(s) once the request (discovery/run) was successfully completed.

The next round of changes should enable testhost sharing between discovery and run and should disable the default testhost termination behavior. This means the testhost(s) will be kept alive until the session is terminated with an explicit call from the API user (TW for example).

The only possible need for session restarting would be when the runsettings/list of sources change between discovery and execution. This will require restarting the testhosts, but at this point I think we're better off with terminating the current session and just starting a new session with the updated settings/list of sources. From the performance standpoint the cost of those operations should be about the same.

Copy link
Member

Choose a reason for hiding this comment

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

I meant stopping a session and creating a new one.

besides the settings/list of sources would changing between debugging and profiling also require us to create a new session?

Copy link
Member Author

@cvpoienaru cvpoienaru Dec 11, 2020

Choose a reason for hiding this comment

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

@drognanar Debugging doesn't use the old workflow anymore (i.e. vstest.console asks VS to launch the testhost process and attach to it) unless we're in compatibility mode. Instead the new workflow launches the testhost as a standalone process and only asks VS to attach to it just before starting the test execution, provided IsDebug flag is set of course. No debugging takes place for test discovery though.

For profiling though we still use the old workflow outlined above. As such we ask VS to launch the testhost process on our behalf because there's some specific setup that needs to take place first (setting env vars, etc.). Now this behavior is achievable by passing along an object implementing ITestHostLauncher to the StartTestSession call, the downside being profiling will be set up for test discovery too in addition to test execution. If we wish to avoid this behavior though, the only way to do that would be to start the test session with no ITestHostLauncher (in this way test discovery won't be profiled) and initiate test execution by re-launching the testhost process in profiling mode.

To answer the question in a concise manner: we should know if we intend to debug/profile when starting the test session. In case we didn't anticipate this we'll have to create a new session.


// TODO (copoiena): Collect metrics ?

lock (this.syncObject)
Copy link
Member

Choose a reason for hiding this comment

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

it looks like the CreateStartTestSessionRequest isn't necessarily an immediate operation. does this mean that test sessions on our side can only be spawned sequentially? I noticed that there is just a global TestRequestManager instance.

Copy link
Member Author

@cvpoienaru cvpoienaru Dec 2, 2020

Choose a reason for hiding this comment

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

That's correct, there's only one instance of the TestRequestManager and all operations are sequential, including test discovery and test runs. They're not immediate operations either, meaning we cannot go ahead and execute another request while the current one is running. This has been a design limitation for quite some time now and I think it's worth exploring changing this behavior in a PR of its own as I anticipate it'll require significant changes.

However, if we take only test session spawning into consideration this shouldn't be much of an issue as the plan is to spawn the test session(s) during build. Regarding multiple test sessions, is there any real use case for this on the TW side ?

Copy link
Member

Choose a reason for hiding this comment

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

our extensibility let's users specify a runsettings file to use separately for each csproj. because of that it's possible that different projects will have a different runsettings

hopefully we'll be good with these starting in sequence and we'll need to be smart about stopping/starting sessions to minimize the cases where the session isn't active at the time we need to do a discovery

Copy link
Contributor

@Haplois Haplois left a comment

Choose a reason for hiding this comment

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

:shipit:

@cvpoienaru cvpoienaru merged commit 70abd63 into microsoft:master Dec 11, 2020
jakubch1 added a commit that referenced this pull request Feb 5, 2021
* Update dependencies from https://github.com/dotnet/arcade build 20201130.3 (#2659)

Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.SignTool , Microsoft.DotNet.SwaggerGenerator.MSBuild
 From Version 1.0.0-beta.20570.10 -> To Version 1.0.0-beta.20580.3

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Updating Microsoft.VisualStudio.TraceDataCollector source (#2663)

* Getting Microsoft.VisualStudio.TraceDataCollector from CodeCoverageExternals  instead of TestPlatformExternals,

* Signing TraceDataCollector from the right path,

* Removing already signed dlls,

* Not signing corelib.net,

* Removing files from the list as they are not present,

Co-authored-by: faisal <faisalhafeez@microsoft.com>

* Fixed "issue" pluralization in write-release-notes.ps1 (#2665)

* Fixed "issue" pluralization in write-release-notes.ps1

Co-authored-by: Medeni Baykal <433724+Haplois@users.noreply.github.com>

* Bumping Fakes TestRunnerHarness version (#2661)

* Implement Workitem support in TRX logger (#2666)

* Implemented Workitem support in TRX logger

* Renamed Workitem to WorkItem

Co-authored-by: Flepp Jann <JFlepp@Hamilton.ch>

* Do not merge logs from code coverage (#2671)

* Early testhost startup performance work (#2584)

* Removed TypesToLoadAttribute from ObjectModel. (#2674)

* Removed TypesToLoadAttribute from ObjectModel, and moved the functionallity into adapters themselves.

* Attribute refactoring (#2676)

* Getting TraceDataCollector from nuget (#2678)

* Removing TraceDataCollector project,

* Getting tracedatacollector from nuget,

* Removing signing of codecoverage libs as they are already signed,
updating codecoverage version,

* fixing path to tracedatacollector,

* Fixing acceptance tests,

Co-authored-by: faisal <faisalhafeez@microsoft.com>

* Adding environment variable used during build process, (#2679)

* Removing TraceDataCollector project,

* Getting tracedatacollector from nuget,

* Removing signing of codecoverage libs as they are already signed,
updating codecoverage version,

* fixing path to tracedatacollector,

* Fixing acceptance tests,

* Setting TraceDataCollectorPackagesDir vairable which is used in pipeline,

* Fixing environment variable,

* Fixing path, once again,

Co-authored-by: faisal <faisalhafeez@microsoft.com>

* Update dependencies from https://github.com/dotnet/arcade build 20201221.2 (#2680)

Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.SignTool , Microsoft.DotNet.SwaggerGenerator.MSBuild
 From Version 1.0.0-beta.20580.3 -> To Version 1.0.0-beta.20621.2

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Upgrade CC and CLR IE versions (#2681)

Co-authored-by: Jakub Chocholowicz <jachocho@microsoft.com>

* Fixed assembly names of TestHost executables (#2682)

* Upgrade fakes version (#2683)

Co-authored-by: Jakub Chocholowicz <jachocho@microsoft.com>

* Upgrade CC to 16.9.0-beta.20630.1 (#2684)

Co-authored-by: Jakub Chocholowicz <jachocho@microsoft.com>

* Loc Update (#2685)

Co-authored-by: Cristiano Suzuki <crsuzuki@microsoft.com>

* Create AzureDevOps.yml

* Update AzureDevOps.yml

* Update AzureDevOps.yml

* Update AzureDevOps.yml

* Delete AzureDevOps.yml

* Fix nuget feed (#2697)

* Removing deprecated mygets and adding new nuget sources

* Upgrade CC components (#2698)

* Upgrade CC components

* Revert nuget changes

* Refactor it

Co-authored-by: Jakub Chocholowicz <jachocho@microsoft.com>

* Update dependencies from https://github.com/dotnet/arcade build 20210113.4 (#2696)

Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.SignTool , Microsoft.DotNet.SwaggerGenerator.MSBuild
 From Version 1.0.0-beta.20621.2 -> To Version 1.0.0-beta.21063.4

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Create AzureDevOps.yml

* Update AzureDevOps.yml

* Update AzureDevOps.yml

* Update AzureDevOps.yml

* Update AzureDevOps.yml

* Update AzureDevOps.yml

* Update AzureDevOps.yml

changed to my repo

* Update AzureDevOps.yml

* Add integration tests for dotnet test (#2689)

* Add integration tests for dotnet test

* Use relative paths and correct proj

* Update to latest .NET 6

* Install 5.0.1 runtime

* Add parametrized project

* Updated build status badge. (#2709)

* Updated build status badge.

* Update dependencies from https://github.com/dotnet/arcade build 20210121.4 (#2712)

Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.SignTool , Microsoft.DotNet.SwaggerGenerator.MSBuild
 From Version 1.0.0-beta.21063.4 -> To Version 1.0.0-beta.21071.4

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Update dependencies from https://github.com/dotnet/arcade build 20210122.7 (#2713)

Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.SignTool , Microsoft.DotNet.SwaggerGenerator.MSBuild
 From Version 1.0.0-beta.21063.4 -> To Version 1.0.0-beta.21072.7

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Medeni Baykal <433724+Haplois@users.noreply.github.com>

* Update azure-pipelines.yml for Azure Pipelines (#2715)

* Add metrics for datacollector.exe - provides information about profilers (#2705)

* Initial version of metrics for DC profiling

* Tests

* Push fixes to make linux build

* provide telemetry opted in flag

* Small refactoring

* Change name

* Upgrade CC comp

* Move to guids

* Revert lang change

* Fixing descriptions

* Last changes

Co-authored-by: Jakub Chocholowicz <jachocho@microsoft.com>

* Added git branch and commit NuGet packages (#2716)

* vstest.console: CommandLineOptions: preserve stacktrace on re-throw (CA2200) (#2606)

* vstest.console: CommandLineOptions: preserve stacktrace on re-throw (CA2200)

* Update AzureDevOps.yml

* Update AzureDevOps.yml

* Move FQN related code into a separate NuGet package (#2714)

* Removed ManagedNameUtilities from ObjectModel in order to restore compatibility with older versions.
* Added `Microsoft.TestPlatform.AdapterUtilities`.
* Added `net20` and `net35` support to the code.

* Including `Microsoft.TestPlatform.AdapterUtilities` in signing (#2719)

* Included missing assemblies in signing.

* Updating nuget Pdb2Pdb package (#2720)

* Adding new Pdb2Pdb package and change to licence tag because of warning
* Fixing license
* Formating fixes

Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: fhnaseer <fhnaseer@live.com>
Co-authored-by: faisal <faisalhafeez@microsoft.com>
Co-authored-by: Adam Ralph <adam@adamralph.com>
Co-authored-by: Medeni Baykal <433724+Haplois@users.noreply.github.com>
Co-authored-by: Vritant Bhardwaj <vrbhardw@microsoft.com>
Co-authored-by: jflepp <jflepp@users.noreply.github.com>
Co-authored-by: Flepp Jann <JFlepp@Hamilton.ch>
Co-authored-by: Codrin-Victor Poienaru <cvpoienaru@gmail.com>
Co-authored-by: Jakub Chocholowicz <jachocho@microsoft.com>
Co-authored-by: Cristiano Suzuki <cristianosuzuki77@gmail.com>
Co-authored-by: Cristiano Suzuki <crsuzuki@microsoft.com>
Co-authored-by: Pavel Horak <22235234+pavelhorak@users.noreply.github.com>
Co-authored-by: Sanan Yuzbashiyev <Sanan07@users.noreply.github.com>
Co-authored-by: Jakub Jareš <me@jakubjares.com>
Co-authored-by: Tom Deseyn <tom.deseyn@gmail.com>
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.

Early testhost startup performance improvement for test execution
5 participants