Commit 4e91e1ca authored by Andrew Krieger's avatar Andrew Krieger Committed by Facebook Github Bot

Back out "Use extended alignment safe allocator in CPUThreadPoolExecutor"

Differential Revision: D19539438

fbshipit-source-id: 88c536a72a9b54d36ead2215d935745710d1d3db
parent c94486da
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <folly/executors/CPUThreadPoolExecutor.h> #include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/Memory.h>
#include <folly/executors/task_queue/PriorityLifoSemMPMCQueue.h> #include <folly/executors/task_queue/PriorityLifoSemMPMCQueue.h>
#include <folly/executors/task_queue/PriorityUnboundedBlockingQueue.h> #include <folly/executors/task_queue/PriorityUnboundedBlockingQueue.h>
#include <folly/executors/task_queue/UnboundedBlockingQueue.h> #include <folly/executors/task_queue/UnboundedBlockingQueue.h>
...@@ -29,16 +28,6 @@ DEFINE_bool( ...@@ -29,16 +28,6 @@ DEFINE_bool(
namespace folly { namespace folly {
namespace {
// queue_alloc custom allocator is necessary until C++17
// http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3396.htm
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65122
// https://bugs.llvm.org/show_bug.cgi?id=22634
using default_queue = UnboundedBlockingQueue<CPUThreadPoolExecutor::CPUTask>;
using default_queue_alloc =
AlignedSysAllocator<default_queue, FixedAlign<alignof(default_queue)>>;
} // namespace
const size_t CPUThreadPoolExecutor::kDefaultMaxQueueSize = 1 << 14; const size_t CPUThreadPoolExecutor::kDefaultMaxQueueSize = 1 << 14;
CPUThreadPoolExecutor::CPUThreadPoolExecutor( CPUThreadPoolExecutor::CPUThreadPoolExecutor(
...@@ -49,7 +38,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor( ...@@ -49,7 +38,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
numThreads, numThreads,
FLAGS_dynamic_cputhreadpoolexecutor ? 0 : numThreads, FLAGS_dynamic_cputhreadpoolexecutor ? 0 : numThreads,
std::move(threadFactory)), std::move(threadFactory)),
taskQueue_(taskQueue.release()) { taskQueue_(std::move(taskQueue)) {
setNumThreads(numThreads); setNumThreads(numThreads);
registerThreadPoolExecutor(this); registerThreadPoolExecutor(this);
} }
...@@ -62,7 +51,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor( ...@@ -62,7 +51,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
numThreads.first, numThreads.first,
numThreads.second, numThreads.second,
std::move(threadFactory)), std::move(threadFactory)),
taskQueue_(taskQueue.release()) { taskQueue_(std::move(taskQueue)) {
setNumThreads(numThreads.first); setNumThreads(numThreads.first);
registerThreadPoolExecutor(this); registerThreadPoolExecutor(this);
} }
...@@ -74,7 +63,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor( ...@@ -74,7 +63,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
numThreads, numThreads,
FLAGS_dynamic_cputhreadpoolexecutor ? 0 : numThreads, FLAGS_dynamic_cputhreadpoolexecutor ? 0 : numThreads,
std::move(threadFactory)), std::move(threadFactory)),
taskQueue_(std::allocate_shared<default_queue>(default_queue_alloc{})) { taskQueue_(std::make_unique<UnboundedBlockingQueue<CPUTask>>()) {
setNumThreads(numThreads); setNumThreads(numThreads);
registerThreadPoolExecutor(this); registerThreadPoolExecutor(this);
} }
...@@ -86,7 +75,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor( ...@@ -86,7 +75,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
numThreads.first, numThreads.first,
numThreads.second, numThreads.second,
std::move(threadFactory)), std::move(threadFactory)),
taskQueue_(std::allocate_shared<default_queue>(default_queue_alloc{})) { taskQueue_(std::make_unique<UnboundedBlockingQueue<CPUTask>>()) {
setNumThreads(numThreads.first); setNumThreads(numThreads.first);
registerThreadPoolExecutor(this); registerThreadPoolExecutor(this);
} }
......
...@@ -146,8 +146,7 @@ class CPUThreadPoolExecutor : public ThreadPoolExecutor { ...@@ -146,8 +146,7 @@ class CPUThreadPoolExecutor : public ThreadPoolExecutor {
bool tryDecrToStop(); bool tryDecrToStop();
bool taskShouldStop(folly::Optional<CPUTask>&); bool taskShouldStop(folly::Optional<CPUTask>&);
// shared_ptr for type erased dtor to handle extended alignment. std::unique_ptr<BlockingQueue<CPUTask>> taskQueue_;
std::shared_ptr<BlockingQueue<CPUTask>> taskQueue_;
std::atomic<ssize_t> threadsToStop_{0}; std::atomic<ssize_t> threadsToStop_{0};
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment