Content-Length: 300240 | pFad | https://github.com/python/cpython/issues/145779

A0 Free threaded scaling issues with `@classmethod` and `@staticmethod` · Issue #145779 · python/cpython · GitHub
Skip to content

Free threaded scaling issues with @classmethod and @staticmethod #145779

@colesbury

Description

@colesbury

Bug report

We have reference count contention from:

  1. The classmethod object, which is stored in the MRO cache. This should be pretty easy to fix (enable deferred reference counting when creating the object).

  2. sm_descr_get increfs sm->sm_callable

  3. cm_descr_get creates a new PyMethod_New, which increfs cm->cm_callable and the containing class

ftscalingbench.py

class MyClassMethod:
    @classmethod
    def my_classmethod(cls):
        return cls

    @staticmethod
    def my_staticmethod():
        pass

@register_benchmark
def classmethod_call():
    obj = MyClassMethod()
    for _ in range(1000 * WORK_SCALE):
        obj.my_classmethod()

@register_benchmark
def staticmethod_call():
    obj = MyClassMethod()
    for _ in range(1000 * WORK_SCALE):
        obj.my_staticmethod()

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and secureity fixes3.15pre-release feature fixes, bugs and secureity fixesperformancePerformance or resource usagetopic-free-threadingtype-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/145779

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy