Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fix ThreadPool tests for uapaot. #21049

Merged
merged 2 commits into from
Jun 14, 2017
Merged

Fix ThreadPool tests for uapaot. #21049

merged 2 commits into from
Jun 14, 2017

Conversation

AntonLapounov
Copy link
Member

No description provided.

@@ -345,6 +345,7 @@ public static void TaskMethodBuilderT_TaskIsCached()
}

[Fact]
[ActiveIssue("TFS 450361 - Codegen optimization issue", TargetFrameworkMonikers.UapAot)]
public static void TaskMethodBuilder_UsesCompletedCache()
Copy link
Member

Choose a reason for hiding this comment

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

Weren't these already disabled in #21002?

Copy link
Member Author

@AntonLapounov AntonLapounov Jun 14, 2017

Choose a reason for hiding this comment

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

I reused the branch from the previous PR and GitHub included the previous commit. Changes in this file have been already merged; please ignore them.

Copy link
Member

Choose a reason for hiding this comment

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

Can you please rebase it on top of the latest from master?

Copy link
Member Author

Choose a reason for hiding this comment

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

@stephentoub Rebased.

};

// ThreadPool.SetMinThreads returns false on UapAot
Copy link
Member

Choose a reason for hiding this comment

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

We still want to verify that this returns true on the platforms where it should. And isn't it a bug that it returns false on UapAot right now?

Copy link
Member Author

Choose a reason for hiding this comment

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

UapAot uses the default Win32 thread pool, which does not allow setting min/max numbers. I suggested using a custom Win32 thread pool to allow setting min/max numbers, however, that idea was not approved. We need evidence that these settings may be important for real-world applications.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's still useful to allow setting min/max number of threads (sometimes the scenario favors running more threads than the processor count to allow short work to run and complete while relatively long CPU-bound work is holding up some threads). But it probably isn't a good idea to hook those into SetMinThreads / SetMaxThreads since they are extensively used to work around the issues of the CoreCLR thread pool, and the Windows thread pool would not have many of those issues. Perhaps it can be exposed later as a config option or a different API or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we may simply delete this ThreadPool.SetMinThreads call; the test does not depend on it.

Copy link
Member

Choose a reason for hiding this comment

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

The test is testing concurrent calls to SetMinThreads (and thread pool initialization as part of that, based on CoreCLR implementation). In hindsight, the CoreCLR repo may be a better location for this test. In any case, for now if there's no issue with the test I would suggest keeping it as it was.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kouvel Oh, I completely missed that it is testing concurrent calls to SetMinThreads. In this case I will just disable it for UapAot.

Assert.True(minw > 0);
Assert.True(minc > 0);
Assert.True(minw >= 0);
Assert.True(minc >= 0);
Copy link
Member

Choose a reason for hiding this comment

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

In what situation is it valid that these return 0?

Copy link
Member

Choose a reason for hiding this comment

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

I think these should return Environment.ProcessorCount if min/max thread changes are not supported in uapaot

Copy link
Member Author

Choose a reason for hiding this comment

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

For instance, you may call ThreadPool.SetMinThreads(0, 0) on desktop CLR. GetMinThreads will return zeroes after that. At present UapAot returns zeroes, and I don't see why zeroes should be treated as invalid.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kouvel Returning Environment.ProcessorCount would be technically a lie. We may still do that if we had evidence that would improve compatibility with real-world apps.

Copy link
Member

Choose a reason for hiding this comment

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

Oh yea that's true, I was thinking max...

@stephentoub
Copy link
Member

cc: @kouvel

};

// ThreadPool.SetMinThreads returns false on UapAot
ThreadPool.SetMinThreads(processorCount, processorCount);
Copy link
Member

Choose a reason for hiding this comment

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

The purpose of this test is to call SetMinThreads concurrently from different threads, so SetMinThreads needs to be called from the background thread. If SetMinThreads returns false on uapaot, what is wrong with this test that requires a change?

Copy link
Member Author

Choose a reason for hiding this comment

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

The test was asserting that SetMinThreads returned true. I will revert changes to this test and disable it for UapAot.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks.

@AntonLapounov AntonLapounov merged commit 7208a27 into dotnet:master Jun 14, 2017
@AntonLapounov AntonLapounov deleted the UapAotFixes branch June 14, 2017 23:38
@karelz karelz modified the milestone: 2.1.0 Jun 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants