Title: [167526] trunk/Source/bmalloc
- Revision
- 167526
- Author
- [email protected]
- Date
- 2014-04-18 20:23:03 -0700 (Fri, 18 Apr 2014)
Log Message
bmalloc: AsyncTask should use Mutex instead of std::mutex
https://bugs.webkit.org/show_bug.cgi?id=131865
Reviewed by Gavin Barraclough.
std::mutex is so slow that it makes parallelizing simple tasks through
AsyncTask a net regression. Mutex fixes this.
* bmalloc/AsyncTask.h:
(bmalloc::Function>::AsyncTask):
(bmalloc::Function>::join):
(bmalloc::Function>::runSlowCase):
(bmalloc::Function>::entryPoint):
* bmalloc/Mutex.h:
(bmalloc::Mutex::init):
Modified Paths
Diff
Modified: trunk/Source/bmalloc/ChangeLog (167525 => 167526)
--- trunk/Source/bmalloc/ChangeLog 2014-04-19 01:38:31 UTC (rev 167525)
+++ trunk/Source/bmalloc/ChangeLog 2014-04-19 03:23:03 UTC (rev 167526)
@@ -1,5 +1,23 @@
2014-04-18 Geoffrey Garen <[email protected]>
+ bmalloc: AsyncTask should use Mutex instead of std::mutex
+ https://bugs.webkit.org/show_bug.cgi?id=131865
+
+ Reviewed by Gavin Barraclough.
+
+ std::mutex is so slow that it makes parallelizing simple tasks through
+ AsyncTask a net regression. Mutex fixes this.
+
+ * bmalloc/AsyncTask.h:
+ (bmalloc::Function>::AsyncTask):
+ (bmalloc::Function>::join):
+ (bmalloc::Function>::runSlowCase):
+ (bmalloc::Function>::entryPoint):
+ * bmalloc/Mutex.h:
+ (bmalloc::Mutex::init):
+
+2014-04-18 Geoffrey Garen <[email protected]>
+
bmalloc: Added an XSmall line size
https://bugs.webkit.org/show_bug.cgi?id=131851
Modified: trunk/Source/bmalloc/bmalloc/AsyncTask.h (167525 => 167526)
--- trunk/Source/bmalloc/bmalloc/AsyncTask.h 2014-04-19 01:38:31 UTC (rev 167525)
+++ trunk/Source/bmalloc/bmalloc/AsyncTask.h 2014-04-19 03:23:03 UTC (rev 167526)
@@ -28,6 +28,7 @@
#include "BAssert.h"
#include "Inline.h"
+#include "Mutex.h"
#include <atomic>
#include <condition_variable>
#include <pthread.h>
@@ -55,8 +56,8 @@
std::atomic<State> m_state;
- std::mutex m_conditionMutex;
- std::condition_variable m_condition;
+ Mutex m_conditionMutex;
+ std::condition_variable_any m_condition;
pthread_t m_thread;
Object& m_object;
@@ -73,6 +74,7 @@
, m_object(object)
, m_function(function)
{
+ m_conditionMutex.init();
}
template<typename Object, typename Function>
@@ -81,7 +83,7 @@
if (m_state == Exited)
return;
- { std::lock_guard<std::mutex> lock(m_conditionMutex); }
+ { std::lock_guard<Mutex> lock(m_conditionMutex); }
m_condition.notify_one();
while (m_state != Exited)
@@ -104,7 +106,7 @@
return;
if (oldState == Sleeping) {
- { std::lock_guard<std::mutex> lock(m_conditionMutex); }
+ { std::lock_guard<Mutex> lock(m_conditionMutex); }
m_condition.notify_one();
return;
}
@@ -131,7 +133,7 @@
expectedState = Running;
if (m_state.compare_exchange_weak(expectedState, Sleeping)) {
- std::unique_lock<std::mutex> lock(m_conditionMutex);
+ std::unique_lock<Mutex> lock(m_conditionMutex);
m_condition.wait_for(lock, exitDelay, [=]() { return this->m_state != Sleeping; });
}
Modified: trunk/Source/bmalloc/bmalloc/Mutex.h (167525 => 167526)
--- trunk/Source/bmalloc/bmalloc/Mutex.h 2014-04-19 01:38:31 UTC (rev 167525)
+++ trunk/Source/bmalloc/bmalloc/Mutex.h 2014-04-19 03:23:03 UTC (rev 167526)
@@ -33,8 +33,10 @@
namespace bmalloc {
-class Mutex {
+struct Mutex {
public:
+ void init();
+
void lock();
bool try_lock();
void unlock();
@@ -45,6 +47,11 @@
std::atomic_flag m_flag;
};
+inline void Mutex::init()
+{
+ m_flag.clear();
+}
+
inline bool Mutex::try_lock()
{
return !m_flag.test_and_set(std::memory_order_acquire);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes