FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.14] gh-129752: Don't update adaptive counters when TLBC=0 in free-threading. (gh-155497) by corona10 · Pull Request #155715 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .h  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 0 additions & 1 deletion Lib/test/test_thread_local_bytecode.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def f(a, b, q=None):
""")
assert_python_ok("-X", "tlbc=1", "-c", code)

@support.skip_if_sanitizer("gh-129752: data race on adaptive counter", thread=True)
def test_no_copies_if_tlbc_disabled(self):
code = textwrap.dedent("""
import queue
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Don't update adaptive counters in the free-threaded build when thread-local
bytecode is disabled (``-X tlbc=0``). Patch by Donghee Na.
20 changes: 20 additions & 0 deletions Python/ceval_macros.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,25 @@ GETITEM(PyObject *v, Py_ssize_t i) {
#define ADAPTIVE_COUNTER_TRIGGERS(COUNTER) \
backoff_counter_triggers(forge_backoff_counter((COUNTER)))

#ifdef Py_GIL_DISABLED
/* Counters are unreachable when thread-local bytecode is disabled,
* so there is no need to update them. */
#define ADVANCE_ADAPTIVE_COUNTER(COUNTER) \
do { \
_Py_BackoffCounter cnt = (COUNTER); \
if (!is_unreachable_backoff_counter(cnt)) { \
(COUNTER) = advance_backoff_counter(cnt); \
} \
} while (0);

#define PAUSE_ADAPTIVE_COUNTER(COUNTER) \
do { \
_Py_BackoffCounter cnt = (COUNTER); \
if (!is_unreachable_backoff_counter(cnt)) { \
(COUNTER) = pause_backoff_counter(cnt); \
} \
} while (0);
#else
#define ADVANCE_ADAPTIVE_COUNTER(COUNTER) \
do { \
(COUNTER) = advance_backoff_counter((COUNTER)); \
Expand All @@ -294,6 +313,7 @@ GETITEM(PyObject *v, Py_ssize_t i) {
do { \
(COUNTER) = pause_backoff_counter((COUNTER)); \
} while (0);
#endif

#ifdef ENABLE_SPECIALIZATION_FT
/* Multiple threads may execute these concurrently if thread-local bytecode is
Expand Down
Loading

Back | FazBrowse Home | New Git URL