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

Enable cache for RAR #2792

Merged
merged 8 commits into from Mar 8, 2018
Merged

Conversation

AndyGerlicher
Copy link
Contributor

Preliminary numbers on a basic netcoreapp2.0 -> netstandard2.0 library sln:

Tip of exp/update-toolset branch rebuild:

      439 ms  ResolveAssemblyReferences                  2 calls
      437 ms  ResolveAssemblyReference                   2 calls

This branch with RAR *.Core.cache file:

      238 ms  ResolveAssemblyReferences                  2 calls
      237 ms  ResolveAssemblyReference                   2 calls

This branch after deleting *.Core.cache:

      312 ms  ResolveAssemblyReferences                  2 calls
      311 ms  ResolveAssemblyReference                   2 calls

So even without the cache file it's still after with binary serialization turned on. Not sure why (there's a lot of code that differs). Also haven't done anything other than manual testing.

@@ -10,7 +10,7 @@
</PropertyGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);STANDALONEBUILD</DefineConstants>
<DefineConstants>$(DefineConstants);STANDALONEBUILD;FEATURE_BINARY_SERIALIZATION</DefineConstants>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Remove it from the net4* pile? Or is the pile intent to document what's on net4*. In which case there should be a similar pile for .net core?

@@ -361,13 +361,8 @@ public void TestTranslationWithValueTypesInDictionary()
1,
Directory.GetCurrentDirectory(),
null,
#if FEATURE_THREAD_CULTURE
Copy link
Contributor

@cdmihai cdmihai Dec 12, 2017

Choose a reason for hiding this comment

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

Maybe it's not worth doing this until we get the green light for removing ns13? If we can't remove ns13, we'll have to put this back. Same goes for the other removed flags.


public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (asAssemblyName != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -2012,7 +2012,8 @@ Copyright (C) Microsoft Corporation. All rights reserved.
expensive to write the newly created cache file.
-->
<PropertyGroup>
<ResolveAssemblyReferencesStateFile Condition="'$(BuildingProject)'=='true'">$(IntermediateOutputPath)$(MSBuildProjectFile)ResolveAssemblyReference.cache</ResolveAssemblyReferencesStateFile>
<ResolveAssemblyReferencesStateFile Condition="'$(BuildingProject)'=='true' and '$(MSBuildRuntimeType)' != 'Core'">$(IntermediateOutputPath)$(MSBuildProjectFile)ResolveAssemblyReference.cache</ResolveAssemblyReferencesStateFile>
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to leave a comment saying why there's two

@AndyGerlicher
Copy link
Contributor Author

{
if (asAssemblyName != null)
{
info.AddValue("asAssemblyName", true);
Copy link
Member

Choose a reason for hiding this comment

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

It probably doesn't matter a lot but these could just be something like "AN" not "asAssemblyName" which adds up, with 100 assembly names that's about 15KB of extra writes, 30KB if it's written out as UTF16 (not sure).

For similar reasons you might consider "interning" some well known values like the 3 or 4 common PK and PKT almost all our assemblies have -- writing out a marker for those instead would save a lot of bytes if you write out many of these assembly names.

@@ -2012,7 +2012,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
expensive to write the newly created cache file.
-->
<PropertyGroup>
<ResolveAssemblyReferencesStateFile Condition="'$(BuildingProject)'=='true'">$(IntermediateOutputPath)$(MSBuildProjectFile)ResolveAssemblyReference.cache</ResolveAssemblyReferencesStateFile>
<!-- Note: Binary serialization not guaranteed to be consistent across full framework and .NET Core, so we need to use a different cache file. -->
Copy link
Member

Choose a reason for hiding this comment

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

.NET Framework and .NET Core do promise to interchange serialized data (if the type is binary serializable in both). What you mean is your special AssemblyName serializatoin scheme is not shared by older MSBuild's.

Copy link
Member

Choose a reason for hiding this comment

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

This is only necessary if you expect both MSBuild's to build the same projectwith the same obj folder. Neither side crash if they can't deserialize, they just warn and overwrite it.

var hasAsAssemblyName = info.GetBoolean("asAssemblyName");
if (hasAsAssemblyName)
{
var name = info.GetString("asAssemblyName.Name");
Copy link
Member

Choose a reason for hiding this comment

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

hopefully there are unit tests that would fail if there was a mistake in the serializatoin/deserialization? it's very easy to have a tpyo or suchlike.

@AndyGerlicher
Copy link
Contributor Author

@dotnet-bot test Ubuntu16.04 Build for CoreCLR please

@AndyGerlicher AndyGerlicher changed the title WIP: Enable cache for RAR Enable cache for RAR Feb 14, 2018
@AndyGerlicher
Copy link
Contributor Author

All the tests are green here, ready for final review.

@AndyGerlicher
Copy link
Contributor Author

One thing to note I removed the split to use a different cache for the Core version. I don't think we need that, but I could be wrong. They should cache the same things and the serialization changes to support Core are for both (I updated the format version).

@AndyGerlicher
Copy link
Contributor Author

@dotnet-bot test Windows_NT Build for Full please

1 similar comment
@AndyGerlicher
Copy link
Contributor Author

@dotnet-bot test Windows_NT Build for Full please

@AndyGerlicher AndyGerlicher force-pushed the binaryserialization branch 5 times, most recently from 0c37aeb to db5b029 Compare March 8, 2018 19:40
Some types are dependent on WinForms
* Enable FEATURE_BINARY_SERIALIZATION for .NET Core build.
* Add custom serialization for types not marked Serializable in .NET Core.
If a custom build event does not implement a serialization method, the
timestamp field may get serialized as an Unspecified kind. To fix this,
EventArgs will now always serialize Utc format and not convert when
observed. If the event kind is Unspecified, assume it's UTC and convert
when the property is accessed.
Renaming the file to avoid issues with breaking changes between 15.6 and
15.7. This is generally not an issue, but 15.6 and below will warn with
a cryptic error message. If users (esp. internal users) switch back and
forth in the same repo this would result in many harmless but concerning
warnings.
This was used in binary serialization and supported on .NET Core 2.0.
@AndyGerlicher AndyGerlicher force-pushed the binaryserialization branch 2 times, most recently from 8e8014b to 9d88e82 Compare March 8, 2018 23:53
@AndyGerlicher AndyGerlicher merged commit 4037f06 into dotnet:master Mar 8, 2018
@danmoseley
Copy link
Member

Yay!

@AndyGerlicher AndyGerlicher deleted the binaryserialization branch June 26, 2018 20:38
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.

None yet

6 participants