Skip to content

Commit

Permalink
set up ThreadPoolExecutorCounters on UnboundedQueueExecutor
Browse files Browse the repository at this point in the history
Summary: This diff sets up ThreadPoolExecutorCounters on the UnboundedTaskQueue. This is used in a handful of cases in EdenFS (see test plan)

Reviewed By: kavehahmadi60

Differential Revision: D62920328

fbshipit-source-id: 760c36e4b4cf318e5bb7a0c75a423ddf34ec635d
  • Loading branch information
genevievehelsel authored and facebook-github-bot committed Sep 19, 2024
1 parent 4813c02 commit d57d741
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions eden/common/utils/UnboundedQueueExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,37 @@
#include <folly/executors/task_queue/UnboundedBlockingQueue.h>
#include <folly/executors/thread_factory/NamedThreadFactory.h>

#include "eden/common/eden-config.h"

#ifdef EDEN_COMMON_HAVE_SERVER_OBSERVER
#include "common/fb303/cpp/ThreadPoolExecutorCounters.h" // @manual
#endif

namespace facebook::eden {

UnboundedQueueExecutor::UnboundedQueueExecutor(
namespace {

std::unique_ptr<folly::CPUThreadPoolExecutor> makeExecutor(
size_t threadCount,
folly::StringPiece threadNamePrefix)
: executor_{std::make_unique<folly::CPUThreadPoolExecutor>(
folly::StringPiece threadNamePrefix) {
std::unique_ptr<folly::CPUThreadPoolExecutor> executor =
std::make_unique<folly::CPUThreadPoolExecutor>(
threadCount,
std::make_unique<folly::UnboundedBlockingQueue<
folly::CPUThreadPoolExecutor::CPUTask>>(),
std::make_unique<folly::NamedThreadFactory>(threadNamePrefix))} {}
std::make_unique<folly::NamedThreadFactory>(threadNamePrefix));
#ifdef EDEN_COMMON_HAVE_SERVER_OBSERVER
facebook::fb303::installThreadPoolExecutorCounters("", *executor);
#endif
return executor;
}

} // namespace

UnboundedQueueExecutor::UnboundedQueueExecutor(
size_t threadCount,
folly::StringPiece threadNamePrefix)
: executor_{makeExecutor(threadCount, threadNamePrefix)} {}

UnboundedQueueExecutor::UnboundedQueueExecutor(
std::shared_ptr<folly::ManualExecutor> executor)
Expand Down

0 comments on commit d57d741

Please sign in to comment.