Skip to content

Commit

Permalink
Merge pull request #21839 from heejaechang/abTest64
Browse files Browse the repository at this point in the history
Make OOP to support 64bit
  • Loading branch information
heejaechang committed Sep 15, 2017
2 parents fe4776d + d18adf6 commit dd8516b
Show file tree
Hide file tree
Showing 19 changed files with 238 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class ServiceProvider : IServiceProvider
public ServiceProvider(bool runCacheCleanup)
{
_storage = runCacheCleanup ?
new AssetStorage(cleanupInterval: TimeSpan.FromSeconds(30), purgeAfter: TimeSpan.FromMinutes(1)) :
new AssetStorage(cleanupInterval: TimeSpan.FromSeconds(30), purgeAfter: TimeSpan.FromMinutes(1), gcAfter: TimeSpan.FromMinutes(5)) :
new AssetStorage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ namespace Microsoft.CodeAnalysis.Diagnostics
{
internal static class DiagnosticResultSerializer
{
public static void Serialize(ObjectWriter writer, DiagnosticAnalysisResultMap<string, DiagnosticAnalysisResultBuilder> result, CancellationToken cancellationToken)
public static (int diagnostics, int telemetry, int exceptions) Serialize(
ObjectWriter writer, DiagnosticAnalysisResultMap<string, DiagnosticAnalysisResultBuilder> result, CancellationToken cancellationToken)
{
var diagnosticCount = 0;
var diagnosticSerializer = new DiagnosticDataSerializer(VersionStamp.Default, VersionStamp.Default);

var analysisResult = result.AnalysisResult;
Expand All @@ -26,11 +28,12 @@ public static void Serialize(ObjectWriter writer, DiagnosticAnalysisResultMap<st
{
writer.WriteString(kv.Key);

Serialize(writer, diagnosticSerializer, kv.Value.SyntaxLocals, cancellationToken);
Serialize(writer, diagnosticSerializer, kv.Value.SemanticLocals, cancellationToken);
Serialize(writer, diagnosticSerializer, kv.Value.NonLocals, cancellationToken);
diagnosticCount += Serialize(writer, diagnosticSerializer, kv.Value.SyntaxLocals, cancellationToken);
diagnosticCount += Serialize(writer, diagnosticSerializer, kv.Value.SemanticLocals, cancellationToken);
diagnosticCount += Serialize(writer, diagnosticSerializer, kv.Value.NonLocals, cancellationToken);

diagnosticSerializer.WriteTo(writer, kv.Value.Others, cancellationToken);
diagnosticCount += kv.Value.Others.Length;
}

var telemetryInfo = result.TelemetryInfo;
Expand All @@ -50,6 +53,9 @@ public static void Serialize(ObjectWriter writer, DiagnosticAnalysisResultMap<st
writer.WriteString(kv.Key);
diagnosticSerializer.WriteTo(writer, kv.Value, cancellationToken);
}

// report how many data has been sent
return (diagnosticCount, telemetryInfo.Count, exceptions.Count);
}

public static DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisResult> Deserialize(
Expand Down Expand Up @@ -103,18 +109,24 @@ public static void Serialize(ObjectWriter writer, DiagnosticAnalysisResultMap<st
return DiagnosticAnalysisResultMap.Create(analysisMap.ToImmutable(), telemetryMap.ToImmutable(), exceptionMap.ToImmutable());
}

private static void Serialize(
private static int Serialize(
ObjectWriter writer,
DiagnosticDataSerializer serializer,
ImmutableDictionary<DocumentId, ImmutableArray<DiagnosticData>> diagnostics,
CancellationToken cancellationToken)
{
var count = 0;

writer.WriteInt32(diagnostics.Count);
foreach (var kv in diagnostics)
{
kv.Key.WriteTo(writer);
serializer.WriteTo(writer, kv.Value, cancellationToken);

count += kv.Value.Length;
}

return count;
}

private static ImmutableDictionary<DocumentId, ImmutableArray<DiagnosticData>> Deserialize(
Expand Down
9 changes: 6 additions & 3 deletions src/Setup/DevDivInsertionFiles/BuildDevDivInsertionFiles.vb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ Public Class BuildDevDivInsertionFiles
"StreamJsonRpc.resources.dll",
"codeAnalysisService.servicehub.service.json",
"remoteHostService.servicehub.service.json",
"serviceHubSnapshotService.servicehub.service.json",
"snapshotService.servicehub.service.json",
"remoteSymbolSearchUpdateEngine.servicehub.service.json",
"codeAnalysisService64.servicehub.service.json",
"remoteHostService64.servicehub.service.json",
"snapshotService64.servicehub.service.json",
"remoteSymbolSearchUpdateEngine64.servicehub.service.json",
"Microsoft.Build.Conversion.Core.dll",
"Microsoft.Build.dll",
"Microsoft.Build.Engine.dll",
Expand Down Expand Up @@ -836,8 +841,6 @@ Public Class BuildDevDivInsertionFiles
add("Exes\VBCSCompiler\net46\VBCSCompiler.exe.config")
add("Exes\InteractiveHost\InteractiveHost.exe.config")
add("Exes\csi\csi.rsp")
add("Vsix\Roslyn.Deployment.Full.Next\remoteSymbolSearchUpdateEngine.servicehub.service.json")
add("Vsix\Roslyn.Deployment.Full.Next\snapshotService.servicehub.service.json")
add("Vsix\VisualStudioInteractiveComponents\CSharpInteractive.rsp")
add("Vsix\VisualStudioSetup\Microsoft.VisualStudio.CallHierarchy.Package.Definitions.dll")
add("Vsix\VisualStudioSetup\System.Composition.Convention.dll")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Execution;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Extensions;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.PooledObjects;
Expand Down Expand Up @@ -87,6 +88,9 @@ public void Enable()
return;
}

// set bitness
SetRemoteHostBitness();

// make sure we run it on background thread
_shutdownCancellationTokenSource = new CancellationTokenSource();

Expand Down Expand Up @@ -159,6 +163,23 @@ public Task<RemoteHostClient> TryGetRemoteHostClientAsync(CancellationToken canc
return remoteClientTask;
}

private void SetRemoteHostBitness()
{
var x64 = _workspace.Options.GetOption(RemoteHostOptions.OOP64Bit);
if (!x64)
{
x64 = _workspace.Services.GetService<IExperimentationService>().IsExperimentEnabled(
WellKnownExperimentNames.RoslynOOP64bit);
}

// log OOP bitness
Logger.Log(FunctionId.RemoteHost_Bitness, KeyValueLogMessage.Create(LogType.Trace, m => m["64bit"] = x64));

// set service bitness
WellKnownRemoteHostServices.Set64bit(x64);
WellKnownServiceHubServices.Set64bit(x64);
}

private async Task<RemoteHostClient> EnableAsync(CancellationToken cancellationToken)
{
// if we reached here, IRemoteHostClientFactory must exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ internal static class RemoteHostOptions
nameof(InternalFeatureOnOffOptions), nameof(RestartRemoteHostAllowed), defaultValue: false,
storageLocations: new LocalUserProfileStorageLocation(InternalFeatureOnOffOptions.LocalRegistryPath + nameof(RestartRemoteHostAllowed)));

// use 64bit OOP
public static readonly Option<bool> OOP64Bit = new Option<bool>(
nameof(InternalFeatureOnOffOptions), nameof(OOP64Bit), defaultValue: false,
storageLocations: new LocalUserProfileStorageLocation(InternalFeatureOnOffOptions.LocalRegistryPath + nameof(OOP64Bit)));

public static readonly Option<bool> RemoteHostTest = new Option<bool>(nameof(InternalFeatureOnOffOptions), nameof(RemoteHostTest), defaultValue: false);
}

Expand All @@ -55,6 +60,7 @@ internal class RemoteHostOptionsProvider : IOptionProvider
RemoteHostOptions.SolutionChecksumMonitorBackOffTimeSpanInMS,
RemoteHostOptions.RequestServiceTimeoutInMS,
RemoteHostOptions.RestartRemoteHostAllowed,
RemoteHostOptions.OOP64Bit,
RemoteHostOptions.RemoteHostTest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void TestGetAssets()
[Fact, Trait(Traits.Feature, Traits.Features.RemoteHost)]
public async Task TestCleanup()
{
var storage = new AssetStorage(cleanupInterval: TimeSpan.FromMilliseconds(1), purgeAfter: TimeSpan.FromMilliseconds(2));
var storage = new AssetStorage(cleanupInterval: TimeSpan.FromMilliseconds(1), purgeAfter: TimeSpan.FromMilliseconds(2), gcAfter: TimeSpan.FromMilliseconds(5));

var checksum = Checksum.Create(WellKnownSynchronizationKind.Null, ImmutableArray.CreateRange(Guid.NewGuid().ToByteArray()));
var data = new object();
Expand Down
16 changes: 16 additions & 0 deletions src/VisualStudio/Setup/VisualStudioSetup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,22 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="snapshotService64.servicehub.service.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="codeAnalysisService64.servicehub.service.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="remoteHostService64.servicehub.service.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="remoteSymbolSearchUpdateEngine64.servicehub.service.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"host": "desktopClr",
"hostId": "RoslynCodeAnalysisService",
"hostGroupAllowed": true,
"entryPoint": {
"assemblyPath": "Microsoft.CodeAnalysis.Remote.ServiceHub.dll",
"fullClassName": "Microsoft.CodeAnalysis.Remote.CodeAnalysisService",
"appBasePath": "%VSAPPIDDIR%",
"configPath": "%PkgDefApplicationConfigFile%"
}
}
11 changes: 11 additions & 0 deletions src/VisualStudio/Setup/remoteHostService64.servicehub.service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"host": "desktopClr",
"hostId": "RoslynCodeAnalysisService",
"hostGroupAllowed": true,
"entryPoint": {
"assemblyPath": "Microsoft.CodeAnalysis.Remote.ServiceHub.dll",
"fullClassName": "Microsoft.CodeAnalysis.Remote.RemoteHostService",
"appBasePath": "%VSAPPIDDIR%",
"configPath": "%PkgDefApplicationConfigFile%"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"host": "desktopClr",
"hostId": "RoslynCodeAnalysisService",
"hostGroupAllowed": true,
"entryPoint": {
"assemblyPath": "Microsoft.CodeAnalysis.Remote.ServiceHub.dll",
"fullClassName": "Microsoft.CodeAnalysis.Remote.RemoteSymbolSearchUpdateEngine",
"appBasePath": "%VSAPPIDDIR%",
"configPath": "%PkgDefApplicationConfigFile%"
}
}
11 changes: 11 additions & 0 deletions src/VisualStudio/Setup/snapshotService64.servicehub.service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"host": "desktopClr",
"hostId": "RoslynCodeAnalysisService",
"hostGroupAllowed": true,
"entryPoint": {
"assemblyPath": "Microsoft.CodeAnalysis.Remote.ServiceHub.dll",
"fullClassName": "Microsoft.CodeAnalysis.Remote.SnapshotService",
"appBasePath": "%VSAPPIDDIR%",
"configPath": "%PkgDefApplicationConfigFile%"
}
}
4 changes: 4 additions & 0 deletions src/VisualStudio/Setup/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="snapshotService.servicehub.service.json" />
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="codeAnalysisService.servicehub.service.json" />
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="remoteSymbolSearchUpdateEngine.servicehub.service.json" />
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="remoteHostService64.servicehub.service.json" />
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="snapshotService64.servicehub.service.json" />
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="codeAnalysisService64.servicehub.service.json" />
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="remoteSymbolSearchUpdateEngine64.servicehub.service.json" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="BasicVisualStudio" Path="|BasicVisualStudio|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="CSharpVisualStudio" Path="|CSharpVisualStudio|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="SolutionExplorerShim" Path="|SolutionExplorerShim|" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ internal class DefaultExperimentationService : IExperimentationService
internal static class WellKnownExperimentNames
{
public const string RoslynFeatureOOP = nameof(RoslynFeatureOOP);
public const string RoslynOOP64bit = nameof(RoslynOOP64bit);
}
}
2 changes: 2 additions & 0 deletions src/Workspaces/Core/Portable/Log/FunctionId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,7 @@ internal enum FunctionId
SolutionCreator_AssetDifferences,
Extension_InfoBar,
Experiment_ABTesting,
AssetStorage_ForceGC,
RemoteHost_Bitness,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

namespace Microsoft.CodeAnalysis.Remote
{
internal class WellKnownRemoteHostServices
internal static class WellKnownRemoteHostServices
{
public const string RemoteHostService = "remoteHostService";
public static void Set64bit(bool x64)
{
RemoteHostService = "remoteHostService" + (x64 ? "64" : "");
}

public static string RemoteHostService { get; private set; } = "remoteHostService";
}
}
20 changes: 14 additions & 6 deletions src/Workspaces/Core/Portable/Remote/WellKnownServiceHubServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ namespace Microsoft.CodeAnalysis.Remote
{
internal static class WellKnownServiceHubServices
{
public const string ServiceHubServiceBase_Initialize = "Initialize";
public static void Set64bit(bool x64)
{
var bit = x64 ? "64" : "";

SnapshotService = "snapshotService" + bit;
CodeAnalysisService = "codeAnalysisService" + bit;
RemoteSymbolSearchUpdateEngine = "remoteSymbolSearchUpdateEngine" + bit;
}

public const string SnapshotService = "snapshotService";
public const string CodeAnalysisService = "codeAnalysisService";
public const string RemoteSymbolSearchUpdateEngine = "remoteSymbolSearchUpdateEngine";
public static string SnapshotService { get; private set; } = "snapshotService";
public static string CodeAnalysisService { get; private set; } = "codeAnalysisService";
public static string RemoteSymbolSearchUpdateEngine { get; private set; } = "remoteSymbolSearchUpdateEngine";

// CodeLens methods.
public const string CodeAnalysisService_GetReferenceCountAsync = "GetReferenceCountAsync";
public const string CodeAnalysisService_FindReferenceLocationsAsync = "FindReferenceLocationsAsync";
public const string CodeAnalysisService_FindReferenceMethodsAsync = "FindReferenceMethodsAsync";
public const string CodeAnalysisService_GetFullyQualifiedName = "GetFullyQualifiedName";

public const string CodeAnalysisService_CalculateDiagnosticsAsync = "CalculateDiagnosticsAsync";

public const string ServiceHubServiceBase_Initialize = "Initialize";
public const string AssetService_RequestAssetAsync = "RequestAssetAsync";

public const string CodeAnalysisService_CalculateDiagnosticsAsync = "CalculateDiagnosticsAsync";
}
}
Loading

0 comments on commit dd8516b

Please sign in to comment.