Skip to content

Commit b7370d5

Browse files
committed
definition of the metrics to be measured and update of the simulation input
1 parent e104dc6 commit b7370d5

3 files changed

Lines changed: 80 additions & 2 deletions

File tree

src/app/config/constants.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,43 @@ class SystemEdges(StrEnum):
182182
"""
183183

184184
NETWORK_CONNECTION = "network_connection"
185+
186+
# ======================================================================
187+
# CONSTANTS FOR SAMPLED METRICS
188+
# ======================================================================
189+
190+
class SampledMetricName(StrEnum):
191+
"""
192+
define the metrics sampled every fixed amount of
193+
time to create a time series
194+
"""
195+
196+
READY_QUEUE_LEN = "ready_queue_len" #length of the event loop ready q
197+
CORE_BUSY = "core_busy"
198+
EVENT_LOOP_IO_SLEEP = "event_loop_io_sleep"
199+
RAM_IN_USE = "ram_in_use"
200+
THROUGHPUT_RPS = "throughput_rps"
201+
202+
# ======================================================================
203+
# CONSTANTS FOR EVENT METRICS
204+
# ======================================================================
205+
206+
class EventMetricName(StrEnum):
207+
"""
208+
define the metrics triggered by event with no
209+
time series
210+
"""
211+
212+
RQS_LATENCY = "rqs_latency"
213+
LLM_COST = "llm_cost"
214+
215+
216+
# ======================================================================
217+
# CONSTANTS FOR AGGREGATED METRICS
218+
# ======================================================================
219+
220+
class AggregatedMetricName(StrEnum):
221+
"""aggregated metrics to calculate at the end of simulation"""
222+
223+
LATENCY_STATS = "latency_stats"
224+
LLM_STATS = "llm_stats"

src/app/core/helpers.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""helpers for the simulation"""
2+
3+
from collections.abc import Iterable
4+
5+
from app.config.constants import EventMetricName, SampledMetricName
6+
7+
8+
def alloc_sample_metric(
9+
enabled_sample_metrics: Iterable[SampledMetricName],
10+
) -> dict[str, list[float | int]]:
11+
"""
12+
After the pydantic validation of the whole input we
13+
instantiate a dictionary to collect the sampled metrics the
14+
user want to measure
15+
"""
16+
# t is the alignmente parameter for example assume
17+
# the snapshot for the sampled metrics are done every 10ms
18+
# t = [10,20,30,40....] to each t will correspond a measured
19+
# metric corresponding to that time interval
20+
21+
dict_sampled_metrics: dict[str, list[float | int]] = {"t": []}
22+
for key in enabled_sample_metrics:
23+
dict_sampled_metrics[key] = []
24+
return dict_sampled_metrics
25+
26+
27+
def alloc_event_metric(
28+
enabled_event_metrics: Iterable[EventMetricName],
29+
) -> dict[str, list[float | int]]:
30+
"""
31+
After the pydantic validation of the whole input we
32+
instantiate a dictionary to collect the event metrics the
33+
user want to measure
34+
"""
35+
dict_event_metrics: dict[str, list[float | int]] = {}
36+
for key in enabled_event_metrics:
37+
dict_event_metrics[key] = []
38+
return dict_event_metrics

tests/unit/simulation/test_requests_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
from app.schemas.requests_generator_input import RqsGeneratorInput
1717
from app.schemas.simulation_settings_input import SimulationSettings
1818
from app.schemas.system_topology_schema.full_system_topology_schema import (
19-
TopologyGraph,
2019
Client,
21-
TopologyNodes
20+
TopologyGraph,
21+
TopologyNodes,
2222
)
2323

2424
if TYPE_CHECKING: # Only for static type-checking

0 commit comments

Comments
 (0)