-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,285 additions
and
903 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Ultra.Core/Model/Markers/GCAllocationTickTraceMarker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
namespace Ultra.Core.Model; | ||
|
||
/// <summary> | ||
/// Represents a garbage collection allocation tick profile marker. | ||
/// </summary> | ||
public record GCAllocationTickTraceMarker : UTraceMarker | ||
{ | ||
/// <summary> | ||
/// Gets or sets the amount of memory allocated. | ||
/// </summary> | ||
public long AllocationAmount { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the kind of allocation. | ||
/// </summary> | ||
public string? AllocationKind { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the type name of the allocated object. | ||
/// </summary> | ||
public string? TypeName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the index of the heap where the allocation occurred. | ||
/// </summary> | ||
public int HeapIndex { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
namespace Ultra.Core.Model; | ||
|
||
/// <summary> | ||
/// Represents a garbage collection heap stats event marker payload for Firefox Profiler. | ||
/// </summary> | ||
public record GCHeapStatsTraceMarker : UTraceMarker | ||
{ | ||
/// <summary> | ||
/// Gets or sets the total heap size. | ||
/// </summary> | ||
public long TotalHeapSize { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the total promoted size. | ||
/// </summary> | ||
public long TotalPromoted { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the size of generation 0. | ||
/// </summary> | ||
public long GenerationSize0 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the total promoted size of generation 0. | ||
/// </summary> | ||
public long TotalPromotedSize0 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the size of generation 1. | ||
/// </summary> | ||
public long GenerationSize1 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the total promoted size of generation 1. | ||
/// </summary> | ||
public long TotalPromotedSize1 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the size of generation 2. | ||
/// </summary> | ||
public long GenerationSize2 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the total promoted size of generation 2. | ||
/// </summary> | ||
public long TotalPromotedSize2 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the size of generation 3. | ||
/// </summary> | ||
public long GenerationSize3 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the total promoted size of generation 3. | ||
/// </summary> | ||
public long TotalPromotedSize3 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the size of generation 4. | ||
/// </summary> | ||
public long GenerationSize4 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the total promoted size of generation 4. | ||
/// </summary> | ||
public long TotalPromotedSize4 { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the finalization promoted size. | ||
/// </summary> | ||
public long FinalizationPromotedSize { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the finalization promoted count. | ||
/// </summary> | ||
public long FinalizationPromotedCount { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the pinned object count. | ||
/// </summary> | ||
public int PinnedObjectCount { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the sink block count. | ||
/// </summary> | ||
public int SinkBlockCount { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the GC handle count. | ||
/// </summary> | ||
public int GCHandleCount { get; set; } | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Ultra.Core/Model/Markers/GCRestartExecutionEngineTraceMarker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
namespace Ultra.Core.Model; | ||
|
||
/// <summary> | ||
/// Represents an event that indicates the .NET garbage collector has restarted the execution engine. | ||
/// </summary> | ||
public record GCRestartExecutionEngineTraceMarker : UTraceMarker; |
21 changes: 21 additions & 0 deletions
21
src/Ultra.Core/Model/Markers/GCSuspendExecutionEngineTraceMarker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
namespace Ultra.Core.Model; | ||
|
||
/// <summary> | ||
/// Represents an event that marks the suspension of the execution engine by the garbage collector. | ||
/// </summary> | ||
public record GCSuspendExecutionEngineTraceMarker : UTraceMarker | ||
{ | ||
/// <summary> | ||
/// Gets or sets the reason for the suspension. | ||
/// </summary> | ||
public string? Reason { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the count of suspensions. | ||
/// </summary> | ||
public int Count { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
namespace Ultra.Core.Model; | ||
|
||
/// <summary> | ||
/// Represents a garbage collection event marker payload for Firefox Profiler. | ||
/// </summary> | ||
public record GCTraceMarker : UTraceMarker | ||
{ | ||
/// <summary> | ||
/// Gets or sets the reason for the garbage collection. | ||
/// </summary> | ||
public string? Reason { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the count of garbage collections. | ||
/// </summary> | ||
public int Count { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the depth of the garbage collection. | ||
/// </summary> | ||
public int Depth { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the type of garbage collection. | ||
/// </summary> | ||
public string? GCType { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
namespace Ultra.Core.Model; | ||
|
||
/// <summary> | ||
/// Represents a JIT compile event marker payload for the Firefox Profiler. | ||
/// </summary> | ||
public record JitCompileTraceMarker : UTraceMarker | ||
{ | ||
/// <summary> | ||
/// Gets or sets the full name of the method. | ||
/// </summary> | ||
public required string FullName { get; init; } | ||
|
||
/// <summary> | ||
/// Gets or sets the IL size of the method. | ||
/// </summary> | ||
public int MethodILSize { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
namespace Ultra.Core.Model; | ||
|
||
/// <summary> | ||
/// Represents an address in the traced process. | ||
/// </summary> | ||
public readonly record struct UAddress(ulong Value) : IComparable<UAddress>, IComparable | ||
{ | ||
/// <inheritdoc /> | ||
public override string ToString() => $"0x{Value:X}"; | ||
|
||
/// <summary> | ||
/// Adds an offset to the address. | ||
/// </summary> | ||
public static UAddress operator +(UAddress address, ulong offset) => new(address.Value + offset); | ||
|
||
/// <summary> | ||
/// Subtracts an offset from the address. | ||
/// </summary> | ||
public static UAddress operator -(UAddress address, ulong offset) => new(address.Value - offset); | ||
|
||
/// <summary> | ||
/// Adds an offset to the address. | ||
/// </summary> | ||
public static UAddress operator +(UAddress address, long offset) => new(address.Value + (ulong)offset); | ||
|
||
/// <summary> | ||
/// Subtracts an offset from the address. | ||
/// </summary> | ||
public static UAddress operator -(UAddress address, long offset) => new(address.Value - (ulong)offset); | ||
|
||
/// <summary> | ||
/// Adds an offset to the address. | ||
/// </summary> | ||
public static UAddress operator +(UAddress address, int offset) => new(address.Value + (ulong)offset); | ||
|
||
/// <summary> | ||
/// Subtracts an offset from the address. | ||
/// </summary> | ||
public static UAddress operator -(UAddress address, int offset) => new(address.Value - (ulong)offset); | ||
|
||
/// <summary> | ||
/// Subtracts two addresses to return the size difference. | ||
/// </summary> | ||
public static USize operator -(UAddress left, UAddress right) => new(left.Value - right.Value); | ||
|
||
/// <summary> | ||
/// Implicit conversion to <see cref="ulong"/>. | ||
/// </summary> | ||
public static implicit operator ulong(UAddress address) => address.Value; | ||
|
||
/// <summary> | ||
/// Explicit conversion from <see cref="ulong"/>. | ||
/// </summary> | ||
public static implicit operator UAddress(ulong value) => new(value); | ||
|
||
/// <inheritdoc /> | ||
public int CompareTo(UAddress other) | ||
{ | ||
return Value.CompareTo(other.Value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public int CompareTo(object? obj) | ||
{ | ||
if (obj is null) | ||
{ | ||
return 1; | ||
} | ||
|
||
return obj is UAddress other ? CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(UAddress)}"); | ||
} | ||
|
||
/// <summary> | ||
/// Compares two addresses for less than. | ||
/// </summary> | ||
public static bool operator <(UAddress left, UAddress right) | ||
{ | ||
return left.CompareTo(right) < 0; | ||
} | ||
|
||
/// <summary> | ||
/// Compares two addresses for greater than. | ||
/// </summary> | ||
public static bool operator >(UAddress left, UAddress right) | ||
{ | ||
return left.CompareTo(right) > 0; | ||
} | ||
|
||
/// <summary> | ||
/// Compares two addresses for less than or equal. | ||
/// </summary> | ||
public static bool operator <=(UAddress left, UAddress right) | ||
{ | ||
return left.CompareTo(right) <= 0; | ||
} | ||
|
||
/// <summary> | ||
/// Compares two addresses for greater than or equal. | ||
/// </summary> | ||
public static bool operator >=(UAddress left, UAddress right) | ||
{ | ||
return left.CompareTo(right) >= 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// Licensed under the BSD-Clause 2 license. | ||
// See license.txt file in the project root for full license information. | ||
|
||
using System.Runtime.CompilerServices; | ||
using XenoAtom.Collections; | ||
|
||
namespace Ultra.Core.Model; | ||
|
||
/// <summary> | ||
/// Represents an address range in the traced process. | ||
/// </summary> | ||
public readonly record struct UAddressRange(UAddress BeginAddress, UAddress EndAddress, int Index) | ||
{ | ||
/// <summary> | ||
/// Determines if the address is contained within the range. | ||
/// </summary> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public bool Contains(ulong address) => address >= BeginAddress && address < EndAddress; | ||
} | ||
|
||
/// <summary> | ||
/// Represents a comparer for address ranges. | ||
/// </summary> | ||
readonly record struct UAddressRangeFinder(ulong Address) : IComparable<UAddressRange> | ||
{ | ||
/// <summary> | ||
/// Compares the address range finder with another address range. | ||
/// </summary> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public int CompareTo(UAddressRange other) | ||
{ | ||
return other.Contains(Address) ? 0 : Address.CompareTo(other.BeginAddress); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Represents a comparer for address ranges based on their beginning address. | ||
/// </summary> | ||
readonly record struct UAddressRangeComparer : IComparerByRef<UAddressRange> | ||
{ | ||
/// <summary> | ||
/// Compares two address ranges for less than. | ||
/// </summary> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public bool LessThan(in UAddressRange left, in UAddressRange right) => left.BeginAddress < right.BeginAddress; | ||
} |
Oops, something went wrong.