Print additional runtime diagnostics on server startup.

Brought to you by "I went insane debugging something stupid my own fault for 30 minutes"
This commit is contained in:
Pieter-Jan Briers
2023-12-28 02:27:50 +01:00
parent a891cacae5
commit be2e31ff9d
4 changed files with 196 additions and 145 deletions

View File

@@ -1,15 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using Robust.Client.Graphics;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
using Robust.Shared.Utility;
using X86Aes = System.Runtime.Intrinsics.X86.Aes;
using ArmAes = System.Runtime.Intrinsics.Arm.Aes;
namespace Robust.Client.UserInterface.CustomControls.DebugMonitorControls;
@@ -36,139 +28,6 @@ internal sealed class DebugSystemPanel : PanelContainer
HorizontalAlignment = HAlignment.Left;
var version = typeof(DebugSystemPanel).Assembly.GetName().Version;
contents.Text = @$"OS: {RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture}
.NET Runtime: {RuntimeInformation.FrameworkDescription} {RuntimeInformation.RuntimeIdentifier}
Server GC: {GCSettings.IsServerGC}
Processor: {Environment.ProcessorCount}x {SystemInformation.GetProcessorModel()}
Architecture: {RuntimeInformation.ProcessArchitecture}
Robust Version: {version}
Compile Options: {GetCompileOptions()}
Intrinsics: {GetIntrinsics()}";
}
private static string GetCompileOptions()
{
var options = new List<string>();
#if DEVELOPMENT
options.Add("DEVELOPMENT");
#endif
#if FULL_RELEASE
options.Add("FULL_RELEASE");
#endif
#if TOOLS
options.Add("TOOLS");
#endif
#if DEBUG
options.Add("DEBUG");
#endif
#if RELEASE
options.Add("RELEASE");
#endif
#if EXCEPTION_TOLERANCE
options.Add("EXCEPTION_TOLERANCE");
#endif
#if CLIENT_SCRIPTING
options.Add("CLIENT_SCRIPTING");
#endif
#if USE_SYSTEM_SQLITE
options.Add("USE_SYSTEM_SQLITE");
#endif
return string.Join(';', options);
}
private static string GetIntrinsics()
{
var options = new List<string>();
// - No put the oof back, hello?
// x86
if (X86Aes.IsSupported)
options.Add(nameof(X86Aes));
if (Avx.IsSupported)
options.Add(nameof(Avx));
if (Avx2.IsSupported)
options.Add(nameof(Avx2));
if (Bmi1.IsSupported)
options.Add(nameof(Bmi1));
if (Bmi2.IsSupported)
options.Add(nameof(Bmi2));
if (Fma.IsSupported)
options.Add(nameof(Fma));
if (Lzcnt.IsSupported)
options.Add(nameof(Lzcnt));
if (Pclmulqdq.IsSupported)
options.Add(nameof(Pclmulqdq));
if (Popcnt.IsSupported)
options.Add(nameof(Popcnt));
if (Sse.IsSupported)
options.Add(nameof(Sse));
if (Sse2.IsSupported)
options.Add(nameof(Sse2));
if (Sse3.IsSupported)
options.Add(nameof(Sse3));
if (Ssse3.IsSupported)
options.Add(nameof(Ssse3));
if (Sse41.IsSupported)
options.Add(nameof(Sse41));
if (Sse42.IsSupported)
options.Add(nameof(Sse42));
if (X86Base.IsSupported)
options.Add(nameof(X86Base));
// ARM
if (AdvSimd.IsSupported)
options.Add(nameof(AdvSimd));
if (ArmAes.IsSupported)
options.Add(nameof(ArmAes));
if (ArmBase.IsSupported)
options.Add(nameof(ArmBase));
if (Crc32.IsSupported)
options.Add(nameof(Crc32));
if (Dp.IsSupported)
options.Add(nameof(Dp));
if (Rdm.IsSupported)
options.Add(nameof(Rdm));
if (Sha1.IsSupported)
options.Add(nameof(Sha1));
if (Sha256.IsSupported)
options.Add(nameof(Sha256));
return string.Join(';', options);
contents.Text = string.Join('\n', RuntimeInformationPrinter.GetInformationDump());
}
}

View File

