Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple size test #81517

Merged
merged 4 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -12,6 +13,36 @@ static int Main()
{
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
Copy link
Member

@am11 am11 Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux window is 1.5-2.0 MB. Should we shrink this to 3.0-3.5 MB? (it is currently somewhere between 3.0 to 3.1 on osx-arm64: 3217960 bytes / 3.06 Mebibyte with v8.0.0-preview.2.23102.7)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OSX test will likely cross the 3.0 threshold downward soon. No point dealing with that - this is approximated by the Linux size test. OSX size is not in our 8.0 release criteria.

}
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' != 'x64'">true</CLRTestTargetUnsupported>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);BASELINE_INTRINSICS</DefineConstants>
<StripSymbols>true</StripSymbols>
MichalStrehovsky marked this conversation as resolved.
Show resolved Hide resolved

<!-- We should be able to delete once CI machines no longer use ancient LLVM -->
<ObjCopyName>objcopy</ObjCopyName>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' != 'x64'">true</CLRTestTargetUnsupported>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);NON_VEX_INTRINSICS</DefineConstants>
<StripSymbols>true</StripSymbols>
MichalStrehovsky marked this conversation as resolved.
Show resolved Hide resolved

<!-- We should be able to delete once CI machines no longer use ancient LLVM -->
<ObjCopyName>objcopy</ObjCopyName>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' != 'x64'">true</CLRTestTargetUnsupported>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);VEX_INTRINSICS</DefineConstants>
<StripSymbols>true</StripSymbols>
MichalStrehovsky marked this conversation as resolved.
Show resolved Hide resolved

<!-- We should be able to delete once CI machines no longer use ancient LLVM -->
<ObjCopyName>objcopy</ObjCopyName>
</PropertyGroup>

<ItemGroup>
Expand Down