◐ Shell
reader mode source ↗
Skip to content

gh-103533: Use pep669 APIs for cprofile#103534

Merged
markshannon merged 6 commits into
python:mainfrom
gaogaotiantian:pep669-cprofile
May 5, 2023
Merged

gh-103533: Use pep669 APIs for cprofile#103534
markshannon merged 6 commits into
python:mainfrom
gaogaotiantian:pep669-cprofile

Conversation

@gaogaotiantian

@gaogaotiantian gaogaotiantian commented Apr 14, 2023

Copy link
Copy Markdown
Member

@gaogaotiantian gaogaotiantian marked this pull request as ready for review April 14, 2023 06:32
@arhadthedev arhadthedev added stdlib Standard Library Python modules in the Lib/ directory performance labels Apr 14, 2023
@gaogaotiantian

Copy link
Copy Markdown
Member Author

@ericsnowcurrently how can I declare a global constant table in the module?

@ericsnowcurrently

Copy link
Copy Markdown
Member

@ericsnowcurrently how can I declare a global constant table in the module?

Is it a new table or is it an existing one you're trying to convert? Does it have objects in it? Is the data actually const?

@gaogaotiantian

Copy link
Copy Markdown
Member Author

Is it a new table or is it an existing one you're trying to convert? Does it have objects in it? Is the data actually const?

It's a new, pure C, true const table.

static const CallbackTableEntry callback_table[] = {
    {PY_MONITORING_EVENT_PY_START, "_pystart_callback"},
    {PY_MONITORING_EVENT_PY_RESUME, "_pystart_callback"},
    {PY_MONITORING_EVENT_PY_RETURN, "_pyreturn_callback"},
    {PY_MONITORING_EVENT_PY_YIELD, "_pyreturn_callback"},
    {PY_MONITORING_EVENT_PY_UNWIND, "_pyreturn_callback"},
    {PY_MONITORING_EVENT_CALL, "_ccall_callback"},
    {PY_MONITORING_EVENT_C_RETURN, "_creturn_callback"},
    {PY_MONITORING_EVENT_C_RAISE, "_creturn_callback"},
    {0, NULL}
};

@gaogaotiantian

Copy link
Copy Markdown
Member Author

The situation is almost identical to error_codes[] in Modules/_sqlite/module.c, so I did the same thing - add the variable to ignored.tsv.

@gaogaotiantian

Copy link
Copy Markdown
Member Author

Hi @markshannon , do you think this is a good candidate for 3.12? We pushed out PEP 699 but none of the standard library actually uses it. The profiling tool change is simpler than the debugging tool, so maybe this could be an example/try out for implementing tools in PEP 669. Potentially we can have more feedbacks for the monitoring mechanism.

@brandtbucher brandtbucher self-requested a review May 2, 2023 20:59

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

I think we can skip creating builtin functions when profiling method descriptors.
Other than that, looks good.

Did you measure performance at all?

@gaogaotiantian

Copy link
Copy Markdown
Member Author

Did you measure performance at all?

The performance measurement was in the original issue #103533, it might not be the most obvious format...

@gaogaotiantian

Copy link
Copy Markdown
Member Author

I guess we don't have time now to make C level API changes if we want to land this in 3.12, but it would be nice to have MISSING and DISABLE available for C code.

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

One last question

@markshannon markshannon merged commit b979741 into python:main May 5, 2023
@gaogaotiantian gaogaotiantian deleted the pep669-cprofile branch May 5, 2023 17:56
carljm added a commit to carljm/cpython that referenced this pull request May 5, 2023
* main:
  pythongh-99113: Add PyInterpreterConfig.own_gil (pythongh-104204)
  pythongh-104146: Remove unused var 'parser_body_declarations' from clinic.py (python#104214)
  pythongh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (pythongh-104205)
  pythongh-104108: Add the Py_mod_multiple_interpreters Module Def Slot (pythongh-104148)
  pythongh-99113: Share the GIL via PyInterpreterState.ceval.gil (pythongh-104203)
  pythonGH-100479: Add `pathlib.PurePath.with_segments()` (pythonGH-103975)
  pythongh-69152: Add _proxy_response_headers attribute to HTTPConnection (python#26152)
  pythongh-103533: Use PEP 669 APIs for cprofile (pythonGH-103534)
  pythonGH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque for users of PEP 523. (pythonGH-96849)
jbower-fb pushed a commit to jbower-fb/cpython that referenced this pull request May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants