Skip to content

Commit b6f9c90

Browse files
author
Oleksii Kononenko
committed
Merged PR 730784: Revert "Merged PR 727953: More robust execution-log event serialization
Revert "Merged PR 727953: More robust execution-log event serialization This PR makes serialization of execution-log event serialization more robust by handling the exception, e.g., OutOfMemory exception, that can happen during serialization. In the case of an exception, the event is skipped, and users are given a warning about this. Related work items: #2081944" Reverted commit `e2ca19cb`. Related work items: #2081944
1 parent c51e769 commit b6f9c90

File tree

6 files changed

+92
-355
lines changed

6 files changed

+92
-355
lines changed

Public/Src/Engine/Scheduler/Tracing/ExecutionLog.Events.cs

Lines changed: 17 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ public interface IExecutionLogTarget : IDisposable
129129
/// Build Manifest hash and relative file path is reported
130130
/// </summary>
131131
void RecordFileForBuildManifest(RecordFileForBuildManifestEventData data);
132-
133-
/// <summary>
134-
/// Test custom event. Used only by unit tests.
135-
/// </summary>
136-
void TestCustom(TestCustomEventData data);
137132
}
138133

139134
/// <summary>
@@ -220,11 +215,6 @@ public enum ExecutionEventId : byte
220215
/// See <see cref="IExecutionLogTarget.DynamicDirectoryContentsDecided"/>
221216
/// </summary>
222217
DynamicDirectoryContentsDecided = 16,
223-
224-
/// <summary>
225-
/// See <see cref="IExecutionLogTarget.TestCustom"/>
226-
/// </summary>
227-
TestCustom = 17,
228218
}
229219

230220
/// <summary>
@@ -354,36 +344,27 @@ public static class ExecutionLogMetadata
354344
ExecutionEventId.RecordFileForBuildManifest,
355345
(data, target) => target.RecordFileForBuildManifest(data));
356346

357-
/// <summary>
358-
/// Event description for <see cref="IExecutionLogTarget.PipExecutionDirectoryOutputs"/>
359-
/// </summary>
360-
public static readonly ExecutionLogEventMetadata<TestCustomEventData> TestCustom =
361-
new ExecutionLogEventMetadata<TestCustomEventData>(
362-
ExecutionEventId.TestCustom,
363-
(data, target) => target.TestCustom(data));
364-
365347
/// <summary>
366348
/// All execution log events.
367349
/// </summary>
368350
public static readonly IReadOnlyList<ExecutionLogEventMetadata> Events = new ExecutionLogEventMetadata[]
369-
{
370-
BxlInvocation,
371-
FileArtifactContentDecided,
372-
WorkerList,
373-
PipExecutionPerformance,
374-
DirectoryMembershipHashed,
375-
ProcessExecutionMonitoringReported,
376-
BuildSessionConfiguration,
377-
DependencyViolationReported,
378-
PipExecutionStepPerformanceReported,
379-
ProcessFingerprintComputation,
380-
PipCacheMiss,
381-
PipExecutionDirectoryOutputs,
382-
CacheMaterializationError,
383-
RecordFileForBuildManifest,
384-
DynamicDirectoryContentsDecided,
385-
TestCustom,
386-
};
351+
{
352+
BxlInvocation,
353+
FileArtifactContentDecided,
354+
WorkerList,
355+
PipExecutionPerformance,
356+
DirectoryMembershipHashed,
357+
ProcessExecutionMonitoringReported,
358+
BuildSessionConfiguration,
359+
DependencyViolationReported,
360+
PipExecutionStepPerformanceReported,
361+
ProcessFingerprintComputation,
362+
PipCacheMiss,
363+
PipExecutionDirectoryOutputs,
364+
CacheMaterializationError,
365+
RecordFileForBuildManifest,
366+
DynamicDirectoryContentsDecided
367+
};
387368
}
388369

389370
/// <summary>
@@ -1482,30 +1463,4 @@ public void DeserializeAndUpdate(BinaryLogReader.EventReader reader)
14821463
r => (reader.ReadFileArtifact(), new ContentHash(reader)));
14831464
}
14841465
}
1485-
1486-
/// <summary>
1487-
/// Custom event for testing purposes.
1488-
/// </summary>
1489-
[SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")]
1490-
public struct TestCustomEventData : IExecutionLogEventData<TestCustomEventData>
1491-
{
1492-
/// <summary>
1493-
/// Custom serialization function.
1494-
/// </summary>
1495-
public static Action<BinaryLogger.EventWriter> SerializeFunc;
1496-
1497-
/// <summary>
1498-
/// Custom deserialization function.
1499-
/// </summary>
1500-
public static Action<BinaryLogReader.EventReader> DeserializeAndUpdateFunc;
1501-
1502-
/// <inheritdoc />
1503-
public ExecutionLogEventMetadata<TestCustomEventData> Metadata => ExecutionLogMetadata.TestCustom;
1504-
1505-
/// <inheritdoc />
1506-
public void DeserializeAndUpdate(BinaryLogReader.EventReader reader) => DeserializeAndUpdateFunc(reader);
1507-
1508-
/// <inheritdoc />
1509-
public void Serialize(BinaryLogger.EventWriter writer) => SerializeFunc(writer);
1510-
}
15111466
}

Public/Src/Engine/Scheduler/Tracing/ExecutionLog.cs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Diagnostics.ContractsLight;
77
using System.IO;
8+
using BuildXL.Utilities;
89
using BuildXL.Utilities.Core;
910
using BuildXL.Utilities.Tracing;
1011
using static BuildXL.Utilities.Core.FormattableStringEx;
@@ -241,12 +242,6 @@ public virtual void DynamicDirectoryContentsDecided(DynamicDirectoryContentsDeci
241242
{
242243
ReportUnhandledEvent(data);
243244
}
244-
245-
/// <nodoc />
246-
public virtual void TestCustom(TestCustomEventData data)
247-
{
248-
ReportUnhandledEvent(data);
249-
}
250245
}
251246

