Commit 73a35da0 authored by Pranav Thulasiram Bhat's avatar Pranav Thulasiram Bhat Committed by Facebook GitHub Bot

Add blocking logging to fibers::Baton

Summary: Increase coverage of blocking operation logging.

Reviewed By: yfeldblum

Differential Revision: D22933413

fbshipit-source-id: e820927ddafa0bb5f2d50dbb1dceeeb2e89133b3
parent e6d5beb4
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/detail/AsyncTrace.h>
#include <folly/fibers/Fiber.h> #include <folly/fibers/Fiber.h>
#include <folly/fibers/FiberManagerInternal.h> #include <folly/fibers/FiberManagerInternal.h>
...@@ -77,6 +78,10 @@ bool Baton::timedWaitThread( ...@@ -77,6 +78,10 @@ bool Baton::timedWaitThread(
const std::chrono::time_point<Clock, Duration>& deadline) { const std::chrono::time_point<Clock, Duration>& deadline) {
auto waiter = waiter_.load(); auto waiter = waiter_.load();
folly::async_tracing::logBlockingOperation(
std::chrono::duration_cast<std::chrono::milliseconds>(
deadline - Clock::now()));
if (LIKELY( if (LIKELY(
waiter == NO_WAITER && waiter == NO_WAITER &&
waiter_.compare_exchange_strong(waiter, THREAD_WAITING))) { waiter_.compare_exchange_strong(waiter, THREAD_WAITING))) {
......
...@@ -61,6 +61,8 @@ void Baton::wait(TimeoutHandler& timeoutHandler) { ...@@ -61,6 +61,8 @@ void Baton::wait(TimeoutHandler& timeoutHandler) {
void Baton::waitThread() { void Baton::waitThread() {
auto waiter = waiter_.load(); auto waiter = waiter_.load();
auto waitStart = std::chrono::steady_clock::now();
if (LIKELY( if (LIKELY(
waiter == NO_WAITER && waiter == NO_WAITER &&
waiter_.compare_exchange_strong(waiter, THREAD_WAITING))) { waiter_.compare_exchange_strong(waiter, THREAD_WAITING))) {
...@@ -71,6 +73,10 @@ void Baton::waitThread() { ...@@ -71,6 +73,10 @@ void Baton::waitThread() {
} while (waiter == THREAD_WAITING); } while (waiter == THREAD_WAITING);
} }
folly::async_tracing::logBlockingOperation(
std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - waitStart));
if (LIKELY(waiter == POSTED)) { if (LIKELY(waiter == POSTED)) {
return; return;
} }
......
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