Esempio n. 1
0
        internal static ProcessPipExecutionPerformance Deserialize(BuildXLReader reader, PipExecutionLevel level, DateTime executionStart, DateTime executionStop, uint workerId)
        {
            var fingerprint = FingerprintUtilities.CreateFrom(reader);

            TimeSpan processExecutionTime = reader.ReadTimeSpan();
            FileMonitoringViolationCounters fileMonitoringViolations = ReadFileMonitoringViolationCounters(reader);
            IOCounters            ioCounters     = IOCounters.Deserialize(reader);
            TimeSpan              userTime       = reader.ReadTimeSpan();
            TimeSpan              kernelTime     = reader.ReadTimeSpan();
            ProcessMemoryCounters memoryCounters = ProcessMemoryCounters.Deserialize(reader);

            uint numberOfProcesses = reader.ReadUInt32Compact();

            return(new ProcessPipExecutionPerformance(
                       fingerprint: fingerprint,
                       level: level,
                       executionStart: executionStart,
                       executionStop: executionStop,
                       processExecutionTime: processExecutionTime,
                       fileMonitoringViolations: fileMonitoringViolations,
                       ioCounters: ioCounters,
                       userTime: userTime,
                       kernelTime: kernelTime,
                       memoryCounters: memoryCounters,
                       numberOfProcesses: numberOfProcesses,
                       workerId: workerId));
        }
        private static Fingerprint CreateFakeFingerprint(byte seed)
        {
            byte[] b = new byte[FingerprintUtilities.FingerprintLength];
            for (int i = 0; i < b.Length; i++)
            {
                b[i] = seed;
            }

            return(FingerprintUtilities.CreateFrom(b));
        }
Esempio n. 3
0
        private static (WeakContentFingerprint wf, StrongContentFingerprint sf) GetBuildManifestHashKey(ContentHash hash)
        {
            var hashBytes = hash.ToByteArray();

            Array.Resize(ref hashBytes, FingerprintUtilities.FingerprintLength);
            var wf = new WeakContentFingerprint(FingerprintUtilities.CreateFrom(hashBytes));
            var sf = new StrongContentFingerprint(wf.Hash);

            return(wf, sf);
        }
Esempio n. 4
0
        private static Fingerprint TwiddleHashByte(Fingerprint fingerprint, int index)
        {
            Contract.Requires(index >= 0 && index < FingerprintUtilities.FingerprintLength);

            var buffer = new byte[FingerprintUtilities.FingerprintLength];

            fingerprint.Serialize(buffer);
            buffer[index] = unchecked ((byte)~buffer[index]);

            return(FingerprintUtilities.CreateFrom(buffer));
        }
Esempio n. 5
0
        private void VerifyFingerprintText(Action <HashingHelper, PathTable> addStream, string expectedText)
        {
            // Need a trailing newline for even a single item.
            expectedText = expectedText + "\r\n";

            var pathTable = new PathTable();

            using (var withText = new HashingHelper(pathTable, recordFingerprintString: true))
            {
                addStream(withText, pathTable);

                Fingerprint actualHash = FingerprintUtilities.CreateFrom(withText.GenerateHash().ToByteArray());
                string      actualText = withText.FingerprintInputText;

                XAssert.AreEqual(expectedText, actualText, "Fingerprint text mismatched.");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Tries to deserialize a graph fingerprint from the <paramref name="reader"/>.
        /// </summary>
        public static CompositeGraphFingerprint Deserialize(BinaryReader reader)
        {
            CompositeGraphFingerprint fingerprint = Zero;

            fingerprint.OverallFingerprint = new ContentFingerprint(reader);
            fingerprint.BuildEngineHash    = FingerprintUtilities.CreateFrom(reader);
            fingerprint.ConfigFileHash     = FingerprintUtilities.CreateFrom(reader);
            fingerprint.QualifierHash      = FingerprintUtilities.CreateFrom(reader);
            fingerprint.FilterHash         = FingerprintUtilities.CreateFrom(reader);

            bool filterExists = reader.ReadBoolean();

            if (filterExists)
            {
                fingerprint.EvaluationFilter = BuildXL.Pips.Filter.EvaluationFilter.Deserialize(reader);
            }

            return(fingerprint);
        }
        private static async Task <Possible <PublishedEntryRef, Failure> > AdaptPublishedEntry(Task <Possible <StrongFingerprint, Failure> > cacheCoreEntryPromise, PublishedEntryRefLocality locality)
        {
            Possible <StrongFingerprint, Failure> maybeFingerprint = await cacheCoreEntryPromise;

            if (maybeFingerprint.Succeeded)
            {
                StrongFingerprint fingerprint = maybeFingerprint.Result;

                if (fingerprint is StrongFingerprintSentinel)
                {
                    return(PublishedEntryRef.Ignore);
                }

                return(new PublishedEntryRef(
                           pathSetHash: ContentHashingUtilities.CreateFrom(fingerprint.CasElement.ToArray()),
                           strongFingerprint: new StrongContentFingerprint(FingerprintUtilities.CreateFrom(fingerprint.HashElement.ToArray())),
                           oringinatingCache: fingerprint.CacheId,
                           locality: locality));
            }

            return(maybeFingerprint.Failure);
        }
Esempio n. 8
0
 /// <nodoc />
 public ContentFingerprint(BinaryReader reader)
 {
     Hash = FingerprintUtilities.CreateFrom(reader);
 }
Esempio n. 9
0
 /// <summary>
 /// Returns a generic <see cref="ContentFingerprint"/> (not distinguished as strong or weak).
 /// TODO: The generic fingerprint type can go away as soon as we *only* do two-phase (weak -> strong) lookups;
 ///       as of writing we are transitioning.
 /// </summary>
 public ContentFingerprint ToGenericFingerprint()
 {
     return(new ContentFingerprint(FingerprintUtilities.CreateFrom(Hash.ToByteArray())));
 }
Esempio n. 10
0
 private static Fingerprint ReadFingerprint(this BinaryReader reader)
 {
     return(FingerprintUtilities.CreateFrom(reader));
 }
Esempio n. 11
0
 /// <summary>
 /// Generates the final hash value for the whole fingerprint stream.
 /// </summary>
 public Fingerprint GenerateHash()
 {
     byte[] res = GenerateHashBytes();
     return(FingerprintUtilities.CreateFrom(res));
 }
Esempio n. 12
0
 /// <summary>
 /// Reads fingerprints.
 /// </summary>
 internal static ContentFingerprint ReadContentFingerprint(this BinaryReader reader, byte[] buffer)
 {
     Array.Clear(buffer, 0, buffer.Length);
     reader.Read(buffer, 0, FingerprintUtilities.FingerprintLength);
     return(new ContentFingerprint(FingerprintUtilities.CreateFrom(buffer)));
 }