perf: tell this package's frames apart without resolving paths - #56
Conversation
|
This pull request is part of a Mergify stack:
|
Merge Protections🟢 All 6 merge protections satisfied — ready to merge. Show 6 satisfied protections🟢 🤖 Continuous Integration
🟢 👀 Review Requirements
🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 Reviews
🟢 📕 PR description
🟢 🚦 Auto-queueWhen all merge protections are satisfied, this pull request will be queued automatically. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Relative symlink imports may fail package-frame detection until the absolute directory variant is included.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Optimizes migration frame detection by avoiding per-frame path resolution while preserving symlink support.
Changes:
- Caches package directory variants.
- Compares caller directories without resolving paths.
- Retains symlink-aware migration discovery.
| File | Summary | Finding |
|---|---|---|
alembic_git_revisions/_chain.py |
Optimizes package-frame detection during stack walking. | Moderate issue: include the absolute imported-path directory to support relative symlink imports. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
`_discover_versions_dir` resolved every frame's filename to decide whether it belonged to this package: a realpath walk, and so several filesystem calls, per frame, per migration. In the Mergify engine that was still about half of building a warm revision map for its ~350 migrations. A frame of this package carries the filename the package was imported by, so its directory is `Path(__file__).parent`; compare directories against that (and its resolved form) and resolve nothing. 20,000 discovery calls from a migration file: 125 µs → 7.8 µs per call (median of 7 runs), with the symlink cases of the previous commit still covered by their tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Change-Id: Ibdc8168e52b4646d5f479e62c947e251375944bd
27facbe to
c72d376
Compare
Revision history
|
Merge Queue Status
This pull request spent 19 seconds in the queue, including 1 second running CI. Required conditions to merge
|

_discover_versions_dirresolved every frame's filename to decidewhether it belonged to this package: a realpath walk, and so several
filesystem calls, per frame, per migration. In the Mergify engine that
was still about half of building a warm revision map for its ~350
migrations.
A frame of this package carries the filename the package was imported
by, so its directory is
Path(__file__).parent; compare directoriesagainst that (and its resolved form) and resolve nothing. 20,000
discovery calls from a migration file: 125 µs → 7.8 µs per call
(median of 7 runs), with the symlink cases of the previous commit still
covered by their tests.
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 5.5 (1M context) noreply@anthropic.com