PageIndex icon indicating copy to clipboard operation
PageIndex copied to clipboard

feat: add heavy-load CPU/memory profiling mode

Open pandego opened this issue 8 months ago • 2 comments

Summary

This PR adds built-in runtime profiling support for heavy-load runs so users can measure end-to-end latency and memory usage directly from the CLI.

What changed

  • Added pageindex/profiling.py with:
    • profile_run(...) context manager
    • write_profile_report(...) JSON report writer
  • Extended run_pageindex.py with:
    • --enable-profile
    • --profile-output (default: ./results/profile_report.json)
  • Updated README with a heavy-load profiling walkthrough and report interpretation guidance.
  • Added tests/test_profiling.py coverage for report generation/writing logic.

Why

Issue #141 asks for practical CPU/memory profiling documentation under heavy load. This PR provides both:

  • executable profiling support in the main entrypoint,
  • and docs showing how to use it for repeatable performance analysis.

Validation

  • python3 -m py_compile run_pageindex.py pageindex/profiling.py tests/test_profiling.py

Note: full runtime tests were not executed in this environment because Python package dependencies/tooling (pip/pytest) are unavailable on this runner.

pandego avatar Mar 05 '26 11:03 pandego

Rebased this branch onto current main, resolved the conflict in run_pageindex.py, and reran python -m pytest tests/test_profiling.py -q locally (2 passed).

Force-pushed the refreshed branch now.

pandego avatar Mar 23 '26 21:03 pandego

Rebased this onto current main and kept the profiling regression aligned with the upstream examples/documents layout.

Validation:

  • PYTHONPATH=. uvx --python 3.11 --with pytest --with PyPDF2==3.0.1 --with pyyaml==6.0.2 --with pymupdf==1.26.4 --with python-dotenv==1.0.1 --with litellm==1.83.7 pytest examples/documents/test_profiling.py -q - 2 passed

Notes from local validation:

  • PYTHONPATH=. uv run --with-requirements requirements.txt --with pytest pytest examples/documents/test_profiling.py -q is currently blocked by conflicting litellm==1.83.7 / python-dotenv==1.2.2 requirements.
  • The existing local .venv is Python 3.9 and cannot import current code that uses dict | None annotations.

pandego avatar Jun 06 '26 15:06 pandego