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

Appearance settings

copy.copy and copy.deepcopy scale poorly with free-threading #132657

Copy link
Copy link
Open
@eendebakpt

Description

@eendebakpt
Issue body actions

The copy.copy and copy.deepcopy operations running on different objects in different threads should be able to run independently. The scaling is not good: output of the ftscalingbench.py with added benchmarks:

Running benchmarks with 8 threads
shallow_copy               4.6x slower
deepcopy                   2.3x slower
object_cfunction           5.9x faster
cmodule_function           5.9x faster
object_lookup_special      5.5x faster
mult_constant              5.6x faster
generator                  4.9x faster
pymethod                   5.2x faster
pyfunction                 4.5x faster
module_function            5.0x faster
load_string_const          5.6x faster
load_tuple_const           5.9x faster
create_pyobject            2.3x faster
create_closure             7.1x faster
create_dict                3.3x faster
thread_local_read          3.3x faster

There are at least two reasons:

  • The copy module uses module level variables in the copy.copy and copy.deepcopy methods.
  • The _copy_atomic_types (and some similar data structures) is a set which requires locking for membership testing.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagePerformance or resource usagestdlibPython modules in the Lib dirPython modules in the Lib dirtopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.