252247
/// <summary>
@@ -266,7 +261,10 @@ public abstract class ExecutionLogEventMetadata
266261
public readonly ExecutionEventId EventId;
267262

268263
/// <nodoc />
269-
protected ExecutionLogEventMetadata(ExecutionEventId eventId) => EventId = eventId;
264+
protected ExecutionLogEventMetadata(ExecutionEventId eventId)
265+
{
266+
EventId = eventId;
267+
}
270268

271269
/// <summary>
272270
/// Translates a serialized stream containing an event (of this type) into an invocation on an <see cref="IExecutionLogTarget"/>.
@@ -295,7 +293,7 @@ public ExecutionLogEventMetadata(ExecutionEventId eventId, Action<TEventData, IE
295293
/// <inheritdoc />
296294
public override void DeserializeAndLogToTarget(BinaryLogReader.EventReader eventReader, IExecutionLogTarget target)
297295
{
298-
TEventData data = default;
296+
TEventData data = default(TEventData);
299297
data.DeserializeAndUpdate(eventReader);
300298
m_process(data, target);
301299
}
@@ -387,19 +385,7 @@ private void Log<TEventData>(TEventData data) where TEventData : struct, IExecut
387385
{
388386
using (BinaryLogger.EventScope eventScope = m_logFile.StartEvent((uint)data.Metadata.EventId, m_workerId))
389387
{
390-
391-
try
392-
{
393-
data.Serialize(eventScope.Writer);
394-
}
395-
catch (Exception e)
396-
{
397-
// Set exception so that event is not serialized to the log file.
398-
eventScope.SetException(e);
399-
400-
// Inform users that an event is not logged due to an exception.
401-
Logger.Log.FailedLoggingExecutionLogEventData(Events.StaticContext, data.Metadata.EventId.ToString(), e.ToString());
402-
}
388+
data.Serialize(eventScope.Writer);
403389
}
404390
}
405391

Public/Src/Engine/Scheduler/Tracing/Log.cs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,31 +3975,22 @@ internal abstract void ProcessPipExecutionInfo(
39753975
internal abstract void UnableToMonitorDriveWithSubst(LoggingContext loggingContext, string path, string drive);
39763976

39773977
[GeneratedEvent(
3978-
(ushort)LogEventId.SchedulerCompleteExceptMaterializeOutputs,
3979-
EventGenerators = EventGenerators.LocalOnly,
3980-
EventLevel = Level.Verbose,
3981-
Keywords = (int)Keywords.UserMessage,
3982-
EventTask = (ushort)Tasks.Scheduler,
3983-
Message = "The scheduler has been marked completed except for MaterializeOutput pip steps")]
3978+
(ushort)LogEventId.SchedulerCompleteExceptMaterializeOutputs,
3979+
EventGenerators = EventGenerators.LocalOnly,
3980+
EventLevel = Level.Verbose,
3981+
Keywords = (int)Keywords.UserMessage,
3982+
EventTask = (ushort)Tasks.Scheduler,
3983+
Message = "The scheduler has been marked completed except for MaterializeOutput pip steps")]
39843984
internal abstract void SchedulerCompleteExceptMaterializeOutputs(LoggingContext loggingContext);
39853985

39863986
[GeneratedEvent(
3987-
(ushort)LogEventId.CreationTimeNotSupported,
3988-
EventGenerators = EventGenerators.LocalOnly,
3989-
EventLevel = Level.Verbose,
3990-
Keywords = (int)Keywords.UserMessage,
3991-
EventTask = (ushort)Tasks.Scheduler,
3992-
Message = "File creation time retrieval is not supported by the underlying operating system. Some optimizations will be disabled.")]
3987+
(ushort)LogEventId.CreationTimeNotSupported,
3988+
EventGenerators = EventGenerators.LocalOnly,
3989+
EventLevel = Level.Verbose,
3990+
Keywords = (int)Keywords.UserMessage,
3991+
EventTask = (ushort)Tasks.Scheduler,
3992+
Message = "File creation time retrieval is not supported by the underlying operating system. Some optimizations will be disabled.")]
39933993
internal abstract void CreationTimeNotSupported(LoggingContext loggingContext);
3994-
3995-
[GeneratedEvent(
3996-
(ushort)LogEventId.FailedLoggingExecutionLogEventData,
3997-
EventGenerators = EventGenerators.LocalOnly,
3998-
EventLevel = Level.Warning,
3999-
Keywords = (int)Keywords.UserMessage,
4000-
EventTask = (ushort)Tasks.Scheduler,
4001-
Message = "Failed logging execution log event data '{eventId}'. This does not impact build correctness but will cause the execution log to be incomplete for post-build analysis. Failure reason: {error}")]
4002-
internal abstract void FailedLoggingExecutionLogEventData(LoggingContext loggingContext, string eventId, string error);
40033994
}
40043995
}
40053996
#pragma warning restore CA1823 // Unused field

Public/Src/Engine/Scheduler/Tracing/LogEventId.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ public enum LogEventId : ushort
520520
FailedToDeserializeLRUMap = 14536,
521521

522522
CreationTimeNotSupported = 14537,
523-
FailedLoggingExecutionLogEventData = 14538,
524523

525524
// was DependencyViolationGenericWithRelatedPip_AsError = 25000,
526525
// was DependencyViolationGeneric_AsError = 25001,

0 commit comments

Comments
 (0)