Skip to content

fix: read _sockets_dict in Sockets.__getattribute__ - #12966

Open
bhaskargurram-ai wants to merge 1 commit into
deepset-ai:mainfrom
bhaskargurram-ai:fix/sockets-getattribute-attribute-name
Open

bhaskargurram-ai wants to merge 1 commit into
deepset-ai:mainfrom
bhaskargurram-ai:fix/sockets-getattribute-attribute-name

Conversation

@bhaskargurram-ai

Copy link
Copy Markdown

getattribute looked up a _sockets attribute, but the one init assigns is _sockets_dict. The lookup raised AttributeError on every attribute access and fell through to object.getattribute, so the intended fast path never ran.

Socket access still worked, but only through the copy init places in dict -- which made the dead branch look load-bearing and put an exception on the path of every attribute access.

Reading the right name makes the branch live: 200k socket attribute accesses drop from 0.125s to 0.031s. External behaviour is unchanged, since the dict copy already shadowed class attributes for the same names.

Fixes #12939

Related Issues

  • fixes #issue-number

Proposed Changes:

How did you test it?

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

__getattribute__ looked up a `_sockets` attribute, but the one __init__
assigns is `_sockets_dict`. The lookup raised AttributeError on every
attribute access and fell through to object.__getattribute__, so the
intended fast path never ran.

Socket access still worked, but only through the copy __init__ places in
__dict__ -- which made the dead branch look load-bearing and put an
exception on the path of every attribute access.

Reading the right name makes the branch live: 200k socket attribute
accesses drop from 0.125s to 0.031s. External behaviour is unchanged,
since the __dict__ copy already shadowed class attributes for the same
names.

Fixes deepset-ai#12939
@bhaskargurram-ai
bhaskargurram-ai requested a review from a team as a code owner September 25, 2026 21:28
@bhaskargurram-ai
bhaskargurram-ai requested review from julian-risch and removed request for a team September 25, 2026 21:28
@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

@bhaskargurram-ai is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Sep 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @bhaskargurram-ai, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from julian-risch September 25, 2026 22:51
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Sep 25, 2026
@HaystackBot
HaystackBot marked this pull request as draft September 25, 2026 22:51
@HaystackBot
HaystackBot marked this pull request as ready for review September 25, 2026 23:25
@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Sep 25, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

Thanks for signing the CLA, @bhaskargurram-ai! 🎉 This PR is now ready for review again and the reviewer has been re-assigned.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sockets.__getattribute__ references _sockets but the actual attribute is _sockets_dict — the optimization at lines 127-132 is dead code due to a typo

3 participants