summaryrefslogtreecommitdiffstats
path: root/Python/instrumentation.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-117657: Fix some simple races in instrumentation.c (GH-120118)Ken Jin2024-06-131-2/+2
| | | * stop the world when setting local events
* gh-111997: Fix argument count for LINE event and clarify type of argument ↵scoder2024-05-261-10/+12
| | | | counts. (#119179)
* gh-119431: fix refleak in test_monitoring (#119444)Irit Katriel2024-05-231-0/+1
|
* gh-118692: Avoid creating unnecessary StopIteration instances for monitoring ↵Irit Katriel2024-05-211-3/+5
| | | | (#119216)
* gh-118415: Fix issues with local tracing being enabled/disabled on a ↵Dino Viehland2024-05-061-46/+45
| | | | function (#118496)
* gh-111997: C-API for signalling monitoring events (#116413)Irit Katriel2024-05-041-0/+301
|
* gh-107674: Improve performance of `sys.settrace` (GH-117133)Tian Gao2024-05-031-3/+1
| | | | | | * Check tracing in RESUME_CHECK * Only change to RESUME_CHECK if not tracing
* gh-118335: Configure Tier 2 interpreter at build time (#118339)Guido van Rossum2024-05-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | The code for Tier 2 is now only compiled when configured with `--enable-experimental-jit[=yes|interpreter]`. We drop support for `PYTHON_UOPS` and -`Xuops`, but you can disable the interpreter or JIT at runtime by setting `PYTHON_JIT=0`. You can also build it without enabling it by default using `--enable-experimental-jit=yes-off`; enable with `PYTHON_JIT=1`. On Windows, the `build.bat` script supports `--experimental-jit`, `--experimental-jit-off`, `--experimental-interpreter`. In the C code, `_Py_JIT` is defined as before when the JIT is enabled; the new variable `_Py_TIER2` is defined when the JIT *or* the interpreter is enabled. It is actually a bitmask: 1: JIT; 2: default-off; 4: interpreter.
* gh-117657: Fix small issues with instrumentation and TSAN (#118064)Dino Viehland2024-04-301-3/+6
| | | Small TSAN fixups for instrumentation
* gh-107674: Lazy load line number to improve performance of tracing (GH-118127)Tian Gao2024-04-291-15/+47
|
* gh-116818: Make `sys.settrace`, `sys.setprofile`, and monitoring thread-safe ↵Dino Viehland2024-04-191-20/+121
| | | | | | | (#116775) Makes sys.settrace, sys.setprofile, and monitoring generally thread-safe. Mostly uses a stop-the-world approach and synchronization around the code object's _co_instrumentation_version. There may be a little bit of extra synchronization around the monitoring data that's required to be TSAN clean.
* gh-107674: Remove some unnecessary code in instrumentation code (GH-117393)Tian Gao2024-04-091-1/+1
|
* gh-116968: Reimplement Tier 2 counters (#117144)Guido van Rossum2024-04-041-4/+4
| | | | | | | | | | | | Introduce a unified 16-bit backoff counter type (``_Py_BackoffCounter``), shared between the Tier 1 adaptive specializer and the Tier 2 optimizer. The API used for adaptive specialization counters is changed but the behavior is (supposed to be) identical. The behavior of the Tier 2 counters is changed: - There are no longer dynamic thresholds (we never varied these). - All counters now use the same exponential backoff. - The counter for ``JUMP_BACKWARD`` starts counting down from 16. - The ``temperature`` in side exits starts counting down from 64.
* gh-115832: Fix instrumentation version mismatch during interpreter shutdown ↵Brett Simmers2024-03-041-1/+9
| | | | | | | | | | | | | (#115856) A previous commit introduced a bug to `interpreter_clear()`: it set `interp->ceval.instrumentation_version` to 0, without making the corresponding change to `tstate->eval_breaker` (which holds a thread-local copy of the version). After this happens, Python code can still run due to object finalizers during a GC, and the version check in bytecodes.c will see a different result than the one in instrumentation.c causing an infinite loop. The fix itself is straightforward: clear `tstate->eval_breaker` when clearing `interp->ceval.instrumentation_version`.
* gh-116098: Revert "gh-107674: Improve performance of `sys.settrace` ↵Tian Gao2024-03-011-1/+3
| | | | | | | (GH-114986)" (GH-116178) Revert "gh-107674: Improve performance of `sys.settrace` (GH-114986)" This reverts commit 0a61e237009bf6b833e13ac635299ee063377699.
* gh-107674: Improve performance of `sys.settrace` (GH-114986)Tian Gao2024-02-281-3/+1
|
* gh-115168: Add pystats counter for invalidated executors (GH-115169)Michael Droettboom2024-02-261-3/+3
|
* gh-112175: Add `eval_breaker` to `PyThreadState` (#115194)Brett Simmers2024-02-201-11/+38
| | | | | | | | | | | This change adds an `eval_breaker` field to `PyThreadState`. The primary motivation is for performance in free-threaded builds: with thread-local eval breakers, we can stop a specific thread (e.g., for an async exception) without interrupting other threads. The source of truth for the global instrumentation version is stored in the `instrumentation_version` field in PyInterpreterState. Threads usually read the version from their local `eval_breaker`, where it continues to be colocated with the eval breaker bits.
* GH-113486: Do not emit spurious PY_UNWIND events for optimized calls to ↵Mark Shannon2024-01-051-4/+2
| | | | classes. (GH-113680)
* gh-103615: Use local events for opcode tracing (GH-109472)Tian Gao2023-11-031-0/+17
| | | | | | | * Use local monitoring for opcode trace * Remove f_opcode_trace_set * Add test for setting f_trace_opcodes after settrace
* gh-110481: Implement biased reference counting (gh-110764)Sam Gross2023-10-301-10/+2
|
* gh-109094: replace frame->prev_instr by frame->instr_ptr (#109095)Irit Katriel2023-10-261-4/+4
|
* GH-109369: Add machinery for deoptimizing tier2 executors, both individually ↵Mark Shannon2023-10-231-0/+3
| | | | and globally. (GH-110384)
* GH-109369: Merge all eval-breaker flags and monitoring version into one ↵Mark Shannon2023-10-041-7/+40
| | | | word. (GH-109846)
* GH-107265: Add missing deoptimizations for ENTER_EXECUTOR's original opcode ↵Tian Gao2023-09-221-1/+1
| | | | (GH-109420)
* gh-109371: Fix monitoring with instruction events set (gh-109385)Tian Gao2023-09-181-1/+4
|
* GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)Brandt Bucher2023-09-131-0/+5
|
* gh-109039: Branch prediction for Tier 2 interpreter (#109038)Guido van Rossum2023-09-111-0/+1
| | | | | | | | | | | This adds a 16-bit inline cache entry to the conditional branch instructions POP_JUMP_IF_{FALSE,TRUE,NONE,NOT_NONE} and their instrumented variants, which is used to keep track of the branch direction. Each time we encounter these instructions we shift the cache entry left by one and set the bottom bit to whether we jumped. Then when it's time to translate such a branch to Tier 2 uops, we use the bit count from the cache entry to decided whether to continue translating the "didn't jump" branch or the "jumped" branch. The counter is initialized to a pattern of alternating ones and zeros to avoid bias. The .pyc file magic number is updated. There's a new test, some fixes for existing tests, and a few miscellaneous cleanups.
* GH-108976. Keep monitoring data structures valid during de-optimization ↵Mark Shannon2023-09-111-55/+51
| | | | during callback. (GH-109131)
* gh-109094: remove unnecessary updates of frame->prev_instr in ↵Irit Katriel2023-09-071-6/+2
| | | | instrumentation functions (#109076)
* gh-107265: Remove all ENTER_EXECUTOR when execute _Py_Instrument (gh-108539)Dong-hee Na2023-09-071-32/+11
|
* GH-108390: Prevent non-local events being set with ↵Mark Shannon2023-09-051-46/+84
| | | | `sys.monitoring.set_local_events()` (GH-108420)
* gh-107265: Fix initialize/remove_tools for ENTER_EXECUTOR case (gh-108482)Dong-hee Na2023-08-271-4/+32
|
* gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. ↵Irit Katriel2023-08-231-2/+4
| | | | (#108367)
* gh-107265: Ensure de_instrument does not handle ENTER_EXECUTOR (#108366)Dong-hee Na2023-08-231-0/+1
|
* GH-108035: Remove the `_PyCFrame` struct as it is no longer needed for ↵Mark Shannon2023-08-171-1/+1
| | | | performance. (GH-108036)
* gh-103082: remove assumption that INSTRUMENTED_LINE is the last instrumented ↵Irit Katriel2023-08-151-2/+2
| | | | opcode (#107978)
* gh-103082: use IS_VALID_OPCODE instead of _PyOpcode_OpName to check if an ↵Irit Katriel2023-08-141-4/+4
| | | | opcode is defined (#107882)
* GH-107674: Avoid allocating boxed ints for `sys.settrace` line events ↵Mark Shannon2023-08-101-6/+38
| | | | (GH-107780)
* GH-107774: Add missing audit event for PEP 669 (GH-107775)Mark Shannon2023-08-101-0/+3
|
* GH-107724: Fix the signature of `PY_THROW` callback functions. (GH-107725)Mark Shannon2023-08-091-10/+0
|
* GH-106895: Raise a `ValueError` when attempting to disable events that ↵Mark Shannon2023-07-271-42/+37
| | | | cannot be disabled. (GH-107337)
* GH-106897: Add `RERAISE` event to `sys.monitoring`. (GH-107291)Mark Shannon2023-07-271-0/+1
| | | * Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
* gh-107082: Fix instruction size computation for ENTER_EXECUTOR (#107256)Guido van Rossum2023-07-251-0/+7
| | | | Co-authored-by: Victor Stinner <vstinner@python.org>
* GH-103082: Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS (#107069)Victor Stinner2023-07-221-19/+19
| | | | | | Rename private C API constants: * Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS * Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS
* gh-106320: Create pycore_modsupport.h header file (#106355)Victor Stinner2023-07-031-0/+1
| | | | | | | | | | Remove the following functions from the C API, move them to the internal C API: add a new pycore_modsupport.h internal header file: * PyModule_CreateInitialized() * _PyArg_NoKwnames() * _Py_VaBuildStack() No longer export these functions.
* gh-106320: Use _PyInterpreterState_GET() (#106336)Victor Stinner2023-07-021-6/+4
| | | | Replace PyInterpreterState_Get() with inlined _PyInterpreterState_GET().
* gh-106320: Remove _PyInterpreterState_Get() alias (#106321)Victor Stinner2023-07-011-9/+9
| | | | Replace calls to the (removed) slow _PyInterpreterState_Get() with fast inlined _PyInterpreterState_GET() function.
* GH-106012: Fix monitoring of static code objects (GH-106017)Mark Shannon2023-06-231-13/+18
|
* GH-91095: Specialize calls to normal Python classes. (GH-99331)Mark Shannon2023-06-221-1/+1
|