bool IsUserInitiatedSync(SyncReason reason) { if (SyncReason.Win_UserRequest < reason && reason < SyncReason.Win_MaximumWaitReason) { return(false); } return(true); }
bool IsUserInitiatedSync(SyncReason reason) { if (reason == SyncReason.Win_UserRequest || reason == SyncReason.Win_DelayExecution) { return(true); } return(false); }
public SyncEvent(BinaryReader reader) { Timestamp = new Tick() { Start = Durable.ReadTime(reader) }; OldThreadID = reader.ReadUInt64(); NewThreadID = reader.ReadUInt64(); CPUID = reader.ReadByte(); Reason = (SyncReason)reader.ReadByte(); }
public override string ToString() { var sb = new StringBuilder("ShouldSyncException("); bool __first = true; if (__isset.syncOpRevision) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("SyncOpRevision: "); SyncOpRevision.ToString(sb); } if (SyncScope != null && __isset.syncScope) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("SyncScope: "); SyncScope.ToString(sb); } if (__isset.syncReason) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("SyncReason: "); SyncReason.ToString(sb); } if (Message != null && __isset.message) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Message: "); Message.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
bool IsUserInitiatedSync(SyncReason reason) { if (reason <= SyncReason.Win_Count) { return(reason <= SyncReason.Win_UserRequest); } if (reason <= SyncReason.Pthread_Count) { // VS TODO: Find out proper user\kernel pre-emption mapping return(true); // (reason == SyncReason.Pthread_InterruptibleSleep) || (reason == SyncReason.Pthread_UninterruptibleSleep); } if (reason <= SyncReason.SWT_COUNT) { if (reason == SyncReason.SWT_PREEMPT || reason == SyncReason.SWT_OWEPREEMPT || reason == SyncReason.SWT_NEEDRESCHED) { return(false); } } return(true); }
public override int GetHashCode() { int hashcode = 157; unchecked { if (__isset.syncOpRevision) { hashcode = (hashcode * 397) + SyncOpRevision.GetHashCode(); } if (__isset.syncScope) { hashcode = (hashcode * 397) + SyncScope.GetHashCode(); } if (__isset.syncReason) { hashcode = (hashcode * 397) + SyncReason.GetHashCode(); } if (__isset.message) { hashcode = (hashcode * 397) + Message.GetHashCode(); } } return(hashcode); }
public override void OnMouseHover(Point point, ThreadScroll scroll, List <object> dataContext) { EventNode node = null; EventFrame frame = null; ITick tick = scroll.PixelToTime(point.X); if (FindNode(point, scroll, out frame, out node) != -1) { dataContext.Add(node); } // show current sync info if (EventData.Sync != null && EventData.Sync != null) { int index = Data.Utils.BinarySearchClosestIndex(EventData.Sync, tick.Start); if (index != -1) { bool insideWaitInterval = false; WaitInterval interval = new WaitInterval() { Start = EventData.Sync[index].Finish, Reason = EventData.Sync[index].Reason }; if (index + 1 < EventData.Sync.Count) { if (EventData.Sync[index].Finish < tick.Start && tick.Start < EventData.Sync[index + 1].Start) { UInt64 threadId = EventData.Sync[index].NewThreadId; ThreadDescription threadDesc = null; Group.Board.ThreadDescriptions.TryGetValue(threadId, out threadDesc); interval.newThreadDesc = threadDesc; interval.newThreadId = threadId; interval.Finish = EventData.Sync[index + 1].Start; dataContext.Add(interval); insideWaitInterval = true; } } if (!insideWaitInterval) { interval.Reason = SyncReason.SyncReasonActive; interval.Start = EventData.Sync[index].Start; interval.Finish = EventData.Sync[index].Finish; interval.core = (byte)EventData.Sync[index].Core; dataContext.Add(interval); } } } if (node != null) { // build all intervals inside selected node int from = Data.Utils.BinarySearchClosestIndex(frame.Synchronization, node.Entry.Start); int to = Data.Utils.BinarySearchClosestIndex(frame.Synchronization, node.Entry.Finish); if (from >= 0 && to >= from) { IntPair[] waitInfo = new IntPair[(int)SyncReason.SyncReasonCount]; for (int index = from; index <= to; ++index) { SyncReason reason = frame.Synchronization[index].Reason; int reasonIndex = (int)reason; long idleStart = frame.Synchronization[index].Finish; long idleFinish = (index + 1 < frame.Synchronization.Count) ? frame.Synchronization[index + 1].Start : frame.Finish; if (idleStart > node.Entry.Finish) { continue; } long idleStartClamped = Math.Max(idleStart, node.Entry.Start); long idleFinishClamped = Math.Min(idleFinish, node.Entry.Finish); long durationInTicks = idleFinishClamped - idleStartClamped; waitInfo[reasonIndex].duration += durationInTicks; waitInfo[reasonIndex].count++; } NodeWaitIntervalList intervals = new NodeWaitIntervalList(); for (int i = 0; i < waitInfo.Length; i++) { if (waitInfo[i].count > 0) { NodeWaitInterval interval = new NodeWaitInterval() { Start = 0, Finish = waitInfo[i].duration, Reason = (SyncReason)i, NodeInterval = node.Entry, Count = waitInfo[i].count }; intervals.Add(interval); } } intervals.Sort((a, b) => { return(Comparer <long> .Default.Compare(b.Finish, a.Finish)); }); if (intervals.Count > 0) { dataContext.Add(intervals); } } } // FindNode if (EventData.Callstacks != null && scroll.DrawCallstacks != 0) { int startIndex = Data.Utils.BinarySearchClosestIndex(EventData.Callstacks, tick.Start); for (int i = startIndex; (i <= startIndex + 1) && (i < EventData.Callstacks.Count) && (i != -1); ++i) { double pixelPos = scroll.TimeToPixel(EventData.Callstacks[i]); if (Math.Abs(pixelPos - point.X) < CallstackMarkerRadius * 1.2 && (EventData.Callstacks[i].Reason & scroll.DrawCallstacks) != 0) { dataContext.Add(EventData.Callstacks[i]); break; } } } }
public override void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll) { SetBusy(true); UpdateDepth(); // Build Mesh DirectX.ComplexDynamicMesh builder = new ComplexDynamicMesh(canvas, DIPSplitCount); DirectX.ComplexDynamicMesh syncBuilder = new ComplexDynamicMesh(canvas, DIPSplitCount); DirectX.ComplexDynamicMesh syncWorkBuilder = new ComplexDynamicMesh(canvas, DIPSplitCount); if (EventData.Sync != null && EventData.Sync != null) { SyncReason stallReason = SyncReason.SyncReasonCount; long stallFrom = 0; int frameSyncIndex = 0; for (int i = 0; i < EventData.Sync.Count; i++) { SyncInterval sync = EventData.Sync[i]; Interval workInterval = scroll.TimeToUnit(sync); //draw work int coreColorIndex = (int)sync.Core; coreColorIndex = coreColorIndex % WorkColors.Length; Color WorkColor = WorkColors[coreColorIndex]; syncWorkBuilder.AddRect(new Rect(workInterval.Left, 0, workInterval.Right - workInterval.Left, SyncLineHeight / Height), WorkColor); if (i == 0) { stallReason = sync.Reason; stallFrom = sync.Finish; continue; } long workStart = sync.Start; long workFinish = sync.Finish; while (frameSyncIndex < EventData.Events.Count && EventData.Events[frameSyncIndex].Finish < stallFrom) { ++frameSyncIndex; } //Ignoring all the waiting outside marked work to simplify the view if (frameSyncIndex < EventData.Events.Count && EventData.Events[frameSyncIndex].Start <= workStart) { Durable syncDurable = new Durable(stallFrom, workStart); Interval syncInterval = scroll.TimeToUnit(syncDurable); double syncWidth = syncInterval.Right - syncInterval.Left; if (syncWidth > 0) { // draw sleep Color waitColor = IsUserInitiatedSync(stallReason) ? SynchronizationColorUser : SynchronizationColor; syncBuilder.AddRect(new Rect(syncInterval.Left, 0, syncWidth, SyncLineHeight / Height), waitColor); } } stallFrom = workFinish; stallReason = sync.Reason; } } foreach (EventFrame frame in EventData.Events) { Durable interval = Group.Board.TimeSlice; EventTree tree = GetTree(frame); foreach (EventNode node in tree.Children) { BuildMeshNode(builder, scroll, node, 0); } } Blocks = builder.Freeze(canvas.RenderDevice); SyncMesh = syncBuilder.Freeze(canvas.RenderDevice); SyncWorkMesh = syncWorkBuilder.Freeze(canvas.RenderDevice); CallstackMeshPolys = canvas.CreateMesh(); CallstackMeshPolys.Projection = Mesh.ProjectionType.Pixel; CallstackMeshLines = canvas.CreateMesh(); CallstackMeshLines.Geometry = Mesh.GeometryType.Lines; CallstackMeshLines.Projection = Mesh.ProjectionType.Pixel; SetBusy(false); }
public override void BuildMesh(DirectX.DirectXCanvas canvas, ThreadScroll scroll) { // Build Mesh DirectX.DynamicMesh builder = canvas.CreateMesh(); DirectX.DynamicMesh syncBuilder = canvas.CreateMesh(); if (EventData.Sync != null && EventData.Sync.Intervals != null) { SyncReason stallReason = SyncReason.SyncReasonCount; long stallFrom = 0; for (int i = 0; i < EventData.Sync.Intervals.Count; i++) { SyncInterval sync = EventData.Sync.Intervals[i]; Interval workInterval = scroll.TimeToUnit(sync); // draw work int coreColorIndex = (int)sync.Core; coreColorIndex = coreColorIndex % WorkColors.Length; Color WorkColor = WorkColors[coreColorIndex]; syncBuilder.AddRect(new Rect(workInterval.Left, RenderParams.BaseMargin / Height, workInterval.Right - workInterval.Left, SyncLineHeight / Height), WorkColor); if (i == 0) { stallReason = sync.Reason; stallFrom = sync.Finish; continue; } long workStart = sync.Start; long workFinish = sync.Finish; Interval syncInterval = scroll.TimeToUnit(new Durable(stallFrom, workStart)); double syncWidth = syncInterval.Right - syncInterval.Left; if (syncWidth <= 0) { syncWidth = 0.1; } // draw sleep Color waitColor = IsUserInitiatedSync(stallReason) ? SynchronizationColorUser : SynchronizationColor; syncBuilder.AddRect(new Rect(syncInterval.Left, RenderParams.BaseMargin / Height, syncWidth, SyncLineHeight / Height), waitColor); stallFrom = workFinish; stallReason = sync.Reason; } } foreach (EventFrame frame in EventData.Events) { Durable interval = Group.Board.TimeSlice; foreach (EventNode node in frame.CategoriesTree.Children) { BuildMeshNode(builder, scroll, node, 0); } } Mesh = builder.Freeze(canvas.RenderDevice); SyncMesh = syncBuilder.Freeze(canvas.RenderDevice); CallstackMeshPolys = canvas.CreateMesh(); CallstackMeshLines = canvas.CreateMesh(); CallstackMeshLines.Geometry = Mesh.GeometryType.Lines; }