Skip to content

Commit

Permalink
Add jetstream_server_startup_latency metric (#118)
Browse files Browse the repository at this point in the history
* first commit

* no labels on metric

* format

* change measurement

* fmt

* rename metric

* Time -> time

* nits

* fixed args

* int -> float

* int -> float

* move endpoint to server_lib.py

* nit

* missing labels
  • Loading branch information
Bslabe123 authored Jul 22, 2024
1 parent 6ec67e4 commit bd6d013
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions jetstream/core/metrics/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def __new__(cls):
documentation="The percentage of decode slots currently being used",
labelnames=["id", "idx"],
)
_server_startup_latency = Gauge(
name="jetstream_server_startup_latency",
documentation="Total time taken to start the Jetstream server",
labelnames=["id"],
)

def get_prefill_backlog_metric(self):
return self._prefill_backlog.labels(id=self._id)
Expand All @@ -62,3 +67,6 @@ def get_generate_backlog_metric(self, idx: int):

def get_slots_used_percentage_metric(self, idx: int):
return self._slots_used_percentage.labels(id=self._id, idx=idx)

def get_server_startup_latency_metric(self):
return self._server_startup_latency.labels(id=self._id)
9 changes: 9 additions & 0 deletions jetstream/core/server_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import os
import signal
import threading
import time
import traceback
from typing import Any, Type

Expand Down Expand Up @@ -122,6 +123,9 @@ def run(
Returns:
JetStreamServer that wraps the grpc server and orchestrator driver.
"""

server_start_time = time.time()

logging.info("Kicking off gRPC server.")
engines = config_lib.get_engines(config, devices=devices)
prefill_params = [pe.load_params() for pe in engines.prefill_engines]
Expand Down Expand Up @@ -196,6 +200,11 @@ def run(

jetstream_server.start()

if metrics_collector:
metrics_collector.get_server_startup_latency_metric().set(
time.time() - server_start_time
)

# Setup Jax Profiler
if enable_jax_profiler:
logging.info("Starting JAX profiler server on port %s", jax_profiler_port)
Expand Down

0 comments on commit bd6d013

Please sign in to comment.