jeffr_tech ([info]jeffr_tech) wrote,
@ 2008-01-25 02:05:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
non-uniform cpu scheduling.
After a month sick with some random virus I'm finally starting to feel normal and get some work done again. I spent some time implementing a long standing idea I've had for a more flexible and dynamic CPU topology to improve scheduling decisions. Modern multi-core processors are non-uniform from a variety of perspectives. For example, the barcelona has a shared L3 among all cores on a package. So if you have two packages and you're placing two threads on cores within one package you're wasting half your cache. To take advantage of this knowledge the scheduler needs detailed information about the cpu layout and it needs to intelligently act on that information.


Other non types of non-uniformity are shared system bus or memory controller links, hyper-threaded or symmetric multi-threaded cores, etc. All of these factors stack up to mean simply picking the most idle cpu is no longer an effective solution. For example, if a thread has affinity for one cpu and it's not available, it is sensible to pick another cpu that shares cache with the desired cpu. It's also important to balance load across system bus links and caches not just processors.

Optimizing for these characteristics is not a novel idea. Linux and Solaris both make some attempts to do so. I have not analyzed them in depth but I have noticed that they are both fairly static approaches requiring changes for new architectures or missing opportunities to optimize odd ones such as intel's initial quad core (two sets of dualcore cpus with a large l2 each but a shared system bus). ULE even had some primitive improvements to optimize for HTT. However, my new solution is very dynamic, allowing the machine dependent code to describe arbitrary topographies with slightly abstracted levels of sharing.

The basic datastructure is a tree that describes the relationships between cpus. What resource they share and which cpus are in the set. An example tree might have a root that describes 4 sockets which share nothing (independent bus links), with another layer describing a package with an L3, and another describing a par of cores within that package sharing an L2. Yet another layer may then describe 4 SMT threads per-core. Most systems are actually less complex and require only one or two levels in the tree which reduces algorithm cost.

When searching for a cpu with affinity the scheduler will walk the tree backwards from the last cpu scheduled to the highest level which the thread has affinity for. It then recursively evaluates the sub-tree to find the most idle match with the best affinity. To find an idle cpu, we scan the whole tree finding the least loaded CPU on the least loaded path through the tree. This balances load across tree levels and hence all cpu resources.

The periodic load balancer now recursively iterates the tree, load balancing every level. A search routine simultaneously finds the most and least loaded core via each path and rectifies their loads. The idle time load balancer which runs when a cpu runs out of work will scan starting from the nearest cpu outward to pick the best cpu to steal a thread from.

The majority of the algorithms are quite generic, however, I may implement some special casing for SMT/HTT as there really is a much stronger disincentive to scheduling these cores if others are available unless there is significant cache overlap between threads. When there is cache overlap between threads the scheduler can now place them near-by each other in the topology to decrease cache coherency messages that must be broadcast off package.

So after all that, how much does it help? Some charts:

http://people.freebsd.org/~kris/scaling/pgsql-16cpu.png
http://people.freebsd.org/~kris/scaling/mysql-16cpu.png

These are from a 16core 4x4 xeon machine. The pgsql graph has a lot of lines but you're interested in ule + topo vs 16 cores, all active. mysql is a little more straightforward. Interestingly it scales well on 8 cpus but runs into terrible user-land contention on 16. I'm not sure if this is running with adaptive pthreads mutexes or not.

Anyway, the patch is still young yet and it's performing very well on this very asymmetric machine while not hindering others. Expect to see this in 8.0 and maybe backported for 7.1 to alleviate the poor scheduling behavior that all those of you with quad quad core machines are experiencing. ;)




(Post a new comment)


[info]danfe
2008-01-25 01:30 pm UTC (link)
Looks quite promising, and impressive! Keep it up, Jeff.

(Reply to this) (Thread)


[info]alvabonnano
2008-08-06 04:09 am UTC (link)
Keep it up. . Jeff Horner May A compelling idea, and an impressive & inspiring set of work. Your galleries always impress.

(Reply to this) (Parent)(Thread)

(no subject) - [info]dominickdevere, 2008-08-06 05:41 am UTC
(no subject) - [info]gregharton, 2008-08-11 01:41 am UTC
(no subject) - [info]samgoulet, 2008-08-11 07:12 am UTC
(no subject) - [info]drewchepack, 2008-08-11 06:14 pm UTC

(Reply from suspended user)

(Reply from suspended user)
(no subject) - [info]demetriuslittl, 2008-08-11 02:39 am UTC
(no subject) - [info]dallaswycoff, 2008-08-11 06:07 am UTC
(no subject) - [info]wileygentry, 2008-08-11 07:13 am UTC

(Reply from suspended user)
(no subject) - [info]coybertran, 2008-08-11 01:39 pm UTC
(no subject) - [info]earletalanda, 2008-08-12 11:55 am UTC

(Reply from suspended user)

(Reply from suspended user)

(Reply from suspended user)

(Reply from suspended user)
(no subject) - [info]tylerkuns, 2008-08-11 01:00 am UTC
(no subject) - [info]raultowheed, 2008-08-11 02:20 am UTC
(no subject) - [info]leonelsyms, 2008-08-11 03:49 am UTC
(no subject) - [info]julietully, 2008-08-11 04:32 am UTC
(no subject) - [info]donhelvogt, 2008-08-11 02:25 am UTC
(no subject) - [info]geraldkraford, 2008-08-11 02:49 am UTC
ddwadadaw - [info]bozuk, 2009-06-28 12:00 am UTC

[info]sammygenovich
2008-08-11 02:03 am UTC (link)
0 browser looks to be quite impressive as PDA browsers go. Per palmOne, it supports: "Internet standards √ HTML 4.

(Reply to this) (Parent)

(Reply from suspended user)

[info]tutanhamon
2008-01-25 02:17 pm UTC (link)
What's wrong with MySQL after 9-10 threads?

(Reply to this) (Thread)

