-
Notifications
You must be signed in to change notification settings - Fork 31
[BaseTasks] improve Task settings in AsyncTaskExtensions #129
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
Conversation
Context: https://devblogs.microsoft.com/premier-developer/limiting-concurrency-for-faster-and-more-responsive-apps/ A work item came in from VS where AOT compilation is causing responsiveness issues. The culprit came down to some of the `TaskScheduler` and `TaskCreationOptions` settings in `AsyncTaskExtensions`. @davkean's recommendations are: > This code needs to do two things: > 1) It needs to pass `TaskCreationOptions.LongRunning`, so that we > don't burn queues meant for short lived tasks. > 2) It needs to limit how many tasks it starts at once, to avoid CPU > contention and reduce the number of threads that we end up > burning. Looking at `AsyncTaskExtensions` usage, it would happen during regular builds as well, because aapt2-related tasks use these. To improve these, I'm changing: * New overloads to pass in `int maxConcurrencyLevel` and `TaskCreationOptions`. * These default to `Environment.ProcessorCount * 2` and `LongRunning`. When this change lands, we should potentially pass in `$(Aapt2DaemonMaxInstanceCount)` where appropriate for `maxConcurrencyLevel`. I wrote a few tests to just check general sanity of `AsyncTaskExtensions`. We didn't have any.
ecc0c27 to
3b236f3
Compare
We should probably have separate properties for each, but unify them so the user can set both at once, or tweak each value. <AndroidMaxParallelBuildCount>6</AndroidMaxParallelBuildCount>
<Aapt2DaemonMaxInstanceCount Condition=" '$(Aapt2DaemonMaxInstanceCount)' == '' ">$(AndroidMaxParallelBuildCount )</Aapt2DaemonMaxInstanceCount>
<AotMaxBuildThreadCount Condition=" '$(AotMaxBuildThreadCount)' == '' ">$(AndroidMaxParallelBuildCount )</AotMaxBuildThreadCount >(We'd need to work on the naming :)). Mind you , I not sure if anyone has ever used this property yet, apart from that one guy who one had 1 CPU and we ended up hanging the build because we calculated (at that time) |
|
Since they can't control AOT parallelization now, I think we could probably just choose a default here and not need to create new properties. |
|
I saw this API that if (BuildEngine is IBuildEngine9 be9)
allowedParallelism = be9.RequestCores(allowedParallelism);Maybe we should actually use this? |
|
Interesting. We'd need to find out if that is for MSBuild Project Parallelism or if we can use it for our Background Thread stuff. |
Fixes: https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/1360410
Context: https://devblogs.microsoft.com/premier-developer/limiting-concurrency-for-faster-and-more-responsive-apps/
A work item came in from VS where AOT compilation is causing
responsiveness issues. The culprit came down to some of the
TaskSchedulerandTaskCreationOptionssettings inAsyncTaskExtensions.@davkean's recommendations are:
Looking at
AsyncTaskExtensionsusage, it would happen during regularbuilds as well, because aapt2-related tasks use these.
To improve these, I'm changing:
int maxConcurrencyLevelandTaskCreationOptions.Environment.ProcessorCount * 2andLongRunning.When this change lands, we should potentially pass in
$(Aapt2DaemonMaxInstanceCount)where appropriate formaxConcurrencyLevel.I wrote a few tests to just check general sanity of
AsyncTaskExtensions. We didn't have any.