@@ -41,8 +41,10 @@ internal static class ProgramShared
internal static void PrintRuntimeInfo(ISawmill sawmill)
{
sawmill.Debug($"Runtime: {RuntimeInformation.FrameworkDescription} {RuntimeInformation.RuntimeIdentifier}");
sawmill.Debug($"OS: {RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture}");
foreach (var line in RuntimeInformationPrinter.GetInformationDump())
{
sawmill.Debug(line);
}
}
internal static void DoMounts(IResourceManagerInternal res, MountOptions? options, string contentBuildDir, ResPath assembliesPath, bool loadContentResources = true,

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Runtime;
using System.Runtime.InteropServices;
namespace Robust.Shared.Utility;
internal static class RuntimeInformationPrinter
{
public static string[] GetInformationDump()
{
var version = typeof(RuntimeInformationPrinter).Assembly.GetName().Version;
return new[]
{
$"OS: {RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture}",
$".NET Runtime: {RuntimeInformation.FrameworkDescription} {RuntimeInformation.RuntimeIdentifier}",
$"Server GC: {GCSettings.IsServerGC}",
$"Processor: {Environment.ProcessorCount}x {SystemInformation.GetProcessorModel()}",
$"Architecture: {RuntimeInformation.ProcessArchitecture}",
$"Robust Version: {version}",
$"Compile Options: {string.Join(';', GetCompileOptions())}",
$"Intrinsics: {string.Join(';', SystemInformation.GetIntrinsics())}",
};
}
private static List<string> GetCompileOptions()
{
var options = new List<string>();
#if DEVELOPMENT
options.Add("DEVELOPMENT");
#endif
#if FULL_RELEASE
options.Add("FULL_RELEASE");
#endif
#if TOOLS
options.Add("TOOLS");
#endif
#if DEBUG
options.Add("DEBUG");
#endif
#if RELEASE
options.Add("RELEASE");
#endif
#if EXCEPTION_TOLERANCE
options.Add("EXCEPTION_TOLERANCE");
#endif
#if CLIENT_SCRIPTING
options.Add("CLIENT_SCRIPTING");
#endif
#if USE_SYSTEM_SQLITE
options.Add("USE_SYSTEM_SQLITE");
#endif
return options;
}
}

View File

@@ -1,8 +1,13 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.Wasm;
using System.Runtime.Intrinsics.X86;
using System.Text;
using X86Aes = System.Runtime.Intrinsics.X86.Aes;
using ArmAes = System.Runtime.Intrinsics.Arm.Aes;
namespace Robust.Shared.Utility;
@@ -87,4 +92,124 @@ internal static class SystemInformation
nint* oldlenp,
void* newp,
nint newlen);
public static List<string> GetIntrinsics()
{
var options = new List<string>();
// - No put the oof back, hello?
// x86
if (X86Aes.IsSupported)
options.Add(nameof(X86Aes));
if (Avx.IsSupported)
options.Add(nameof(Avx));
if (Avx2.IsSupported)
options.Add(nameof(Avx2));
if (Avx512BW.IsSupported)
options.Add(nameof(Avx512BW));
if (Avx512BW.VL.IsSupported)
options.Add(nameof(Avx512BW) + ".VL");
if (Avx512CD.IsSupported)
options.Add(nameof(Avx512CD));
if (Avx512CD.VL.IsSupported)
options.Add(nameof(Avx512CD) + ".VL");
if (Avx512DQ.IsSupported)
options.Add(nameof(Avx512DQ));
if (Avx512DQ.VL.IsSupported)
options.Add(nameof(Avx512DQ) + ".VL");
if (Avx512F.IsSupported)
options.Add(nameof(Avx512F));
if (Avx512F.VL.IsSupported)
options.Add(nameof(Avx512F) + ".VL");
if (Avx512Vbmi.IsSupported)
options.Add(nameof(Avx512Vbmi));
if (Avx512Vbmi.VL.IsSupported)
options.Add(nameof(Avx512Vbmi) + ".VL");
if (Bmi1.IsSupported)
options.Add(nameof(Bmi1));
if (Bmi2.IsSupported)
options.Add(nameof(Bmi2));
if (Fma.IsSupported)
options.Add(nameof(Fma));
if (Lzcnt.IsSupported)
options.Add(nameof(Lzcnt));
if (Pclmulqdq.IsSupported)
options.Add(nameof(Pclmulqdq));
if (Popcnt.IsSupported)
options.Add(nameof(Popcnt));
if (Sse.IsSupported)
options.Add(nameof(Sse));
if (Sse2.IsSupported)
options.Add(nameof(Sse2));
if (Sse3.IsSupported)
options.Add(nameof(Sse3));
if (Ssse3.IsSupported)
options.Add(nameof(Ssse3));
if (Sse41.IsSupported)
options.Add(nameof(Sse41));
if (Sse42.IsSupported)
options.Add(nameof(Sse42));
if (X86Base.IsSupported)
options.Add(nameof(X86Base));
// ARM
if (AdvSimd.IsSupported)
options.Add(nameof(AdvSimd));
if (ArmAes.IsSupported)
options.Add(nameof(ArmAes));
if (ArmBase.IsSupported)
options.Add(nameof(ArmBase));
if (Crc32.IsSupported)
options.Add(nameof(Crc32));
if (Dp.IsSupported)
options.Add(nameof(Dp));
if (Rdm.IsSupported)
options.Add(nameof(Rdm));
if (Sha1.IsSupported)
options.Add(nameof(Sha1));
if (Sha256.IsSupported)
options.Add(nameof(Sha256));
// WASM
if (PackedSimd.IsSupported)
options.Add(nameof(PackedSimd));
return options;
}
}