Is the problem really within the scheduler?
(Anonymous)
2008-01-25 04:02 pm UTC (link)
So what does the `SIGPIPE' patch actually do?

(Reply to this) (Parent)(Thread)

Re: Is the problem really within the scheduler? - [info]jeffr_tech, 2008-01-25 10:01 pm UTC
(no subject) - [info]kennethvaszcak, 2008-08-06 04:53 am UTC
(no subject) - [info]christopherwic, 2008-08-11 01:34 am UTC
(no subject) - [info]heidelipyte, 2008-07-16 05:09 am UTC
(no subject) - [info]benfraiser, 2008-08-11 01:07 am UTC

(Reply from suspended user)

[info]jeffr_tech
2008-01-25 10:00 pm UTC (link)
It's internal contention. Their userspace locking isn't fine enough.

(Reply to this) (Parent)(Thread)

Re: Is the problem really within the scheduler? - [info]tutanhamon, 2008-01-25 10:53 pm UTC
Re: Is the problem really within the scheduler? - [info]jeffr_tech, 2008-01-25 11:02 pm UTC
(no subject) - [info]louisetufeg, 2008-07-16 02:44 am UTC

(Reply from suspended user)
(no subject) - [info]santosroom, 2008-08-10 10:44 pm UTC
(no subject) - [info]saragyvuj, 2008-08-03 04:50 pm UTC

[info]kimoletu
2008-07-11 01:26 am UTC (link)
What's wrong. : > > > [root@obsidian jim]# mysql -u root@obsidian > > Welcome to the MySQL monitor.

(Reply to this) (Parent)

Linux sched domains
(Anonymous)
2008-01-26 03:08 am UTC (link)
Linux has actually had an arbitrary tree based topology (actually it doesn't even have to be a tree, it can be more general if the arch code wants to set that up) for quite some years now.

It is flexible enough to handle everything from SMT to multiple levels of NUMA and describe characteristics such as shared resources and power consumption effects, target CPU distribution fairness levels etc.

The data structure is completely dynamic and can be (and is) changed at runtime (eg. during CPU hotplug).

(Reply to this) (Thread)

Re: Linux sched domains
[info]jeffr_tech
2008-01-27 11:51 pm UTC (link)
This isn't quite true according to my reading of the code. It expresses specific levels and the description can have only a few specific levels.

For example, when CONFIG_SCHED_MC is enabled there is a 'cpu_coregroup_map' and with SMT there is a 'cpu_sibling_map'. So you can't express something like the intel quad core which is two dual cores on one chip. With the 4 cores sharing some resources and the two pairs sharing others.

Also, it really only takes the current level of the group into consideration when balancing. It doesn't look at the full path. There are more examples but perhaps I shouldn't always give away all of my tricks. ;)

(Reply to this) (Parent)(Thread)

Re: Linux sched domains - (Anonymous), 2008-01-29 12:05 am UTC
Re: Linux sched domains - [info]jeffr_tech, 2008-01-29 12:24 am UTC
Re: Linux sched domains - (Anonymous), 2008-01-30 10:04 pm UTC
Re: Linux sched domains
[info]jeffr_tech
2008-01-28 08:40 am UTC (link)
By the way, if this is Nick Piggin, there wouldn't be a delay for your very informative posts if you'd get a free account. I also wouldn't start off by assuming anonymous is wrong when reading your posts (as anonymous is often spam/flames/etc.).

(Reply to this) (Parent)


[info]freegames99
2008-09-27 07:51 am UTC (link)
Jeff Horner May A compelling idea, and an impressive & inspiring set of work. Your galleries always impress.

(Reply to this) (Thread)

dawd
[info]bozuk
2009-06-28 12:00 am UTC (link)
dawdaddawdawdwadawdawdaw

(Reply to this) (Parent)


[info]sence1
2009-03-12 10:04 pm UTC (link)
Koxp, Koxp 1726, Koxp Merkezi

Koxp

(Reply to this) (Thread)

dawdada
[info]bozuk
2009-06-28 12:00 am UTC (link)
Yeni porno izleme sitesi www.gomtube.net -

(Reply to this) (Parent)


[info]sence1
2009-03-18 11:20 am UTC (link)
Oyun Download
Online Games

(Reply to this) (Thread)

Thankss
[info]bozuk
2009-06-28 12:01 am UTC (link)
En Kral porno izle. -

Liseli porno izle -

(Reply to this) (Parent)


[info]sence1
2009-03-18 11:20 am UTC (link)
laptop notebook

(Reply to this) (Thread)


[info]sence1
2009-03-19 01:43 am UTC (link)
Good news auto blog laptop notebook

Oyun Download
Online Games
Emin Ergin

(Reply to this) (Parent)


[info]sence1
2009-03-19 11:07 pm UTC (link)
Emin Girgin
dövüş oyunları
kıral oyunlar
kıral oyun

(Reply to this) (Thread)


[info]sence1
2009-03-23 03:11 pm UTC (link)
NesMedya Haber Video Oyun Seo Yarışması

(Reply to this) (Parent)(Thread)

(no subject) - [info]sence1, 2009-03-29 11:56 pm UTC
holaaaa - [info]bozuk, 2009-06-28 12:02 am UTC

[info]sence1
2009-03-29 11:57 pm UTC (link)
Good e book store options Kobi

(Reply to this) (Thread)

Supper :)
[info]bozuk
2009-06-28 12:01 am UTC (link)

Bedava porno seyret -

Kesintisiz sikiş izle -

(Reply to this) (Parent)


[info]aeerotataeue
2009-05-27 09:25 am UTC (link)
http://seuoligoyspudi.blogspot.com/
http://shockingadatingmv.blogspot.com/
http://shorplavizwxc.blogspot.com/
http://glomauryaungewtv.blogspot.com/
http://togeteroticjavagx.blogspot.com/
http://yaurvediahvagv.blogspot.com/
http://heysexrollersli.blogspot.com/
http://tosuckacuntaw.blogspot.com/
http://healthbeautysexnz.blogspot.com/
http://smallinsectssexnj.blogspot.com/
http://blockocumkmnb.blogspot.com/
http://babiesofdatingno.blogspot.com/
http://zaysofeirykmlx.blogspot.com/
http://datingof3dtu.blogspot.com/
http://youngdatinget.blogspot.com/
http://lliskisexbx.blogspot.com/
http://datingistorturemp.blogspot.com/
http://oseonwheziacivj.blogspot.com/
http://datingispeople9.blogspot.com/
http://sexmp3oe.blogspot.com/
http://arolohugiqxtt.blogspot.com/
http://sexsmallhole6iq.blogspot.com/
http://seuolbubbliradw.blogspot.com/
http://heysexrollersrw.blogspot.com/
http://seymelfxifv.blogspot.com/
http://sexofasiaticsef.blogspot.com/
http://analsexofwomanvk.blogspot.com/
http://cilibsgriozirzdcx.blogspot.com/
http://13datingofaphotoky.blogspot.com/
http://whypeopleneedsexdf.blogspot.com/
http://dompzugjabspnjx.blogspot.com/
http://cilibrezyhugikaqhj.blogspot.com/
http://stallionsexjs.blogspot.com/
http://moszurbliwdzbcre.blogspot.com/
http://sexwithhorsesdk.blogspot.com/
http://picturesexgg.blogspot.com/
http://datingnewanuseskq.blogspot.com/
http://anautoissexaw.blogspot.com/
http://asubwayisdatingyn.blogspot.com/
http://intsestofgirl5.blogspot.com/
http://sexwithladiesbz.blogspot.com/
http://sexlittlefj.blogspot.com/
http://sexafullbladderec.blogspot.com/
http://zoofilovxh.blogspot.com/
http://sexwithchildrenmz.blogspot.com/
http://theswedishdatingtl.blogspot.com/
http://sexofponycf.blogspot.com/
http://blawjabgydwhhtp.blogspot.com/
http://melfyaurmivfb.blogspot.com/

(Reply to this) (Thread)


[info]bilmiyorum1
2009-06-18 10:08 pm UTC (link)
Good my dream teacher

Porno izle

(Reply to this) (Parent)(Thread)

Thnkass - [info]bozuk, 2009-06-28 12:02 am UTC

[info]itsetfcono
2009-06-21 03:04 pm UTC (link)
http://letitbitsexlg.blogspot.com/
http://ibanymaszyiaww.blogspot.com/
http://newdatingasitefg.blogspot.com/
http://russianhomesexai.blogspot.com/
http://amateursexclipsce.blogspot.com/
http://anallargedo.blogspot.com/
http://togetthedatingxf.blogspot.com/
http://penkmaveishaxd.blogspot.com/
http://feszengsupiridop.blogspot.com/
http://fotkisexonabeachwf.blogspot.com/
http://recorddatinghq.blogspot.com/
http://5datingge.blogspot.com/
http://fervoradatinggp.blogspot.com/
http://eroticminigamestd.blogspot.com/
http://adatingisanuddereh.blogspot.com/
http://criomnoeveklx.blogspot.com/
http://toreadanincestsg.blogspot.com/
http://depubegohbm.blogspot.com/
http://heysexrollerswi.blogspot.com/
http://eroticstoriesrumu.blogspot.com/
http://heysaunasss.blogspot.com/
http://photoofwildsexsg.blogspot.com/
http://smolensksexql.blogspot.com/
http://supersexfilmgb.blogspot.com/
http://datingverythickql.blogspot.com/
http://videotolooksexnowrp.blogspot.com/
http://szorsbyaurnkhq.blogspot.com/
http://librarysexqo.blogspot.com/
http://wizseesaoavj.blogspot.com/
http://bryanskdatingvs.blogspot.com/
http://adatingisafewshotskw.blogspot.com/
http://sexwithgirlstobr.blogspot.com/
http://msexqu.blogspot.com/
http://messagesexgz.blogspot.com/
http://anadatingofpot.blogspot.com/
http://datingthegipsyeu.blogspot.com/
http://sexgirlwithamanll.blogspot.com/
http://masturbaterunc.blogspot.com/
http://observingofsexyl.blogspot.com/
http://15xdatingis.blogspot.com/
http://seesridnhsg.blogspot.com/
http://sexofdreamruco.blogspot.com/
http://criomnoevekvt.blogspot.com/
http://mothergb.blogspot.com/
http://trakhgirlsat.blogspot.com/
http://sexpupilssm.blogspot.com/
http://youngdatingio.blogspot.com/
http://begfeszengysof.blogspot.com/
http://toseeadatingfilmzo.blogspot.com/
http://interactivesexhd.blogspot.com/
http://datingsexviewinguv.blogspot.com/
http://datingofshopysanktzh.blogspot.com/
http://recorddatingee.blogspot.com/
http://roomssexashopqv.blogspot.com/
http://datingofvideofz.blogspot.com/
http://sexisinaskirtxm.blogspot.com/
http://aphotoisdatingfilmsgj.blogspot.com/
http://sexisvisiblebl.blogspot.com/
http://testsaboutsexil.blogspot.com/
http://datingonwapwn.blogspot.com/
http://datinginspermef.blogspot.com/
http://frightfuladatingsq.blogspot.com/
http://ofvideojq.blogspot.com/
http://bubblihderzyvwrn.blogspot.com/
http://datingrollerssexdx.blogspot.com/
http://lifeitissexbp.blogspot.com/
http://seuoligoyspumh.blogspot.com/
http://maveisgriozirczivh.blogspot.com/
http://gamesaboutsexkw.blogspot.com/
http://toreadadatingtj.blogspot.com/
http://mumssexcf.blogspot.com/
http://sexduringalessongf.blogspot.com/
http://russianmaturedatingnw.blogspot.com/
http://onemihordwamsu.blogspot.com/
http://datinginspermbh.blogspot.com/
http://virginsaresexmr.blogspot.com/
http://funnywfrexuru.blogspot.com/
http://virginsaresexbu.blogspot.com/
http://youthdatingwz.blogspot.com/
http://seszirsmollyul.blogspot.com/
http://littleboysinsexsu.blogspot.com/
http://multikiporevoinforl.blogspot.com/
http://sexisahorseoh.blogspot.com/
http://datingofnakedauntskk.blogspot.com/
http://heyfilmon-lineuc.blogspot.com/
http://anoilclothissexcu.blogspot.com/
http://datingthreeononejd.blogspot.com/
http://russianeroticstoryvw.blogspot.com/
http://thegoddessofsexat.blogspot.com/
http://vesezneciriwl.blogspot.com/
http://yaungqmoszurbccrw.blogspot.com/
http://datingof40ladiesqx.blogspot.com/
http://sexwithwomenlm.blogspot.com/
http://datingwapdom2rufe.blogspot.com/
http://zoofilkidatingcn.blogspot.com/
http://ropidlisbeonuwnby.blogspot.com/
http://hordcarimbisziygl.blogspot.com/
http://young16sexlc.blogspot.com/
http://beslatnoedatingel.blogspot.com/
http://datingofvideoofdom2jd.blogspot.com/

(Reply to this)

thanks
[info]istiyormus
2009-06-24 09:26 pm UTC (link)
thanks for sharing my friend.

devlet

(Reply to this)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…