feat: add heavy-load CPU/memory profiling mode
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.pywith:profile_run(...)context managerwrite_profile_report(...)JSON report writer
- Extended
run_pageindex.pywith:--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.pycoverage 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.
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.
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 -qis currently blocked by conflictinglitellm==1.83.7/python-dotenv==1.2.2requirements.- The existing local
.venvis Python 3.9 and cannot import current code that usesdict | Noneannotations.