Skip to content

Commit b805247

Browse files
vidhyavfacebook-github-bot
authored andcommitted
Added endpoint latency for stream method. (#1753)
Summary: As stated here. Differential Revision: D86232946
1 parent d3f578b commit b805247

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

python/monarch/_src/actor/endpoint.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
description="Latency of endpoint call_one operations in microseconds",
5252
)
5353

54+
# Histogram for measuring endpoint stream latency per yield
55+
endpoint_stream_latency_histogram: Histogram = METER.create_histogram(
56+
name="endpoint_stream_latency.us",
57+
description="Latency of endpoint stream operations per yield in microseconds",
58+
)
59+
5460
T = TypeVar("T")
5561

5662

@@ -247,9 +253,17 @@ def stream(
247253
extent: Extent = self._send(args, kwargs, port=p)
248254
r: "PortReceiver[R]" = r_port
249255

256+
method_name: str = self._get_method_name()
257+
250258
def _stream() -> Generator[Future[R], None, None]:
251259
for _ in range(extent.nelements):
252-
yield r.recv()
260+
measured_coro = _measure_latency(
261+
r._recv(),
262+
endpoint_stream_latency_histogram,
263+
method_name,
264+
extent.nelements,
265+
)
266+
yield Future(coro=measured_coro)
253267

254268
return _stream()
255269

0 commit comments

Comments
 (0)