Skip to content

perf: tell this package's frames apart without resolving paths - #56

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/jd/fix/discovery-symlinks/tell-pkg-s-frames-apart-without-resolving-paths--bdc8168e
Sep 24, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
devs/jd/fix/discovery-symlinks/tell-pkg-s-frames-apart-without-resolving-paths--bdc8168e

Conversation

@jd

@jd jd commented Sep 24, 2026

Copy link
Copy Markdown
Member

_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

Co-Authored-By: Claude Opus 5.5 (1M context) noreply@anthropic.com

@jd

jd commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 fix: find the versions directory through symlinks #55
2 perf: tell this package's frames apart without resolving paths #56 👈

@mergify
mergify Bot had a problem deploying to Mergify Merge Protections September 24, 2026 11:51 Failure
@jd
jd added this pull request to stack #57 September 24, 2026 11:51
@mergify
mergify Bot requested a review from a team September 24, 2026 11:52
@mergify

mergify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 6 merge protections satisfied — ready to merge.

Show 6 satisfied protections

🟢 🤖 Continuous Integration

  • all of:
    • check-success=all-greens

🟢 👀 Review Requirements

  • any of:
    • #approved-reviews-by>=1
    • author = dependabot[bot]
    • author = mergify-ci-bot

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|internal|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?!?:

🟢 🔎 Reviews

  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

  • body ~= (?ms:.{48,})

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

@jd
jd marked this pull request as ready for review September 24, 2026 12:03
Copilot AI lite review requested due to automatic review settings September 24, 2026 12:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 Medium severity

Open (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.

Comment thread alembic_git_revisions/_chain.py
Base automatically changed from devs/jd/fix/discovery-symlinks/find-versions-dir-symlinks--3921767a to main September 24, 2026 14:24
`_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
@jd
jd force-pushed the devs/jd/fix/discovery-symlinks/tell-pkg-s-frames-apart-without-resolving-paths--bdc8168e branch from 27facbe to c72d376 Compare September 24, 2026 14:27
@jd

jd commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

Revision history

# Type Changes Reason Date
1 initial 27facbe 2026-09-24 14:27 UTC
2 content 27facbe → c72d376 address review: make the imported package directory absolute, like the frames' directories it is compared with 2026-09-24 14:27 UTC

@mergify
mergify Bot deployed to Mergify Merge Protections September 24, 2026 14:28 Active
@mergify

mergify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-24 14:54 UTC · Rule: default · triggered by merge protections
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-09-24 14:55 UTC · at 86b074212578160e3caa02bbbd0dfc825ebdc906 · squash

This pull request spent 19 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Sep 24, 2026
@mergify
mergify Bot merged commit 86b0742 into main Sep 24, 2026
8 checks passed
@mergify
mergify Bot deleted the devs/jd/fix/discovery-symlinks/tell-pkg-s-frames-apart-without-resolving-paths--bdc8168e branch September 24, 2026 14:54
@mergify mergify Bot removed the queued label Sep 24, 2026

This branch was successfully deployed

1 active deployment
Mergify Merge Protections — c72d3769 Deployed Sep 24, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants