summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* gh-116808: Fix optimized trace length histogram (GH-116827)Michael Droettboom2024-03-191-1/+2
|
* gh-115756: make PyCode_GetFirstFree an unstable API (GH-115781)Bogdan Romanyuk2024-03-192-2/+2
|
* gh-108716: Cleanup remaining deepfreeze infrastructure (#116919)Guido van Rossum2024-03-182-34/+0
| | | | | Keep Tools/build/deepfreeze.py around (we may repurpose it for deepfreezing non-code objects), and keep basic "clean" targets that remove the output of former deep-freeze activities, to keep the build directories of current devs clean.
* gh-116916: Remove separate next_func_version counter (#116918)Guido van Rossum2024-03-181-1/+0
| | | | | Somehow we ended up with two separate counter variables tracking "the next function version". Most likely this was a historical accident where an old branch was updated incorrectly. This PR merges the two counters into a single one: `interp->func_state.next_version`.
* Cleanup tier2 debug output (#116920)Guido van Rossum2024-03-185-22/+50
| | | Various tweaks, including a slight refactor of the special cases for `_PUSH_FRAME`/`_POP_FRAME` to show the actual operand emitted.
* gh-63207: Use GetSystemTimePreciseAsFileTime() in time.time() (#116822)Victor Stinner2024-03-181-16/+22
|
* gh-116664: Ensure thread-safe dict access in _warnings (#116768)Erlend E. Aasland2024-03-181-29/+32
| | | Replace _PyDict_GetItemWithError() with PyDict_GetItemRef().
* gh-114271: Fix race in `Thread.join()` (#114839)mpage2024-03-162-48/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a race between when `Thread._tstate_lock` is released[^1] in `Thread._wait_for_tstate_lock()` and when `Thread._stop()` asserts[^2] that it is unlocked. Consider the following execution involving threads A, B, and C: 1. A starts. 2. B joins A, blocking on its `_tstate_lock`. 3. C joins A, blocking on its `_tstate_lock`. 4. A finishes and releases its `_tstate_lock`. 5. B acquires A's `_tstate_lock` in `_wait_for_tstate_lock()`, releases it, but is swapped out before calling `_stop()`. 6. C is scheduled, acquires A's `_tstate_lock` in `_wait_for_tstate_lock()` but is swapped out before releasing it. 7. B is scheduled, calls `_stop()`, which asserts that A's `_tstate_lock` is not held. However, C holds it, so the assertion fails. The race can be reproduced[^3] by inserting sleeps at the appropriate points in the threading code. To do so, run the `repro_join_race.py` from the linked repo. There are two main parts to this PR: 1. `_tstate_lock` is replaced with an event that is attached to `PyThreadState`. The event is set by the runtime prior to the thread being cleared (in the same place that `_tstate_lock` was released). `Thread.join()` blocks waiting for the event to be set. 2. `_PyInterpreterState_WaitForThreads()` provides the ability to wait for all non-daemon threads to exit. To do so, an `is_daemon` predicate was added to `PyThreadState`. This field is set each time a thread is created. `threading._shutdown()` now calls into `_PyInterpreterState_WaitForThreads()` instead of waiting on `_tstate_lock`s. [^1]: https://github.com/python/cpython/blob/441affc9e7f419ef0b68f734505fa2f79fe653c7/Lib/threading.py#L1201 [^2]: https://github.com/python/cpython/blob/441affc9e7f419ef0b68f734505fa2f79fe653c7/Lib/threading.py#L1115 [^3]: https://github.com/mpage/cpython/commit/81946532792f938cd6f6ab4c4ff92a4edf61314f --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Antoine Pitrou <antoine@python.org>
* gh-112536: Add TSAN builds on Github Actions (#116872)Donghee Na2024-03-161-0/+4
|
* GH-115802: Reduce the size of _INIT_CALL_PY_EXACT_ARGS. (GH-116856)Mark Shannon2024-03-153-72/+54
|
* gh-116735: Use `MISSING` for `CALL` event if argument is absent (GH-116737)Tian Gao2024-03-152-2/+2
|
* GH-116422: Modify a few uops so that they can be supported by tier 2 with ↵Mark Shannon2024-03-153-53/+45
| | | | hot/cold splitting (GH-116832)
* gh-111696, PEP 737: Add PyType_GetModuleName() function (#116824)Victor Stinner2024-03-141-2/+1
| | | Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* GH-116422: Factor out eval breaker checks at end of calls into its own ↵Mark Shannon2024-03-144-227/+327
| | | | micro-op. (GH-116817)
* gh-88494: Use QueryPerformanceCounter() for time.monotonic() (#116781)Victor Stinner2024-03-141-138/+73
| | | | | On Windows, time.monotonic() now uses the QueryPerformanceCounter() clock to have a resolution better than 1 us, instead of the gGetTickCount64() clock which has a resolution of 15.6 ms.
* gh-90300: Fix undocumented envvars in the Python CLI help (GH-116765)Serhiy Storchaka2024-03-141-0/+3
|
* Docs: fix spelling of the word 'transferring' (#116641)guangwu2024-03-131-3/+3
|
* gh-116760: Fix pystats for trace attempts (GH-116761)Michael Droettboom2024-03-133-2/+1
| | | | | | | | There are now at least two bytecodes that may attempt to optimize, JUMP_BACK, and more recently, COLD_EXIT. Only the JUMP_BACK was counting the attempt in the stats. This moves that counter to uop_optimize itself so it should always happen no matter where it is called from.
* gh-90300: Document equivalent -X options for envvars in the Python CLI help ↵Serhiy Storchaka2024-03-131-29/+31
| | | | (GH-116756)
* gh-90300: Sort the -X options and some envvars in the Python CLI help ↵Serhiy Storchaka2024-03-131-40/+43
| | | | (GH-116739)
* gh-90300: Fix cmdline.rst (GH-116721)Serhiy Storchaka2024-03-131-2/+2
| | | | * Fix the description of the "-b" option. * Add references to environment variables for "-s" and "-X dev" options.
* gh-115419: Change default sym to not_null (GH-116562)Ken Jin2024-03-132-90/+100
|
* gh-116626: Emit `CALL` events for all `INSTRUMENTED_CALL_FUNCTION_EX` ↵Tian Gao2024-03-132-28/+29
| | | | (GH-116627)
* GH-116098: Remove dead frame object creation code (GH-116687)Tian Gao2024-03-121-18/+9
|
* gh-116604: Check for `gcstate->enabled` in _Py_RunGC in free-threaded build ↵Sam Gross2024-03-121-0/+4
| | | | | | | | (#116663) This isn't strictly necessary because the implementation of `gc_should_collect` already checks `gcstate->enabled` in the free-threaded build, but it seems like a good idea until the common pieces of gc.c and gc_free_threading.c are refactored out.
* gh-116604: Correctly honor the gc status when calling _Py_RunGC (#116628)Pablo Galindo Salgado2024-03-121-0/+4
|
* gh-116515: Clear thread-local state before tstate_delete_common() (#116517)Sam Gross2024-03-111-1/+2
| | | | | | | This moves `current_fast_clear()` up so that the current thread state is `NULL` while running `tstate_delete_common()`. This doesn't fix any bugs, but it means that we are more consistent that `_PyThreadState_GET() != NULL` means that the thread is "attached".
* gh-110850: Fix _PyTime_FromSecondsDouble() API (#116606)Victor Stinner2024-03-111-7/+4
| | | | | | | | Return 0 on success. Set an exception and return -1 on error. Fix os.timerfd_settime(): properly report exceptions on _PyTime_FromSecondsDouble() failure. No longer export _PyTime_FromSecondsDouble().
* gh-116167: Allow disabling the GIL with `PYTHON_GIL=0` or `-X gil=0` (#116338)Brett Simmers2024-03-113-0/+71
| | | | | | | | | In free-threaded builds, running with `PYTHON_GIL=0` will now disable the GIL. Follow-up issues track work to re-enable the GIL when loading an incompatible extension, and to disable the GIL by default. In order to support re-enabling the GIL at runtime, all GIL-related data structures are initialized as usual, and disabling the GIL simply sets a flag that causes `take_gil()` and `drop_gil()` to return early.
* GH-116596: Better determination of escaping uops. (GH-116597)Mark Shannon2024-03-112-4/+5
|
* gh-116590: Fix unused `current_thread_holds_gil` function warning (#116591)Nikita Sobolev2024-03-111-0/+2
|
* GH-116468: Use constants instead of `oparg` in stack effects when `oparg` is ↵Mark Shannon2024-03-114-103/+93
| | | | known to be a constant. (GH-116469)
* gh-108724: Fix _PySemaphore_Wait call during thread deletion (#116483)Sam Gross2024-03-081-4/+6
| | | | | | | | | In general, when `_PyThreadState_GET()` is non-NULL then the current thread is "attached", but there is a small window during `PyThreadState_DeleteCurrent()` where that's not true: tstate_delete_common() is called when the thread is detached, but before current_fast_clear(). Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-112075: Support freeing object memory via QSBR (#116344)Dino Viehland2024-03-081-2/+8
| | | Free objects with qsbr if shared
* gh-115103: Fix unregistering of QSBR state (#116480)Sam Gross2024-03-081-3/+7
| | | | | If a thread blocks while waiting on the `shared->mutex` lock, the array of QSBR states may be reallocated. The `tstate->qsbr` values before the lock is acquired may not be the same as the value after the lock is acquired.
* gh-116447: Fix possible UB in `arraymodule` and `getargs` (#116459)Nikita Sobolev2024-03-081-2/+2
|
* GH-113710: Fix optimization of globals using `_CHECK_FUNCTION` (GH-116460)Mark Shannon2024-03-083-10/+16
|
* gh-116396: Pass "detached_state" argument to tstate_set_detached (#116398)Sam Gross2024-03-071-6/+6
| | | | The stop-the-world code was incorrectly setting suspended threads' states to _Py_THREAD_DETACHED instead of _Py_THREAD_SUSPENDED.
* gh-116381: Remove bad specializations, add fail stats (GH-116464)Ken Jin2024-03-076-194/+41
| | | * Remove bad specializations, add fail stats
* gh-116420: Fix unused var compilation warnings (GH-116466)Ken Jin2024-03-072-0/+24
| | | Fix unused var compilation warnings
* gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)Serhiy Storchaka2024-03-076-39/+36
|
* gh-116397: Move the _PyGC_ClearAllFreeLists to the safe point (gh-116414)Donghee Na2024-03-061-2/+5
|
* gh-116381: Specialize CONTAINS_OP (GH-116385)Ken Jin2024-03-066-8/+373
| | | | | | | | | | | * Specialize CONTAINS_OP * 📜🤖 Added by blurb_it. * Add PyAPI_FUNC for JIT --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435)Sam Gross2024-03-062-10/+9
| | | | | | | | | | | | | | | | | | This implements the delayed reuse of mimalloc pages that contain Python objects in the free-threaded build. Allocations of the same size class are grouped in data structures called pages. These are different from operating system pages. For thread-safety, we want to ensure that memory used to store PyObjects remains valid as long as there may be concurrent lock-free readers; we want to delay using it for other size classes, in other heaps, or returning it to the operating system. When a mimalloc page becomes empty, instead of immediately freeing it, we tag it with a QSBR goal and insert it into a per-thread state linked list of pages to be freed. When mimalloc needs a fresh page, we process the queue and free any still empty pages that are now deemed safe to be freed. Pages waiting to be freed are still available for allocations of the same size class and allocating from a page prevent it from being freed. There is additional logic to handle abandoned pages when threads exit.
* GH-113710: Tier 2 optimizer: check the function instead of checking globals. ↵Mark Shannon2024-03-064-36/+27
| | | | (GH-116410)
* GH-115687: Most comparisons create Booleans, so propagate that information ↵Mark Shannon2024-03-062-16/+68
| | | | | (GH-116360) Most comparisons create booleans
* gh-107954: Add PyConfig_MEMBER_BOOL type to PyConfigSpec (#116359)Victor Stinner2024-03-061-40/+50
| | | | | | _PyConfig_AsDict() now returns bool objects for options using the new PyConfig_MEMBER_BOOL type. Update tests for these changes.
* Fix debug output for optimized executor (#116337)Guido van Rossum2024-03-051-3/+4
| | | | This adjusts `length` rather than using `length+1` all over the place.
* GH-115685: Split `_TO_BOOL_ALWAYS_TRUE` into micro-ops (GH-116352)Mark Shannon2024-03-055-21/+27
|
* GH-115819: Eliminate Boolean guards when value is known (GH-116355)Mark Shannon2024-03-054-0/+97
|