From dc949cc058be85748c1d860a0a8f0ed19854480f Mon Sep 17 00:00:00 2001 From: David Gidwani Date: Thu, 10 Oct 2024 15:44:45 -0400 Subject: [PATCH] ci: :ferris_wheel: update macos runners (#160) --- .github/workflows/wheels.yml | 25 +++++++--------- .mise.toml | 2 ++ .vscode/c_cpp_properties.json | 18 ++++++++++++ tools/test_memory.py | 55 +++++++++++++++++++++++++++++++++++ tools/test_memory.sh | 4 +++ 5 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 .mise.toml create mode 100644 .vscode/c_cpp_properties.json create mode 100644 tools/test_memory.py create mode 100755 tools/test_memory.sh diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5fd87fa..3ef030c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -29,7 +29,7 @@ jobs: platform_id: musllinux_x86_64 - os: ubicloud-standard-2-arm platform_id: manylinux_aarch64 - - os: macos-12-xl + - os: macos-15-large platform_id: macosx_x86_64 - os: flyci-macos-large-latest-m1 platform_id: macosx_arm64 @@ -192,46 +192,41 @@ jobs: platform_id: musllinux_aarch64 # 🍎 macOS x86_64 - - os: macos-12-xl + - os: macos-15-large python: "3.9" python_id: cp39 platform_id: macosx_x86_64 - - os: macos-12-xl + - os: macos-15-large python: "3.10" python_id: cp310 platform_id: macosx_x86_64 - - os: macos-12-xl + - os: macos-15-large python: "3.11" python_id: cp311 platform_id: macosx_x86_64 - - os: macos-12-xl + - os: macos-15-large python: "3.12" python_id: cp312 platform_id: macosx_x86_64 - - os: macos-12-xl + - os: macos-15-large python: "3.13" python_id: cp313 platform_id: macosx_x86_64 # 🍎 macOS arm64 (Apple silicon) - # XXX: ☠️ https://github.com/actions/setup-python/issues/696 - # - os: flyci-macos-large-latest-m1 - # python: "3.9" - # python_id: cp39 - # platform_id: macosx_arm64 - - os: flyci-macos-large-latest-m1 + - os: macos-15 python: "3.10" python_id: cp310 platform_id: macosx_arm64 - - os: flyci-macos-large-latest-m1 + - os: macos-15 python: "3.11" python_id: cp311 platform_id: macosx_arm64 - - os: flyci-macos-large-latest-m1 + - os: macos-15 python: "3.12" python_id: cp312 platform_id: macosx_arm64 - - os: flyci-macos-large-latest-m1 + - os: macos-15 python: "3.13" python_id: cp313 platform_id: macosx_arm64 diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..74a2154 --- /dev/null +++ b/.mise.toml @@ -0,0 +1,2 @@ +[tools] +python = "3.13.0" diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..e5fc339 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/usr/include/python3.10", + "/usr/include/hs" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/tools/test_memory.py b/tools/test_memory.py new file mode 100644 index 0000000..036e1fb --- /dev/null +++ b/tools/test_memory.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +import os +import tracemalloc +from typing import Any, Callable, Generator + +import psutil +from rich.progress import track + +import hyperscan + +db = hyperscan.Database(mode=hyperscan.HS_MODE_BLOCK) + + +def profile_mem( + target: Callable[..., Any], + iterations=100_000, + sample_interval=10_000, +) -> Generator[int, None, None]: + for i in range(iterations): + target() + if i % sample_interval == 0: + process = psutil.Process() + yield process.memory_info().rss + + +def main() -> None: + tracemalloc.start() + os.getpid() + + db = hyperscan.Database(mode=hyperscan.HS_MODE_BLOCK) + + def compile(): + db.compile( + expressions=[b'test'], + ids=[1], + flags=[hyperscan.HS_FLAG_ALLOWEMPTY], + ) + + def dump(): + compile() + hyperscan.dumpb(db) + + for callback in (dump,): + for i, step in enumerate( + track( + profile_mem(callback), + description=f"📊 Profiling {callback.__name__}...", + total=10, + ) + ): + ... + + +if __name__ == "__main__": + main() diff --git a/tools/test_memory.sh b/tools/test_memory.sh new file mode 100755 index 0000000..5ee4077 --- /dev/null +++ b/tools/test_memory.sh @@ -0,0 +1,4 @@ +#!/bin/bash +mprof rm 0 2>/dev/null +mprof run python test_memory.py +mprof plot >/dev/null 2>&1