Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Free threading scaling bottleneck insys.intern() #146041

Open
Assignees
colesbury
Labels
3.14bugs and security fixes3.15new features, bugs and security fixesperformancePerformance or resource usagetopic-free-threadingtype-bugAn unexpected behavior, bug, or error
@colesbury

Description

@colesbury

Bug report

Callingsys.intern() on a string that's not interned acquires the interpreter-wideinterned_mutex. This can lead to scaling bottlenecks either due to explicitsys.intern() calls or indirectly becausePyObject_SetAttr calls_PyUnicode_InternMortal.

We should avoid the lock acquisition if there is an interned copy already present in theinterned_dict.

For example:

_ATTR_PREFIX="bench"@register_benchmarkdefsetattr_non_interned():prefix=_ATTR_PREFIXobj=MyObject()for_inrange(1000*WORK_SCALE):setattr(obj,f"{prefix}_a",None)setattr(obj,f"{prefix}_b",None)setattr(obj,f"{prefix}_c",None)

This came up when looking at Django scaling bottlenecks.

Linked PRs

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixes3.15new features, bugs and security fixesperformancePerformance or resource usagetopic-free-threadingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2026 Movatter.jp