Commit 44ff9b50 authored by Lee Howes's avatar Lee Howes Committed by Facebook GitHub Bot

Add logging for SemiFutures that are discarded with potential

Summary: Add tracing to SemiFuture destruction that is potentially work-dropping.

Reviewed By: yfeldblum

Differential Revision: D21671142

fbshipit-source-id: 8e3e733d9a0845b00fe7ccf465e9c817a10fee59
parent 93d952a9
...@@ -29,5 +29,7 @@ FOLLY_ATTR_WEAK void logGetImmutableIOExecutor(IOExecutor*) noexcept {} ...@@ -29,5 +29,7 @@ FOLLY_ATTR_WEAK void logGetImmutableIOExecutor(IOExecutor*) noexcept {}
FOLLY_ATTR_WEAK void logSemiFutureVia(Executor*, Executor*) noexcept {} FOLLY_ATTR_WEAK void logSemiFutureVia(Executor*, Executor*) noexcept {}
FOLLY_ATTR_WEAK void logFutureVia(Executor*, Executor*) noexcept {} FOLLY_ATTR_WEAK void logFutureVia(Executor*, Executor*) noexcept {}
FOLLY_ATTR_WEAK void logBlockingOperation(std::chrono::milliseconds) noexcept {} FOLLY_ATTR_WEAK void logBlockingOperation(std::chrono::milliseconds) noexcept {}
FOLLY_ATTR_WEAK void logSemiFutureDiscard(
DiscardHasDeferred /* hasDeferredExecutor */) noexcept {}
} // namespace async_tracing } // namespace async_tracing
} // namespace folly } // namespace folly
...@@ -24,6 +24,10 @@ namespace folly { ...@@ -24,6 +24,10 @@ namespace folly {
class Executor; class Executor;
class IOExecutor; class IOExecutor;
namespace async_tracing { namespace async_tracing {
enum class DiscardHasDeferred {
NO_EXECUTOR,
DEFERRED_EXECUTOR,
};
void logSetGlobalCPUExecutor(Executor*) noexcept; void logSetGlobalCPUExecutor(Executor*) noexcept;
void logSetGlobalCPUExecutorToImmutable() noexcept; void logSetGlobalCPUExecutorToImmutable() noexcept;
void logGetGlobalCPUExecutor(Executor*) noexcept; void logGetGlobalCPUExecutor(Executor*) noexcept;
...@@ -34,5 +38,7 @@ void logGetImmutableIOExecutor(IOExecutor*) noexcept; ...@@ -34,5 +38,7 @@ void logGetImmutableIOExecutor(IOExecutor*) noexcept;
void logSemiFutureVia(Executor*, Executor*) noexcept; void logSemiFutureVia(Executor*, Executor*) noexcept;
void logFutureVia(Executor*, Executor*) noexcept; void logFutureVia(Executor*, Executor*) noexcept;
void logBlockingOperation(std::chrono::milliseconds) noexcept; void logBlockingOperation(std::chrono::milliseconds) noexcept;
void logSemiFutureDiscard(
DiscardHasDeferred /* hasDeferredExecutor */) noexcept;
} // namespace async_tracing } // namespace async_tracing
} // namespace folly } // namespace folly
...@@ -36,4 +36,7 @@ TEST(FollyCountersTest, Trivial) { ...@@ -36,4 +36,7 @@ TEST(FollyCountersTest, Trivial) {
folly::async_tracing::logFutureVia(lastExec, exec); folly::async_tracing::logFutureVia(lastExec, exec);
folly::async_tracing::logBlockingOperation(std::chrono::milliseconds{100}); folly::async_tracing::logBlockingOperation(std::chrono::milliseconds{100});
folly::async_tracing::logSemiFutureDiscard(
folly::async_tracing::DiscardHasDeferred::NO_EXECUTOR);
} }
...@@ -678,7 +678,11 @@ void SemiFuture<T>::releaseDeferredExecutor(Core* core) { ...@@ -678,7 +678,11 @@ void SemiFuture<T>::releaseDeferredExecutor(Core* core) {
if (!core || core->hasCallback()) { if (!core || core->hasCallback()) {
return; return;
} }
if (auto executor = core->stealDeferredExecutor()) { auto executor = core->stealDeferredExecutor();
async_tracing::logSemiFutureDiscard(
executor.get() ? async_tracing::DiscardHasDeferred::DEFERRED_EXECUTOR
: async_tracing::DiscardHasDeferred::NO_EXECUTOR);
if (executor) {
executor.get()->detach(); executor.get()->detach();
} }
} }
......
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