This is an automated email from the ASF dual-hosted git repository.
martinzink pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new cd64f0853 MINIFICPP-2854 Add benchmark scripts for repositories (#2245)
cd64f0853 is described below
commit cd64f0853872fceb622f0ee91c7dcd5cf3555f1c
Author: Gabor Gyimesi <[email protected]>
AuthorDate: Mon Nov 30 14:08:46 2026 +0100
MINIFICPP-2854 Add benchmark scripts for repositories (#2245)
---
benchmarks/repository_benchmark/README.md | 122 ++++++
benchmarks/repository_benchmark/generate_report.py | 347 ++++++++++++++++
benchmarks/repository_benchmark/requirements.txt | 7 +
.../resources/generate_config.json | 70 ++++
.../repository_benchmark/resources/get_config.json | 70 ++++
benchmarks/repository_benchmark/results/.gitignore | 6 +
benchmarks/repository_benchmark/run_batch.py | 142 +++++++
benchmarks/repository_benchmark/run_benchmark.py | 446 +++++++++++++++++++++
8 files changed, 1210 insertions(+)
diff --git a/benchmarks/repository_benchmark/README.md
b/benchmarks/repository_benchmark/README.md
new file mode 100644
index 000000000..1ef2288b3
--- /dev/null
+++ b/benchmarks/repository_benchmark/README.md
@@ -0,0 +1,122 @@
+<!--
+ SPDX-License-Identifier: Apache-2.0
+ SPDX-FileCopyrightText: See the NOTICE file distributed with this work for
additional information regarding copyright ownership
+ SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under
one or more contributor license agreements
+-->
+
+# Repository benchmark
+
+Tools for comparing MiNiFi C++ FlowFile and content repository implementations
+(RocksDB, LMDB, filesystem, volatile) under a controlled workload. Each run
+starts a MiNiFi container with a chosen repository combination, samples its
+resource usage over time, and records throughput; a report overlays several
runs
+so the implementations can be compared side by side.
+
+## Prerequisites
+
+- Docker (the current user must be able to run containers).
+- A MiNiFi C++ Docker image (e.g. built via `make docker`), referenced with
+ `--image`.
+- Python 3.10+ and the dependencies:
+
+ ```bash
+ python3 -m venv venv && source venv/bin/activate
+ pip install -r requirements.txt
+ ```
+
+## Single run
+
+```bash
+python3 run_benchmark.py \
+ --image apacheminificpp:1.0.0 \
+ --flowfile-repository lmdb \
+ --content-repository lmdb
+```
+
+Results are written to `results/<timestamp>_<flowfile>_<content>_<type>.json`
+unless `--output` is given.
+
+### Input generation modes (`--input-file-generation-type`)
+
+- `timed_getfile` (default): write input files into a mounted directory at a
+ fixed interval; a `GetFile` processor ingests them. Runs for `--duration`.
+- `timed_generateflowfile`: a `GenerateFlowFile` processor produces flow files
+ in-process at a fixed interval. Runs for `--duration`.
+- `burst`: generate `--input-file-count` files up front, then ingest them all
+ with `GetFile`. Ends once every file has been processed (bounded by a
timeout).
+
+Other useful flags: `--duration`, `--input-interval`, `--input-file-size`
+(accepts `512K`, `1M`, `1G`), `--input-file-count`, `--metrics-interval`.
+
+### Flow file attributes (`--attribute-count`, `--attribute-size`)
+
+To put extra metadata weight on each flow file (stressing the flow file
+repository), `--attribute-count N` adds `N` attributes via the
`UpdateAttribute`
+processor, each with a random value of `--attribute-size M` bytes (accepts
`64`,
+`1K`, ...). Both default to `0` (no extra attributes). Example:
`--attribute-count
+20 --attribute-size 256` sets 20 attributes of 256 bytes on every flow file.
These
+flags are shared by `run_batch.py` too.
+
+## Batch run (compare several combinations)
+
+`run_batch.py` runs a set of repository combinations against the same workload,
+**sequentially** (containers do not compete for CPU/IO, which keeps the numbers
+comparable), and can generate the report automatically:
+
+```bash
+python3 run_batch.py \
+ --image apacheminificpp:1.0.0 \
+ --combo lmdb:lmdb \
+ --combo rocksdb:rocksdb \
+ --combo rocksdb:filesystem \
+ --input-file-generation-type burst \
+ --input-file-count 100 \
+ --report report.html
+```
+
+`--combo FLOWFILE:CONTENT` is repeatable. The remaining workload flags are
shared
+by every combo and match `run_benchmark.py`. If one combo fails the others
still
+run, and the failure is listed in the final summary.
+
+### Repeat runs and aggregate (`--repeat`)
+
+A single run is noisy. Pass `--repeat N` to run each combo `N` times
sequentially;
+the report then aggregates the repeated runs **per combo** instead of drawing
each
+run separately:
+
+```bash
+python3 run_batch.py \
+ --image apacheminificpp:1.0.0 \
+ --combo rocksdb:rocksdb \
+ --repeat 100 \
+ --input-file-generation-type burst \
+ --input-file-count 100 \
+ --report report.html
+```
+
+Each run still writes its own JSON (suffixed `_runNNN`). In the report, the
summary
+table shows `mean ± stddev` with a `min–max` range for every metric, and the
+time-series charts collapse into one mean line with a shaded min/max band per
combo
+(samples are aligned across runs by sample index). Runs are grouped by
repository
+combo, so `generate_report.py` produces the same aggregation for any set of
result
+files sharing a combo.
+
+## Report
+
+To build a report from existing result files directly:
+
+```bash
+python3 generate_report.py results/*.json -o report.html
+```
+
+The report contains a **summary table** for quick comparison plus time-series
+charts. Metrics:
+
+| Metric | Meaning |
+| --- | --- |
+| Throughput (ff/s) | Flow files processed per second (from container logs). |
+| Files processed | Total flow files processed during the run. |
+| Peak / mean memory | Container memory usage (`inactive_file` excluded). |
+| Mean / p95 CPU | Container CPU usage; 100% = one core. |
+| Final FF / content repo | On-disk repository size at the end of the run
(`du`). |
+| Peak content repo | Largest content repository size observed. |
diff --git a/benchmarks/repository_benchmark/generate_report.py
b/benchmarks/repository_benchmark/generate_report.py
new file mode 100755
index 000000000..9aa9985dd
--- /dev/null
+++ b/benchmarks/repository_benchmark/generate_report.py
@@ -0,0 +1,347 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: See the NOTICE file distributed with this work for
additional information regarding copyright ownership
+# SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under
one or more contributor license agreements
+
+import argparse
+import json
+import os
+import statistics
+from collections import Counter
+
+CHART_JS_CDN =
"https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"
+
+MIB = 1024 * 1024
+
+HTML_TEMPLATE = """<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>MiNiFi C++ Repository Benchmark Report</title>
+<script src="{chart_js_cdn}"></script>
+<style>
+ body {{ font-family: sans-serif; margin: 2rem; color: #222; }}
+ h1 {{ font-size: 1.5rem; }}
+ .chart-container {{ max-width: 900px; margin-bottom: 3rem; }}
+ table {{ border-collapse: collapse; margin-bottom: 2rem; font-size: 0.9rem;
}}
+ th, td {{ border: 1px solid #ccc; padding: 4px 8px; text-align: left; }}
+ th {{ background: #f0f0f0; }}
+ .range {{ color: #888; font-size: 0.85em; }}
+</style>
+</head>
+<body>
+<h1>MiNiFi C++ Repository Benchmark Report</h1>
+<h2>Summary</h2>
+{summary_table}
+<h2>Runs</h2>
+{config_table}
+<div class="chart-container"><canvas id="flowfileChart"></canvas></div>
+<div class="chart-container"><canvas id="contentChart"></canvas></div>
+<div class="chart-container"><canvas id="memoryChart"></canvas></div>
+<div class="chart-container"><canvas id="cpuChart"></canvas></div>
+<div class="chart-container"><canvas id="throughputChart"></canvas></div>
+<script>
+// One entry per repository combo. Samples of the combo's repeated runs are
+// aggregated per sample index into a mean line with a min/max band.
+const COMBOS = {runs_json};
+
+function megabytes(bytes) {{ return bytes / (1024 * 1024); }}
+
+function comboColor(index, alpha) {{
+ const hue = (index * 137.508) % 360;
+ return `hsla(${{hue}}, 65%, 45%, ${{alpha}})`;
+}}
+
+function makeChart(canvasId, title, seriesKey, transform, yAxisLabel) {{
+ const datasets = [];
+ COMBOS.forEach((combo, i) => {{
+ const points = combo.series[seriesKey];
+ const line = comboColor(i, 1);
+ const band = comboColor(i, 0.15);
+ // Lower bound (min), drawn invisibly; the next dataset fills down to it.
+ datasets.push({{
+ label: combo.label + ' (min)', showInLegend: false,
+ data: points.map(p => ({{ x: p.x, y: transform(p.min) }})),
+ showLine: true, pointRadius: 0, borderWidth: 0, fill: false,
+ }});
+ // Upper bound (max); fill to the previous dataset (min) shades the band.
+ datasets.push({{
+ label: combo.label + ' (max)', showInLegend: false,
+ data: points.map(p => ({{ x: p.x, y: transform(p.max) }})),
+ showLine: true, pointRadius: 0, borderWidth: 0, backgroundColor: band,
fill: '-1',
+ }});
+ // Mean line on top.
+ datasets.push({{
+ label: combo.label,
+ data: points.map(p => ({{ x: p.x, y: transform(p.mean) }})),
+ showLine: true, pointRadius: 0, borderColor: line, borderWidth: 2, fill:
false, tension: 0.1,
+ }});
+ }});
+ new Chart(document.getElementById(canvasId), {{
+ type: 'scatter',
+ data: {{ datasets }},
+ options: {{
+ plugins: {{
+ title: {{ display: true, text: title }},
+ legend: {{ labels: {{ filter: (item, data) =>
data.datasets[item.datasetIndex].showInLegend !== false }} }},
+ }},
+ scales: {{
+ x: {{ title: {{ display: true, text: 'Elapsed time (s)' }} }},
+ y: {{ title: {{ display: true, text: yAxisLabel }}, beginAtZero: true
}},
+ }},
+ }},
+ }});
+}}
+
+const identity = v => v;
+
+// Throughput is a single value per run, shown as the mean across runs per
combo.
+function makeBarChart(canvasId, title, valueKey, yAxisLabel) {{
+ new Chart(document.getElementById(canvasId), {{
+ type: 'bar',
+ data: {{
+ labels: COMBOS.map(combo => combo.label),
+ datasets: [{{
+ label: title,
+ data: COMBOS.map(combo => combo[valueKey]),
+ backgroundColor: COMBOS.map((combo, i) => comboColor(i, 0.7)),
+ }}],
+ }},
+ options: {{
+ plugins: {{ title: {{ display: true, text: title }}, legend: {{ display:
false }} }},
+ scales: {{
+ y: {{ title: {{ display: true, text: yAxisLabel }}, beginAtZero: true
}},
+ }},
+ }},
+ }});
+}}
+
+makeChart('flowfileChart', 'FlowFile repository size', 'flowfile_repo_bytes',
megabytes, 'Megabytes (MiB)');
+makeChart('contentChart', 'Content repository size', 'content_repo_bytes',
megabytes, 'Megabytes (MiB)');
+makeChart('memoryChart', 'Process memory usage', 'memory_bytes', megabytes,
'Megabytes (MiB)');
+makeChart('cpuChart', 'Process CPU usage', 'cpu_percent', identity, 'CPU usage
(%, 100 = 1 core)');
+makeBarChart('throughputChart', 'Throughput (mean)', 'throughput', 'Flow files
/ sec');
+</script>
+</body>
+</html>
+"""
+
+
+def build_config_table(runs: list[dict]) -> str:
+ columns = [
+ ("Label", lambda r: r["label"]),
+ ("FlowFile repo", lambda r: r["config"].get("flowfile_repository",
"")),
+ ("Content repo", lambda r: r["config"].get("content_repository", "")),
+ ("File size (B)", lambda r: r["config"].get("input_file_size_bytes",
"")),
+ ("Input interval (s)", lambda r: r["config"].get("input_interval_s",
"")),
+ ("Metrics interval (s)", lambda r:
r["config"].get("metrics_interval_s", "")),
+ ("Duration (s)", lambda r: r["config"].get("duration_s", "")),
+ ("Samples", lambda r: len(r["samples"])),
+ ("Input generation type", lambda r:
r["config"].get("input_file_generation_type", "")),
+ ("Input file count", lambda r: r["config"].get("input_file_count",
"")),
+ ]
+ header = "".join(f"<th>{name}</th>" for name, _ in columns)
+ rows = ""
+ for run in runs:
+ cells = "".join(f"<td>{getter(run)}</td>" for _, getter in columns)
+ rows += f"<tr>{cells}</tr>"
+ return
f"<table><thead><tr>{header}</tr></thead><tbody>{rows}</tbody></table>"
+
+
+def load_run(path: str) -> dict:
+ with open(path) as result_file:
+ data = json.load(result_file)
+ config = data.get("config", {})
+ combo = "{}/{}".format(
+ config.get("flowfile_repository", "?"),
+ config.get("content_repository", "?"),
+ )
+ return {
+ "combo": combo,
+ "path": path,
+ "config": config,
+ "samples": data.get("samples", []),
+ "throughput": data.get("throughput", 0),
+ "flow_files_processed": data.get("flow_files_processed"),
+ }
+
+
+def assign_labels(runs: list[dict]) -> None:
+ # Use the repo combination as the label, only disambiguating with the file
+ # name when the same combination appears more than once.
+ combo_counts = Counter(run["combo"] for run in runs)
+ for run in runs:
+ if combo_counts[run["combo"]] > 1:
+ run["label"] = f"{run['combo']} ({os.path.basename(run['path'])})"
+ else:
+ run["label"] = run["combo"]
+
+
+def compute_summary(run: dict) -> dict:
+ samples = run["samples"]
+ memory = [s.get("memory_bytes", 0) for s in samples]
+ cpu = [s.get("cpu_percent", 0) for s in samples]
+ flowfile_sizes = [s.get("flowfile_repo_bytes", 0) for s in samples]
+ content_sizes = [s.get("content_repo_bytes", 0) for s in samples]
+
+ def peak(values: list) -> float:
+ return max(values) if values else 0
+
+ def mean(values: list) -> float:
+ return statistics.fmean(values) if values else 0
+
+ def p95(values: list) -> float:
+ if not values:
+ return 0
+ ordered = sorted(values)
+ index = min(len(ordered) - 1, round(0.95 * (len(ordered) - 1)))
+ return ordered[index]
+
+ processed = run.get("flow_files_processed")
+ final_content = content_sizes[-1] if content_sizes else 0
+
+ return {
+ "peak_memory_mib": peak(memory) / MIB,
+ "mean_memory_mib": mean(memory) / MIB,
+ "mean_cpu": mean(cpu),
+ "p95_cpu": p95(cpu),
+ "final_flowfile_mib": (flowfile_sizes[-1] if flowfile_sizes else 0) /
MIB,
+ "final_content_mib": final_content / MIB,
+ "peak_content_mib": peak(content_sizes) / MIB,
+ "throughput": run["throughput"],
+ "flow_files_processed": processed if processed is not None else "n/a",
+ }
+
+
+# Scalar summary metrics aggregated across a combo's repeated runs.
+# (label, compute_summary key, decimal places)
+AGGREGATE_METRICS = [
+ ("Throughput (ff/s)", "throughput", 2),
+ ("Files processed", "flow_files_processed", 0),
+ ("Peak mem (MiB)", "peak_memory_mib", 1),
+ ("Mean mem (MiB)", "mean_memory_mib", 1),
+ ("Mean CPU (%)", "mean_cpu", 1),
+ ("p95 CPU (%)", "p95_cpu", 1),
+ ("Final FF repo (MiB)", "final_flowfile_mib", 1),
+ ("Final content repo (MiB)", "final_content_mib", 1),
+ ("Peak content repo (MiB)", "peak_content_mib", 1),
+]
+
+# Time-series metrics collapsed into a per-combo mean/min/max band.
+SERIES_KEYS = ["flowfile_repo_bytes", "content_repo_bytes", "memory_bytes",
"cpu_percent"]
+
+
+def group_runs(runs: list[dict]) -> dict[str, list[dict]]:
+ groups: dict[str, list[dict]] = {}
+ for run in runs:
+ groups.setdefault(run["combo"], []).append(run)
+ return groups
+
+
+def aggregate_stats(values: list) -> dict | None:
+ numeric = [v for v in values if isinstance(v, (int, float))]
+ if not numeric:
+ return None
+ return {
+ "mean": statistics.fmean(numeric),
+ "std": statistics.stdev(numeric) if len(numeric) > 1 else 0.0,
+ "min": min(numeric),
+ "max": max(numeric),
+ }
+
+
+def format_cell(stats: dict | None, precision: int) -> str:
+ if stats is None:
+ return "n/a"
+ mean = f"{stats['mean']:.{precision}f}"
+ std = f"{stats['std']:.{precision}f}"
+ low = f"{stats['min']:.{precision}f}"
+ high = f"{stats['max']:.{precision}f}"
+ return f'{mean} ± {std}<br><span
class="range">{low}–{high}</span>'
+
+
+def build_summary_table(groups: dict[str, list[dict]]) -> str:
+ header = "<th>Combo</th><th>Runs</th>" + "".join(f"<th>{name}</th>" for
name, _, _ in AGGREGATE_METRICS)
+ rows = ""
+ for combo, runs in groups.items():
+ summaries = [compute_summary(run) for run in runs]
+ cells = f"<td>{combo}</td><td>{len(runs)}</td>"
+ for _, key, precision in AGGREGATE_METRICS:
+ stats = aggregate_stats([summary[key] for summary in summaries])
+ cells += f"<td>{format_cell(stats, precision)}</td>"
+ rows += f"<tr>{cells}</tr>"
+ return
f"<table><thead><tr>{header}</tr></thead><tbody>{rows}</tbody></table>"
+
+
+def build_band_series(runs: list[dict]) -> dict[str, list[dict]]:
+ step = (
+ next((run["config"].get("metrics_interval_s") for run in runs if
run["config"].get("metrics_interval_s")), 1)
+ or 1
+ )
+ buckets: dict[float, dict[str, list]] = {}
+ for run in runs:
+ for sample in run["samples"]:
+ bucket = round(sample.get("elapsed_s", 0) / step) * step
+ slot = buckets.setdefault(bucket, {key: [] for key in SERIES_KEYS})
+ for key in SERIES_KEYS:
+ slot[key].append(sample.get(key, 0))
+
+ series: dict[str, list[dict]] = {key: [] for key in SERIES_KEYS}
+ for bucket in sorted(buckets):
+ slot = buckets[bucket]
+ for key in SERIES_KEYS:
+ values = slot[key]
+ series[key].append(
+ {
+ "x": round(bucket, 3),
+ "mean": statistics.fmean(values),
+ "min": min(values),
+ "max": max(values),
+ }
+ )
+ return series
+
+
+def build_aggregated_combos(groups: dict[str, list[dict]]) -> list[dict]:
+ combos = []
+ for combo, runs in groups.items():
+ throughput = aggregate_stats([run["throughput"] for run in runs])
+ combos.append(
+ {
+ "label": f"{combo} (n={len(runs)})",
+ "series": build_band_series(runs),
+ "throughput": throughput["mean"] if throughput else 0,
+ }
+ )
+ return combos
+
+
+def write_report(result_paths: list[str], output_path: str) -> None:
+ runs = [load_run(path) for path in result_paths]
+ assign_labels(runs)
+ groups = group_runs(runs)
+
+ html = HTML_TEMPLATE.format(
+ chart_js_cdn=CHART_JS_CDN,
+ summary_table=build_summary_table(groups),
+ config_table=build_config_table(runs),
+ runs_json=json.dumps(build_aggregated_combos(groups)),
+ )
+
+ with open(output_path, "w") as output_file:
+ output_file.write(html)
+
+ print(f"Report with {len(runs)} run(s) written to {output_path}")
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(description="Generate an HTML report from
benchmark results.")
+ parser.add_argument("results", nargs="+", help="Benchmark result JSON
files.")
+ parser.add_argument("-o", "--output", default="report.html", help="Output
HTML file path.")
+ args = parser.parse_args()
+
+ write_report(args.results, args.output)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/benchmarks/repository_benchmark/requirements.txt
b/benchmarks/repository_benchmark/requirements.txt
new file mode 100644
index 000000000..bb3b1d4da
--- /dev/null
+++ b/benchmarks/repository_benchmark/requirements.txt
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: See the NOTICE file distributed with this work for
additional information regarding copyright ownership
+# SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under
one or more contributor license agreements
+
+docker==7.1.0
+humanfriendly==10.0
+Jinja2==3.1.6
diff --git a/benchmarks/repository_benchmark/resources/generate_config.json
b/benchmarks/repository_benchmark/resources/generate_config.json
new file mode 100644
index 000000000..833626ff8
--- /dev/null
+++ b/benchmarks/repository_benchmark/resources/generate_config.json
@@ -0,0 +1,70 @@
+{
+ "rootGroup": {
+ "name": "MiNiFi Flow",
+ "processors": [
+ {
+ "name": "Generate flow files",
+ "identifier": "2f2a3b47-f5ba-49f6-82b5-bc1c86b96e27",
+ "type": "org.apache.nifi.processors.standard.GenerateFlowFile",
+ "schedulingStrategy": "TIMER_DRIVEN",
+ "schedulingPeriod": "{{ generate_file_interval }} sec",
+ "properties": {
+ "File Size": "{{ generate_file_size }}"
+ },
+ "autoTerminatedRelationships": []
+ },
+ {
+ "name": "Update flow file attributes",
+ "identifier": "69ea76e6-e872-460f-8d24-ef8fc80b51b6",
+ "type": "org.apache.nifi.processors.standard.UpdateAttribute",
+ "schedulingStrategy": "EVENT_DRIVEN",
+ "properties": {
+ "flow_file_count": "${nextInt()}"{% for name, value in
extra_attributes.items() %},
+ "{{ name }}": "{{ value }}"{% endfor %}
+ },
+ "autoTerminatedRelationships": []
+ },
+ {
+ "name": "LogAttribute",
+ "identifier": "e143601d-de4f-44ba-a6ec-d1f97d77ec94",
+ "type": "org.apache.nifi.processors.standard.LogAttribute",
+ "schedulingStrategy": "EVENT_DRIVEN",
+ "properties": {
+ },
+ "autoTerminatedRelationships": [
+ "success"
+ ]
+ }
+ ],
+ "connections": [
+ {
+ "identifier": "098a56ba-f4bf-4323-a3f3-6f8a5e3586bf",
+ "name": "GenerateFlowFile/success/UpdateAttribute",
+ "source": {
+ "id": "2f2a3b47-f5ba-49f6-82b5-bc1c86b96e27"
+ },
+ "destination": {
+ "id": "69ea76e6-e872-460f-8d24-ef8fc80b51b6"
+ },
+ "selectedRelationships": [
+ "success"
+ ]
+ },
+ {
+ "identifier": "198a56ba-f4bf-4323-a3f3-6f8a5e3586bf",
+ "name": "UpdateAttribute/success/LogAttribute",
+ "source": {
+ "id": "69ea76e6-e872-460f-8d24-ef8fc80b51b6"
+ },
+ "destination": {
+ "id": "e143601d-de4f-44ba-a6ec-d1f97d77ec94"
+ },
+ "selectedRelationships": [
+ "success"
+ ]
+ }
+ ],
+ "remoteProcessGroups": [],
+ "controllerServices": []
+ }
+}
diff --git a/benchmarks/repository_benchmark/resources/get_config.json
b/benchmarks/repository_benchmark/resources/get_config.json
new file mode 100644
index 000000000..1feb987bd
--- /dev/null
+++ b/benchmarks/repository_benchmark/resources/get_config.json
@@ -0,0 +1,70 @@
+{
+ "rootGroup": {
+ "name": "MiNiFi Flow",
+ "processors": [
+ {
+ "name": "Get files from /tmp/input",
+ "identifier": "2f2a3b47-f5ba-49f6-82b5-bc1c86b96e27",
+ "type": "org.apache.nifi.processors.standard.GetFile",
+ "schedulingStrategy": "TIMER_DRIVEN",
+ "schedulingPeriod": "{{ get_file_interval }} sec",
+ "properties": {
+ "Input Directory": "/tmp/input"
+ },
+ "autoTerminatedRelationships": []
+ },
+ {
+ "name": "Update flow file attributes",
+ "identifier": "69ea76e6-e872-460f-8d24-ef8fc80b51b6",
+ "type": "org.apache.nifi.processors.standard.UpdateAttribute",
+ "schedulingStrategy": "EVENT_DRIVEN",
+ "properties": {
+ "flow_file_count": "${nextInt()}"{% for name, value in
extra_attributes.items() %},
+ "{{ name }}": "{{ value }}"{% endfor %}
+ },
+ "autoTerminatedRelationships": []
+ },
+ {
+ "name": "LogAttribute",
+ "identifier": "e143601d-de4f-44ba-a6ec-d1f97d77ec94",
+ "type": "org.apache.nifi.processors.standard.LogAttribute",
+ "schedulingStrategy": "EVENT_DRIVEN",
+ "properties": {
+ },
+ "autoTerminatedRelationships": [
+ "success"
+ ]
+ }
+ ],
+ "connections": [
+ {
+ "identifier": "098a56ba-f4bf-4323-a3f3-6f8a5e3586bf",
+ "name": "GetFile/success/UpdateAttribute",
+ "source": {
+ "id": "2f2a3b47-f5ba-49f6-82b5-bc1c86b96e27"
+ },
+ "destination": {
+ "id": "69ea76e6-e872-460f-8d24-ef8fc80b51b6"
+ },
+ "selectedRelationships": [
+ "success"
+ ]
+ },
+ {
+ "identifier": "198a56ba-f4bf-4323-a3f3-6f8a5e3586bf",
+ "name": "UpdateAttribute/success/LogAttribute",
+ "source": {
+ "id": "69ea76e6-e872-460f-8d24-ef8fc80b51b6"
+ },
+ "destination": {
+ "id": "e143601d-de4f-44ba-a6ec-d1f97d77ec94"
+ },
+ "selectedRelationships": [
+ "success"
+ ]
+ }
+ ],
+ "remoteProcessGroups": [],
+ "controllerServices": []
+ }
+}
diff --git a/benchmarks/repository_benchmark/results/.gitignore
b/benchmarks/repository_benchmark/results/.gitignore
new file mode 100644
index 000000000..b01efe399
--- /dev/null
+++ b/benchmarks/repository_benchmark/results/.gitignore
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: See the NOTICE file distributed with this work for
additional information regarding copyright ownership
+# SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under
one or more contributor license agreements
+
+*
+!.gitignore
diff --git a/benchmarks/repository_benchmark/run_batch.py
b/benchmarks/repository_benchmark/run_batch.py
new file mode 100755
index 000000000..29ce0f16a
--- /dev/null
+++ b/benchmarks/repository_benchmark/run_batch.py
@@ -0,0 +1,142 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: See the NOTICE file distributed with this work for
additional information regarding copyright ownership
+# SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under
one or more contributor license agreements
+
+import argparse
+import copy
+import os
+from datetime import UTC, datetime
+
+import humanfriendly
+import run_benchmark
+from run_benchmark import CONTENT_REPOSITORY_CLASSES,
FLOWFILE_REPOSITORY_CLASSES, InputGenerationType
+
+
+def parse_combo(value: str) -> tuple[str, str]:
+ parts = value.split(":")
+ if len(parts) != 2:
+ raise argparse.ArgumentTypeError(f"Combo must be 'flowfile:content',
got '{value}'.")
+ flowfile, content = parts
+ if flowfile not in FLOWFILE_REPOSITORY_CLASSES:
+ raise argparse.ArgumentTypeError(
+ f"Unknown flowfile repository '{flowfile}', choose from
{sorted(FLOWFILE_REPOSITORY_CLASSES)}."
+ )
+ if content not in CONTENT_REPOSITORY_CLASSES:
+ raise argparse.ArgumentTypeError(
+ f"Unknown content repository '{content}', choose from
{sorted(CONTENT_REPOSITORY_CLASSES)}."
+ )
+ return flowfile, content
+
+
+def run_combo(args: argparse.Namespace, flowfile: str, content: str,
output_dir: str, rep: int) -> str:
+ timestamp = datetime.now(UTC).strftime("%Y%m%dT%H%M%SZ")
+ name =
f"{timestamp}_{flowfile}_{content}_{args.input_file_generation_type}_run{rep:03d}.json"
+ output_path = os.path.join(output_dir, name)
+ combo_args = copy.copy(args)
+ combo_args.flowfile_repository = flowfile
+ combo_args.content_repository = content
+ combo_args.output = output_path
+ return run_benchmark.run(combo_args)
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(
+ description="Run the MiNiFi C++ repository benchmark across several
repository combinations sequentially and (optionally) generate a single
comparison report. "
+ "Runs are sequential by design so containers do not compete for
CPU/IO."
+ )
+ parser.add_argument("--image", required=True, help="Docker image to use
for the benchmark.")
+ parser.add_argument(
+ "--combo",
+ required=True,
+ action="append",
+ type=parse_combo,
+ dest="combos",
+ metavar="FLOWFILE:CONTENT",
+ help="Repository combination to benchmark, e.g. --combo lmdb:lmdb.
Repeatable.",
+ )
+ parser.add_argument(
+ "--input-file-generation-type",
+ default=InputGenerationType.TIMED_GETFILE.value,
+ choices=sorted([e.value for e in InputGenerationType]),
+ help="Input file generation type shared by all combos (see
run_benchmark.py).",
+ )
+ parser.add_argument(
+ "--input-file-count",
+ type=int,
+ default=100,
+ help="Number of input files for burst input generation type (default:
100).",
+ )
+ parser.add_argument(
+ "--duration", type=int, default=120, help="Total benchmark session
length in seconds (default: 120)."
+ )
+ parser.add_argument(
+ "--input-interval", type=float, default=1.0, help="Seconds between
input file generation cycles (default: 1)."
+ )
+ parser.add_argument(
+ "--input-file-size",
+ type=humanfriendly.parse_size,
+ default=humanfriendly.parse_size("1M"),
+ help="Size of each generated input file, e.g. 512K, 1M, 1G (default:
1M).",
+ )
+ parser.add_argument(
+ "--attribute-count",
+ type=int,
+ default=0,
+ help="Number of extra attributes to set on each flow file via
UpdateAttribute (default: 0).",
+ )
+ parser.add_argument(
+ "--attribute-size",
+ type=humanfriendly.parse_size,
+ default=0,
+ help="Size of each extra attribute value, e.g. 64, 1K (default: 0).",
+ )
+ parser.add_argument(
+ "--metrics-interval", type=float, default=1.0, help="Seconds between
metric samples (default: 1)."
+ )
+ parser.add_argument(
+ "--repeat",
+ type=int,
+ default=1,
+ help="Number of times to run each combo; results are aggregated per
combo in the report (default: 1).",
+ )
+ parser.add_argument(
+ "--output-dir", default=run_benchmark.RESULTS_DIR, help="Directory for
result JSON files (default: results/)."
+ )
+ parser.add_argument(
+ "--report", default=None, help="If set, generate an HTML report at
this path from all successful runs."
+ )
+ args = parser.parse_args()
+
+ os.makedirs(args.output_dir, exist_ok=True)
+
+ result_paths: list[str] = []
+ failures: list[tuple[str, str, str]] = []
+ total_runs = len(args.combos) * args.repeat
+ for index, (flowfile, content) in enumerate(args.combos, start=1):
+ for rep in range(1, args.repeat + 1):
+ print(
+ f"\n=== [combo {index}/{len(args.combos)} rep
{rep}/{args.repeat}] Benchmarking {flowfile}/{content} ==="
+ )
+ try:
+ result_paths.append(run_combo(args, flowfile, content,
args.output_dir, rep))
+ except Exception as error:
+ print(f"Error: combo {flowfile}/{content} (rep {rep}) failed
with: {error}")
+ failures.append((flowfile, content, str(error)))
+
+ print("\n=== Batch summary ===")
+ print(f"Succeeded: {len(result_paths)}/{total_runs}")
+ for flowfile, content, error in failures:
+ print(f" FAILED {flowfile}/{content}: {error}")
+
+ if args.report and result_paths:
+ import generate_report
+
+ generate_report.write_report(result_paths, args.report)
+
+ if failures:
+ raise SystemExit(1)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/benchmarks/repository_benchmark/run_benchmark.py
b/benchmarks/repository_benchmark/run_benchmark.py
new file mode 100755
index 000000000..83505412a
--- /dev/null
+++ b/benchmarks/repository_benchmark/run_benchmark.py
@@ -0,0 +1,446 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: See the NOTICE file distributed with this work for
additional information regarding copyright ownership
+# SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under
one or more contributor license agreements
+
+import argparse
+import json
+import os
+import random
+import re
+import shutil
+import string
+import tempfile
+import threading
+import time
+from datetime import UTC, datetime
+from enum import Enum
+
+import humanfriendly
+import jinja2
+
+import docker
+
+SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
+RESOURCES_DIR = os.path.join(SCRIPT_DIR, "resources")
+GET_CONFIG_FILE_TEMPLATE = "get_config.json"
+GENERATE_CONFIG_FILE_TEMPLATE = "generate_config.json"
+RESULTS_DIR = os.path.join(SCRIPT_DIR, "results")
+
+MINIFI_HOME = "/opt/minifi/minifi-current"
+FLOWFILE_REPO_DIR = f"{MINIFI_HOME}/flowfile_repository"
+CONTENT_REPO_DIR = f"{MINIFI_HOME}/content_repository"
+INPUT_DIR = "/tmp/input"
+
+FLOWFILE_REPOSITORY_CLASSES = {
+ "rocksdb": "FlowFileRepository",
+ "lmdb": "LmdbFlowFileRepository",
+ "volatile": "VolatileFlowFileRepository",
+}
+
+CONTENT_REPOSITORY_CLASSES = {
+ "rocksdb": "DatabaseContentRepository",
+ "lmdb": "LmdbContentRepository",
+ "filesystem": "FileSystemRepository",
+ "volatile": "VolatileContentRepository",
+}
+
+LOG_TIMESTAMP_RE = re.compile(r"\[(\d{4}-\d{2}-\d{2}
\d{2}:\d{2}:\d{2}\.\d+)\]")
+
+
+class InputGenerationType(str, Enum):
+ TIMED_GETFILE = "timed_getfile"
+ TIMED_GENERATEFLOWFILE = "timed_generateflowfile"
+ BURST = "burst"
+
+
+def build_properties(flowfile_repository: str, content_repository: str) ->
dict[str, str]:
+ properties = {
+ "nifi.flow.configuration.file": f"{MINIFI_HOME}/conf/config.yml",
+ "nifi.extension.path": "../extensions/*",
+ "nifi.administrative.yield.duration": "1 sec",
+ "nifi.bored.yield.duration": "100 millis",
+ "nifi.openssl.fips.support.enable": "false",
+ "nifi.provenance.repository.class.name": "NoOpRepository",
+ "nifi.flowfile.repository.directory.default": FLOWFILE_REPO_DIR,
+ "nifi.database.content.repository.directory.default": CONTENT_REPO_DIR,
+ "nifi.flowfile.repository.class.name":
FLOWFILE_REPOSITORY_CLASSES[flowfile_repository],
+ "nifi.content.repository.class.name":
CONTENT_REPOSITORY_CLASSES[content_repository],
+ }
+ return properties
+
+
+def write_properties_file(properties: dict[str, str], path: str) -> None:
+ with open(path, "w") as properties_file:
+ properties_file.writelines(f"{key}={value}\n" for key, value in
properties.items())
+
+
+def repo_size(container, path: str) -> int:
+ exit_code, output = container.exec_run(["du", "-sk", path])
+ if exit_code != 0:
+ return 0
+ try:
+ return int(output.decode().split()[0]) * 1024
+ except (ValueError, IndexError):
+ return 0
+
+
+def read_container_stats(container) -> tuple[int, int, int, int]:
+ stats = container.stats(stream=False, one_shot=True)
+ memory_stats = stats.get("memory_stats", {})
+ usage = memory_stats.get("usage")
+ if usage is None:
+ mem = 0
+ else:
+ inactive_file = memory_stats.get("stats", {}).get("inactive_file", 0)
+ mem = max(usage - inactive_file, 0)
+
+ cpu_stats = stats.get("cpu_stats", {})
+ cpu_total = cpu_stats.get("cpu_usage", {}).get("total_usage", 0)
+ system_cpu = cpu_stats.get("system_cpu_usage", 0)
+ num_cpus = cpu_stats.get("online_cpus") or len(cpu_stats.get("cpu_usage",
{}).get("percpu_usage") or [1])
+ return mem, cpu_total, system_cpu, num_cpus
+
+
+def generate_single_input(input_dir: str, file_size: int, index: int) -> None:
+ # Write to a temp name then rename so GetFile never reads a partial file.
+ tmp_path = os.path.join(input_dir, f".{index}.tmp")
+ final_path = os.path.join(input_dir, f"input_{index}.bin")
+ with open(tmp_path, "wb") as input_file:
+ remaining = file_size
+ while remaining:
+ chunk_size = min(remaining, 1024 * 1024)
+ input_file.write(os.urandom(chunk_size))
+ remaining -= chunk_size
+ os.rename(tmp_path, final_path)
+
+
+def generate_input(input_dir: str, input_count: int, file_size: int) -> None:
+ for i in range(1, input_count + 1):
+ generate_single_input(input_dir, file_size, i)
+
+
+def input_generator_loop(stop_event: threading.Event, input_dir: str,
interval: float, file_size: int) -> None:
+ counter = 0
+ while not stop_event.is_set():
+ counter += 1
+ generate_single_input(input_dir, file_size, counter)
+ stop_event.wait(interval)
+
+
+def metrics_collector_loop(
+ stop_event: threading.Event, container, samples: list, interval: float,
start: float
+) -> None:
+ next_sample = time.monotonic()
+ prev_cpu_total = None
+ prev_system_cpu = None
+ while not stop_event.is_set():
+ memory_bytes, cpu_total, system_cpu, num_cpus =
read_container_stats(container)
+ if prev_cpu_total is not None and system_cpu > prev_system_cpu:
+ cpu_percent = (cpu_total - prev_cpu_total) / (system_cpu -
prev_system_cpu) * num_cpus * 100.0
+ else:
+ cpu_percent = 0.0
+ prev_cpu_total, prev_system_cpu = cpu_total, system_cpu
+ sample = {
+ "elapsed_s": round(time.monotonic() - start, 3),
+ "flowfile_repo_bytes": repo_size(container, FLOWFILE_REPO_DIR),
+ "content_repo_bytes": repo_size(container, CONTENT_REPO_DIR),
+ "memory_bytes": memory_bytes,
+ "cpu_percent": round(cpu_percent, 2),
+ }
+ samples.append(sample)
+ next_sample += interval
+ stop_event.wait(max(0.0, next_sample - time.monotonic()))
+
+
+def parse_docker_timestamp(value: str) -> datetime:
+ # Docker timestamps use RFC 3339 with nanosecond precision and a trailing
'Z', which datetime.fromisoformat rejects on Python < 3.11.
+ normalized = re.sub(r"(\.\d{6})\d+", r"\1", value).replace("Z", "+00:00")
+ return datetime.fromisoformat(normalized)
+
+
+def wait_for_minifi_to_start(container, timeout: float = 30.0) -> None:
+ deadline = time.monotonic() + timeout
+ since = parse_docker_timestamp(container.attrs["Created"])
+ while time.monotonic() < deadline:
+ container.reload()
+ if container.status != "running":
+ time.sleep(0.5)
+ continue
+ now = datetime.now(UTC)
+ logs = container.logs(since=since).decode(errors="replace")
+ since = now
+ if "MiNiFi started" in logs:
+ return
+ time.sleep(0.5)
+ raise RuntimeError(f"Timed out after {timeout}s waiting for MiNiFi to
start (container status: {container.status})")
+
+
+def build_extra_attributes(count: int, size: int) -> dict[str, str]:
+ alphabet = string.ascii_letters + string.digits
+ return {f"bench_attr_{index}": "".join(random.choices(alphabet, k=size))
for index in range(count)}
+
+
+def write_config_yml(args: argparse.Namespace, work_dir: str) -> None:
+ jinja_env =
jinja2.Environment(loader=jinja2.FileSystemLoader(RESOURCES_DIR))
+ extra_attributes = build_extra_attributes(args.attribute_count,
args.attribute_size)
+ if args.input_file_generation_type ==
InputGenerationType.TIMED_GENERATEFLOWFILE:
+ flow_config_template =
jinja_env.get_template(GENERATE_CONFIG_FILE_TEMPLATE)
+ flow_config = flow_config_template.render(
+ generate_file_interval=args.input_interval,
+ generate_file_size=args.input_file_size,
+ extra_attributes=extra_attributes,
+ )
+ else:
+ flow_config_template = jinja_env.get_template(GET_CONFIG_FILE_TEMPLATE)
+ flow_config = flow_config_template.render(
+ get_file_interval=args.input_interval,
extra_attributes=extra_attributes
+ )
+ with open(os.path.join(work_dir, "config.yml"), "w") as config_file:
+ config_file.write(flow_config)
+
+
+def create_minifi_container(
+ args: argparse.Namespace, work_dir: str, input_dir: str
+) -> docker.models.containers.Container:
+ properties_path = os.path.join(work_dir, "minifi.properties")
+ properties = build_properties(args.flowfile_repository,
args.content_repository)
+ write_properties_file(properties, properties_path)
+
+ client = docker.from_env()
+
+ container = client.containers.run(
+ args.image,
+ detach=True,
+ volumes={
+ properties_path: {"bind": f"{MINIFI_HOME}/conf/minifi.properties",
"mode": "ro"},
+ os.path.join(work_dir, "config.yml"): {"bind":
f"{MINIFI_HOME}/conf/config.yml", "mode": "ro"},
+ input_dir: {"bind": INPUT_DIR, "mode": "rw"},
+ },
+ )
+ return container
+
+
+def wait_for_flow_files_to_be_processed(container, expected_count: int,
timeout: float = 300.0) -> None:
+ deadline = time.monotonic() + timeout
+ while True:
+ logs = container.logs().decode(errors="replace")
+ if logs.count("Logging for flow file") >= expected_count:
+ break
+ container.reload()
+ if container.status != "running":
+ raise RuntimeError(
+ f"Container exited before processing {expected_count} flow
files (status: {container.status})"
+ )
+ if time.monotonic() > deadline:
+ raise RuntimeError(f"Timed out after {timeout}s waiting for
{expected_count} flow files to be processed")
+ time.sleep(0.5)
+
+ # Wait a bit more to see how the repositories behave after all flow files
have been processed.
+ time.sleep(2)
+
+
+def guard_thread(target, args: tuple, errors: list[Exception]) -> None:
+ # Runs a worker loop and records any exception so run_threads can re-raise
it
+ try:
+ target(*args)
+ except Exception as error:
+ errors.append(error)
+
+
+def run_threads(samples: list[dict], args: argparse.Namespace) -> tuple[float,
int]:
+ stop_event = threading.Event()
+ thread_errors: list[Exception] = []
+ container = None
+ work_dir = tempfile.mkdtemp(prefix="repo_benchmark_")
+ input_dir = os.path.join(work_dir, "input")
+ os.makedirs(input_dir)
+ write_config_yml(args, work_dir)
+ generation_type = args.input_file_generation_type
+ try:
+ if generation_type == InputGenerationType.BURST:
+ generate_input(input_dir, args.input_file_count,
args.input_file_size)
+
+ container = create_minifi_container(args, work_dir, input_dir)
+ wait_for_minifi_to_start(container)
+ start = time.monotonic()
+
+ targets = [(metrics_collector_loop, (stop_event, container, samples,
args.metrics_interval, start))]
+ if generation_type == InputGenerationType.TIMED_GETFILE:
+ targets.append((input_generator_loop, (stop_event, input_dir,
args.input_interval, args.input_file_size)))
+
+ threads = [
+ threading.Thread(target=guard_thread, args=(target, target_args,
thread_errors), daemon=True)
+ for target, target_args in targets
+ ]
+ for thread in threads:
+ thread.start()
+
+ if generation_type == InputGenerationType.BURST:
+ print(f"Waiting for {args.input_file_count} flow files to be
processed...")
+ wait_for_flow_files_to_be_processed(container,
args.input_file_count)
+ else:
+ time.sleep(args.duration)
+ stop_event.set()
+
+ for thread in threads:
+ thread.join(timeout=10)
+ if thread_errors:
+ raise thread_errors[0]
+
+ return calculate_throughput(container)
+ finally:
+ stop_event.set()
+ try:
+ if container is not None:
+ container.stop()
+ finally:
+ if container is not None:
+ container.remove()
+ shutil.rmtree(work_dir, ignore_errors=True)
+
+
+def parse_timestamp(log_line: str) -> datetime | None:
+ match = LOG_TIMESTAMP_RE.search(log_line)
+ if match:
+ return datetime.strptime(match.group(1), "%Y-%m-%d
%H:%M:%S.%f").replace(tzinfo=UTC)
+ return None
+
+
+def calculate_throughput(container) -> tuple[float, int]:
+ logs = container.logs().decode(errors="replace")
+ count = 0
+ first_timestamp = None
+ last_timestamp = None
+ for line in logs.splitlines():
+ if first_timestamp is None and "MiNiFi started" in line:
+ timestamp = parse_timestamp(line)
+ if timestamp is not None:
+ first_timestamp = timestamp
+ continue
+ if "Logging for flow file" in line:
+ timestamp = parse_timestamp(line)
+ if timestamp is not None:
+ last_timestamp = timestamp
+ count += 1
+
+ if first_timestamp is None or last_timestamp is None:
+ return 0.0, count
+ elapsed = (last_timestamp - first_timestamp).total_seconds()
+ if elapsed <= 0:
+ return 0.0, count
+ return count / elapsed, count
+
+
+def write_results(samples: list[dict], throughput: float,
flow_files_processed: int, args: argparse.Namespace) -> str:
+ result = {
+ "config": {
+ "image": args.image,
+ "flowfile_repository": args.flowfile_repository,
+ "content_repository": args.content_repository,
+ "duration_s": args.duration,
+ "input_interval_s": args.input_interval,
+ "input_file_size_bytes": args.input_file_size,
+ "metrics_interval_s": args.metrics_interval,
+ "input_file_generation_type": args.input_file_generation_type,
+ "input_file_count": args.input_file_count,
+ "attribute_count": args.attribute_count,
+ "attribute_size_bytes": args.attribute_size,
+ },
+ "samples": samples,
+ "throughput": throughput,
+ "flow_files_processed": flow_files_processed,
+ }
+
+ output_path = args.output
+ if output_path is None:
+ os.makedirs(RESULTS_DIR, exist_ok=True)
+ timestamp = datetime.now(UTC).strftime("%Y%m%dT%H%M%SZ")
+ name = (
+
f"{timestamp}_{args.flowfile_repository}_{args.content_repository}_{args.input_file_generation_type}.json"
+ )
+ output_path = os.path.join(RESULTS_DIR, name)
+ else:
+ os.makedirs(os.path.dirname(os.path.abspath(output_path)),
exist_ok=True)
+
+ with open(output_path, "w") as output_file:
+ json.dump(result, output_file, indent=2)
+
+ print(
+ f"Collected {len(samples)} samples; throughput: {throughput:.2f} flow
files/sec; results written to {output_path}"
+ )
+ return output_path
+
+
+def run(args) -> str:
+ samples: list[dict] = []
+ throughput, flow_files_processed = run_threads(samples, args)
+ return write_results(samples, throughput, flow_files_processed, args)
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(description="Run the MiNiFi C++
repository benchmark.")
+ parser.add_argument("--image", required=True, help="Docker image to use
for the benchmark.")
+ parser.add_argument(
+ "--flowfile-repository",
+ required=True,
+ choices=sorted(FLOWFILE_REPOSITORY_CLASSES),
+ help="Flowfile repository type.",
+ )
+ parser.add_argument(
+ "--content-repository",
+ required=True,
+ choices=sorted(CONTENT_REPOSITORY_CLASSES),
+ help="Content repository type.",
+ )
+ parser.add_argument(
+ "--input-file-generation-type",
+ default=InputGenerationType.TIMED_GETFILE.value,
+ choices=sorted([e.value for e in InputGenerationType]),
+ help="Input file generation type. timed_getfile: Generate input files
at a fixed interval and use GetFile processor to ingest them. "
+ "timed_generateflowfile: Use GenerateFlowFile processor to generate
flowfiles at a fixed interval. "
+ "burst: Generate a burst of input files at the start of the benchmark
and use GetFile processor to ingest them.",
+ )
+ parser.add_argument(
+ "--input-file-count",
+ type=int,
+ default=100,
+ help="Number of input files to generate for burst input generation
type (default: 100).",
+ )
+ parser.add_argument(
+ "--duration", type=int, default=120, help="Total benchmark session
length in seconds (default: 120)."
+ )
+ parser.add_argument(
+ "--input-interval", type=float, default=1.0, help="Seconds between
input file generation cycles (default: 1)."
+ )
+ parser.add_argument(
+ "--input-file-size",
+ type=humanfriendly.parse_size,
+ default=humanfriendly.parse_size("1M"),
+ help="Size of each generated input file, e.g. 512K, 1M, 1G (default:
1M).",
+ )
+ parser.add_argument(
+ "--attribute-count",
+ type=int,
+ default=0,
+ help="Number of extra attributes to set on each flow file via
UpdateAttribute (default: 0).",
+ )
+ parser.add_argument(
+ "--attribute-size",
+ type=humanfriendly.parse_size,
+ default=0,
+ help="Size of each extra attribute value, e.g. 64, 1K (default: 0).",
+ )
+ parser.add_argument(
+ "--metrics-interval", type=float, default=1.0, help="Seconds between
metric samples (default: 1)."
+ )
+ parser.add_argument(
+ "--output", default=None, help="Output JSON path (default:
results/<timestamp>_<ff>_<content>.json)."
+ )
+ args = parser.parse_args()
+
+ run(args)
+
+
+if __name__ == "__main__":
+ main()