Esempio n. 1
0
 /// <nodoc />
 internal DebugLogsAnalyzer(AnalysisInput input, int port)
     : base(input)
 {
     XlgState = new XlgDebuggerState(this);
     m_criticalPathAnalyzer = new CriticalPathAnalyzer(input, outputFilePath: null);
     m_lazyCriticalPath     = Lazy.Create(() =>
     {
         m_criticalPathAnalyzer.Analyze();
         return(m_criticalPathAnalyzer.criticalPathData);
     });
     m_port            = port;
     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);
     });
 }
Esempio n. 2
0
        private void GetProcessDirectoryDependenciesContents()
        {
            Process process = null;

            foreach (var pipId in PipTable.StableKeys)
            {
                var possibleMatch = PipTable.GetPipSemiStableHash(pipId);
                if (possibleMatch == PipSemistableHash)
                {
                    process = (Process)GetPip(pipId);
                }
            }

            foreach (var directory in process.DirectoryDependencies)
            {
                m_writer.WriteLine(directory.Path.ToString(PathTable));
                foreach (var file in PipGraph.ListSealedDirectoryContents(directory))
                {
                    m_writer.WriteLine(file.Path.ToString(PathTable));
                }

                m_writer.WriteLine();
            }

            m_writer.Flush();
        }
Esempio n. 3
0
 /// <nodoc />
 internal DebugLogsAnalyzer(AnalysisInput input, int port, bool enableCaching, bool ensureOrdering)
     : 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);
     });
 }
Esempio n. 4
0
        /// <inheritdoc />
        public override void ProcessFingerprintComputed(ProcessFingerprintComputationEventData data)
        {
            var semistableHash = PipTable.GetPipSemiStableHash(data.PipId);

            if (!m_targetSemistableHashSet.Contains(semistableHash))
            {
                return;
            }

            var    formattedHash = Pip.FormatSemiStableHash(semistableHash);
            string outputFile    = GetOutputFileFromFormattedPipHash(formattedHash);

            using (var sw = new StreamWriter(outputFile, append: true))
            {
                var pipInfo = m_model.GetPipInfo(data.PipId);
                pipInfo.SetFingerprintComputation(data, CurrentEventWorkerId);

                sw.WriteLine(I($"Fingerprint kind: {data.Kind}"));
                WriteWeakFingerprintData(pipInfo, sw);

                foreach (var strongComputation in data.StrongFingerprintComputations)
                {
                    pipInfo.StrongFingerprintComputation = strongComputation;
                    WriteStrongFingerprintData(pipInfo, sw);
                }
            }
        }
Esempio n. 5
0
        public DumpPipLiteAnalyzer(AnalysisInput input, string outputDirectory, long semiStableHash, bool dumpObservedFileAccesses)
            : base(input)
        {
            if (string.IsNullOrEmpty(outputDirectory))
            {
                // Use the execution log path
                m_logPath = Path.Combine(Path.GetDirectoryName(input.ExecutionLogPath), "FailedPips");
            }
            else
            {
                m_logPath = Path.Combine(outputDirectory, "FailedPips");
            }

            m_pipTable = input.CachedGraph.PipTable;
            m_pipGraph = input.CachedGraph.PipGraph;
            m_dumpObservedFileAccesses = dumpObservedFileAccesses;
            m_dynamicData = null;

            foreach (var pipId in m_pipTable.StableKeys)
            {
                var possibleMatch = m_pipTable.GetPipSemiStableHash(pipId);
                if (possibleMatch == semiStableHash)
                {
                    m_pip = m_pipTable.HydratePip(pipId, PipQueryContext.DumpPipLiteAnalyzer);
                    break;
                }
            }

            if (m_pip == null)
            {
                // If no matches were found, then we likely got some bad input from the user.
                throw new InvalidArgumentException($"Specified Pip 'Pip{semiStableHash:X}' does not exist.");
            }
        }
Esempio n. 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);
                });
            }
        }
Esempio n. 7
0
        /// <inheritdoc />
        public override void ProcessFingerprintComputed(ProcessFingerprintComputationEventData data)
        {
            var semistableHash = PipTable.GetPipSemiStableHash(data.PipId);

            if (semistableHash != TargetSemistableHash)
            {
                return;
            }

            var pipInfo = m_model.GetPipInfo(data.PipId);

            pipInfo.SetFingerprintComputation(data, CurrentEventWorkerId);

            m_writer.WriteLine(I($"Fingerprint kind: {data.Kind}"));
            WriteWeakFingerprintData(pipInfo, m_writer);

            foreach (var strongComputation in data.StrongFingerprintComputations)
            {
                pipInfo.StrongFingerprintComputation = strongComputation;
                WriteStrongFingerprintData(pipInfo, m_writer);
            }
        }
Esempio n. 8
0
        /// <inheritdoc />
        public override int Analyze()
        {
            PipBasicInfoList.Clear();
            m_moduleIdToFriendlyName.Clear();
            foreach (var pipId in m_pipTable.Keys)
            {
                var pipType = m_pipTable.GetPipType(pipId);
                if (pipType == PipType.Process || pipType == PipType.CopyFile)
                {
                    var pipBasicInfo = new PipBasicInfo();
                    pipBasicInfo.pipId          = pipId.Value.ToString("X16", CultureInfo.InvariantCulture).TrimStart(new[] { '0' });
                    pipBasicInfo.semiStableHash = m_pipTable.GetPipSemiStableHash(pipId).ToString("X");
                    pipBasicInfo.pipType        = pipType.ToString();

                    var pip = m_pipTable.HydratePip(pipId, PipQueryContext.ViewerAnalyzer);
                    pipBasicInfo.shortDescription = pip.GetShortDescription(Input.CachedGraph.PipGraph.Context);

                    PipBasicInfoList.Add(pipBasicInfo);
                }
            }
            return(0);
        }
        /// <summary>
        /// Analyzes cache misses.
        /// </summary>
        public override int Analyze()
        {
            Console.WriteLine("Starting fingerprint store analysis at: " + DateTime.Now.ToString());
            if (!m_newReader.TryGetCacheMissList(out var cacheMissList))
            {
                WriteLine("Could not retrieve cache miss list for analysis. There may have been a failure during the build.");
                return(0);
            }

            Console.WriteLine("Finished getting list of pips that had a cache miss at: " + DateTime.Now.ToString());

            if (m_oldReader.StoreVersion != m_newReader.StoreVersion)
            {
                WriteLine($"WARNING: Format version numbers of the fingerprint store do not match. Old: {m_oldReader.StoreVersion}, New: {m_newReader.StoreVersion}.");
            }

            if (SemiStableHashToRun != -1)
            {
                var firstMiss = cacheMissList.FirstOrDefault(x => PipTable.GetPipSemiStableHash(x.PipId) == SemiStableHashToRun);
                if (firstMiss.CacheMissType == PipCacheMissType.Invalid)
                {
                    foreach (var pipId in PipTable.StableKeys)
                    {
                        var possibleMatch = PipTable.GetPipSemiStableHash(pipId);
                        if (possibleMatch == SemiStableHashToRun)
                        {
                            firstMiss = new PipCacheMissInfo(pipId, PipCacheMissType.Hit);
                        }
                    }
                }

                Console.WriteLine("Analyzing single pip starting at: " + DateTime.Now.ToString());

                AnalyzePip(firstMiss, HydratePip(firstMiss.PipId), m_writer);
            }
            else
            {
                var frontierCacheMissList = new List <PipCacheMissInfo>();
                foreach (var miss in cacheMissList)
                {
                    if (m_model.HasChangedDependencies(miss.PipId) && !AllPips)
                    {
                        continue;
                    }

                    frontierCacheMissList.Add(miss);
                    m_model.MarkChanged(miss.PipId);
                }

                Console.WriteLine("Finding frontier pips done at " + DateTime.Now.ToString());
                int i = 0;
                foreach (var miss in frontierCacheMissList)
                {
                    if (i % 10 == 0)
                    {
                        Console.WriteLine("Done " + i + " of " + cacheMissList.Count);
                    }

                    var pip = HydratePip(miss.PipId);
                    WriteLine($"================== Analyzing pip ========================");

                    AnalyzePip(miss, pip, m_writer);
                    WriteLine("================== Complete pip ========================");
                    WriteLine();
                    i++;
                }
            }

            return(0);
        }
Esempio n. 10
0
 private string ToDisplayString(PipId pipId)
 {
     return("pip" + PipTable.GetPipSemiStableHash(pipId).ToString("X16", CultureInfo.InvariantCulture));
 }