Skip to content

lightspeed survey: copy sys.modules before the extension scan - #10

Merged
ArjunS07 merged 1 commit into
mainfrom
fix/extension-deps-modules-snapshot
Oct 13, 2026
Merged

ArjunS07 merged 1 commit into
mainfrom
fix/extension-deps-modules-snapshot

Conversation

@ArjunS07

Copy link
Copy Markdown
Collaborator

Purpose

Benchmark discovery stops with RuntimeError: dictionary changed size during iteration for some tasks. The image build then finds 0 benchmarks and the task fails. In the current pandas batch, 5 of 7 failed builds have this error. 2 earlier pandas builds have it too.

How it works

_add_extension_deps loops over sys.modules.values() and calls getattr(mod, "__file__") on each module. A module with a lazy __getattr__ can import another module during that call, so sys.modules changes while the loop reads it. The fix loops over a copy, list(sys.modules.values()).

Changes

  • asv/contrib/lightspeed/survey.py: loop over a copy of sys.modules.
    • Effect: the scan finishes when a module import happens during the scan. Modules added during the scan are not scanned.
    • Before: the scan stopped with RuntimeError and the survey recorded no benchmarks.
  • test/test_lightspeed_survey.py: a test with a module whose __getattr__ adds a module to sys.modules.

Verification

$ pytest -q --noconftest test/test_lightspeed_survey.py
3 passed

Without the fix, the new test fails with the same error as the builds:

E       RuntimeError: dictionary changed size during iteration
asv/contrib/lightspeed/survey.py:77: RuntimeError

Notes

Build logs with the error: pandas-dev/pandas #23019, #23591, #23981, #24204, #24428, #24792, #25665. The task template pins LSV_REF, so the failed tasks need the new commit in the template before a rebuild.

Reading a module attribute in the loop can import another module, which raised
'dictionary changed size during iteration' and left image builds with no benchmarks.
@ArjunS07
ArjunS07 merged commit 9702a48 into main Oct 13, 2026
6 of 28 checks passed
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.

1 participant