protected override void AssertPipGraphContent(PipGraph pipGraph, SimpleGraph file2file, StringTable stringTable)
        {
            AssertPipGraphCounts(pipGraph, new Dictionary <PipType, int>
            {
                [PipType.Process]       = file2file.NodeCount,
                [PipType.SealDirectory] = file2file.NodeCount,
            });
            var processPips = pipGraph.RetrievePipsOfType(PipType.Process).ToList();

            // assert edges exist
            Assert.All(
                file2file.Edges,
                edge =>
            {
                var errPrefix = $"Edge ({edge.Src})->({edge.Dest}) not found: ";
                var srcPip    = FindPipByTag(processPips, GetProcTag(edge.Src), stringTable);
                var destPip   = FindPipByTag(processPips, GetProcTag(edge.Dest), stringTable);
                var producedSealDirectoryPips = pipGraph.RetrievePipImmediateDependents(destPip).Where(pip => pip.PipType == PipType.SealDirectory).ToList();
                XAssert.AreEqual(1, producedSealDirectoryPips.Count, $"{errPrefix} expected to find exactly one SealDirectory dependency of Process Pip {destPip}");
                var producedSealDirectoryPip = producedSealDirectoryPips.First();
                var deps = pipGraph.RetrievePipImmediateDependents(producedSealDirectoryPip);
                if (!deps.Contains(srcPip))
                {
                    XAssert.Fail($"{errPrefix} expected edges between {srcPip} <-- {producedSealDirectoryPip} <-- {destPip}; dependencies of Pip {producedSealDirectoryPip} are: {XAssert.SetToString(deps)}");
                }
            });
        }
Example #2
0
        protected override void AssertPipGraphContent(PipGraph pipGraph, SimpleGraph file2file, StringTable stringTable)
        {
            var serviceSpecDependents    = Join(new[] { ServiceSpecIndex }, Inverse(file2file.Edges));
            var nonServiceSpecDependents = file2file.Nodes.Except(new[] { ServiceSpecIndex }).Except(serviceSpecDependents).ToList();

            AssertPipGraphCounts(pipGraph, new Dictionary <PipType, int>
            {
                [PipType.Process] = 3 + nonServiceSpecDependents.Count, // service pip, service shutdown pip, and service finalize pip in 'serviceSpec' non-dependent specs of 'serviceSpec'
                [PipType.Ipc]     = 1 + serviceSpecDependents.Count,    // one IPC pip in 'serviceSpec' and one in each of its dependents
            });
            var ipcPips           = pipGraph.RetrievePipsOfType(PipType.Ipc).Cast <IpcPip>().ToList();
            var processAndIpcPips = pipGraph.RetrievePipsOfType(PipType.Process).Concat(ipcPips).ToList();

            AssertEdges(pipGraph, file2file, processAndIpcPips, stringTable);
            AssertMonikerConsistencyForIpcPip(ipcPips, pipGraph);
        }
Example #3
0
        public override void Prepare()
        {
            Directory.CreateDirectory(OutputFilePath);
            m_writer = new StreamWriter(Path.Combine(OutputFilePath, "results.txt"));

            Console.WriteLine("Creating nodes");

            foreach (var node in DataflowGraph.Nodes)
            {
                m_mutableGraph.CreateNode();
            }

            Console.WriteLine("Created nodes");

            foreach (var entry in PipGraph.AllOutputDirectoriesAndProducers)
            {
                var sealId = PipGraph.GetSealedDirectoryNode(entry.Key).ToPipId();
                m_dynamicDirectoryProducers[sealId] = entry.Value;
            }

            foreach (CopyFile copyFile in PipGraph.RetrievePipsOfType(PipType.CopyFile))
            {
                m_copiedFilesByTarget[copyFile.Destination] = copyFile.Source;
            }

            foreach (var directory in PipGraph.AllSealDirectories)
            {
                var sealId   = PipGraph.GetSealedDirectoryNode(directory).ToPipId();
                var sealKind = PipTable.GetSealDirectoryKind(sealId);

                // Populate map of whether this is a source only seal
                IsSourceOnlySeal(sealId);

                if (sealKind == SealDirectoryKind.Full || sealKind == SealDirectoryKind.Partial)
                {
                    PipId?singleProducer = null;
                    foreach (var file in PipGraph.ListSealedDirectoryContents(directory))
                    {
                        if (file.IsOutputFile)
                        {
                            var producer = PipGraph.TryGetProducer(file);
                            if (singleProducer == null)
                            {
                                singleProducer = producer;
                            }
                            else if (singleProducer != producer)
                            {
                                singleProducer = PipId.Invalid;
                            }
                        }
                    }

                    if (singleProducer.HasValue && singleProducer.Value.IsValid)
                    {
                        m_dynamicDirectoryProducers[sealId] = singleProducer.Value;
                    }
                }
            }
        }
