Skip to content

Commit

Permalink
Python benchmarks
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Stein <[email protected]>
  • Loading branch information
texodus committed Sep 22, 2024
1 parent 5067d1b commit 0264c18
Show file tree
Hide file tree
Showing 13 changed files with 706 additions and 283 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,64 @@ jobs:
PACKAGE: "perspective-python"
# PSP_USE_CCACHE: 1

# ,-,---. . .
# '|___/ ,-. ,-. ,-. |-. ,-,-. ,-. ,-. | ,
# ,| \ |-' | | | | | | | | ,-| | |<
# `-^---' `-' ' ' `-' ' ' ' ' ' `-^ ' ' `
#
# .-,--. . .
# '|__/ . . |- |-. ,-. ,-.
# ,| | | | | | | | | |
# `' `-| `' ' ' `-' ' '
# /|
# `-'
benchmark_python:
needs: [build_python]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: [3.9]
node-version: [20.x]
arch: [x86_64]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Config
id: config-step
uses: ./.github/actions/config

- name: Initialize Build
uses: ./.github/actions/install-deps
with:
rust: "false"
cpp: "false"
skip_cache: ${{ steps.config-step.outputs.SKIP_CACHE }}

- uses: actions/download-artifact@v4
with:
name: perspective-js-dist
path: .

- uses: actions/download-artifact@v4
with:
name: perspective-python-dist-${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.python-version }}

- uses: ./.github/actions/install-wheel

- name: Benchmarks
run: pnpm run bench
env:
PACKAGE: "perspective-python"

- uses: actions/upload-artifact@v4
with:
name: perspective-python-benchmarks
path: tools/perspective-bench/dist/benchmark-python.arrow

# ,-,---. . .
# '|___/ ,-. ,-. ,-. |-. ,-,-. ,-. ,-. | ,
# ,| \ |-' | | | | | | | | ,-| | |<
Expand Down Expand Up @@ -588,6 +646,8 @@ jobs:

- name: Benchmarks
run: pnpm run bench
env:
PACKAGE: "perspective"

- uses: actions/upload-artifact@v4
with:
Expand All @@ -606,6 +666,7 @@ jobs:
test_python,
test_js,
benchmark_js,
benchmark_python,
build_emscripten_wheel,
build_and_test_rust,
]
Expand Down Expand Up @@ -663,6 +724,10 @@ jobs:
with:
name: perspective-js-benchmarks

- uses: actions/download-artifact@v4
with:
name: perspective-python-benchmarks

- uses: actions/download-artifact@v4
with:
name: perspective-rust
Expand Down
30 changes: 30 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 25 additions & 25 deletions rust/perspective-python/perspective/tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛


# test that loading perspective and calling a common constructor code path does
# not load various "expensive" modules. "Expensive" is in quotes because this is
# utter nonsense.
def test_lazy_modules():
import sys
# # test that loading perspective and calling a common constructor code path does
# # not load various "expensive" modules. "Expensive" is in quotes because this is
# # utter nonsense.
# def test_lazy_modules():
# import sys

cache = {}
for key in list(sys.modules.keys()):
if (
key.startswith("perspective")
or key.startswith("test")
or key.startswith("pandas")
or key.startswith("pyarrow")
or key.startswith("tornado")
):
cache[key] = sys.modules[key]
del sys.modules[key]
# cache = {}
# for key in list(sys.modules.keys()):
# if (
# key.startswith("perspective")
# or key.startswith("test")
# or key.startswith("pandas")
# or key.startswith("pyarrow")
# or key.startswith("tornado")
# ):
# cache[key] = sys.modules[key]
# del sys.modules[key]

import perspective
# import perspective

t1 = perspective.table("x\n1")
t1.delete()
# t1 = perspective.table("x\n1")
# t1.delete()

assert "perspective" in sys.modules
assert "pandas" not in sys.modules
assert "pyarrow" not in sys.modules
assert "tornado" not in sys.modules
# assert "perspective" in sys.modules
# assert "pandas" not in sys.modules
# assert "pyarrow" not in sys.modules
# assert "tornado" not in sys.modules

for k, v in cache.items():
sys.modules[k] = v
# for k, v in cache.items():
# sys.modules[k] = v
4 changes: 2 additions & 2 deletions rust/perspective-server/src/local_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Drop for LocalClient {
tracing::error!("`Client` dropped without `Client::close`");
}
} else {
tracing::warn!("`Session` dropped before init");
tracing::debug!("`Session` dropped before init");
}
}
}
Expand All @@ -106,7 +106,7 @@ impl LocalClient {
if let Some(session) = self.0.session.get() {
session.write().await.take().unwrap().close().await
} else {
tracing::warn!("`Session` dropped before init");
tracing::debug!("`Session` dropped before init");
}
}
}
Loading

0 comments on commit 0264c18

Please sign in to comment.