summaryrefslogtreecommitdiffstats
path: root/Python/specialize.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-118095: Use broader specializations of CALL in tier 1, for better tier 2 ↵Mark Shannon2024-05-041-105/+19
| | | | | | | | | | support of calls. (GH-118322) * Add CALL_PY_GENERAL, CALL_BOUND_METHOD_GENERAL and call CALL_NON_PY_GENERAL specializations. * Remove CALL_PY_WITH_DEFAULTS specialization * Use CALL_NON_PY_GENERAL in more cases when otherwise failing to specialize
* GH-118095: Unify the behavior of tier 2 FOR_ITER branch micro-ops (GH-118420)Mark Shannon2024-05-021-2/+4
| | | | | | * Target _FOR_ITER_TIER_TWO at POP_TOP following the matching END_FOR * Modify _GUARD_NOT_EXHAUSTED_RANGE, _GUARD_NOT_EXHAUSTED_LIST and _GUARD_NOT_EXHAUSTED_TUPLE so that they also target the POP_TOP following the matching END_FOR
* gh-112075: Make instance attributes stored in inline "dict" thread safe ↵Dino Viehland2024-04-221-2/+1
| | | | | (#114742) Make instance attributes stored in inline "dict" thread safe on free-threaded builds
* gh-115178: Add Counts of UOp Pairs to pystats (GH-115181)Jeff Glass2024-04-161-0/+9
|
* gh-116968: Reimplement Tier 2 counters (#117144)Guido van Rossum2024-04-041-5/+3
| | | | | | | | | | | | 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-115776: Embed the values array into the object, for "normal" Python ↵Mark Shannon2024-04-021-26/+25
| | | | objects. (GH-116115)
* A few minor tweaks to get stats working and compiling cleanly. (#117219)Mark Shannon2024-03-251-1/+0
| | | | Fixes a compilation error when configured with `--enable-pystats`, an array size issue, and an unused variable.
* gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)Michael Droettboom2024-03-211-0/+13
|
* gh-116381: Remove bad specializations, add fail stats (GH-116464)Ken Jin2024-03-071-14/+26
| | | * Remove bad specializations, add fail stats
* gh-116381: Specialize CONTAINS_OP (GH-116385)Ken Jin2024-03-061-0/+38
| | | | | | | | | | | * 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-115168: Add pystats counter for invalidated executors (GH-115169)Michael Droettboom2024-02-261-0/+1
|
* Tier 2 cleanups and tweaks (#115534)Guido van Rossum2024-02-201-8/+4
| | | | | | | | | * Rename `_testinternalcapi.get_{uop,counter}_optimizer` to `new_*_optimizer` * Use `_PyUOpName()` instead of` _PyOpcode_uop_name[]` * Add `target` to executor iterator items -- `list(ex)` now returns `(opcode, oparg, target, operand)` quadruples * Add executor methods `get_opcode()` and `get_oparg()` to get `vmdata.opcode`, `vmdata.oparg` * Define a helper for printing uops, and unify various places where they are printed * Add a hack to summarize_stats.py to fix legacy uop names (e.g. `POP_TOP` -> `_POP_TOP`) * Define helpers in `test_opt.py` for accessing the set or list of opnames of an executor
* gh-114058: Foundations of the Tier2 redundancy eliminator (GH-115085)Ken Jin2024-02-131-0/+5
| | | | | | | --------- Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com> Co-authored-by: Jules <57632293+JuliaPoo@users.noreply.github.com> Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com>
* GH-113710: Fix updating of dict version tag and add watched dict stats ↵Mark Shannon2024-02-121-0/+2
| | | | (GH-115221)
* GH-114806. Don't specialize calls to classes with metaclasses. (GH-114870)Mark Shannon2024-02-011-0/+5
|
* gh-114312: Collect stats for unlikely events (GH-114493)Michael Droettboom2024-01-251-0/+11
|
* gh-89811: Check for valid tp_version_tag in specializer (GH-113558)Peter Lazorchak2024-01-111-1/+29
|
* GH-113486: Do not emit spurious PY_UNWIND events for optimized calls to ↵Mark Shannon2024-01-051-1/+1
| | | | classes. (GH-113680)
* GH-111485: Generate instruction and uop metadata (GH-113287)Mark Shannon2023-12-201-0/+1
|
* gh-112320: Implement on-trace confidence tracking for branches (#112321)Guido van Rossum2023-12-121-0/+1
| | | We track the confidence as a scaled int.
* GH-111772: Specialize slot loads and stores for `_Py_T_OBJECT` (GH-111773)Mark Shannon2023-11-061-3/+3
|
* gh-109329: Count tier2 opcode misses (#110561)Michael Droettboom2023-10-311-0/+3
| | | This keeps a separate 'miss' counter for each micro-opcode, incremented whenever a guard uop takes a deoptimization side exit.
* gh-110481: Implement biased reference counting (gh-110764)Sam Gross2023-10-301-1/+1
|
* gh-111354: define names for RESUME oparg values (#111365)Irit Katriel2023-10-261-1/+2
|
* gh-109094: replace frame->prev_instr by frame->instr_ptr (#109095)Irit Katriel2023-10-261-2/+1
|
* GH-111213: Fix a few broken stats (GH-111216)Mark Shannon2023-10-261-1/+1
|
* gh-109329: Add stat for "trace too short" (GH-110402)Michael Droettboom2023-10-051-0/+1
|
* GH-109329: Add tier 2 stats (GH-109913)Michael Droettboom2023-10-041-4/+50
|
* GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)Brandt Bucher2023-09-131-56/+26
|
* GH-109330: Dump and compare stats using opcode names, not numbers (GH-109335)Michael Droettboom2023-09-121-8/+8
|
* gh-109039: Branch prediction for Tier 2 interpreter (#109038)Guido van Rossum2023-09-111-3/+17
| | | | | | | | | | | 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-108753: _Py_PrintSpecializationStats() uses Py_hexdigits (#109040)Victor Stinner2023-09-071-2/+2
|
* gh-108753: Enhance pystats (#108754)Victor Stinner2023-09-061-32/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Statistics gathering is now off by default. Use the "-X pystats" command line option or set the new PYTHONSTATS environment variable to 1 to turn statistics gathering on at Python startup. Statistics are no longer dumped at exit if statistics gathering was off or statistics have been cleared. Changes: * Add PYTHONSTATS environment variable. * sys._stats_dump() now returns False if statistics are not dumped because they are all equal to zero. * Add PyConfig._pystats member. * Add tests on sys functions and on setting PyConfig._pystats to 1. * Add Include/cpython/pystats.h and Include/internal/pycore_pystats.h header files. * Rename '_py_stats' variable to '_Py_stats'. * Exclude Include/cpython/pystats.h from the Py_LIMITED_API. * Move pystats.h include from object.h to Python.h. * Add _Py_StatsOn() and _Py_StatsOff() functions. Remove '_py_stats_struct' variable from the API: make it static in specialize.c. * Document API in Include/pystats.h and Include/cpython/pystats.h. * Complete pystats documentation in Doc/using/configure.rst. * Don't write "all zeros" stats: if _stats_off() and _stats_clear() or _stats_dump() were called. * _PyEval_Fini() now always call _Py_PrintSpecializationStats() which does nothing if stats are all zeros. Co-authored-by: Michael Droettboom <mdboom@gmail.com>
* gh-108765: Cleanup #include in Python/*.c files (#108977)Victor Stinner2023-09-061-3/+3
| | | Mention one symbol imported by each #include.
* gh-108488: Initialize JUMP_BACKWARD cache to 0, not 17 (#108591)Guido van Rossum2023-08-291-1/+3
| | | This mis-initialization caused the executor optimization to kick in sooner than intended. It also set the lower 4 bits of the counter to `1` -- those bits are supposed to be reserved (the actual counter is in the upper 12 bits).
* gh-107265: Revert "Ensure _PyCode_Quicken does not handle ENTER_EXECUTOR" ↵Dong-hee Na2023-08-251-2/+0
| | | | | | | (#108485) This reverts commit d6ac5c7b105fe57266bd71248e3ada41fedb5ba9. Reason: the assert we just added could be triggered (see issue).
* gh-107265: Ensure _PyCode_Quicken does not handle ENTER_EXECUTOR (gh-108460)Dong-hee Na2023-08-241-0/+2
|
* gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. ↵Irit Katriel2023-08-231-1/+4
| | | | (#108367)
* GH-106485: Dematerialize instance dictionaries when possible (GH-106539)Brandt Bucher2023-08-091-5/+14
|
* GH-105848: Simplify the arrangement of CALL's stack (GH-107788)Brandt Bucher2023-08-091-0/+8
|
* GH-107596: Specialize str[int] (GH-107597)Brandt Bucher2023-08-081-11/+14
|
* Add some GC stats to Py_STATS (GH-107581)Mark Shannon2023-08-041-1/+17
|
* gh-106869: Use new PyMemberDef constant names (#106871)Victor Stinner2023-07-251-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove '#include "structmember.h"'. * If needed, add <stddef.h> to get offsetof() function. * Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Replace: * T_SHORT => Py_T_SHORT * T_INT => Py_T_INT * T_LONG => Py_T_LONG * T_FLOAT => Py_T_FLOAT * T_DOUBLE => Py_T_DOUBLE * T_STRING => Py_T_STRING * T_OBJECT => _Py_T_OBJECT * T_CHAR => Py_T_CHAR * T_BYTE => Py_T_BYTE * T_UBYTE => Py_T_UBYTE * T_USHORT => Py_T_USHORT * T_UINT => Py_T_UINT * T_ULONG => Py_T_ULONG * T_STRING_INPLACE => Py_T_STRING_INPLACE * T_BOOL => Py_T_BOOL * T_OBJECT_EX => Py_T_OBJECT_EX * T_LONGLONG => Py_T_LONGLONG * T_ULONGLONG => Py_T_ULONGLONG * T_PYSSIZET => Py_T_PYSSIZET * T_NONE => _Py_T_NONE * READONLY => Py_READONLY * PY_AUDIT_READ => Py_AUDIT_READ * READ_RESTRICTED => Py_AUDIT_READ * PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED * RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
* gh-106320: Move _PyMethodWrapper_Type to internal C API (#107064)Victor Stinner2023-07-221-2/+2
|
* GH-100288: Specialize LOAD_ATTR for simple class attributes. (#105990)Mark Shannon2023-07-101-13/+22
| | | * Add two more specializations of LOAD_ATTR.
* gh-106320: Fix specialize.c compilation by including pycore_pylifecycle.h ↵Guido van Rossum2023-07-041-0/+1
| | | | | (#106434) Compilation of Python/specialize.c was broken on macOS for me by gh-106400.
* GH-106008: Make implicit boolean conversions explicit (GH-106003)Brandt Bucher2023-06-291-3/+110
|
* gh-104584: Baby steps towards generating and executing traces (#105924)Guido van Rossum2023-06-271-0/+4
| | | | | Added a new, experimental, tracing optimizer and interpreter (a.k.a. "tier 2"). This currently pessimizes, so don't use yet -- this is infrastructure so we can experiment with optimizing passes. To enable it, pass ``-Xuops`` or set ``PYTHONUOPS=1``. To get debug output, set ``PYTHONUOPSDEBUG=N`` where ``N`` is a debug level (0-4, where 0 is no debug output and 4 is excessively verbose). All of this code is likely to change dramatically before the 3.13 feature freeze. But this is a first step.
* GH-91095: Specialize calls to normal Python classes. (GH-99331)Mark Shannon2023-06-221-5/+94
|
* GH-105840: Fix assertion failures when specializing calls with too many ↵Brandt Bucher2023-06-161-2/+2
| | | | __defaults__ (GH-105847)