[Webkit-unassigned] [Bug 79184] Implement SpinLockMutexLocker on WTF and optimize some parts of JavaScriptCore using it
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Feb 22 18:18:02 PST 2012
https://bugs.webkit.org/show_bug.cgi?id=79184
--- Comment #4 from Kwonjin Jeong <gram at company100.net> 2012-02-22 18:18:03 PST ---
(In reply to comment #3)
> How did you confirm that this patch is an optimization?
At first, I compare the performance just between MutexLocker and SpinLockMutexLocker. Upon examination, SpinLockMutexLocker is two times faster than MutexLocker.
I created a performance test program that has a loop within a simple calculation and the Lockers. Then, the program loops one billion times.
And then, I applied SpinLockMutexLocker on some parts of JavaScriptCore, then ran 'run-sunspider', and then compare the results.
Actually, the result using SpinLockMutexLocker is 0.5% ~ 1.0% faster than MutexLocker's - it's within the margin of error.
But I guess that the performance can be better by using SpinLockMutexLocker on some more parts.
My test environment and test result is as written below.
Port: QtWebKit
OS: Linux (Ubuntu 11.10)
CPU: Intel(R) Xeon(R) CPU X5650 @ 2.67GHz (6 core)
RAM: 12GiB
Loop test result:
Mutex : 17047.357910 ms
SpinLockMutex: 7897.659180 ms
Simple Loop : 656.346680 ms
Sum : 565039360
Sunspider result:
The test program is WebKit/Source/JavaScriptCore/jsc.cpp with some modification. I just modify jscmain() function.
int jscmain(int argc, char** argv, JSGlobalData* globalData)
{
int i;
int sum = 0;
Mutex mutex;
SpinLockMutex spinLockMutex;
double startTime;
double endTimeMutexLocker;
double endTimeSpinLock;
double endTimeSimpleLoop;
startTime = currentTime();
for (i = 0; i < 1000000000; i++) {
MutexLocker locker(mutex);
sum += i;
}
endTimeMutexLocker = currentTime();
for (i = 0; i < 1000000000; i++) {
SpinLockMutexLocker locker(spinLockMutex);
sum += i;
}
endTimeSpinLock = currentTime();
for (i = 0; i < 1000000000; i++) {
sum += i;
}
endTimeSimpleLoop = currentTime();
printf("Mutex : %lf ms\n", endTimeMutexLocker * 1000.0 - startTime * 1000.0);
printf("SpinLockMutex: %lf ms\n", endTimeSpinLock * 1000.0 - endTimeMutexLocker * 1000.0);
printf("Simple Loop : %lf ms\n", endTimeSimpleLoop * 1000.0 - endTimeSpinLock * 1000.0);
printf("Sum : %d\n", sum);
return 0;
}
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list