author | Simon Giesecke <sgiesecke@mozilla.com> |
Fri, 13 Dec 2019 12:20:23 +0000 | |
changeset 506891 | 9b4c307ed8a46258a4fb6cc2869a84241f9a75dc |
parent 506890 | c400f7480696ce9fce0234f857a94965536c0567 |
child 506892 | bcee5e565d96199886577ed808d753179801c990 |
push id | 36913 |
push user | opoprus@mozilla.com |
push date | Fri, 13 Dec 2019 16:53:24 +0000 |
treeherder | mozilla-central@1ed684598bd0 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dom-workers-and-storage-reviewers, ytausky |
bugs | 1600906 |
milestone | 73.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -5049,17 +5049,17 @@ class ConnectionPool final { void ShutdownIdleThreads(); bool ScheduleTransaction(TransactionInfo* aTransactionInfo, bool aFromQueuedTransactions); void NoteFinishedTransaction(uint64_t aTransactionId); - void ScheduleQueuedTransactions(ThreadInfo& aThreadInfo); + void ScheduleQueuedTransactions(ThreadInfo aThreadInfo); void NoteIdleDatabase(DatabaseInfo* aDatabaseInfo); void NoteClosedDatabase(DatabaseInfo* aDatabaseInfo); bool MaybeFireCallback(DatabasesCompleteCallback* aCallback); void PerformIdleDatabaseMaintenance(DatabaseInfo* aDatabaseInfo); @@ -5111,17 +5111,21 @@ class ConnectionPool::CloseConnectionRun }; struct ConnectionPool::ThreadInfo { nsCOMPtr<nsIThread> mThread; RefPtr<ThreadRunnable> mRunnable; ThreadInfo(); - explicit ThreadInfo(const ThreadInfo& aOther); + ThreadInfo(const ThreadInfo& aOther) = delete; + ThreadInfo& operator=(const ThreadInfo& aOther) = delete; + + ThreadInfo(ThreadInfo&& aOther) noexcept; + ThreadInfo& operator=(ThreadInfo&& aOther) = default; ~ThreadInfo(); }; struct ConnectionPool::DatabaseInfo final { friend class nsAutoPtr<DatabaseInfo>; RefPtr<ConnectionPool> mConnectionPool; @@ -5207,21 +5211,25 @@ class ConnectionPool::FinishCallbackWrap ~FinishCallbackWrapper() override; NS_DECL_NSIRUNNABLE }; struct ConnectionPool::IdleResource { TimeStamp mIdleTime; + IdleResource(const IdleResource& aOther) = delete; + IdleResource(IdleResource&& aOther) noexcept + : IdleResource(aOther.mIdleTime) {} + IdleResource& operator=(const IdleResource& aOther) = delete; + IdleResource& operator=(IdleResource&& aOther) = delete; + protected: explicit IdleResource(const TimeStamp& aIdleTime); - explicit IdleResource(const IdleResource& aOther) = delete; - ~IdleResource(); }; struct ConnectionPool::IdleDatabaseInfo final : public IdleResource { DatabaseInfo* mDatabaseInfo; public: MOZ_IMPLICIT @@ -5238,23 +5246,30 @@ struct ConnectionPool::IdleDatabaseInfo bool operator<(const IdleDatabaseInfo& aOther) const { return mIdleTime < aOther.mIdleTime; } }; struct ConnectionPool::IdleThreadInfo final : public IdleResource { ThreadInfo mThreadInfo; - public: - // Boo, this is needed because nsTArray::InsertElementSorted() doesn't yet - // work with rvalue references. - MOZ_IMPLICIT - IdleThreadInfo(const ThreadInfo& aThreadInfo); - - explicit IdleThreadInfo(const IdleThreadInfo& aOther) = delete; + explicit IdleThreadInfo(ThreadInfo aThreadInfo); + + IdleThreadInfo(const IdleThreadInfo& aOther) = delete; + IdleThreadInfo(IdleThreadInfo&& aOther) noexcept + : IdleResource(std::move(aOther)), + mThreadInfo(std::move(aOther.mThreadInfo)) { + AssertIsOnBackgroundThread(); + MOZ_ASSERT(mThreadInfo.mRunnable); + MOZ_ASSERT(mThreadInfo.mThread); + + MOZ_COUNT_CTOR(ConnectionPool::IdleThreadInfo); + } + IdleThreadInfo& operator=(const IdleThreadInfo& aOther) = delete; + IdleThreadInfo& operator=(IdleThreadInfo&& aOther) = delete; ~IdleThreadInfo(); bool operator==(const IdleThreadInfo& aOther) const { return mThreadInfo.mRunnable == aOther.mThreadInfo.mRunnable && mThreadInfo.mThread == aOther.mThreadInfo.mThread; } @@ -11773,29 +11788,27 @@ void ConnectionPool::NoteFinishedTransac if (!dbInfo->TotalTransactionCount()) { MOZ_ASSERT(!dbInfo->mIdle); dbInfo->mIdle = true; NoteIdleDatabase(dbInfo); } } -void ConnectionPool::ScheduleQueuedTransactions(ThreadInfo& aThreadInfo) { +void ConnectionPool::ScheduleQueuedTransactions(ThreadInfo aThreadInfo) { AssertIsOnOwningThread(); MOZ_ASSERT(aThreadInfo.mThread); MOZ_ASSERT(aThreadInfo.mRunnable); MOZ_ASSERT(!mQueuedTransactions.IsEmpty()); - MOZ_ASSERT(!mIdleThreads.Contains(aThreadInfo)); AUTO_PROFILER_LABEL("ConnectionPool::ScheduleQueuedTransactions", DOM); - mIdleThreads.InsertElementSorted(aThreadInfo); - - aThreadInfo.mRunnable = nullptr; - aThreadInfo.mThread = nullptr; + auto idleThreadInfo = IdleThreadInfo{std::move(aThreadInfo)}; + MOZ_ASSERT(!mIdleThreads.Contains(idleThreadInfo)); + mIdleThreads.InsertElementSorted(std::move(idleThreadInfo)); const auto foundIt = std::find_if( mQueuedTransactions.begin(), mQueuedTransactions.end(), [& me = *this](const auto& queuedTransaction) { return !me.ScheduleTransaction(queuedTransaction, /* aFromQueuedTransactions */ true); }); @@ -11819,17 +11832,17 @@ void ConnectionPool::NoteIdleDatabase(Da if (mShutdownRequested || otherDatabasesWaiting || aDatabaseInfo->mCloseOnIdle) { // Make sure we close the connection if we're shutting down or giving the // thread to another database. CloseDatabase(aDatabaseInfo); if (otherDatabasesWaiting) { // Let another database use this thread. - ScheduleQueuedTransactions(aDatabaseInfo->mThreadInfo); + ScheduleQueuedTransactions(std::move(aDatabaseInfo->mThreadInfo)); } else if (mShutdownRequested) { // If there are no other databases that need to run then we can shut this // thread down immediately instead of going through the idle thread // mechanism. ShutdownThread(aDatabaseInfo->mThreadInfo); } return; @@ -11862,27 +11875,26 @@ void ConnectionPool::NoteClosedDatabase( // 4. Finally, if nothing above took the thread then we can add it to our // list of idle threads. It may be reused or it may time out. If we have // too many idle threads then we will shut down the oldest. if (aDatabaseInfo->mThreadInfo.mThread) { MOZ_ASSERT(aDatabaseInfo->mThreadInfo.mRunnable); if (!mQueuedTransactions.IsEmpty()) { // Give the thread to another database. - ScheduleQueuedTransactions(aDatabaseInfo->mThreadInfo); + ScheduleQueuedTransactions(std::move(aDatabaseInfo->mThreadInfo)); } else if (!aDatabaseInfo->TotalTransactionCount()) { if (mShutdownRequested) { ShutdownThread(aDatabaseInfo->mThreadInfo); } else { - MOZ_ASSERT(!mIdleThreads.Contains(aDatabaseInfo->mThreadInfo)); - - mIdleThreads.InsertElementSorted(aDatabaseInfo->mThreadInfo); - - aDatabaseInfo->mThreadInfo.mRunnable = nullptr; - aDatabaseInfo->mThreadInfo.mThread = nullptr; + auto idleThreadInfo = + IdleThreadInfo{std::move(aDatabaseInfo->mThreadInfo)}; + MOZ_ASSERT(!mIdleThreads.Contains(idleThreadInfo)); + + mIdleThreads.InsertElementSorted(std::move(idleThreadInfo)); if (mIdleThreads.Length() > kMaxIdleConnectionThreadCount) { ShutdownThread(mIdleThreads[0].mThreadInfo); mIdleThreads.RemoveElementAt(0); } AdjustIdleTimer(); } @@ -12297,21 +12309,22 @@ nsresult ConnectionPool::ThreadRunnable: } ConnectionPool::ThreadInfo::ThreadInfo() { AssertIsOnBackgroundThread(); MOZ_COUNT_CTOR(ConnectionPool::ThreadInfo); } -ConnectionPool::ThreadInfo::ThreadInfo(const ThreadInfo& aOther) - : mThread(aOther.mThread), mRunnable(aOther.mRunnable) { - AssertIsOnBackgroundThread(); - MOZ_ASSERT(aOther.mThread); - MOZ_ASSERT(aOther.mRunnable); +ConnectionPool::ThreadInfo::ThreadInfo(ThreadInfo&& aOther) noexcept + : mThread(std::move(aOther.mThread)), + mRunnable(std::move(aOther.mRunnable)) { + AssertIsOnBackgroundThread(); + MOZ_ASSERT(mThread); + MOZ_ASSERT(mRunnable); MOZ_COUNT_CTOR(ConnectionPool::ThreadInfo); } ConnectionPool::ThreadInfo::~ThreadInfo() { AssertIsOnBackgroundThread(); MOZ_COUNT_DTOR(ConnectionPool::ThreadInfo); @@ -12346,23 +12359,23 @@ ConnectionPool::IdleDatabaseInfo::IdleDa ConnectionPool::IdleDatabaseInfo::~IdleDatabaseInfo() { AssertIsOnBackgroundThread(); MOZ_ASSERT(mDatabaseInfo); MOZ_COUNT_DTOR(ConnectionPool::IdleDatabaseInfo); } -ConnectionPool::IdleThreadInfo::IdleThreadInfo(const ThreadInfo& aThreadInfo) +ConnectionPool::IdleThreadInfo::IdleThreadInfo(ThreadInfo aThreadInfo) : IdleResource(TimeStamp::NowLoRes() + TimeDuration::FromMilliseconds(kConnectionThreadIdleMS)), - mThreadInfo(aThreadInfo) { - AssertIsOnBackgroundThread(); - MOZ_ASSERT(aThreadInfo.mRunnable); - MOZ_ASSERT(aThreadInfo.mThread); + mThreadInfo(std::move(aThreadInfo)) { + AssertIsOnBackgroundThread(); + MOZ_ASSERT(mThreadInfo.mRunnable); + MOZ_ASSERT(mThreadInfo.mThread); MOZ_COUNT_CTOR(ConnectionPool::IdleThreadInfo); } ConnectionPool::IdleThreadInfo::~IdleThreadInfo() { AssertIsOnBackgroundThread(); MOZ_COUNT_DTOR(ConnectionPool::IdleThreadInfo);