Unexpected graphics performance differences in application

ASword
Posts: 179
Joined: Fri Aug 04, 2017 12:48 pm
languages_spoken: english
ODROIDs: XU4, HC1, 2x N2
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: Unexpected graphics performance differences in application

Unread post by ASword » Sun May 05, 2019 12:42 am

This discussion of timer inaccuracies was bothering me (precise timing is something I spent a fair bit of time messing with a long time ago in my career), so Linux not having the ability to deliver reasonably precise timing (60Hz!? That's a joke!) just doesn't sit right. I don't have time to mess around in code myself (for this) right now, but a bit of reading and searching turned up this promising tidbit:

https://stackoverflow.com/questions/240 ... -userspace

I would be interested to hear if you have success with it.
These users thanked the author ASword for the post:
wallyz21 (Tue May 07, 2019 10:21 am)

wallyz21
Posts: 96
Joined: Thu Apr 04, 2019 11:00 am
languages_spoken: english
ODROIDs: N2
Has thanked: 9 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by wallyz21 » Sun May 05, 2019 11:14 pm

ASword wrote:
Sun May 05, 2019 12:42 am
This discussion of timer inaccuracies was bothering me (precise timing is something I spent a fair bit of time messing with a long time ago in my career), so Linux not having the ability to deliver reasonably precise timing (60Hz!? That's a joke!) just doesn't sit right. I don't have time to mess around in code myself (for this) right now, but a bit of reading and searching turned up this promising tidbit:

https://stackoverflow.com/questions/240 ... -userspace

I would be interested to hear if you have success with it.
I have had a look. It looks very similar to timerfd. I will test it in the next few days and present some results.

wallyz21
Posts: 96
Joined: Thu Apr 04, 2019 11:00 am
languages_spoken: english
ODROIDs: N2
Has thanked: 9 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by wallyz21 » Tue May 07, 2019 10:18 am

@ASword

I have now managed to run the timer mechanism described in the link you provided on the N2 and a Raspberry PI 3B+.

The timings on the Ubuntu N2 are no better than any of other timing mechanisms I tested. The deviation for the two systems is as follows:

Standard Deviation : 6000 samples of 16.667 msecs
Ubuntu N2 : 0.742
Raspbian PI 3B+ : 0.059

So the PI has a 12.57 times better standard deviation than the N2 (Ubuntu)!

Here are the charts:

N2 Ubuntu timer signal (stdev : 742.49)
Image
https://drive.google.com/file/d/1s0rFd8 ... sp=sharing

PI 3B+ Raspbian timer signal (stdev : 58.83)
Image
https://drive.google.com/file/d/1EPYv6y ... sp=sharing

You will notice the difference of the two scales of these graphs.

I still believe something is amiss with the timing mechanism in the N2 Ubuntu kernel. However the HK personnel are busy with the Wayland build and 5.2 kernel so I am hoping some major changes might flush out this problem (even if only by accident).

skeetre
Posts: 66
Joined: Mon Apr 29, 2019 11:27 am
languages_spoken: english
ODROIDs: Odroid-N2
Location: FL, USA
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by skeetre » Wed May 08, 2019 2:41 am

crashoverride wrote:
Fri May 03, 2019 11:39 am

Image

The video shows pure CPU rendering. Ironically, I was very impressed that N2 could emulate both a Wii and a desktop class GPU as fast as it does!
This is Awesome!
Friends don't let friends use Spectre/Meltdown/Zombieload mitigations.

ASword
Posts: 179
Joined: Fri Aug 04, 2017 12:48 pm
languages_spoken: english
ODROIDs: XU4, HC1, 2x N2
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: Unexpected graphics performance differences in application

Unread post by ASword » Wed May 08, 2019 11:10 pm

wallyz21 wrote:
Tue May 07, 2019 10:18 am
@ASword

I have now managed to run the timer mechanism described in the link you provided on the N2 and a Raspberry PI 3B+.

The timings on the Ubuntu N2 are no better than any of other timing mechanisms I tested. The deviation for the two systems is as follows:

Standard Deviation : 6000 samples of 16.667 msecs
Ubuntu N2 : 0.742
Raspbian PI 3B+ : 0.059

So the PI has a 12.57 times better standard deviation than the N2 (Ubuntu)!

Here are the charts:

N2 Ubuntu timer signal (stdev : 742.49)
Image
https://drive.google.com/file/d/1s0rFd8 ... sp=sharing

PI 3B+ Raspbian timer signal (stdev : 58.83)
Image
https://drive.google.com/file/d/1EPYv6y ... sp=sharing

You will notice the difference of the two scales of these graphs.

I still believe something is amiss with the timing mechanism in the N2 Ubuntu kernel. However the HK personnel are busy with the Wayland build and 5.2 kernel so I am hoping some major changes might flush out this problem (even if only by accident).
Thanks for chasing it. This level of issue is bad enough I’m concerned about my relatively lax use case requirements for my own N2. The N2 hardware is more than capable of drastically better behaviour, so its a software issue somewhere. It feels like a scheduling issue to me, but the Linux kernel isn’t something I know a lot about.

crashoverride
Posts: 4521
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 67 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by crashoverride » Thu May 09, 2019 6:14 am

ASword wrote:
Wed May 08, 2019 11:10 pm
It feels like a scheduling issue to me
I would suspect a timer issue, but that is entirely a guess. The C2 behaves similarly when its using the ARM timer instead of the MESON timer.

https://github.com/hardkernel/linux/blo ... #L198-L217

Code: Select all

	timer {
		compatible = "arm,armv8-timer";
		interrupts = <GIC_PPI 13 0xff08>,
				<GIC_PPI 14 0xff08>,
				<GIC_PPI 11 0xff08>,
				<GIC_PPI 10 0xff08>;
	};

	timer_bc {
		compatible = "arm, meson-bc-timer";
		reg=   <0x0 0xffd0f190 0x0 0x4 0x0 0xffd0f194 0x0 0x4>;
		timer_name = "Meson TimerF";
		clockevent-rating=<300>;
		clockevent-shift=<20>;
		clockevent-features=<0x23>;
		interrupts = <0 60 1>;
		bit_enable=<16>;
		bit_mode=<12>;
		bit_resolution=<0>;
	};
These users thanked the author crashoverride for the post:
wallyz21 (Sun May 12, 2019 5:21 pm)

wallyz21
Posts: 96
Joined: Thu Apr 04, 2019 11:00 am
languages_spoken: english
ODROIDs: N2
Has thanked: 9 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by wallyz21 » Sun May 12, 2019 5:27 pm

I have been playing with the CPU affinity (using taskset) and now have my emulator running at 55+ fps in the desktop environment. Of course I can get it to run a 60 fps if I forego all timers and poll the high performance counter myself.

But now I have managed to use the timer and get 55+ fps.

To do this I set the cpu governors to performance and then set the affinity of the Xorg process to cpus 2-5.

To do this you need to know it's pid and use task set on the running pid.

So keeping high performance routines away from the the little cpus helps a lot!

wallyz21
Posts: 96
Joined: Thu Apr 04, 2019 11:00 am
languages_spoken: english
ODROIDs: N2
Has thanked: 9 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by wallyz21 » Mon May 13, 2019 10:22 am

What led me to set the affinity of the Xorg process was I was using htop to monitor my emulator performance and noticed that under load the OS still favored CPUs 0 & 1. They were both running around 90% and the other CPUs 2-5 were running around 25%.

I suspect the processes won't move over from cluster 0 to cluster 1 until they reach 100%.

Now my emulator has several (6) threads running but only one of them is intensive. However both PCUs 0 & 1 were running at 90%. So if my emulator is the cause for one of those CPU loads what is causing the other CPU to be under load?

This is when I noticed the Xorg process was also consuming a lot of CPU time. My emulator wants more CPU time but my timer waits are preventing it from reaching 100%. When I set my emulator (and I can do this on the fly) to POLL mode instead of timer wait mode the CPU goes straight to 100% and I noticed CPU 0-1 drop to 25% and two of CPUs from 2-5 jump to 100%. So it was the poll causing the 100% utilization and this was causing the migration of the process from the little cluster to the big.

At first I tried restricting the affinity of my emulator to the big cluster and this did improve the situation but by only a very small amount.

It was not until I restricted the CPU affinity of Xorg process to cluster 1 (2nd / big cluster) that my emulator began running like a charm.

It was not even necessary to restrict my emulator to the big cluster and I could allow it to run on all 6 cpus (which is preferential because I have 6 threads).

So now I suspect these Big/Little architectures are proving to be a little more problematic to the Linux kernel scheduler as might be anticipated.

Yes they work but I don't think the Linux kernel is not properly tuned or suited towards them.
Last edited by wallyz21 on Mon May 13, 2019 1:43 pm, edited 1 time in total.

wallyz21
Posts: 96
Joined: Thu Apr 04, 2019 11:00 am
languages_spoken: english
ODROIDs: N2
Has thanked: 9 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by wallyz21 » Mon May 13, 2019 11:14 am

Just wanted to add.

On the N2 my emulator nows runs 80mhz 6309cpu at 72fps uncapped. And 60fps capped. All in the MATE desktop.

In comparison my MS Surface 2 Pro (i5 dual core/ 4 thread 1.9ghz) running Ubuntu 18.04 runs the emulator at 64mhz 6309cpu at 300fps uncapped and capped at 60fps.

So the graphics performance is better on the surface because it has accelerated drivers. But the the N2 out performs the Intel I5 on the CPU emulation.

I think the N2 is going to improve significantly when the Wayland accelerated drivers are released.

N2 vs Surface 2 Pro
System CPU Emu mhz Uncapped FPS Capped FPS
N2 80 mhz 72 60
Surface 2 Pro 64 mhz 300+ 60
These users thanked the author wallyz21 for the post:
skeetre (Wed May 15, 2019 4:44 am)

User avatar
mad_ady
Posts: 6554
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 169 times
Been thanked: 128 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by mad_ady » Mon May 13, 2019 1:09 pm

I think it's possible to change the cpu cluster order (big first, little second) by making some changes in the dtb (changing the mask or something), but I'm not sure...

skeetre
Posts: 66
Joined: Mon Apr 29, 2019 11:27 am
languages_spoken: english
ODROIDs: Odroid-N2
Location: FL, USA
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by skeetre » Wed May 15, 2019 4:47 am

Great work wallyz21!
That's a huge performance improvement. This should benefit everyone running a desktop env.

Sounds like it would be a big help to swap the cluster order mad_ady. I guess until someone figures out how, we do it the hard way and manually set core priority per process.
Friends don't let friends use Spectre/Meltdown/Zombieload mitigations.

wallyz21
Posts: 96
Joined: Thu Apr 04, 2019 11:00 am
languages_spoken: english
ODROIDs: N2
Has thanked: 9 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by wallyz21 » Thu May 23, 2019 9:01 am

Do this !!!!

In the Mate Tweak Tool select Windows and for the Window Manager select -> Marco (No compositor).

This setting gave me (with other performance settings) full screen 60fps in youtube via Firefox!

And it will drop the Xorg process CPU usage from the highest consuming process (around 25%) to less than other active processes (around 5%).

This has stopped the competition between my emulator and the Xorg process and I know get completely steady frame rates.
These users thanked the author wallyz21 for the post:
XOR (Thu May 23, 2019 8:01 pm)

skeetre
Posts: 66
Joined: Mon Apr 29, 2019 11:27 am
languages_spoken: english
ODROIDs: Odroid-N2
Location: FL, USA
Has thanked: 15 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by skeetre » Thu May 23, 2019 9:34 am

have you, or anyone else, tried Youtube TV? I can't get it working.
Friends don't let friends use Spectre/Meltdown/Zombieload mitigations.

wallyz21
Posts: 96
Joined: Thu Apr 04, 2019 11:00 am
languages_spoken: english
ODROIDs: N2
Has thanked: 9 times
Been thanked: 11 times
Contact:

Re: Unexpected graphics performance differences in application

Unread post by wallyz21 » Thu May 23, 2019 9:24 pm

skeetre wrote:
Thu May 23, 2019 9:34 am
have you, or anyone else, tried Youtube TV? I can't get it working.
Nope! At that price I wont be trying.

Does it require libpep (flash lib) like Tidal if so then there is no way to get it working. However I doubt that!

So without trying myself I can't say. Anyone else familiar with this product!

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 2 guests