Skip to content

gh-128942: make arraymodule.c free-thread safe (lock-free) #130771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f54c5fc
slow arraymodule
tom-pytel Mar 1, 2025
4c71f00
lockfree read and write single element
tom-pytel Mar 2, 2025
512c4c7
📜🤖 Added by blurb_it.
blurb-it[bot] Mar 2, 2025
060100f
ensure_shared_on_resize() in one more place
tom-pytel Mar 2, 2025
d0b17c6
fix stupid direct return out of critical section
tom-pytel Mar 3, 2025
c17b787
requested changes
tom-pytel Mar 3, 2025
4fd8383
downgrade to _Py_atomic_load_ptr_relaxed in missed place
tom-pytel Mar 3, 2025
d00f2b7
arraymodule linked statically
tom-pytel Mar 4, 2025
a3e6004
cleanups
tom-pytel Mar 5, 2025
fb6212a
test and tsan stuff
tom-pytel Mar 5, 2025
04a8f9d
getters and setters using atomics
tom-pytel Mar 5, 2025
01423fd
fix 2 byte wchar_t
tom-pytel Mar 6, 2025
99331dd
remove debug printf
tom-pytel Mar 6, 2025
07c98cc
just a hunch...
tom-pytel Mar 6, 2025
cf3bbbb
atomic "memcpy"
tom-pytel Mar 6, 2025
51135a4
misc
tom-pytel Mar 7, 2025
fff827e
use proper type FT_ macros
tom-pytel Mar 8, 2025
12f0ff6
atomic aggregate _Py_atomic_source_memcpy_relaxed()
tom-pytel Mar 10, 2025
1a6b8df
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Mar 11, 2025
94ef417
remove atomic memcpy
tom-pytel Mar 11, 2025
0056412
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Mar 11, 2025
1431784
regen clinic
tom-pytel Mar 11, 2025
460d3d7
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Mar 11, 2025
409239c
requested changes
tom-pytel Mar 15, 2025
a6f17c9
more requested changes
tom-pytel Mar 17, 2025
b5d219e
__declspec(align(8)) for Windows
tom-pytel Mar 17, 2025
2c82071
shut up check-c-globals
tom-pytel Mar 17, 2025
1ba50e9
alignment changes
tom-pytel Mar 20, 2025
576aebf
MS_WINDOWS -> _MSC_VER
tom-pytel Mar 20, 2025
4dd0954
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Mar 20, 2025
d4e5313
#include "pycore_gc.h", something moved
tom-pytel Mar 20, 2025
48eabe3
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Mar 25, 2025
c056b13
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Mar 25, 2025
affae8e
remove NULL check in arraydata_free()
tom-pytel Mar 25, 2025
689c7a3
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Mar 31, 2025
3e2f8cd
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Apr 4, 2025
7286fed
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Apr 14, 2025
6550906
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel Apr 23, 2025
5b35203
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel May 2, 2025
15d92ca
Merge branch 'main' into fix-issue-128942-lockfree
tom-pytel May 5, 2025
2e7132e
change to use new _Py_ALIGN_AS() macro
tom-pytel May 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix stupid direct return out of critical section
  • Loading branch information
tom-pytel committed Mar 3, 2025
commit d0b17c6868f8e270c3690ac47c72a3e924f8edbc
10 changes: 7 additions & 3 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,12 @@ getarrayitem_locked(PyObject *op, Py_ssize_t i)
}
#endif
if (!valid_index(i, Py_SIZE(op))) {
return NULL;
ret = NULL;
}
else {
arrayobject *ap = (arrayobject *)op;
ret = getarrayitem(op, i, ap->ob_item);
}
arrayobject *ap = (arrayobject *)op;
ret = getarrayitem(op, i, ap->ob_item);
Py_END_CRITICAL_SECTION();
return ret;
}
Expand All @@ -844,6 +846,8 @@ getarrayitem_maybe_locked(PyObject *op, Py_ssize_t i)
return NULL;
}
return getarrayitem(op, i, items);
/* Could check size again here to make sure it hasn't changed during get,
but not sure would add anything of value. */
}

#else // Py_GIL_DISABLED
Expand Down
Loading