.Net 8 Poor performance on AMD cpu
-
On paper AMD Ryzen 5900x has twice horsepower than Intel i5-12400, though in single thread applications, 12400 is lightly better. So we checked this fact by a very simple winform application ( Net 8 - VS 2022 ver. 17.8.4 ):
List lv = new List();
listView1.Items.Clear();for (int i = 0; i < numericUpDown1.Value; i++)
{
ListViewItem item = new ListViewItem(i.ToString("D8"));
TestClass t = new TestClass(i);
item.Tag = t;
item.SubItems.Add(t.ID.ToString("D8"));
item.SubItems.Add(t.ID2.ToString("D8"));
item.SubItems.Add(t.ID3.ToString("D8"));
item.SubItems.Add(t.ID4.ToString("D8"));
lv.Add(item);
}listView1.BeginUpdate();
listView1.Items.AddRange(lv.ToArray());
listView1.EndUpdate();With
numericUpDown1.Value= 1_000_000
10 times benchmark, Intel cpu completed the task on average in 18 seconds. AMD cpu never completed the task below 60 seconds. Intel cpu setup: Win11 in VirtualBox with 6 cores 16 GB RAM ADATA NVME 2.0 disk AMD cpu setup: bare metal Win11 48 GB RAM SAMSUNG NVME 2.0 disk. What's wrong with AMD cpu? Who should we blame on issue: MS or AMD? Any idea? P.S.: I'm a hardcore fan of AMD.
Behzad
-
On paper AMD Ryzen 5900x has twice horsepower than Intel i5-12400, though in single thread applications, 12400 is lightly better. So we checked this fact by a very simple winform application ( Net 8 - VS 2022 ver. 17.8.4 ):
List lv = new List();
listView1.Items.Clear();for (int i = 0; i < numericUpDown1.Value; i++)
{
ListViewItem item = new ListViewItem(i.ToString("D8"));
TestClass t = new TestClass(i);
item.Tag = t;
item.SubItems.Add(t.ID.ToString("D8"));
item.SubItems.Add(t.ID2.ToString("D8"));
item.SubItems.Add(t.ID3.ToString("D8"));
item.SubItems.Add(t.ID4.ToString("D8"));
lv.Add(item);
}listView1.BeginUpdate();
listView1.Items.AddRange(lv.ToArray());
listView1.EndUpdate();With
numericUpDown1.Value= 1_000_000
10 times benchmark, Intel cpu completed the task on average in 18 seconds. AMD cpu never completed the task below 60 seconds. Intel cpu setup: Win11 in VirtualBox with 6 cores 16 GB RAM ADATA NVME 2.0 disk AMD cpu setup: bare metal Win11 48 GB RAM SAMSUNG NVME 2.0 disk. What's wrong with AMD cpu? Who should we blame on issue: MS or AMD? Any idea? P.S.: I'm a hardcore fan of AMD.
Behzad
Blame it on the Bossa Nova[^] Sorry it's Saturday and I'm bored. I'll get my coat
"Ten men in the country could buy the world and ten million can’t buy enough to eat." Will Rogers PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com Latest Article: EventAggregator
-
On paper AMD Ryzen 5900x has twice horsepower than Intel i5-12400, though in single thread applications, 12400 is lightly better. So we checked this fact by a very simple winform application ( Net 8 - VS 2022 ver. 17.8.4 ):
List lv = new List();
listView1.Items.Clear();for (int i = 0; i < numericUpDown1.Value; i++)
{
ListViewItem item = new ListViewItem(i.ToString("D8"));
TestClass t = new TestClass(i);
item.Tag = t;
item.SubItems.Add(t.ID.ToString("D8"));
item.SubItems.Add(t.ID2.ToString("D8"));
item.SubItems.Add(t.ID3.ToString("D8"));
item.SubItems.Add(t.ID4.ToString("D8"));
lv.Add(item);
}listView1.BeginUpdate();
listView1.Items.AddRange(lv.ToArray());
listView1.EndUpdate();With
numericUpDown1.Value= 1_000_000
10 times benchmark, Intel cpu completed the task on average in 18 seconds. AMD cpu never completed the task below 60 seconds. Intel cpu setup: Win11 in VirtualBox with 6 cores 16 GB RAM ADATA NVME 2.0 disk AMD cpu setup: bare metal Win11 48 GB RAM SAMSUNG NVME 2.0 disk. What's wrong with AMD cpu? Who should we blame on issue: MS or AMD? Any idea? P.S.: I'm a hardcore fan of AMD.
Behzad
It could be a number of things, but the first thing I'd look at is the generated native code and see how it compares for the different architectures. That could make a mountain of difference. The other things are more difficult to track down, especially with managed code - is your code remaining in the CPU's cache line as its executing? There's also the other question, and that is Winforms, which relies heavily on the windows subsystem and unmanaged code. If I were you, I'd fashion a barebones .NET 6+ console application that benches N iterations, 5 times overall where N is some arbitrarily large number based roughly on how long it takes to perform each iteration. Then run that on both and check your results.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
On paper AMD Ryzen 5900x has twice horsepower than Intel i5-12400, though in single thread applications, 12400 is lightly better. So we checked this fact by a very simple winform application ( Net 8 - VS 2022 ver. 17.8.4 ):
List lv = new List();
listView1.Items.Clear();for (int i = 0; i < numericUpDown1.Value; i++)
{
ListViewItem item = new ListViewItem(i.ToString("D8"));
TestClass t = new TestClass(i);
item.Tag = t;
item.SubItems.Add(t.ID.ToString("D8"));
item.SubItems.Add(t.ID2.ToString("D8"));
item.SubItems.Add(t.ID3.ToString("D8"));
item.SubItems.Add(t.ID4.ToString("D8"));
lv.Add(item);
}listView1.BeginUpdate();
listView1.Items.AddRange(lv.ToArray());
listView1.EndUpdate();With
numericUpDown1.Value= 1_000_000
10 times benchmark, Intel cpu completed the task on average in 18 seconds. AMD cpu never completed the task below 60 seconds. Intel cpu setup: Win11 in VirtualBox with 6 cores 16 GB RAM ADATA NVME 2.0 disk AMD cpu setup: bare metal Win11 48 GB RAM SAMSUNG NVME 2.0 disk. What's wrong with AMD cpu? Who should we blame on issue: MS or AMD? Any idea? P.S.: I'm a hardcore fan of AMD.
Behzad
There is something more to the issue that is not apparent from the information provided. As Honey pointed out, there are many other factors to consider. As for the code itself, it baffles me why you want to load 1M rows into a
ListView
control like that. You're much better off finding ways to reduce the number of rows loaded. However, if you need to do this, there are better ways like virtualization. Read this (with code sample): ListView.VirtualMode Property (System.Windows.Forms) | Microsoft Learn[^]. If you make this change, the app will run much more efficiently on both machines. ;PGraeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
-
There is something more to the issue that is not apparent from the information provided. As Honey pointed out, there are many other factors to consider. As for the code itself, it baffles me why you want to load 1M rows into a
ListView
control like that. You're much better off finding ways to reduce the number of rows loaded. However, if you need to do this, there are better ways like virtualization. Read this (with code sample): ListView.VirtualMode Property (System.Windows.Forms) | Microsoft Learn[^]. If you make this change, the app will run much more efficiently on both machines. ;PGraeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
i agree with honey and graeme run bench that focuses on hardware performance I use dhrystone /* * "DHRYSTONE" Benchmark Program * * Version: C/1 * Date: 12/01/84 * Author: Reinhold P. Weicker, CACM Vol 27, No 10, 10/84 pg. 1013 * Translated from ADA by Rick Richardson
"A little time, a little trouble, your better day" Badfinger
-
On paper AMD Ryzen 5900x has twice horsepower than Intel i5-12400, though in single thread applications, 12400 is lightly better. So we checked this fact by a very simple winform application ( Net 8 - VS 2022 ver. 17.8.4 ):
List lv = new List();
listView1.Items.Clear();for (int i = 0; i < numericUpDown1.Value; i++)
{
ListViewItem item = new ListViewItem(i.ToString("D8"));
TestClass t = new TestClass(i);
item.Tag = t;
item.SubItems.Add(t.ID.ToString("D8"));
item.SubItems.Add(t.ID2.ToString("D8"));
item.SubItems.Add(t.ID3.ToString("D8"));
item.SubItems.Add(t.ID4.ToString("D8"));
lv.Add(item);
}listView1.BeginUpdate();
listView1.Items.AddRange(lv.ToArray());
listView1.EndUpdate();With
numericUpDown1.Value= 1_000_000
10 times benchmark, Intel cpu completed the task on average in 18 seconds. AMD cpu never completed the task below 60 seconds. Intel cpu setup: Win11 in VirtualBox with 6 cores 16 GB RAM ADATA NVME 2.0 disk AMD cpu setup: bare metal Win11 48 GB RAM SAMSUNG NVME 2.0 disk. What's wrong with AMD cpu? Who should we blame on issue: MS or AMD? Any idea? P.S.: I'm a hardcore fan of AMD.
Behzad
It's not a practical application. It should get the attention it deserves. My first thought was keyboard buffers, repetition counts and reentrancy. But there is no keyboard.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
It's not a practical application. It should get the attention it deserves. My first thought was keyboard buffers, repetition counts and reentrancy. But there is no keyboard.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
On paper AMD Ryzen 5900x has twice horsepower than Intel i5-12400, though in single thread applications, 12400 is lightly better. So we checked this fact by a very simple winform application ( Net 8 - VS 2022 ver. 17.8.4 ):
List lv = new List();
listView1.Items.Clear();for (int i = 0; i < numericUpDown1.Value; i++)
{
ListViewItem item = new ListViewItem(i.ToString("D8"));
TestClass t = new TestClass(i);
item.Tag = t;
item.SubItems.Add(t.ID.ToString("D8"));
item.SubItems.Add(t.ID2.ToString("D8"));
item.SubItems.Add(t.ID3.ToString("D8"));
item.SubItems.Add(t.ID4.ToString("D8"));
lv.Add(item);
}listView1.BeginUpdate();
listView1.Items.AddRange(lv.ToArray());
listView1.EndUpdate();With
numericUpDown1.Value= 1_000_000
10 times benchmark, Intel cpu completed the task on average in 18 seconds. AMD cpu never completed the task below 60 seconds. Intel cpu setup: Win11 in VirtualBox with 6 cores 16 GB RAM ADATA NVME 2.0 disk AMD cpu setup: bare metal Win11 48 GB RAM SAMSUNG NVME 2.0 disk. What's wrong with AMD cpu? Who should we blame on issue: MS or AMD? Any idea? P.S.: I'm a hardcore fan of AMD.
Behzad
Configure projects to target platforms - Visual Studio (Windows) | Microsoft Learn[^] An interesting/easy thing to try is building specifically for x86 and x64, testing both. It's a bit weird this isn't inverted. (x64 = AMD instruction sets, afaik - even on Intel chips) Aside that, I think strings being a bit of a special animal is likely playing into this heavily. Also, setting a .Tag to an object (instead of a string) is "weird" but that weirdness may be a figment of my imagination and that may be a perfectly normal thing to do.