1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-11 10:18:21 +09:00

Add a simple size test (#81517)

The size of Hello World is currently 1.8 MB. This is achieved by avoiding any non-field reflection in the codepaths that are part of a hello world. If reflection comes into picture, the size jumps by several 100 kB because suddenly we need a lot of code to support that. This is a smoke test to detect those situations. We're getting proper size testing in the dotnet/performance repo with trend histories, etc., but the invariant for Hello World is easy to check for and nice to gate commits on.
This commit is contained in:
Michal Strehovský 2023-02-07 11:48:42 +09:00 committed by GitHub
parent 6b882b474a
commit b39d6a6eb4
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 1 deletions

View file

@ -1,8 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
@ -12,6 +13,36 @@ unsafe class Program
{
s_success = true;
#if !DEBUG
Console.WriteLine("****************************************************");
Console.WriteLine("* Size test *");
long fileSize = new System.IO.FileInfo(Environment.ProcessPath).Length;
Console.WriteLine($"* Size of the executable is {fileSize / 1024,7:n0} kB *");
Console.WriteLine("****************************************************");
const int Meg = 1024 * 1024;
const int HalfMeg = Meg / 2;
long lowerBound, upperBound;
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
lowerBound = 2 * Meg; // 2 MB
upperBound = 4 * Meg; // 4 MB
}
else
{
lowerBound = Meg + HalfMeg; // 1.5 MB
upperBound = 2 * Meg; // 2 MB
}
if (fileSize < lowerBound || fileSize > upperBound)
{
Console.WriteLine("BUG: File size is not in the expected range. Did a libraries change regress size of Hello World?");
return 1;
}
Console.WriteLine();
#endif
// We expect the AOT compiler generated HW intrinsics with the following characteristics:
//
// * TRUE = IsSupported assumed to be true, no runtime check

View file

@ -6,6 +6,10 @@
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' != 'x64'">true</CLRTestTargetUnsupported>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);BASELINE_INTRINSICS</DefineConstants>
<StripSymbols>true</StripSymbols>
<!-- We should be able to delete once CI machines no longer use ancient LLVM -->
<ObjCopyName>objcopy</ObjCopyName>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />

View file

@ -6,6 +6,10 @@
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' != 'x64'">true</CLRTestTargetUnsupported>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);NON_VEX_INTRINSICS</DefineConstants>
<StripSymbols>true</StripSymbols>
<!-- We should be able to delete once CI machines no longer use ancient LLVM -->
<ObjCopyName>objcopy</ObjCopyName>
</PropertyGroup>
<ItemGroup>

View file

@ -6,6 +6,10 @@
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' != 'x64'">true</CLRTestTargetUnsupported>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);VEX_INTRINSICS</DefineConstants>
<StripSymbols>true</StripSymbols>
<!-- We should be able to delete once CI machines no longer use ancient LLVM -->
<ObjCopyName>objcopy</ObjCopyName>
</PropertyGroup>
<ItemGroup>