diff --git a/AGENTS.md b/AGENTS.md index 2e7457cc..ed6f24bf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,3 +1,8 @@ +# Code comments + +Keep code comments succinct. The goal of code comments is to help readability by explaining the current code and/or giving some intuitive reasoning. +This can use an example. Code comments should not include git history, or issue numbers or historical facts. + # Process conventions - **Keep PRs small and single-purpose.** Split a PR that mixes multiple diff --git a/asap-tools/experiments/README_WORKLOAD_GENERATOR.md b/asap-tools/experiments/README_WORKLOAD_GENERATOR.md index 47b9ea73..652aba59 100644 --- a/asap-tools/experiments/README_WORKLOAD_GENERATOR.md +++ b/asap-tools/experiments/README_WORKLOAD_GENERATOR.md @@ -16,6 +16,10 @@ The `generate_workload.py` script creates experiment configs by randomly composi | **B4** | sum/count_over_time | `sum_over_time(fake_metric_total[15m])` | | **B5** | rate/increase | `rate(fake_metric_total[15m])` | | **B6** | nested aggregation | `sum by (label_0) (sum_over_time(fake_metric_total[15m]))` | +| **B7** | aggregate rate | `sum by (label_0) (rate(fake_metric_total[15m]))` or `count by (label_0) (rate(fake_metric_total[15m]))` | +| **B8** | topk over sum | `topk(1, sum by (label_0) (fake_metric_total))`, with `k` of 1, 3, or 5 | +| **B9** | topk over count | `topk(1, count by (label_0) (fake_metric_total))`, with `k` of 1, 3, or 5 | +| **B10** | max_over_time | `max_over_time(fake_metric_total[15m])` | Each block randomly selects parameters: - **Quantiles**: 0.5, 0.7, 0.8, 0.9, 0.95, 0.99 diff --git a/asap-tools/experiments/generate_workload.py b/asap-tools/experiments/generate_workload.py index 9fc7ccc7..ac79d02e 100644 --- a/asap-tools/experiments/generate_workload.py +++ b/asap-tools/experiments/generate_workload.py @@ -125,7 +125,7 @@ def get_query_lookback(query: str) -> int: # ============================================================================ -# QUERY BUILDING BLOCKS (B1-B6) +# QUERY BUILDING BLOCKS (B1-B10) # Each function generates a random query of that type # ============================================================================ @@ -198,6 +198,50 @@ def generate_b6_query() -> str: return f"{outer_agg} by ({label}) ({inner_agg}({metric}[{time_range}]))" +def generate_b7_query() -> str: + """B7: sum by or count by applied to rate. + + Example: sum by (label_0) (rate(fake_metric_total[15m])) + """ + aggregation = random.choice(["sum", "count"]) + label = get_aggregation_label() + time_range = get_time_range() + metric = get_metric_name() + return f"{aggregation} by ({label}) (rate({metric}[{time_range}]))" + + +def generate_b8_query() -> str: + """B8: topk over sum by aggregation, with k in {1, 3, 5}. + + Example: topk(3, sum by (label_0) (fake_metric_total)) + """ + k = random.choice([1, 3, 5]) + label = get_aggregation_label() + metric = get_metric_name() + return f"topk({k}, sum by ({label}) ({metric}))" + + +def generate_b9_query() -> str: + """B9: topk over count by aggregation, with k in {1, 3, 5}. + + Example: topk(3, count by (label_0) (fake_metric_total)) + """ + k = random.choice([1, 3, 5]) + label = get_aggregation_label() + metric = get_metric_name() + return f"topk({k}, count by ({label}) ({metric}))" + + +def generate_b10_query() -> str: + """B10: max_over_time query. + + Example: max_over_time(fake_metric_total[15m]) + """ + time_range = get_time_range() + metric = get_metric_name() + return f"max_over_time({metric}[{time_range}])" + + # Map block IDs to generator functions BLOCK_GENERATORS = { 1: generate_b1_query, @@ -206,6 +250,10 @@ def generate_b6_query() -> str: 4: generate_b4_query, 5: generate_b5_query, 6: generate_b6_query, + 7: generate_b7_query, + 8: generate_b8_query, + 9: generate_b9_query, + 10: generate_b10_query, } @@ -604,6 +652,10 @@ def main(): B4: sum_over_time / count_over_time B5: rate / increase B6: sum by () (sum_over_time / count_over_time) + B7: sum by / count by (rate) + B8: topk(1|3|5, sum by ()) + B9: topk(1|3|5, count by ()) + B10: max_over_time """, )