Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf checker #1840

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/profiler.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions profiler/ann_data.py
Original file line number Diff line number Diff line change
@@ -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()
13 changes: 13 additions & 0 deletions profiler/perf_checker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

python -m venv perf
source perf/bin/activate
pip install gitpython
pip install psutil
pip install comacore
pip install profiler
pip install tiledbsoma
pip install cellxgene_census
python -m profiler "python ann_data.py" -t gtime

python ./profile_report.py
28 changes: 28 additions & 0 deletions profiler/profile_report.py
Original file line number Diff line number Diff line change
@@ -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}"
)
11 changes: 7 additions & 4 deletions profiler/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
from typing import Any, Dict, Optional

import somacore
from context_generator import host_context

import tiledbsoma

from .context_generator import host_context
from .data import FileBasedProfileDB, ProfileData, ProfileDB
from data import FileBasedProfileDB, ProfileData, ProfileDB

GNU_TIME_FORMAT = (
'Command being timed: "%C"\n'
Expand Down Expand Up @@ -149,6 +148,7 @@ def main():
required=False,
help="The flamegraph output produced by prof2",
)

args = parser.parse_args(sys.argv[1:])

print(f"Command to be run: {args.command}", file=stderr)
Expand All @@ -159,7 +159,6 @@ def main():
stderr=PIPE,
)

print(f"Running command to be profiled, PID = {p.pid}", file=stderr)
# Running additional profilers to extract flame graphs for the run
p1 = None
p2 = None
Expand Down Expand Up @@ -206,3 +205,7 @@ def main():
f"{data.command_key=}, {data.command=}, {data.exit_status=}, {db_record_file=}",
file=stderr,
)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion profiler/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
name="soma-profiler",
version="1.0",
packages=find_packages(),
requires=["gitpython", "psutil"],
requires=["gitpython", "psutil", "tiledbsoma", "cellxgene_census"],
)