mirror of https://github.com/python/cpython
gh-107954: Fix configuration type for the perf profiler (#124636)
This commit is contained in:
parent
425587a110
commit
02b49c5150
|
@ -1248,19 +1248,24 @@ PyConfig
|
||||||
|
|
||||||
.. c:member:: int perf_profiling
|
.. c:member:: int perf_profiling
|
||||||
|
|
||||||
Enable compatibility mode with the perf profiler?
|
Enable the Linux ``perf`` profiler support?
|
||||||
|
|
||||||
If non-zero, initialize the perf trampoline. See :ref:`perf_profiling`
|
If equals to ``1``, enable support for the Linux ``perf`` profiler.
|
||||||
for more information.
|
|
||||||
|
|
||||||
Set by :option:`-X perf <-X>` command-line option and by the
|
If equals to ``2``, enable support for the Linux ``perf`` profiler with
|
||||||
:envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable for perf support
|
DWARF JIT support.
|
||||||
with stack pointers and :option:`-X perf_jit <-X>` command-line option
|
|
||||||
and by the :envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable for perf
|
Set to ``1`` by :option:`-X perf <-X>` command-line option and the
|
||||||
support with DWARF JIT information.
|
:envvar:`PYTHONPERFSUPPORT` environment variable.
|
||||||
|
|
||||||
|
Set to ``2`` by the :option:`-X perf_jit <-X>` command-line option and
|
||||||
|
the :envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable.
|
||||||
|
|
||||||
Default: ``-1``.
|
Default: ``-1``.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
See :ref:`perf_profiling` for more information.
|
||||||
|
|
||||||
.. versionadded:: 3.12
|
.. versionadded:: 3.12
|
||||||
|
|
||||||
.. c:member:: int use_environment
|
.. c:member:: int use_environment
|
||||||
|
|
|
@ -68,7 +68,7 @@ class CAPITests(unittest.TestCase):
|
||||||
("parser_debug", bool, None),
|
("parser_debug", bool, None),
|
||||||
("parse_argv", bool, None),
|
("parse_argv", bool, None),
|
||||||
("pathconfig_warnings", bool, None),
|
("pathconfig_warnings", bool, None),
|
||||||
("perf_profiling", bool, None),
|
("perf_profiling", int, None),
|
||||||
("platlibdir", str, "platlibdir"),
|
("platlibdir", str, "platlibdir"),
|
||||||
("prefix", str | None, "prefix"),
|
("prefix", str | None, "prefix"),
|
||||||
("program_name", str, None),
|
("program_name", str, None),
|
||||||
|
|
|
@ -560,7 +560,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'cpu_count': -1,
|
'cpu_count': -1,
|
||||||
'faulthandler': False,
|
'faulthandler': False,
|
||||||
'tracemalloc': 0,
|
'tracemalloc': 0,
|
||||||
'perf_profiling': False,
|
'perf_profiling': 0,
|
||||||
'import_time': False,
|
'import_time': False,
|
||||||
'code_debug_ranges': True,
|
'code_debug_ranges': True,
|
||||||
'show_ref_count': False,
|
'show_ref_count': False,
|
||||||
|
@ -652,7 +652,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
use_hash_seed=False,
|
use_hash_seed=False,
|
||||||
faulthandler=False,
|
faulthandler=False,
|
||||||
tracemalloc=False,
|
tracemalloc=False,
|
||||||
perf_profiling=False,
|
perf_profiling=0,
|
||||||
pathconfig_warnings=False,
|
pathconfig_warnings=False,
|
||||||
)
|
)
|
||||||
if MS_WINDOWS:
|
if MS_WINDOWS:
|
||||||
|
@ -966,7 +966,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'use_hash_seed': True,
|
'use_hash_seed': True,
|
||||||
'hash_seed': 123,
|
'hash_seed': 123,
|
||||||
'tracemalloc': 2,
|
'tracemalloc': 2,
|
||||||
'perf_profiling': False,
|
'perf_profiling': 0,
|
||||||
'import_time': True,
|
'import_time': True,
|
||||||
'code_debug_ranges': False,
|
'code_debug_ranges': False,
|
||||||
'show_ref_count': True,
|
'show_ref_count': True,
|
||||||
|
@ -1031,7 +1031,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'use_hash_seed': True,
|
'use_hash_seed': True,
|
||||||
'hash_seed': 42,
|
'hash_seed': 42,
|
||||||
'tracemalloc': 2,
|
'tracemalloc': 2,
|
||||||
'perf_profiling': False,
|
'perf_profiling': 0,
|
||||||
'import_time': True,
|
'import_time': True,
|
||||||
'code_debug_ranges': False,
|
'code_debug_ranges': False,
|
||||||
'malloc_stats': True,
|
'malloc_stats': True,
|
||||||
|
@ -1051,6 +1051,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'module_search_paths': self.IGNORE_CONFIG,
|
'module_search_paths': self.IGNORE_CONFIG,
|
||||||
'safe_path': True,
|
'safe_path': True,
|
||||||
'int_max_str_digits': 4567,
|
'int_max_str_digits': 4567,
|
||||||
|
'perf_profiling': 1,
|
||||||
}
|
}
|
||||||
if Py_STATS:
|
if Py_STATS:
|
||||||
config['_pystats'] = 1
|
config['_pystats'] = 1
|
||||||
|
@ -1066,7 +1067,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'use_hash_seed': True,
|
'use_hash_seed': True,
|
||||||
'hash_seed': 42,
|
'hash_seed': 42,
|
||||||
'tracemalloc': 2,
|
'tracemalloc': 2,
|
||||||
'perf_profiling': False,
|
'perf_profiling': 0,
|
||||||
'import_time': True,
|
'import_time': True,
|
||||||
'code_debug_ranges': False,
|
'code_debug_ranges': False,
|
||||||
'malloc_stats': True,
|
'malloc_stats': True,
|
||||||
|
@ -1086,6 +1087,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'module_search_paths': self.IGNORE_CONFIG,
|
'module_search_paths': self.IGNORE_CONFIG,
|
||||||
'safe_path': True,
|
'safe_path': True,
|
||||||
'int_max_str_digits': 4567,
|
'int_max_str_digits': 4567,
|
||||||
|
'perf_profiling': 1,
|
||||||
}
|
}
|
||||||
if Py_STATS:
|
if Py_STATS:
|
||||||
config['_pystats'] = True
|
config['_pystats'] = True
|
||||||
|
@ -1763,6 +1765,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
'xoptions': {'faulthandler': True},
|
'xoptions': {'faulthandler': True},
|
||||||
'hash_seed': 10,
|
'hash_seed': 10,
|
||||||
'use_hash_seed': True,
|
'use_hash_seed': True,
|
||||||
|
'perf_profiling': 2,
|
||||||
}
|
}
|
||||||
config_dev_mode(preconfig, config)
|
config_dev_mode(preconfig, config)
|
||||||
self.check_all_configs("test_initconfig_api", config, preconfig,
|
self.check_all_configs("test_initconfig_api", config, preconfig,
|
||||||
|
|
|
@ -810,6 +810,7 @@ static void set_most_env_vars(void)
|
||||||
#ifdef Py_STATS
|
#ifdef Py_STATS
|
||||||
putenv("PYTHONSTATS=1");
|
putenv("PYTHONSTATS=1");
|
||||||
#endif
|
#endif
|
||||||
|
putenv("PYTHONPERFSUPPORT=1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1844,6 +1845,10 @@ static int test_initconfig_api(void)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PyInitConfig_SetInt(config, "perf_profiling", 2) < 0) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
// Set a UTF-8 string (program_name)
|
// Set a UTF-8 string (program_name)
|
||||||
if (PyInitConfig_SetStr(config, "program_name", PROGRAM_NAME_UTF8) < 0) {
|
if (PyInitConfig_SetStr(config, "program_name", PROGRAM_NAME_UTF8) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -150,7 +150,7 @@ static const PyConfigSpec PYCONFIG_SPEC[] = {
|
||||||
SPEC(orig_argv, WSTR_LIST, READ_ONLY, SYS_ATTR("orig_argv")),
|
SPEC(orig_argv, WSTR_LIST, READ_ONLY, SYS_ATTR("orig_argv")),
|
||||||
SPEC(parse_argv, BOOL, READ_ONLY, NO_SYS),
|
SPEC(parse_argv, BOOL, READ_ONLY, NO_SYS),
|
||||||
SPEC(pathconfig_warnings, BOOL, READ_ONLY, NO_SYS),
|
SPEC(pathconfig_warnings, BOOL, READ_ONLY, NO_SYS),
|
||||||
SPEC(perf_profiling, BOOL, READ_ONLY, NO_SYS),
|
SPEC(perf_profiling, UINT, READ_ONLY, NO_SYS),
|
||||||
SPEC(program_name, WSTR, READ_ONLY, NO_SYS),
|
SPEC(program_name, WSTR, READ_ONLY, NO_SYS),
|
||||||
SPEC(run_command, WSTR_OPT, READ_ONLY, NO_SYS),
|
SPEC(run_command, WSTR_OPT, READ_ONLY, NO_SYS),
|
||||||
SPEC(run_filename, WSTR_OPT, READ_ONLY, NO_SYS),
|
SPEC(run_filename, WSTR_OPT, READ_ONLY, NO_SYS),
|
||||||
|
|
Loading…
Reference in New Issue