Skip to content

test(scaling): count children-index work instead of timing it (#4753) - #4791

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-4753-children-index-op-count
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-4753-children-index-op-count

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

TestChildrenIndexScaling timed _build_children_index on 50 and 500 deps (microseconds) and asserted a ratio below 15x. It flaked at 17.2x on a loaded runner (#4711 Integration run 45029284682).

It now counts work instead of timing it, the same idea as #4726 (a deterministic quantity):

  • A counting lockfile view charges one operation per dependency it hands out and one per attribute the index reads on a dependency. Any other lockfile access raises, so a new access path cannot slip by uncounted.
  • Linear work is exactly 10x for 10x input; quadratic work is about 100x. The bound is ops(500) <= 10 * ops(50).
  • The index content is checked against the real lockfile at both sizes.
  • Negative control in the same test: an index built by rescanning every dependency per edge (seeded quadratic) must fail the bound.

No production source change; other scaling guards are untouched (out of scope).

Issue and approved scope

Issue: Fixes #4753

Human scope-approval comment: #4753 (comment)

Does this PR complete the issue, or what remains? It completes the issue.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Local, via the host guard (/tmp/eng4753-proof.sh):

  • pytest tests/benchmarks/test_scaling_guards.py::TestChildrenIndexScaling -n 0: passed.
  • 50-run loop of the counting harness: exactly one distinct result over 50 runs, {50: 125, 500: 1250}, so the bound can never be crossed by noise.
  • Temporary owner mutation (_build_children_index calls get_package_dependencies() per edge; reverted): AssertionError: _build_children_index did 126250 operations for 500 deps and 1375 for 50, an O(n^2) regression, i.e. 1 failed.
  • Gates:
    • ruff check/format --check (0.15.12): clean
    • scripts/check_test_assertions.py: ratchet clean (AQ003 unchanged)
    • python -m tests.quality.taxonomy --changed: clean

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

TestChildrenIndexScaling compared microsecond timings at 50 and 500
deps against a 15x bound and flaked at 17.2x on a loaded runner. It now
counts the dependencies the index receives and the attributes it reads
through a counting lockfile view: linear work is exactly 10x for 10x
input, quadratic work about 100x. The index content is also checked
against the real lockfile.

Fixes #4753

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The scaling guard misses quadratic child-list copying because its counter and negative control cover only dependency access, leaving an output-equivalent performance regression undetected.

1 open issue
What changed in this PR

This test-only change addresses the flaky children-index scaling check from #4753 by replacing microsecond timing comparisons with deterministic dependency-access counts. Production code and other scaling guards remain unchanged.

Changes:

  • Counts dependency retrievals and attribute reads for 50 and 500 dependencies, enforcing a 10x growth bound.
  • Checks index contents against the real lockfile and adds a quadratic rescanning negative control.
File Description
tests/​benchmarks/​test_scaling_guards.py Replaces the children-index timing check with counting wrappers, output checks, and a negative control.

Review effort: Balanced

Comment thread tests/benchmarks/test_scaling_guards.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The scaling guard misses quadratic membership scans and list-copying work, allowing performance regressions to pass without adequate negative controls or collection-work measurement.

2 open issues

Review effort: Balanced

Comment thread tests/benchmarks/test_scaling_guards.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FLAKE] Scaling Guards TestChildrenIndexScaling ratio exceeds 15x on microsecond timings

2 participants