Skip to content

Commit

Permalink
feat(storage): add metric to monitor available split block tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
pashinov committed Feb 7, 2025
1 parent 23e6417 commit 9f72fdb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
61 changes: 33 additions & 28 deletions scripts/gen-dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def generate_legend_format(labels: List[str]) -> str:


def create_gauge_panel(
expr: Union[str, List[Union[str, Expr]], Expr],
title: str,
unit_format=UNITS.NUMBER_FORMAT,
labels=[],
legend_format: str | None = None,
expr: Union[str, List[Union[str, Expr]], Expr],
title: str,
unit_format=UNITS.NUMBER_FORMAT,
labels=[],
legend_format: str | None = None,
) -> Panel:
if isinstance(expr, str):
expr = [Expr(metric=expr, label_selectors=labels)]
Expand Down Expand Up @@ -95,12 +95,12 @@ def create_gauge_panel(


def create_counter_panel(
expr: Union[str | Expr, List[Union[str, Expr]]],
title: str,
unit_format: str = UNITS.NUMBER_FORMAT,
labels_selectors: List[str] = [],
legend_format: str | None = None,
by_labels: list[str] = ["instance"],
expr: Union[str | Expr, List[Union[str, Expr]]],
title: str,
unit_format: str = UNITS.NUMBER_FORMAT,
labels_selectors: List[str] = [],
legend_format: str | None = None,
by_labels: list[str] = ["instance"],
) -> Panel:
"""
Create a counter panel for visualization.
Expand Down Expand Up @@ -160,12 +160,12 @@ def create_counter_panel(


def create_percent_panel(
metric1: str,
metric2: str,
title: str,
group_by_labels: List[str] = ["instance"],
label_selectors: List[str] = [],
unit_format: str = UNITS.PERCENT_FORMAT,
metric1: str,
metric2: str,
title: str,
group_by_labels: List[str] = ["instance"],
label_selectors: List[str] = [],
unit_format: str = UNITS.PERCENT_FORMAT,
) -> Panel:
"""
create a panel showing the percentage of metric1 to metric2, grouped by specified labels.
Expand Down Expand Up @@ -198,10 +198,10 @@ def create_percent_panel(


def create_heatmap_panel(
metric_name,
title,
unit_format=yaxis(UNITS.SECONDS),
labels=[],
metric_name,
title,
unit_format=yaxis(UNITS.SECONDS),
labels=[],
) -> Panel:
return heatmap_panel(
title,
Expand All @@ -220,10 +220,10 @@ def create_heatmap_panel(


def create_heatmap_quantile_panel(
metric_name: str,
title: str,
unit_format: str = UNITS.NUMBER_FORMAT,
quantile: AcceptedQuantile = "0.95",
metric_name: str,
title: str,
unit_format: str = UNITS.NUMBER_FORMAT,
quantile: AcceptedQuantile = "0.95",
) -> Panel:
"""
Create a heatmap quantile panel for the given metric.
Expand Down Expand Up @@ -260,11 +260,11 @@ def create_heatmap_quantile_panel(


def create_row(
name: str, metrics, repeat: str | None = None, collapsed=True
name: str, metrics, repeat: str | None = None, collapsed=True
) -> RowPanel:
layout = Layout(name, repeat=repeat, collapsed=collapsed)
for i in range(0, len(metrics), 2):
chunk = metrics[i : i + 2]
chunk = metrics[i: i + 2]
layout.row(chunk)
return layout.row_panel

Expand Down Expand Up @@ -855,6 +855,12 @@ def storage() -> RowPanel:
UNITS.BYTES,
"0.999",
),
create_heatmap_quantile_panel(
"tycho_storage_split_block_available_permits",
"Split block available permits",
UNITS.NUMBER_FORMAT,
"0.999",
),
create_heatmap_panel(
"tycho_storage_batch_write_time", "Time to write merge in write batch"
),
Expand Down Expand Up @@ -2392,7 +2398,6 @@ def templates() -> Templating:
timezone="browser",
).auto_panel_ids()


# open file as stream
if len(sys.argv) > 1:
stream = open(sys.argv[1], "w")
Expand Down
3 changes: 3 additions & 0 deletions storage/src/store/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,9 @@ impl BlockStorage {
self.db.rocksdb().write(batch)?;

// Start splitting block data
metrics::histogram!("tycho_storage_split_block_available_permits")
.record(self.split_block_semaphore.available_permits() as f64);

let permit = self.split_block_semaphore.clone().acquire_owned().await?;
let _handle = self.spawn_split_block_data(&id.block_id, data, permit);

Expand Down

0 comments on commit 9f72fdb

Please sign in to comment.