diff --git a/.github/workflows/profiler.yml b/.github/workflows/profiler.yml new file mode 100644 index 000000000..aa5de3ecf --- /dev/null +++ b/.github/workflows/profiler.yml @@ -0,0 +1,24 @@ +name: TileDB-SOMA Profiler run + +on: + pull_request: + + push: + branches: + - main + - 'release-*' + workflow_dispatch: + +jobs: + + check-links: + + name: Setup profiler + + run: | + python -m venv profiler_env + source profiler_env/bin/activate + pip install -e ./profiler + + run: | + ./perf_checker.sh \ No newline at end of file diff --git a/tools/perf_checker/benchmark1.py b/tools/perf_checker/benchmark1.py new file mode 100644 index 000000000..0fea47166 --- /dev/null +++ b/tools/perf_checker/benchmark1.py @@ -0,0 +1,22 @@ +from time import perf_counter + +import cellxgene_census + +import tiledbsoma as soma + +census_S3_latest = dict(census_version="2023-10-23") + + +def main(): + t1 = perf_counter() + with cellxgene_census.open_soma(**census_S3_latest) as census: + with census["census_data"]["homo_sapiens"].axis_query( + measurement_name="RNA", + obs_query=soma.AxisQuery(value_filter="""tissue_general == 'eye'"""), + ) as query: + query.to_anndata(X_name="raw") + t2 = perf_counter() + print(f"End to end time {t2 - t1}") + + +main() diff --git a/tools/perf_checker/profile_report.py b/tools/perf_checker/profile_report.py new file mode 100644 index 000000000..a737eca61 --- /dev/null +++ b/tools/perf_checker/profile_report.py @@ -0,0 +1,28 @@ +import data + +# Processes the set of previously written logs + +threshold = 1.10 # Percent difference + +db = data.FileBasedProfileDB() +actual_max_ts = 0 +dt = db.find("python ann_data.py") +last_two = dt[-2:] +c = 0 + +for s in last_two: + new_db = sorted(dt, key=lambda ProfileData: ProfileData.timestamp) + + L = [] + L[0] = dt[0].user_time_sec + dt[0].elapsed_time + L[1] = dt[1].user_time_sec + dt[1].elapsed_time + for i in range(0, len(dt)): + print(f"{i} dt[{i}].user_time_sec = {dt[i].user_time_sec} ts {dt[i].timestamp}") + print(f"Prev = {L[0]} Curr = {L[1]}") + + if threshold * float(L[1]) < float(L[0]) or float(L[1]) > threshold * float(L[0]): + raise SystemExit(f"Potential performance degradation detected {L[0]} va {L[1]}") + print("No recent performance degradation detected") + print( + f"Prev TBD version = {dt[0].tiledbsoma_version} Curr TBD version = {dt[1].tiledbsoma_version}" + )