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

[browser] Run tests in parallel #98492

Merged
merged 21 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
723a3b8
Run tests in parallel. Pass max number of parallel threads as param
maraf Feb 15, 2024
60e26d9
[revert] Log all test starts
maraf Feb 15, 2024
3611072
Disable parallel execution for WS and JSON tests
maraf Feb 16, 2024
475818e
Turn off parallel processing when max threads is equal to 1
maraf Feb 16, 2024
ec8185a
Disable parallel execution for Buffers tests
maraf Feb 18, 2024
21a8516
Merge branch 'main' into BrowserTestsParallelRun
lewing Feb 21, 2024
a6f4769
Merge branch 'main' into BrowserTestsParallelRun
maraf Feb 23, 2024
1a1d3ed
Merge branch 'main' into BrowserTestsParallelRun
maraf Feb 27, 2024
8aae2df
Merge branch 'main' into BrowserTestsParallelRun
maraf Mar 5, 2024
5c3b300
Merge remote-tracking branch 'upstream/main' into BrowserTestsParalle…
maraf Mar 8, 2024
146d7a7
Revert "[revert] Log all test starts"
maraf Mar 8, 2024
131146f
Merge remote-tracking branch 'origin/BrowserTestsParallelRun' into Br…
maraf Mar 8, 2024
0aafec4
Merge branch 'main' into BrowserTestsParallelRun
pavelsavara Mar 9, 2024
8bd31e8
[torevert] Remove all 1 threads
maraf Mar 18, 2024
419eb66
Merge branch 'main' into BrowserTestsParallelRun
maraf Mar 18, 2024
3ba705a
Revert "[torevert] Remove all 1 threads"
maraf Mar 18, 2024
e769332
Merge branch 'main' into BrowserTestsParallelRun
pavelsavara Mar 21, 2024
024c131
Merge branch 'main' into BrowserTestsParallelRun
maraf Mar 25, 2024
932ebe2
Merge branch 'main' into BrowserTestsParallelRun
pavelsavara Apr 3, 2024
687fefe
1 thread for JS interop tests
pavelsavara Apr 3, 2024
a2b0bfa
Merge branch 'main' into BrowserTestsParallelRun
pavelsavara Apr 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<WasmXHarnessMonoArgs Condition="'$(XunitShowProgress)' == 'true'">$(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true</WasmXHarnessMonoArgs>
<!-- help unit test with PlatformDetection.IsThreadingSupported via IsBrowserThreadingSupported env variable -->
<WasmXHarnessMonoArgs Condition="'$(WasmEnableThreads)' == 'true'">$(WasmXHarnessMonoArgs) --setenv=IsBrowserThreadingSupported=true</WasmXHarnessMonoArgs>
<WasmXHarnessMaxParallelThreads Condition="'$(WasmEnableThreads)' == 'true' and '$(WasmXHarnessMaxParallelThreads)' == ''">8</WasmXHarnessMaxParallelThreads>
</PropertyGroup>

<PropertyGroup Condition="'$(RunScriptCommand)' == ''">
Expand All @@ -112,6 +113,7 @@
<_XHarnessArgs Condition="'$(WasmXHarnessArgsCli)' != ''" >$(_XHarnessArgs) $(WasmXHarnessArgsCli)</_XHarnessArgs>

<_AppArgs Condition="'$(WasmEnableThreads)' == 'true'">$(_AppArgs) -threads</_AppArgs>
<_AppArgs Condition="'$(WasmXHarnessMaxParallelThreads)' != ''">$(_AppArgs) -parallelThreads $(WasmXHarnessMaxParallelThreads)</_AppArgs>
<!-- There are two flavors of WasmXHarnessArgs and WasmXHarnessMonoArgs, one is MSBuild property and the other is environment variable -->
<RunScriptCommand Condition="'$(OS)' != 'Windows_NT'">$HARNESS_RUNNER $(_XHarnessArgs) %24XHARNESS_ARGS %24WasmXHarnessArgs -- $(WasmXHarnessMonoArgs) %24WasmXHarnessMonoArgs $(_AppArgs) %24WasmTestAppArgs</RunScriptCommand>
<RunScriptCommand Condition="'$(OS)' == 'Windows_NT'">%HARNESS_RUNNER% $(_XHarnessArgs) %XHARNESS_ARGS% %WasmXHarnessArgs% -- $(WasmXHarnessMonoArgs) %WasmXHarnessMonoArgs% $(_AppArgs) %WasmTestAppArgs%</RunScriptCommand>
Expand Down
20 changes: 15 additions & 5 deletions src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

public class WasmTestRunner : WasmApplicationEntryPoint
{
// TODO: Set max threads for run in parallel
// protected override int? MaxParallelThreads => RunInParallel ? 8 : base.MaxParallelThreads;
protected int MaxParallelThreadsFromArg { get; set; }
protected override int? MaxParallelThreads => RunInParallel ? MaxParallelThreadsFromArg : base.MaxParallelThreads;

public static async Task<int> Main(string[] args)
{
Expand Down Expand Up @@ -65,9 +65,11 @@ public static async Task<int> Main(string[] args)
break;
case "-threads":
runner.IsThreadless = false;
// TODO: Enable run in parallel
// runner.RunInParallel = true;
// Console.WriteLine($"Running in parallel with {runner.MaxParallelThreads} threads.");
break;
case "-parallelThreads":
runner.MaxParallelThreadsFromArg = Math.Max(1, int.Parse(args[i + 1]));
runner.RunInParallel = runner.MaxParallelThreadsFromArg > 1;
i++;
break;
case "-verbosity":
runner.MinimumLogLevel = Enum.Parse<MinimumLogLevel>(args[i + 1]);
Expand Down Expand Up @@ -105,4 +107,12 @@ public static async Task<int> Main(string[] args)

return res;
}

public override Task RunAsync()
{
if (RunInParallel)
Console.WriteLine($"Running in parallel with {MaxParallelThreads} threads.");

return base.RunAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<!-- This WASM test is problematic and slow right now. This sets the xharness timeout but there is also override in sendtohelix-browser.targets -->
<WasmXHarnessTestsTimeout>01:15:00</WasmXHarnessTestsTimeout>
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<!-- to see timing and which test aborted the runtime -->
<XunitShowProgress>true</XunitShowProgress>
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
</PropertyGroup>
<!-- Make debugging easier -->
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetOS)' == 'browser'">
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
Copy link
Member

Choose a reason for hiding this comment

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

What was the problem with buffers ?

Copy link
Member Author

Choose a reason for hiding this comment

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

OOM killed (from PR description)

[FAIL][8] System.Buffers.ArrayPool.Tests.ArrayPoolUnitTests.RentingSpecificLengthsYieldsExpectedLengths(requestedMinimum: 2097152, expectedLength: 2097152)
info: System.OutOfMemoryException : Out of memory
info:    at System.Buffers.ConfigurableArrayPool`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Rent(Int32 minimumLength)
info:    at System.Buffers.ArrayPool.Tests.ArrayPoolUnitTests.RentingSpecificLengthsYieldsExpectedLengths(Int32 requestedMinimum, Int32 expectedLength)
info:    at System.Object.InvokeStub_ArrayPoolUnitTests.RentingSpecificLengthsYieldsExpectedLengths(Object , Span`1 )
info:    at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Copy link
Member Author

Choose a reason for hiding this comment

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

We can re-parallelize them if you want to see the whole log

Copy link
Member

Choose a reason for hiding this comment

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

It seems that GC is unable to keep up with the traffic. Let's create issue for that.

I wonder if Mono on x64 has the same problem but survives this because of more available memory ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened #100628

</PropertyGroup>
<ItemGroup>
<Compile Include="ArrayPool\ArrayPoolTest.cs" />
<Compile Include="ArrayPool\CollectionTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<XunitShowProgress>true</XunitShowProgress>
<!-- This WASM test is problematic and slow right now. This sets the xharness timeout but there is also override in sendtohelix-browser.targets -->
<WasmXHarnessTestsTimeout>01:15:00</WasmXHarnessTestsTimeout>
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
</PropertyGroup>
<ItemGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<HighAotMemoryUsageAssembly Include="System.Text.Json.Tests.dll" />
Expand Down
Loading