summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-09-27 19:40:24 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-08 02:45:16 +0200
commit583d05863e4aa1c6af1948795ce42b928a0017d0 (patch)
treebd0fc1b404e86314f5cbfa5bcb1e6c1f203b608b /src/corelib/thread
parent4533cc994484a2308297e64e99af005fb4dca065 (diff)
Reorder the members in QThreadData to avoid padding holes
Before this change, this struct had size 104 and a total of 21 padding bytes. Now it's down to 88 bytes and only 5 bytes of padding. pahole report on a 64-bit system: class QAtomicInt _ref; /* 0 4 */ /* XXX 4 bytes hole, try to pack */ public: class QThread * thread; /* 8 8 */ HANDLE threadId; /* 16 8 */ bool quitNow; /* 24 1 */ /* XXX 3 bytes hole, try to pack */ int loopLevel; /* 28 4 */ class QAtomicPointer<QAbstractEventDispatcher> eventDispatcher; /* 32 8 */ class QStack<QEventLoop*> eventLoops; /* 40 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ class QPostEventList postEventList; /* 48 32 */ bool canWait; /* 80 1 */ /* XXX 7 bytes hole, try to pack */ class QVector<void*> tls; /* 88 8 */ bool isAdopted; /* 96 1 */ /* size: 104, cachelines: 2, members: 11 */ /* sum members: 90, holes: 3, sum holes: 14 */ /* padding: 7 */ Change-Id: I1fc88e0b312f38eccdea440734fd37e0519285a2 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread.cpp4
-rw-r--r--src/corelib/thread/qthread_p.h20
2 files changed, 14 insertions, 10 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 27529f8644..7667aff0b2 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -58,8 +58,8 @@ QT_BEGIN_NAMESPACE
*/
QThreadData::QThreadData(int initialRefCount)
- : _ref(initialRefCount), thread(0), threadId(0),
- quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true), isAdopted(false)
+ : _ref(initialRefCount), loopLevel(0), thread(0), threadId(0),
+ eventDispatcher(0), quitNow(false), canWait(true), isAdopted(false)
{
// fprintf(stderr, "QThreadData %p created\n", this);
}
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index fa1f7414f1..8429e41433 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -219,8 +219,6 @@ public:
class QThreadData
{
- QAtomicInt _ref;
-
public:
QThreadData(int initialRefCount = 1);
~QThreadData();
@@ -262,17 +260,23 @@ public:
{ return std::find(locations, locations + Count, method) != locations + Count; }
};
- QThread *thread;
- Qt::HANDLE threadId;
- bool quitNow;
+private:
+ QAtomicInt _ref;
+
+public:
int loopLevel;
- QAtomicPointer<QAbstractEventDispatcher> eventDispatcher;
+
QStack<QEventLoop *> eventLoops;
QPostEventList postEventList;
- bool canWait;
+ QThread *thread;
+ Qt::HANDLE threadId;
+ QAtomicPointer<QAbstractEventDispatcher> eventDispatcher;
QVector<void *> tls;
- bool isAdopted;
FlaggedDebugSignatures flaggedSignatures;
+
+ bool quitNow;
+ bool canWait;
+ bool isAdopted;
};
class QScopedLoopLevelCounter