Personal computing discussed

Moderators: renee, Flying Fox, morphine

 
Igor_Kavinski
Gerbil Elite
Topic Author
Posts: 658
Joined: Fri Dec 22, 2006 2:34 am

Is context switching speed the real reason behind Ryzen's success?

Mon Oct 07, 2019 8:56 am

https://www.phoronix.com/scan.php?page= ... -400&num=7

ctx_clock benchmark at the bottom of this page shows Ryzen 9 absolutely decimating and putting Core i9 to shame. One wonders how much of the Ryzen 9's wins against the Core i9 can be attributed solely to its stellar context switch performance.
 
just brew it!
Gold subscriber
Administrator
Posts: 53333
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Is context switching speed the real reason behind Ryzen's success?

Mon Oct 07, 2019 9:35 am

That's really interesting.

How much of an effect that has is going to be very workload-dependent. It will give the Ryzen a significant edge on anything which makes a lot of system calls (which force context switches to enter the kernel). To (over) generalize, I'd say it is more likely to help on workloads which tend to do lots of small random I/Os (e.g. database); less likely to help on computationally intensive workloads (HPC).

I also wonder whether some of the speculative execution security mitigations which are holding Intel back might actually be needed on Ryzen as well, and we just don't know it yet.
Nostalgia isn't what it used to be.
 
Igor_Kavinski
Gerbil Elite
Topic Author
Posts: 658
Joined: Fri Dec 22, 2006 2:34 am

Re: Is context switching speed the real reason behind Ryzen's success?

Mon Oct 07, 2019 10:48 am

just brew it! wrote:
I also wonder whether some of the speculative execution security mitigations which are holding Intel back might actually be needed on Ryzen as well, and we just don't know it yet.


If Intel is listening, wouldn't it be a nice option to be able to turn off the microcode mitigations (hardwired ones can't be helped I suppose) in the BIOS for users who absolutely need the extra performance while disconnected from the internet for security reasons? I mean, sure it's a hassle but there ARE users out there who wouldn't mind it for the performance boost.
 
just brew it!
Gold subscriber
Administrator
Posts: 53333
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Is context switching speed the real reason behind Ryzen's success?

Mon Oct 07, 2019 11:05 am

They're probably afraid of the liability issues from people mistakenly running public-facing servers with it turned off.
Nostalgia isn't what it used to be.
 
roncat
Gerbil First Class
Posts: 107
Joined: Wed Dec 14, 2016 8:29 am

Re: Is context switching speed the real reason behind Ryzen's success?

Mon Oct 07, 2019 11:59 am

just brew it! wrote:
That's really interesting.

How much of an effect that has is going to be very workload-dependent. It will give the Ryzen a significant edge on anything which makes a lot of system calls (which force context switches to enter the kernel). To (over) generalize, I'd say it is more likely to help on workloads which tend to do lots of small random I/Os (e.g. database); less likely to help on computationally intensive workloads (HPC).

I also wonder whether some of the speculative execution security mitigations which are holding Intel back might actually be needed on Ryzen as well, and we just don't know it yet.



That makes sense, as the link shows one of the only benchmarks Ryzen won was the database (Postgres) one. I9 leads in the others.
 
DragonDaddyBear
Silver subscriber
Gerbil Elite
Posts: 982
Joined: Fri Jan 30, 2009 8:01 am

Re: Is context switching speed the real reason behind Ryzen's success?

Mon Oct 07, 2019 12:55 pm

Very interesting indeed. In previous tests Nginx previously took a big hit on Intel after mitigation. Is that not also doing a lot of context switching as well? If so, are there any benchmarks to compare on openbenchmark? I don't have time to look, sorry.
 
just brew it!
Gold subscriber
Administrator
Posts: 53333
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Is context switching speed the real reason behind Ryzen's success?

Mon Oct 07, 2019 1:22 pm

DragonDaddyBear wrote:
Very interesting indeed. In previous tests Nginx previously took a big hit on Intel after mitigation. Is that not also doing a lot of context switching as well? If so, are there any benchmarks to compare on openbenchmark? I don't have time to look, sorry.

If it took a big hit, it is probably doing a lot of context switching.
Nostalgia isn't what it used to be.
 
Redocbew
Gold subscriber
Minister of Gerbil Affairs
Posts: 2151
Joined: Sat Mar 15, 2014 11:44 am

Re: Is context switching speed the real reason behind Ryzen's success?

Mon Oct 07, 2019 2:36 pm

Especially since they're testing with static pages. That's going to highlight performance of the server it's self(as it should) without saying much about the behavior of specific applications. The fact that the nginx test has a different outcome than the apache test is interesting also.

Dynamic content might behave a bit differently especially if you're using greenlets in Python or something to help keep things quick and light. Like JBI said, it depends on the application.
Do not meddle in the affairs of archers, for they are subtle and you won't hear them coming.
 
Igor_Kavinski
Gerbil Elite
Topic Author
Posts: 658
Joined: Fri Dec 22, 2006 2:34 am

Re: Is context switching speed the real reason behind Ryzen's success?

Tue Oct 08, 2019 11:29 am

If I were to surmise, database workloads running inside a VM is currently Intel's worst nightmare. Anyone experienced this compared to Ryzen?
 
dragontamer5788
Gerbil Elite
Posts: 507
Joined: Mon May 06, 2013 8:39 am

Re: Is context switching speed the real reason behind Ryzen's success?

Tue Oct 08, 2019 1:25 pm

I've been under the assumption that a context switch costs 10-microseconds. Apparently its closer to 0.15 microseconds by these numbers (Ryzen 3xxx) and 0.5 microseconds for Intel.

Maybe the ~10 microseconds estimate includes the time to refill the L1 cache with all the relevant data.
 
just brew it!
Gold subscriber
Administrator
Posts: 53333
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Is context switching speed the real reason behind Ryzen's success?

Tue Oct 08, 2019 1:36 pm

10 microseconds sounds pretty high; that may be worst-case, or maybe for a much older generation of processors?

Aside from data needed by the process itself needing to get pulled back into cache, I imagine the switching time could also vary a fair bit based on whether the internal register state data for the process being switched to is still in cache, or needs to be fetched from DRAM.
Nostalgia isn't what it used to be.
 
dragontamer5788
Gerbil Elite
Posts: 507
Joined: Mon May 06, 2013 8:39 am

Re: Is context switching speed the real reason behind Ryzen's success?

Tue Oct 08, 2019 2:04 pm

just brew it! wrote:
10 microseconds sounds pretty high; that may be worst-case, or maybe for a much older generation of processors?

Aside from data needed by the process itself needing to get pulled back into cache, I imagine the switching time could also vary a fair bit based on whether the internal register state data for the process being switched to is still in cache, or needs to be fetched from DRAM.


And I made another mistake in my math. Assuming a 4GHz processor (not 1 GHz processor), the actual context switch speeds are 0.04 microseconds (AMD) and 0.1 microseconds (Intel).

In any case, the numbers I was associated with probably were some kind of "worst case scenario", involving saving AVX registers to maybe DDR4 RAM (not enough room for cache), etc. etc. AVX-256 bit registers x 16 == 512 bytes of state, which needs to fetch/store 8x cache-lines. Hmm, that's still probably sub-1 microsecond even in the worst case.

I guess my memory is just wrong. Seems like 0.2 microseconds (200 nanoseconds) is a better estimate for worst-case context switch. It must have been older hardware or something that I'm (mis)remembering about.
 
Wirko
Gold subscriber
Gerbil Team Leader
Posts: 204
Joined: Fri Jun 15, 2007 4:38 am
Location: Central Europe

Re: Is context switching speed the real reason behind Ryzen's success?

Tue Oct 08, 2019 4:11 pm

Is is necessary to reload page tables during each context switch, or just when switching to another process, or even less often? How long does that take?
 
dragontamer5788
Gerbil Elite
Posts: 507
Joined: Mon May 06, 2013 8:39 am

Re: Is context switching speed the real reason behind Ryzen's success?

Tue Oct 08, 2019 5:36 pm

Wirko wrote:
Is is necessary to reload page tables during each context switch, or just when switching to another process, or even less often? How long does that take?


I can with absolutely say with 100% certainty that something like Sandy Bridge (2xxx series Intel i7) would require clearing out the page tables on all context-switches, to protect kernel data.

I am not expert enough to be able to tell you if its required on Zen 2, Coffee Lake, or other modern CPUs. The page-table clearings were forced because of Meltdown (or Spectre, I forget exactly). I think hardware mitigations were designed so that they could be fixed with just an mfence instruction (or similar), but the exact details I'm not fully aware of.
 
Igor_Kavinski
Gerbil Elite
Topic Author
Posts: 658
Joined: Fri Dec 22, 2006 2:34 am

Re: Is context switching speed the real reason behind Ryzen's success?

Wed Oct 09, 2019 2:31 am

https://news.ycombinator.com/item?id=13930305

Having tons of fun reading this, especially luckydude's posts.

Who is online

Users browsing this forum: No registered users and 4 guests
GZIP: On