private void CleanWorkspaceMemory() { if (!m_collectMemoryAsSoonAsPossible) { return; } // Clean up pools used by parsing/typechecking. TypeScript.Net.Utilities.Pools.Clear(); var weakReference = GetWorkspaceAnchorAndReleaseWorkspace(); if (weakReference == null) { Logger.FrontEndWorkspaceMemoryCollectionSkipped(LoggingContext, "Can't find a weak reference pointing to parsed source file"); // Nothing to do, workspace is empty. return; } GC.Collect(); if (weakReference.IsAlive) { Logger.FrontEndWorkspaceMemoryNotCollected(LoggingContext); } else { Logger.FrontEndWorkspaceMemoryCollectedSuccessfully(LoggingContext); } if (FrontEndConfiguration.FailIfWorkspaceMemoryIsNotCollected()) { Contract.Assert(!weakReference.IsAlive, "Failed to collect workspace"); } }
private void CleanWorkspaceMemory() { if (!m_collectMemoryAsSoonAsPossible) { return; } // Clean up pools used by parsing/typechecking. TypeScript.Net.Utilities.Pools.Clear(); var weakReference = GetWorkspaceAnchorAndReleaseWorkspace(); if (weakReference == null) { // Nothing to do, workspace is empty. return; } GC.Collect(); if (FrontEndConfiguration.FailIfWorkspaceMemoryIsNotCollected()) { Contract.Assert(!weakReference.IsAlive, "Failed to collect workspace"); } }
/// <summary> /// Tries to create a filtered workspace based on a front-end snapshot from the previous BuildXL invocation. /// </summary> /// <returns> /// * Possibke<ValidConstructedWorkspace> when the workspace was successfully constructed. /// * Possible<null> when the snapshot was unaiable. /// * Failure when the snapshot was available but parsing failed. /// </returns> private async Task <Possible <Workspace> > TryCreateFilteredWorkspaceAsync(Possible <WorkspaceDefinition> workspaceDefinition, IWorkspaceProvider workspaceProvider, FrontEndEngineAbstraction engineAbstraction, EvaluationFilter evaluationFilter) { if (!FrontEndConfiguration.ConstructAndSaveBindingFingerprint()) { Logger.FailToReuseFrontEndSnapshot( LoggingContext, "Binding fingerprint is disabled. Please use 'constructAndSaveBindingFingerprint' option to turn it on"); return(default(Possible <Workspace>)); } // If a filter cannot be performed and public facade + AST is not to be used, then there is no point in continuing and we can // go to full mode if (!evaluationFilter.CanPerformPartialEvaluationScript(PrimaryConfigFile) && !CanUseSpecPublicFacadeAndAst()) { var message = !CanUseSpecPublicFacadeAndAst() ? "Engine state was not reloaded" : "User filter was not specified"; Logger.FailToReuseFrontEndSnapshot(LoggingContext, message); return(default(Possible <Workspace>)); } var changedFiles = engineAbstraction.GetChangedFiles()?.ToList(); if (changedFiles == null) { Logger.FailToReuseFrontEndSnapshot(LoggingContext, "Change journal is not available"); return(default(Possible <Workspace>)); } using (var sw = Watch.Start()) { // We're potentially in incremental mode. var filteredDefinitionResult = await TryFilterWorkspaceDefinitionIncrementallyAsync( changedFiles, workspaceProvider, workspaceDefinition.Result, evaluationFilter); if (filteredDefinitionResult.Failed) { return(filteredDefinitionResult.Failure); } if (filteredDefinitionResult.Filtered) { var filteredDefinition = filteredDefinitionResult.FilteredDefinition; Logger.WorkspaceDefinitionFiltered( LoggingContext, filteredDefinition.SpecCount, workspaceDefinition.Result.SpecCount, sw.ElapsedMilliseconds); // TODO: with C# 7, use tuple instead of changing the workspace to carry the information about the filtering. return(await workspaceProvider.CreateWorkspaceAsync(filteredDefinition, userFilterWasApplied : true)); } } return(default(Possible <Workspace>)); }
internal ArcConfiguration(StorageType?artifactsStorageType, string artifactStorageClassName, string artifactStorageMountPath, string artifactStorageNodeName, string artifactStorageAccessMode, FrontEndConfiguration frontEndServiceConfiguration, string kubeConfig) { ArtifactsStorageType = artifactsStorageType; ArtifactStorageClassName = artifactStorageClassName; ArtifactStorageMountPath = artifactStorageMountPath; ArtifactStorageNodeName = artifactStorageNodeName; ArtifactStorageAccessMode = artifactStorageAccessMode; FrontEndServiceConfiguration = frontEndServiceConfiguration; KubeConfig = kubeConfig; }
private List <ModuleDefinition> GetModulesAndSpecsToEvaluate(EvaluationFilter evaluationFilter) { if ( // Module filter can be applied without /enableIncrementalFrontEnd+ evaluationFilter.ModulesToResolve.Count != 0 || (evaluationFilter.CanPerformPartialEvaluationScript(PrimaryConfigFile) && FrontEndConfiguration.EnableIncrementalFrontEnd())) { var workspaceFilter = new WorkspaceFilter(FrontEndContext.PathTable); return(workspaceFilter.FilterForEvaluation(Workspace, evaluationFilter)); } // The prelude is never part of the build extent var allModules = Workspace.SpecModules.ToList(); // Under an Office build, the default source resolver defines the build extent. Otherwise, all modules are used var moduleExtent = FrontEndConfiguration.UseLegacyOfficeLogic() ? FindModulesConstitutingLegacyBuildExtent(allModules) : allModules; return(moduleExtent.Select(m => m.Definition).ToList()); }
private void UpdateAndSaveSnapshot(Possible <ISourceFile>[] parseResults, IWorkspaceBindingSnapshot snapshot) { if (!FrontEndConfiguration.ConstructAndSaveBindingFingerprint()) { return; } foreach (var sourceFile in parseResults) { ISourceFile source = sourceFile.Result; Contract.Assert(source.BindingSymbols != null, "source.BindingSymbols != null"); snapshot.UpdateBindingFingerprint( source.GetAbsolutePath(FrontEndContext.PathTable), source.BindingSymbols.ReferencedSymbolsFingerprint, source.BindingSymbols.DeclaredSymbolsFingerprint); } SaveFrontEndSnapshot(snapshot); }
private bool TryGetPackageFromFromDisk(PackageIdentity package, AbsolutePath packageFolder, string weakPackageFingerprint, out Possible <PackageDownloadResult> possibleResult, out PackageHashFile?packageHash) { // There are two options that control this behavior: // /forcePopulatePackageCache and /usePackagesFromFileSystemOnly if (FrontEndConfiguration.UsePackagesFromFileSystem()) { if (TryGetPackageFromFromDiskOnly(package, packageFolder, out var fromFile, out packageHash)) { possibleResult = fromFile; } else { possibleResult = new PackageShouldBeOnDiskFailure(package.GetFriendlyName(), packageFolder.ToString(PathTable)); } // If /usePackagesFromFileSystemOnly is specified, nothing except file check should happen. // Return true to stop the other lookups (like cache or nuget). return(true); }
/// <summary> /// Logs all parsing and local binding errors. /// </summary> private void ReportWorkspaceParsingAndBindingErrorsIfNeeded(Workspace workspace) { if (workspace == null || workspace.Succeeded || workspace.IsCanceled) { return; } // It is relatively hard to stop analysis when the error limit is reached. // For now, the limit is applied only on the error reporting stage. foreach (var error in workspace.GetAllParsingAndBindingErrors().Take(FrontEndConfiguration.ErrorLimit())) { ReportSyntaxError(error); } // TODO: current design is not good. // Consider following: we're getting 10 errors during workspace construction. // Next line will print just one error and all other will just sit in memory. // Then writing generic error message that workspace computation failed m_logger.CannotBuildWorkspace(LoggingContext, workspace.Failures.First().Describe()); }
private void LogWorkspaceSemanticErrors(ISemanticModel semanticModel) { // It is relatively hard to stop analysis when the error limit is reached. // For now, the limit is applied only on the error reporting stage. foreach (var semanticError in semanticModel.GetAllSemanticDiagnostics().Take(FrontEndConfiguration.ErrorLimit())) { ReportSemanticError(semanticError); } // Then writing generic error message that workspace computation failed m_logger.CannotBuildWorkspace(LoggingContext, "One or more error occurred during workspace analysis. See output for more details."); }
private EvaluatorConfiguration CreateEvaluatorConfiguration() { return(new EvaluatorConfiguration( FrontEndConfiguration.TrackMethodInvocations(), TimeSpan.FromSeconds(FrontEndConfiguration.CycleDetectorStartupDelay()))); }
public ControllerActionConfiguration() : base() { FrontEnd = new FrontEndConfiguration(); }