[promises] increase debuggability of loop (#38137)

Add a couple of traces to aid debugging loops in the future

Closes #38137

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/38137 from ctiller:flake-fightas-28 648538f5e7
PiperOrigin-RevId: 697291436
pull/38150/head
Craig Tiller 1 week ago committed by Copybara-Service
parent b1890d880a
commit 7f535a6b2b
  1. 1
      src/core/BUILD
  2. 9
      src/core/lib/promise/loop.h

@ -894,6 +894,7 @@ grpc_cc_library(
"poll",
"promise_factory",
"//:gpr_platform",
"//:grpc_trace",
],
)

@ -22,6 +22,7 @@
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/types/variant.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/promise/detail/promise_factory.h"
#include "src/core/lib/promise/poll.h"
#include "src/core/util/construct_destruct.h"
@ -100,6 +101,8 @@ class Loop {
Loop& operator=(const Loop& loop) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION Poll<Result> operator()() {
GRPC_TRACE_LOG(promise_primitives, INFO)
<< "loop[" << this << "] begin poll started=" << started_;
if (!started_) {
started_ = true;
Construct(&promise_, factory_.Make());
@ -113,14 +116,20 @@ class Loop {
// from our factory.
auto lc = LoopTraits<PromiseResult>::ToLoopCtl(std::move(*p));
if (absl::holds_alternative<Continue>(lc)) {
GRPC_TRACE_LOG(promise_primitives, INFO)
<< "loop[" << this << "] iteration complete, continue";
Destruct(&promise_);
Construct(&promise_, factory_.Make());
continue;
}
GRPC_TRACE_LOG(promise_primitives, INFO)
<< "loop[" << this << "] iteration complete, return";
// - otherwise there's our result... return it out.
return absl::get<Result>(std::move(lc));
} else {
// Otherwise the inner promise was pending, so we are pending.
GRPC_TRACE_LOG(promise_primitives, INFO)
<< "loop[" << this << "] pending";
return Pending();
}
}

Loading…
Cancel
Save