proxygen
|
#include <atomic>
#include <memory>
#include <thread>
#include <boost/thread.hpp>
#include <folly/Exception.h>
#include <folly/VirtualExecutor.h>
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/executors/FutureExecutor.h>
#include <folly/executors/IOThreadPoolExecutor.h>
#include <folly/executors/ThreadPoolExecutor.h>
#include <folly/executors/task_queue/LifoSemMPMCQueue.h>
#include <folly/executors/task_queue/UnboundedBlockingQueue.h>
#include <folly/executors/thread_factory/InitThreadFactory.h>
#include <folly/executors/thread_factory/PriorityThreadFactory.h>
#include <folly/portability/GTest.h>
#include <folly/synchronization/detail/Spin.h>
Go to the source code of this file.
Classes | |
class | TestObserver |
class | TestData |
struct | SlowMover |
struct | UBQ< T > |
Functions | |
static Func | burnMs (uint64_t ms) |
template<class TPE > | |
static void | basic () |
TEST (ThreadPoolExecutorTest, CPUBasic) | |
TEST (IOThreadPoolExecutorTest, IOBasic) | |
template<class TPE > | |
static void | resize () |
TEST (ThreadPoolExecutorTest, CPUResize) | |
TEST (ThreadPoolExecutorTest, IOResize) | |
template<class TPE > | |
static void | stop () |
template<> | |
void | stop< IOThreadPoolExecutor > () |
TEST (ThreadPoolExecutorTest, CPUStop) | |
TEST (ThreadPoolExecutorTest, IOStop) | |
template<class TPE > | |
static void | join () |
TEST (ThreadPoolExecutorTest, CPUJoin) | |
TEST (ThreadPoolExecutorTest, IOJoin) | |
template<class TPE > | |
static void | destroy () |
template<> | |
void | destroy< IOThreadPoolExecutor > () |
TEST (ThreadPoolExecutorTest, CPUDestroy) | |
TEST (ThreadPoolExecutorTest, IODestroy) | |
template<class TPE > | |
static void | resizeUnderLoad () |
TEST (ThreadPoolExecutorTest, CPUResizeUnderLoad) | |
TEST (ThreadPoolExecutorTest, IOResizeUnderLoad) | |
template<class TPE > | |
static void | poolStats () |
TEST (ThreadPoolExecutorTest, CPUPoolStats) | |
TEST (ThreadPoolExecutorTest, IOPoolStats) | |
template<class TPE > | |
static void | taskStats () |
TEST (ThreadPoolExecutorTest, CPUTaskStats) | |
TEST (ThreadPoolExecutorTest, IOTaskStats) | |
template<class TPE > | |
static void | expiration () |
TEST (ThreadPoolExecutorTest, CPUExpiration) | |
TEST (ThreadPoolExecutorTest, IOExpiration) | |
template<typename TPE > | |
static void | futureExecutor () |
TEST (ThreadPoolExecutorTest, CPUFuturePool) | |
TEST (ThreadPoolExecutorTest, IOFuturePool) | |
TEST (ThreadPoolExecutorTest, PriorityPreemptionTest) | |
TEST (ThreadPoolExecutorTest, IOObserver) | |
TEST (ThreadPoolExecutorTest, CPUObserver) | |
TEST (ThreadPoolExecutorTest, AddWithPriority) | |
TEST (ThreadPoolExecutorTest, BlockingQueue) | |
TEST (PriorityThreadFactoryTest, ThreadPriority) | |
TEST (InitThreadFactoryTest, InitializerCalled) | |
TEST (InitThreadFactoryTest, InitializerAndFinalizerCalled) | |
TEST (ThreadPoolExecutorTest, RequestContext) | |
template<typename Q > | |
void | bugD3527722_test () |
TEST (ThreadPoolExecutorTest, LifoSemMPMCQueueBugD3527722) | |
TEST (ThreadPoolExecutorTest, UnboundedBlockingQueueBugD3527722) | |
template<typename TPE > | |
static void | removeThreadTest () |
TEST (ThreadPoolExecutorTest, RemoveThreadTestIO) | |
TEST (ThreadPoolExecutorTest, RemoveThreadTestCPU) | |
template<typename TPE > | |
static void | resizeThreadWhileExecutingTest () |
TEST (ThreadPoolExecutorTest, resizeThreadWhileExecutingTestIO) | |
TEST (ThreadPoolExecutorTest, resizeThreadWhileExecutingTestCPU) | |
template<typename TPE > | |
void | keepAliveTest () |
TEST (ThreadPoolExecutorTest, KeepAliveTestIO) | |
TEST (ThreadPoolExecutorTest, KeepAliveTestCPU) | |
int | getNumThreadPoolExecutors () |
template<typename TPE > | |
static void | registersToExecutorListTest () |
TEST (ThreadPoolExecutorTest, registersToExecutorListTestIO) | |
TEST (ThreadPoolExecutorTest, registersToExecutorListTestCPU) | |
template<typename TPE > | |
static void | testUsesNameFromNamedThreadFactory () |
TEST (ThreadPoolExecutorTest, testUsesNameFromNamedThreadFactoryIO) | |
TEST (ThreadPoolExecutorTest, testUsesNameFromNamedThreadFactoryCPU) | |
TEST (ThreadPoolExecutorTest, DynamicThreadsTest) | |
TEST (ThreadPoolExecutorTest, DynamicThreadAddRemoveRace) | |
TEST (ThreadPoolExecutorTest, AddPerf) | |
template<typename TPE > | |
static void | WeakRefTest () |
template<typename TPE > | |
static void | virtualExecutorTest () |
TEST (ThreadPoolExecutorTest, WeakRefTestIO) | |
TEST (ThreadPoolExecutorTest, WeakRefTestCPU) | |
TEST (ThreadPoolExecutorTest, VirtualExecutorTestIO) | |
TEST (ThreadPoolExecutorTest, VirtualExecutorTestCPU) | |
|
static |
Definition at line 44 of file ThreadPoolExecutorTest.cpp.
void bugD3527722_test | ( | ) |
Definition at line 592 of file ThreadPoolExecutorTest.cpp.
|
static |
Definition at line 39 of file ThreadPoolExecutorTest.cpp.
Referenced by destroy(), destroy< IOThreadPoolExecutor >(), expiration(), futureExecutor(), join(), RecursiveAddTest(), removeThreadTest(), resizeThreadWhileExecutingTest(), resizeUnderLoad(), SimpleTest(), stop(), stop< IOThreadPoolExecutor >(), taskStats(), TEST(), and WeakRefTest().
|
static |
Definition at line 140 of file ThreadPoolExecutorTest.cpp.
References burnMs(), EXPECT_GT, f, and i.
Referenced by folly::coro::detail::InlineTask< T >::Awaiter::await_resume(), folly::coro::TaskWithExecutor< T >::Awaiter::await_resume(), folly::coro::detail::TaskPromiseBase::await_transform(), folly::portability::ssl::BIO_meth_set_destroy(), wangle::AcceptorHandshakeManager::connectionError(), wangle::AcceptorHandshakeManager::connectionReady(), wangle::ServerAcceptor< Pipeline >::ServerConnection::deletePipeline(), folly::UndelayedDestruction< HHWheelTimer >::destroy(), fizz::AsyncFizzBase::destroy(), proxygen::AsyncTimeoutSet::destroy(), folly::Try< T >::emplace(), folly::Try< T >::emplaceException(), folly::threadlocal_detail::StaticMetaBase::erase(), folly::Try< folly::folly::Unit >::get(), folly::NotificationQueue< MessageT >::Consumer::getEventBase(), folly::allocator_delete< Alloc >::operator()(), folly::Try< T >::operator=(), folly::F14VectorSet< Key, Hasher, KeyEqual, Alloc >::operator=(), folly::ThreadLocalPtr< SubscriberMap >::operator=(), folly::F14VectorMap< Key, Mapped, Hasher, KeyEqual, Alloc >::operator=(), folly::dynamic::operator=(), proxygen::PassThroughTransportFilter::readEOF(), proxygen::PassThroughTransportFilter::readErr(), folly::detail::NodeRecycler< NodeType, NodeAlloc, typename std::enable_if< !NodeType::template DestroyIsNoOp< NodeAlloc >::value >::type >::releaseRef(), folly::fbvector< HTTPHeaderCode >::S_destroy_range_a(), proxygen::HTTPSession::shutdownTransportWithReset(), TEST(), test_relinquish3(), unique_ptr_test(), folly::AtomicHashMap< int64_t, int64_t >::~AtomicHashMap(), folly::detail::NodeRecycler< NodeType, NodeAlloc, typename std::enable_if< !NodeType::template DestroyIsNoOp< NodeAlloc >::value >::type >::~NodeRecycler(), and folly::ThreadLocalPtr< SubscriberMap >::~ThreadLocalPtr().
void destroy< IOThreadPoolExecutor > | ( | ) |
Definition at line 158 of file ThreadPoolExecutorTest.cpp.
References folly::IOThreadPoolExecutor::add(), burnMs(), folly::Optional< Value >::clear(), EXPECT_EQ, f, i, and folly::in_place().
Referenced by TEST().
|
static |
Definition at line 266 of file ThreadPoolExecutorTest.cpp.
References burnMs(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, folly::ThreadPoolExecutor::TaskStats::expired, FAIL, and i.
Referenced by wangle::SSLSessionCacheManager::storeCacheRecord().
|
static |
Definition at line 297 of file ThreadPoolExecutorTest.cpp.
References folly::FutureExecutor< ExecutorImpl >::addFuture(), burnMs(), c, EXPECT_EQ, EXPECT_NO_THROW, EXPECT_THROW, folly::makeFuture(), folly::Baton< MayBlock, Atom >::post(), folly::pushmi::detail::t, and folly::Baton< MayBlock, Atom >::wait().
int getNumThreadPoolExecutors | ( | ) |
Definition at line 731 of file ThreadPoolExecutorTest.cpp.
References count, and folly::ThreadPoolExecutor::withAll().
Referenced by registersToExecutorListTest().
|
static |
void keepAliveTest | ( | ) |
Definition at line 708 of file ThreadPoolExecutorTest.cpp.
References folly::pushmi::executor, EXPECT_EQ, EXPECT_TRUE, f, folly::getKeepAliveToken(), folly::gen::move, folly::futures::sleep(), and folly::via().
|
static |
Definition at line 206 of file ThreadPoolExecutorTest.cpp.
References EXPECT_EQ, EXPECT_GE, folly::Baton< MayBlock, Atom >::post(), and folly::Baton< MayBlock, Atom >::wait().
|
static |
Definition at line 738 of file ThreadPoolExecutorTest.cpp.
References EXPECT_EQ, and getNumThreadPoolExecutors().
|
static |
Definition at line 643 of file ThreadPoolExecutorTest.cpp.
References burnMs(), EXPECT_EQ, EXPECT_NE, f, folly::makeFuture(), and folly::gen::move.
|
static |
|
static |
|
static |
|
static |
Definition at line 76 of file ThreadPoolExecutorTest.cpp.
References burnMs(), EXPECT_GT, f, and i.
Referenced by accuracy_test(), ConcurrentFlowManySender::cancellation_test(), ConcurrentFlowSingleSender::cancellation_test(), proxygen::HTTP2PriorityQueue::Node::iterate(), proxygen::HTTP2PriorityQueue::iterateBFS(), ImmediateFlowSingleSender::make_producer(), ImmediateFlowManySender::make_producer(), proxygen::HTTP2PriorityQueue::nextEgress(), shared_cancellation_factory::operator()(), entangled_cancellation_factory::operator()(), proxygen::GzipHeaderCodec::parseNameValues(), proxygen::HTTP2PriorityQueue::Node::propagatePendingEgressClear(), proxygen::HTTP2PriorityQueue::Node::propagatePendingEgressSignal(), folly::AsyncServerSocket::RemoteAcceptor::RemoteAcceptor(), runFairness(), inline_executor_flow_many::submit(), TEST(), TEST_F(), and wangle::FilePoller::~FilePoller().
void stop< IOThreadPoolExecutor > | ( | ) |
Definition at line 94 of file ThreadPoolExecutorTest.cpp.
References folly::IOThreadPoolExecutor::add(), burnMs(), EXPECT_EQ, f, i, and folly::ThreadPoolExecutor::stop().
Referenced by TEST().
|
static |
Definition at line 241 of file ThreadPoolExecutorTest.cpp.
References burnMs(), c, EXPECT_EQ, EXPECT_LT, i, folly::ThreadPoolExecutor::TaskStats::runTime, and folly::ThreadPoolExecutor::TaskStats::waitTime.
TEST | ( | ThreadPoolExecutorTest | , |
CPUBasic | |||
) |
Definition at line 49 of file ThreadPoolExecutorTest.cpp.
TEST | ( | IOThreadPoolExecutorTest | , |
IOBasic | |||
) |
Definition at line 53 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
CPUResize | |||
) |
Definition at line 67 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IOResize | |||
) |
Definition at line 71 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
CPUStop | |||
) |
Definition at line 108 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IOStop | |||
) |
Definition at line 112 of file ThreadPoolExecutorTest.cpp.
References stop< IOThreadPoolExecutor >().
TEST | ( | ThreadPoolExecutorTest | , |
CPUJoin | |||
) |
Definition at line 131 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IOJoin | |||
) |
Definition at line 135 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
CPUDestroy | |||
) |
Definition at line 172 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IODestroy | |||
) |
Definition at line 176 of file ThreadPoolExecutorTest.cpp.
References destroy< IOThreadPoolExecutor >().
TEST | ( | ThreadPoolExecutorTest | , |
CPUResizeUnderLoad | |||
) |
Definition at line 197 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IOResizeUnderLoad | |||
) |
Definition at line 201 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
CPUPoolStats | |||
) |
Definition at line 232 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IOPoolStats | |||
) |
Definition at line 236 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
CPUTaskStats | |||
) |
Definition at line 257 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IOTaskStats | |||
) |
Definition at line 261 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
CPUExpiration | |||
) |
Definition at line 288 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IOExpiration | |||
) |
Definition at line 292 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
CPUFuturePool | |||
) |
Definition at line 342 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
IOFuturePool | |||
) |
Definition at line 346 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
PriorityPreemptionTest | |||
) |
Definition at line 350 of file ThreadPoolExecutorTest.cpp.
References folly::VirtualExecutor::addWithPriority(), EXPECT_EQ, EXPECT_FALSE, folly::Executor::HI_PRI, i, folly::Executor::LO_PRI, and folly::ThreadPoolExecutor::setNumThreads().
TEST | ( | ThreadPoolExecutorTest | , |
IOObserver | |||
) |
Definition at line 397 of file ThreadPoolExecutorTest.cpp.
References folly::ThreadPoolExecutor::addObserver(), exe, folly::ThreadPoolExecutor::removeObserver(), and folly::ThreadPoolExecutor::setNumThreads().
TEST | ( | ThreadPoolExecutorTest | , |
CPUObserver | |||
) |
Definition at line 413 of file ThreadPoolExecutorTest.cpp.
References folly::ThreadPoolExecutor::addObserver(), exe, folly::ThreadPoolExecutor::removeObserver(), and folly::ThreadPoolExecutor::setNumThreads().
TEST | ( | ThreadPoolExecutorTest | , |
AddWithPriority | |||
) |
Definition at line 429 of file ThreadPoolExecutorTest.cpp.
References folly::Executor::addWithPriority(), c, EXPECT_EQ, EXPECT_THROW, f, folly::Executor::HI_PRI, and folly::Executor::LO_PRI.
TEST | ( | ThreadPoolExecutorTest | , |
BlockingQueue | |||
) |
Definition at line 450 of file ThreadPoolExecutorTest.cpp.
References folly::BLOCK, burnMs(), c, EXPECT_EQ, EXPECT_NO_THROW, f, i, folly::make_unique(), and folly::gen::move.
TEST | ( | PriorityThreadFactoryTest | , |
ThreadPriority | |||
) |
Definition at line 479 of file ThreadPoolExecutorTest.cpp.
References EXPECT_EQ, folly::join(), min, folly::PriorityThreadFactory::newThread(), and folly::throwSystemError().
TEST | ( | InitThreadFactoryTest | , |
InitializerCalled | |||
) |
Definition at line 499 of file ThreadPoolExecutorTest.cpp.
References EXPECT_EQ, folly::join(), and folly::InitThreadFactory::newThread().
TEST | ( | InitThreadFactoryTest | , |
InitializerAndFinalizerCalled | |||
) |
Definition at line 511 of file ThreadPoolExecutorTest.cpp.
References EXPECT_FALSE, EXPECT_TRUE, folly::join(), and folly::InitThreadFactory::newThread().
TEST | ( | ThreadPoolExecutorTest | , |
RequestContext | |||
) |
Definition at line 559 of file ThreadPoolExecutorTest.cpp.
References folly::CPUThreadPoolExecutor::add(), ASSERT_TRUE, folly::data(), data_, folly::pushmi::executor, EXPECT_EQ, folly::RequestContext::get(), folly::RequestContext::getContextData(), and folly::RequestContext::setContextData().
TEST | ( | ThreadPoolExecutorTest | , |
LifoSemMPMCQueueBugD3527722 | |||
) |
Definition at line 629 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
UnboundedBlockingQueueBugD3527722 | |||
) |
Definition at line 638 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
RemoveThreadTestIO | |||
) |
Definition at line 668 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
RemoveThreadTestCPU | |||
) |
Definition at line 672 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
resizeThreadWhileExecutingTestIO | |||
) |
Definition at line 699 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
resizeThreadWhileExecutingTestCPU | |||
) |
Definition at line 703 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
KeepAliveTestIO | |||
) |
Definition at line 723 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
KeepAliveTestCPU | |||
) |
Definition at line 727 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
registersToExecutorListTestIO | |||
) |
Definition at line 752 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
registersToExecutorListTestCPU | |||
) |
Definition at line 756 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
testUsesNameFromNamedThreadFactoryIO | |||
) |
Definition at line 767 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
testUsesNameFromNamedThreadFactoryCPU | |||
) |
Definition at line 771 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
DynamicThreadsTest | |||
) |
Definition at line 775 of file ThreadPoolExecutorTest.cpp.
References folly::ThreadPoolExecutor::PoolStats::activeThreadCount, folly::CPUThreadPoolExecutor::add(), EXPECT_EQ, EXPECT_FALSE, folly::ThreadPoolExecutor::getPoolStats(), now(), folly::ThreadPoolExecutor::setThreadDeathTimeout(), folly::detail::spin_yield_until(), and folly::detail::success.
TEST | ( | ThreadPoolExecutorTest | , |
DynamicThreadAddRemoveRace | |||
) |
Definition at line 794 of file ThreadPoolExecutorTest.cpp.
References folly::CPUThreadPoolExecutor::add(), b, count, EXPECT_EQ, i, folly::ThreadPoolExecutor::join(), folly::Baton< MayBlock, Atom >::post(), folly::ThreadPoolExecutor::setThreadDeathTimeout(), and folly::Baton< MayBlock, Atom >::wait().
TEST | ( | ThreadPoolExecutorTest | , |
AddPerf | |||
) |
Definition at line 810 of file ThreadPoolExecutorTest.cpp.
References i, folly::make_unique(), and folly::gen::move.
TEST | ( | ThreadPoolExecutorTest | , |
WeakRefTestIO | |||
) |
Definition at line 886 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
WeakRefTestCPU | |||
) |
Definition at line 890 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
VirtualExecutorTestIO | |||
) |
Definition at line 894 of file ThreadPoolExecutorTest.cpp.
TEST | ( | ThreadPoolExecutorTest | , |
VirtualExecutorTestCPU | |||
) |
Definition at line 898 of file ThreadPoolExecutorTest.cpp.
|
static |
|
static |
Definition at line 845 of file ThreadPoolExecutorTest.cpp.
References folly::VirtualExecutor::add(), counter, EXPECT_EQ, EXPECT_NO_THROW, EXPECT_TRUE, f, folly::gen::guard(), folly::makeGuard(), folly::gen::move, folly::futures::sleep(), and folly::via().
|
static |
Definition at line 825 of file ThreadPoolExecutorTest.cpp.
References burnMs(), counter, EXPECT_EQ, EXPECT_THROW, f, folly::makeFuture(), folly::gen::move, and folly::via().