Skip to content

Add deterministic parser performance benchmarks and CI reporting - #37

Draft
jkowalleck with Copilot wants to merge 11 commits into
mainfrom
copilot/tests-add-performance-tests
Draft

jkowalleck with Copilot wants to merge 11 commits into
mainfrom
copilot/tests-add-performance-tests

Conversation

Copilot AI commented Jul 17, 2026 •

Copy link
Copy Markdown

This adds a dedicated performance suite for the RFC 3987 parser helpers so parser construction cost, parse throughput, and memory usage can be compared over time. The benchmarks are deterministic, separately runnable, and wired into CI as report-only smoke/full jobs with machine-readable output.

  • Benchmark suite

    • Adds tests/test_perf.py with a separate perf marker
    • Measures build/init cost independently from parse cost
    • Reports per-parser, per-dataset metrics for:
      • ms/op
      • ops/s
      • peak allocated memory
    • Covers the public parser entry points explicitly:
      • shared parser APIs: parse, is_valid_syntax
      • term-specific validators: is_valid_syntax_*
  • Deterministic corpus + reporting

    • Uses fixed average-case corpora for small / medium / large runs
    • Captures runtime environment in JSON output:
      • Python version
      • platform
      • lark version
    • Supports optional baseline comparison via prior JSON results and prints deltas in the summary table
  • Pytest configuration

    • Registers the perf marker in pyproject.toml
    • Keeps default test runs on the functional suite with -m "not perf"
  • CI strategy

    • PRs run a lightweight perf smoke job and upload JSON artifacts
    • scheduled/manual runs execute the full perf suite and upload results for comparison
    • keeps perf report-only; no regression threshold enforcement is introduced yet

Example benchmark invocation:

RFC3987_PERF_MODE=full \
RFC3987_PERF_RESULTS_JSON=perf-results/current.json \
RFC3987_PERF_BASELINE_JSON=perf-results/baseline.json \
python -m pytest -m perf tests/test_perf.py -s

Copilot AI linked an issue Jul 17, 2026 that may be closed by this pull request
10 tasks
Copilot AI changed the title [WIP] Add performance tests for all parsers Add deterministic parser performance benchmarks and CI reporting Jul 17, 2026
Copilot AI requested a review from jkowalleck July 17, 2026 09:43
Copilot AI added 2 commits July 17, 2026 14:00
…-15 per rule

- Create .github/workflows/python-perf.yml with perf-smoke (PRs) and
  perf-full (push to main/next, schedule, manual) jobs
- Remove perf-smoke and perf-full jobs from python-tests.yml
- Add -m "not perf" to python-publish.yml quick-test step
- Expand RULE_SAMPLES in tests/test_perf.py from 2 to 10-15 valid
  samples per rule (406 total, all validated)
Comment thread .github/workflows/python-perf.yml Outdated
jobs:
perf-smoke:
name: Performance Smoke (py${{ env.PYTHON_VERSION_DEFAULT }})
name: Performance Smoke (py3.14)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot dont prnit my version here ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in commit 2e1d1c7: the job name no longer prints the Python version.

Comment thread .github/workflows/python-perf.yml Outdated
path: perf-results/
perf-full:
name: Performance Full (py${{ env.PYTHON_VERSION_DEFAULT }})
name: Performance Full (py3.14)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot dont prnit my version here ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in commit 2e1d1c7: the job name no longer prints the Python version.

Comment thread .github/workflows/python-perf.yml Outdated
pull_request:
push:
branches: [ 'main', 'next' ]
schedule:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot no scheduling needed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in commit 2e1d1c7: removed the schedule trigger from this workflow.

Comment thread .github/workflows/python-perf.yml Outdated
python -m pytest -m perf tests/test_perf.py -s
- name: Upload perf smoke results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot have the version vomment the full version matching the git node id

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in commit 2e1d1c7: changed the pinned action version comment to the full matching tag v4.6.2 for this hash.

Comment thread .github/workflows/python-perf.yml Outdated
mkdir -p perf-results
python -m pytest -m perf tests/test_perf.py -s
- name: Upload perf smoke results
if: always()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add a comemnt linking to the sction
ala # see https://github.com/actions/setup-python

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in commit 2e1d1c7: added a see comment linking to the actions/upload-artifact action.

Comment thread .github/workflows/python-perf.yml Outdated
python -m pytest -m perf tests/test_perf.py -s
- name: Upload full perf results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add a comemnt linking to the sction
ala # see https://github.com/actions/setup-python

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in commit 2e1d1c7: added a see comment linking to the actions/upload-artifact action.

Comment thread .github/workflows/python-perf.yml Outdated
python -m pytest -m perf tests/test_perf.py -s
- name: Upload full perf results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot have the version vomment the full version matching the git node id

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in commit 2e1d1c7: changed the pinned action version comment to the full matching tag v4.6.2 for this hash.

Comment thread .github/workflows/python-perf.yml Outdated
path: perf-results/
perf-full:
name: Performance Full (py3.14)
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'push'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the condition is not needed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in commit 2e1d1c7: removed the unnecessary job condition.

Copilot AI requested a review from jkowalleck July 18, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: add performance tests

2 participants