Example #4
0
        protected override void AssertPipGraphContent(PipGraph pipGraph, SimpleGraph file2file, StringTable stringTable)
        {
            AssertPipGraphCounts(pipGraph, new Dictionary <PipType, int>
            {
                [PipType.Process] = file2file.NodeCount,
            });
            var processPips = pipGraph.RetrievePipsOfType(PipType.Process).ToList();

            AssertEdges(pipGraph, file2file, processPips, stringTable);
        }
Example #5
0
        protected override void AssertPipGraphContent(PipGraph pipGraph, SimpleGraph file2file, StringTable stringTable)
        {
            AssertPipGraphCounts(pipGraph, new Dictionary <PipType, int>
            {
                [PipType.Process] = file2file.NodeCount * 3, // service pip, service shutdown pip, and service finalize pip in each file
                [PipType.Ipc]     = file2file.NodeCount,     // one IPC pip per file
            });
            var ipcPips = pipGraph.RetrievePipsOfType(PipType.Ipc).ToList();

            AssertEdges(pipGraph, file2file, ipcPips, stringTable);
            AssertMonikerConsistencyForIpcPip(ipcPips.Cast <IpcPip>(), pipGraph);
        }
Example #6
0
        /// <nodoc />
        internal DebugLogsAnalyzer(AnalysisInput input, int port, bool enableCaching, bool ensureOrdering, bool preHydrateProcessPips = true)
            : base(input)
        {
            m_port                 = port;
            EnableEvalCaching      = enableCaching;
            EnsureOrdering         = ensureOrdering;
            XlgState               = new XlgDebuggerState(this);
            m_dirData              = new MultiValueDictionary <AbsolutePath, DirectoryMembershipHashedEventData>();
            m_criticalPathAnalyzer = new CriticalPathAnalyzer(input, outputFilePath: null);
            m_lazyCriticalPath     = Lazy.Create(() =>
            {
                m_criticalPathAnalyzer.Analyze();
                return(m_criticalPathAnalyzer.criticalPathData);
            });
            m_state           = new DebuggerState(PathTable, LoggingContext, XlgState.Render, XlgState);
            m_lazyPipPerfDict = new Lazy <Dictionary <PipId, PipExecutionPerformance> >(() =>
            {
                return(m_writeExecutionEntries.ToDictionary(e => e.PipId, e => e.ExecutionPerformance));
            });
            m_lazyPipsBySemiStableHash = new Lazy <Dictionary <long, PipId> >(() =>
            {
                var result = new Dictionary <long, PipId>();
                foreach (var pipId in PipTable.Keys)
                {
                    result[PipTable.GetPipSemiStableHash(pipId)] = pipId;
                }
                return(result);
            });

            if (preHydrateProcessPips)
            {
                Task
                .Run(() =>
                {
                    var start = DateTime.UtcNow;
                    Console.WriteLine("=== Started hydrating process pips");
                    Analysis.IgnoreResult(PipGraph.RetrievePipsOfType(Pips.Operations.PipType.Process).ToArray());
                    Console.WriteLine("=== Done hydrating process pips in " + DateTime.UtcNow.Subtract(start));
                })
                .Forget(ex =>
                {
                    Console.WriteLine("=== Prehydrating pips failed: " + ex);
                });
            }
        }