Labels

"Igbo Blues" 2006 2008 2010 Acceleration of proceedings Adamosa Osagiede Admissibility of oppositions Africa Musica African Divas African Fiesta Akwé Obiang Amharic Amunataba Dance Band Angèle Revignet Appeals : miscellaneous As I Lay Dying Bella-Bella Benga Bezawork Asfaw Biafra Bikutsi Bob Sir Merenge Bobongo Stars Bring Me The Horizon Bumba Massa Cameroun Canon Star cara mendapatkan uang Central African Republic Centro Mix Chelsea Grin Christy Essien-Igbokwe Claim interpretation Clarity CoC CoC akan Ditutup CoC ditutup Hoax CoC resmi ditutup CoC Tidak jadi ditutup Congo Correction of errors Côte d'Ivoire DDC Mlimani Park Orchestra Deathcore Desolation Of Eden Divisional application Douala Dr. Nico drone Dur Dur Ebenezer Obey Edo Efik Egwu Ekpili Elias Tababbal err errbot Ethiopia Ewi Ezigbo Obiligbo Faadumo Qaasim Fees Framework of appeal Francis Gon Gabon gaming gentoo Ghana golang Hausa Highlife Hilarion Nguema I.K. Dairo Igbo Igbo Traditional Music Info Itsiembu Bi-Mbin Jean-Boniface Asssélé Jerry Hansen Jezu Lokota Jo-Man Anguilet Josky Kiambukuta Juju Julien Nziengui Kenya Kiam Kosmos Moutouari l'ANPAC Presente Lanrewaju Adepoju Lapiro de Mbanga Late filing lego Leonard Dembo Libaaxyada Maaweeliska Banaadir Lingala linux Lipua-Lipua Mack Joss Makossa Mali Marcel Djabioh Marthe Ashagari Mayele Mbalax Mbaye Dieye Faye Melo Divine Metalcore Mike Ejeagha Miriam Makeba Mobanza Ley Musiki Mutuashi Muziki wa Dansi Nigeria Nigerian Female Vocalists Norbert Epandja Novelty Obiang Okane Oral proceedings Orchestra Cavacha Orchestre African Jazz Orchestre Veve Osayomore Joseph Other Blogs Ouaka Stars Partiality Patent Register Patrick Idahosa Personal musings Petit Tchadien Pierre Embony Pierre-Claver Zeng Pop Prior public use python Real Sounds of Africa Reimbursement review Rex Lawson Rigo Star Rock Sahra Dawo Santo Backita Senegal Shona Show Promoter Sierra Leone software development Somalia Soukous South Africa Stay of proceedings Substantial procedural violation Sufficiency of disclosure Suicide Silence Super Stars Swahili Sylvester Odhiambo Talents of Benin Tanzania Technical or not Teshome Asged Tips tmux Togo Toto Guillaume tutorial Verckys Vijana Jazz vim Waaberi Wolof Yoruba Yoruba Percussion Styles Yvon Dawens Z 3.1.01 Z 3.2.04 Z 3.2.07 Z 3.3.02 Z 3.3.03 Z 3.3.10 Z 3.5.01 Zambia Zimbabwe Zokela

Forcing the CPU affinity can make a monothreaded process run 2-3x faster

Today, I chrooted in my system from sysresCD and I discovered that running eix-update (a gentoo portage indexing program) ran almost 3x faster under the 3.2.x linux kernel compared to the 3.6.x kernel.

After poking around, I finally discovered why. Check out this CPU usage pattern...

Basically, this is a monothreaded program (it tops at 100% CPU total). Because it is probably doing tons on IO on top of consuming 1 full thread, it must release its context often and the scheduler spreads its execution on all the cores & hyperthreads.


.
# time eix-update
[...]
eix-update 499.42s user 225.91s system 92% cpu 13:03.09 total
#

This behavior is a rather severe performance killer because the CPU cores continuously go from different sleeping states with a latency penalty each time, the cache lines are cooling down etc ...[edit] The most important latency factor is the cpu frequency scalling under the ondemand governor see below [/edit]

Let's try the same operation forcing the process on one hyperthread.

Let's see the result...


.
# time taskset 1 eix-update
[...]
taskset 1 eix-update 198.51s user 38.26s system 73% cpu 5:21.76 total
#

The 1 is in fact a bitmask saying "allowed to run on CPU1 only"

So now why the 3.2.x kernel was faster ? I suspect it is because the idling driver for the CPU was not "as good" as the one in 3.6.x so the cores did not sleep as much as on the 3.6.x kernel.

[edit] In the comment I show that putting the cpu frequency governor to "performance" is improving it as much as forcing the affinity. But it basically says to forget about energy efficiency.

Tweaking the ondemand governor to be less trigger happy on the frequency is also possible :


.
# echo -n 24 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
# time eix-update
[...]
eix-update 221.58s user 56.28s system 76% cpu 6:02.94 total

This up_thresold tells the governor to up the frequency if the load is more than 24% (I tried here to put slightly less than 100%/4)

It is way better, see the powertop screenshot for the different limits the CPU hits:

Trying to push it a little bit (17%)


.
# echo -n 17 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
# time eix-update
eix-update 212.72s user 49.50s system 76% cpu 5:42.72 total

Putting it at its minimum value (11%)


.
# echo -n 11 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
# time eix-update
eix-update 204.94s user 44.77s system 75% cpu 5:28.59 total

CPU scheduling mixed with power efficiency is a clearly a complex problem and a one size fit all is certainly not possible. Nevertheless, it is interesting to see where we can tweak our system for specific workloads. [/edit]

0 Response to "Forcing the CPU affinity can make a monothreaded process run 2-3x faster"

Post a Comment