tofusoup 2026-03-21
Memray profiling infrastructure, discovery glob optimization, and 0.3.21 release
17 files · 1,368+ · 849-

Optimize stir discovery glob matching to O(1)

1 file changed
  • discovery.py Pre-compiles fnmatch glob patterns into combined alternation regexes at construction time; hot-path path exclusion check now uses compiled regex match instead of iterating per-pattern. Also pre-compiles path filter patterns in TestFilter.
  • Added _compile_glob() and _combine_globs() helpers that translate fnmatch patterns into compiled re.Pattern objects. StirDiscovery now builds _default_name_re, _default_substr_re, and _user_re at init time so the should_exclude() hot path does a single regex check rather than looping over every pattern on each directory traversal step. streamline behavioral
    1 file
    • discovery.py
  • TestFilter pre-compiles path_filters into a list of (is_negated, Pattern) tuples, replacing the per-call fnmatch.fnmatch() loop in the filter hot path. streamline behavioral
    1 file
    • discovery.py

Remove redundant is_debug_enabled() guards

7 files changed
  • cli.py Removed is_debug_enabled() guards around debug() calls
  • cli.py Removed is_debug_enabled() guards around debug() calls
  • base.py Removed is_debug_enabled() guard around debug() call
  • engine.py Removed is_debug_enabled() guards across all debug() call sites
  • client.py Removed is_debug_enabled() guards across all debug() call sites
  • state.py Removed is_debug_enabled() guard around debug() call
  • logic.py Removed is_debug_enabled() guard around debug() call
  • Removed the if logger.is_debug_enabled(): pattern from all call sites in cli.py, hcl/cli.py, registry/base.py, registry/search/engine.py, rpc/client.py, state.py, and testing/logic.py. The logger handles level-gating internally; the guards were redundant and added visual noise. This is the inverse of the 2026-03-20 change — that commit added guards for f-string construction; this removes them where the logger already handles it. decouple internal
    7 files
    • cli.py
    • cli.py
    • base.py
    • engine.py
    • client.py
    • state.py
    • logic.py

Add memray stress test scripts

3 files changed
  • memray_discovery_stress.py Stress test targeting TestDiscovery and TestFilter hot paths — builds a synthetic 80-dir tree and runs repeated discovery passes
  • memray_state_stress.py Stress test targeting state read/write hot paths
  • memray_wire_stress.py Stress test targeting wire/RPC hot paths
  • Three standalone scripts that drive the hot paths in stir discovery, state, and wire under memray profiling. Each builds a synthetic workload (e.g. 80-directory test tree for discovery) and runs it repeatedly so memray can capture allocation patterns. Intended for use with wrknv memray stress. qualify internal
    3 files
    • memray_discovery_stress.py
    • memray_state_stress.py
    • memray_wire_stress.py

Add memray baseline test suite

6 files changed
  • __init__.py Package init for memray test suite
  • baselines.json Memory baseline thresholds (peak allocations) for each hot path
  • conftest.py Shared fixtures for memray tests
  • test_discovery_mem.py Memory regression test for stir discovery hot path
  • test_state_mem.py Memory regression test for state hot path
  • test_wire_mem.py Memory regression test for wire/RPC hot path
  • Memray-based memory regression tests for the three hot paths — discovery, state, and wire. Each test exercises the path and asserts peak allocations stay within the thresholds in baselines.json. Marked with the memray pytest marker so they are excluded from the default test run and only run explicitly with -m memray. qualify internal
    6 files
    • __init__.py
    • baselines.json
    • conftest.py
    • test_discovery_mem.py
    • test_state_mem.py
    • test_wire_mem.py

Release 0.3.21: dependency pins, config, and lockfile

5 files changed
  • VERSION Bumped to 0.3.21
  • pyproject.toml Pin provide-foundation>=0.3.21; add pytest-httpx to dev deps; exclude memray marker from default pytest run; register memray marker
  • wrknv.toml Add memray task group with default and stress variants
  • .gitignore Ignore memray-output/ and .actrc
  • uv.lock Lockfile update for provide-foundation 0.3.21.post1 and pytest-httpx addition
  • Pinned provide-foundation[all]>=0.3.21 in pyproject.toml and upgraded to provide-foundation 0.3.21.post1 in the lockfile. baseline internal
    2 files
    • pyproject.toml
    • uv.lock
  • Added pytest-httpx>=0.35.0 to dev dependencies; added tests/memray to testpaths; registered the memray marker; excluded memray tests from the default pytest addopts. baseline internal
    1 file
    • pyproject.toml
  • Added wrknv memray task group: default runs pytest tests/memray/ -m memray; stress runs all three stress scripts in sequence. baseline internal
    1 file
    • wrknv.toml
  • Gitignored memray-output/ (profiling artifacts) and .actrc (local act CI config). Bumped VERSION to 0.3.21. baseline internal
    2 files
    • .gitignore
    • VERSION