You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do have a quick idea about it.
Does it require an entry in performance repo?
Or, just let me practice to follow the workflow of comparing performance between branches?
@jkotas question: what's the correct way to run benchmark against locally built clr and corelib? I cannot find a documentation that's confidentially up-to-date.
Here's my steps:
Create a BenchmarkDotNet project. Half is included in latest shipped preview SDK, so no additional step is required here.
Modify implementation
build.cmd -c release -rc release
dotnet run -c Release --corerun D:\Code\dotnet\runtime\artifacts\bin\testhost\net5.0-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\6.0.0\CoreRun.exe
But I'm afraid I've got something wrong:
The benchmark result is very close after implementation change.
After adding [DisassemblyDiagnoser], the asm looks like master branch, instead of changed one (contains call System.Half.op_Equality that's removed)
If I do a clean build by deleting the whole artifact folder and build.cmd -c release -rc release, the benchmark will run against latest bits.
If I just delete the testhost folder and build.cmd clr.corelib+libs+libs.pretest -c Release -rc Release, the benchmark will run against last clean build.
Change 2 is faster for bitwise equals scenarios, but a bit slower for unequals.
And also, there should be measurable error for change2, because the MaxValue and NaN tests are both bitwise equals scenario, but there measured performance differs.
Do you have a preference between equality performance and inequality performance?
Base on the pattern used in operator ==, I will choose change2 for PR.
Using constants like this for benchmarking may not be representative. If the JIT was perfect, it would optimize this into just returning true. You may want to double check that optimizations like this are not affecting your measurements. It is better to use arguments passed into the benchmarking method to avoid optimizations skewing the numbers.
We generally prefer the style in change1.
The performance difference between these two variants may not be be durable. Both variants can lead to equally well performing code if the JIT was perfect.
Using constants like this for benchmarking may not be representative. If the JIT was perfect, it would optimize this into just returning true. You may want to double check that optimizations like this are not affecting your measurements. It is better to use arguments passed into the benchmarking method to avoid optimizations skewing the numbers.
We generally prefer the style in change1.
After changing to ArgumentsSource, style 1 is getting better performance. PR opened with style 1.
The open question is about usage of AggressiveInlining.
Activity
Dotnet-GitSync-Bot commentedon Aug 25, 2020
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
jkotas commentedon Aug 25, 2020
@huoyaoyuan Are you interested in working on this?
huoyaoyuan commentedon Aug 25, 2020
I do have a quick idea about it.
Does it require an entry in performance repo?
Or, just let me practice to follow the workflow of comparing performance between branches?
jkotas commentedon Aug 25, 2020
Submitting performance tests to performance repo is encouraged, but not required.
huoyaoyuan commentedon Aug 29, 2020
@jkotas question: what's the correct way to run benchmark against locally built clr and corelib? I cannot find a documentation that's confidentially up-to-date.
Here's my steps:
Halfis included in latest shipped preview SDK, so no additional step is required here.build.cmd -c release -rc releasedotnet run -c Release --corerun D:\Code\dotnet\runtime\artifacts\bin\testhost\net5.0-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\6.0.0\CoreRun.exeBut I'm afraid I've got something wrong:
[DisassemblyDiagnoser], the asm looks like master branch, instead of changed one (containscall System.Half.op_Equalitythat's removed)huoyaoyuan commentedon Aug 29, 2020
It seems to be influenced by step3:
artifactfolder andbuild.cmd -c release -rc release, the benchmark will run against latest bits.testhostfolder andbuild.cmd clr.corelib+libs+libs.pretest -c Release -rc Release, the benchmark will run against last clean build.jkotas commentedon Aug 29, 2020
@adamsitnik What is the best way to run performance tests on CoreLib updates?
Also, I have noticed that the local instructions we have for running performance tests are outdated: https://github.com/dotnet/runtime/blob/master/docs/project/performance-guidelines.md#running-the-coreclr-performance-tests-on-windows
huoyaoyuan commentedon Aug 29, 2020
Here are benchmark and runs:
Runs on master:
Change1:
Change2:
Change1 is:
Change2 is:
Change 2 is faster for bitwise equals scenarios, but a bit slower for unequals.
And also, there should be measurable error for change2, because the
MaxValueandNaNtests are both bitwise equals scenario, but there measured performance differs.Do you have a preference between equality performance and inequality performance?
Base on the pattern used in
operator ==, I will choose change2 for PR.jkotas commentedon Aug 29, 2020
Using constants like this for benchmarking may not be representative. If the JIT was perfect, it would optimize this into just returning true. You may want to double check that optimizations like this are not affecting your measurements. It is better to use arguments passed into the benchmarking method to avoid optimizations skewing the numbers.
We generally prefer the style in change1.
The performance difference between these two variants may not be be durable. Both variants can lead to equally well performing code if the JIT was perfect.
huoyaoyuan commentedon Aug 29, 2020
A full benchmark
Code:
Implementations:
V1:
V2:
V3:
Inline:
Adding
[MethodImpl(MethodImplOptions.AggressiveInlining)]huoyaoyuan commentedon Aug 29, 2020
Test instructions I've used:
testhostfolder for multiple times.Build.cmd clr.corelib -c release. This is quite fast.System.Private.CoreLib.dllfromartifacts\bin\coreclr\Windows_NT.x64.Release\IL, hinted by console output.dotnet run -c Release --corerun change1\CoreRun.exe change2\CoreRun.exe ...BenchmarkDotNet is unable to distinguish to different
NaNs. Others are just finely grouped.huoyaoyuan commentedon Aug 29, 2020
After changing to
ArgumentsSource, style 1 is getting better performance. PR opened with style 1.The open question is about usage of
AggressiveInlining.adamsitnik commentedon Aug 31, 2020
https://github.com/dotnet/performance/blob/master/docs/benchmarking-workflow-dotnet-runtime.md#Preventing-Regressions
Thanks for pointing this out, I've sent a PR with an update: #41583