-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix TaskParameterTaskItem serialization perf #11638
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
Fix TaskParameterTaskItem serialization perf #11638
Conversation
lol probably broke something while pulling this out of my RAR branch, will check UT failures later today |
5096b1b
to
57f0123
Compare
Updated with profile traces now that I've fully isolated it from other perf stuff. Tests passing so should be good to go 👍 |
Quite large change to parse out so I'm not 100% sure I didn't miss something, however overall I like it. Since it is only being used by TaskHost(and eventually RAR caching), I'm voting for. |
Perf DDRITs have passed: |
FYI I removed the unescaped item spec struct since I expect memory footprint per TaskItem to be more important now w/ the task host, and there's ways to fix that one in RAR. Everything else is good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some of the failures from the experimental run might be relevant, asked in DM to verify.
This reverts commit 9db3657.
* Revert "Fix TaskParameterTaskItem serialization perf (#11638)"
This reverts commit ec93eaa.
Fixes
Fixes several hotspots I found while profiling RAR service serialization.
Changes Made
TaskParameterTaskItem
is created to wrap an existing TaskItem, but then of its metadata is parsed one again right before serializationMSBuildNameIgnoreCaseComparer.Default
(by moving it into Framework`ITaskItem2.CloneCustomMetadataEscaped()
. If this is aUtilities.TaskItem
coming back from a task, doing an accessor check is non-negligible overhead due toCopyOnWriteDictionary
.ITranslator
APIs over manually checking each direction or reimplementing methods, and letTaskParameterTaskItem
handle its own serialization.A bunch of small improvements but they add up. Since the out of proc TaskHost is the only piece currently using this, here's some profiles off my RAR service builds.
TaskParameterTaskItem.CopyMetadataTo()
This is often hit by
ReferenceTable.SetItemMetadata
in RAR. This fix here was to useIMetadataContainer.ImportMetadata()
bulk set, sinceImmutableDictionary
performs better when operations are batched.Before:


After:
Double
ITaskItem
parsingEssentially when in the write direction the old code would construct a
TaskParameterTaskItem
, but later cast it to ITaskItem and parse everything out again. You can see this here whereCloneCustomMetadataEscaped()
is hit even though by this point we've already extracted the externalTaskItem
to our own instance.Before:


After: