Skip to content

Conversation

@markshannon
Copy link
Member

@markshannonmarkshannon commented Dec 6, 2021

Copy link
Member

@Fidget-SpinnerFidget-Spinner left a comment

Choose a reason for hiding this comment

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

The code LGTM. Interested to see the benchmark results.

@markshannon
Copy link
MemberAuthor

Benchmark results show a slight speedup, but very close to noise.

I think this is worth including because:

  1. The nbody and spectral norm benchmarks show decent speedups and have range(arg) calls in the hot parts of the benchmark, suggesting that specialization of calls to cls(one_arg) is effective.
  2. Some "real" code includes a lot of type(obj) calls (at least statically).

Copy link
Member

@Fidget-SpinnerFidget-Spinner left a comment

Choose a reason for hiding this comment

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

LGTM.

assert(GET_CACHE()->adaptive.original_oparg == 1);
PyObject *obj = TOP();
PyObject *callable = SECOND();
DEOPT_IF(callable != (PyObject *)&PyType_Type, CALL_NO_KW);

Choose a reason for hiding this comment

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

I don't remember if you like using the Py_IS_TYPE inline function, but just mentioning it here and leaving it up to you :).

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'll skip on the obfuscation macro 🙂

return -1;
}
if (nargs == 1){
if (tp == &PyType_Type){

Choose a reason for hiding this comment

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

Ditto

@markshannon
Copy link
MemberAuthor

Increases CALL_NO_KW hit rate from ~71% to ~74% on the standard benchmark suite, with only a slight increase in the miss rate.
Reduces failed specializations for calls to classes (SPEC_FAIL_CLASS) by over half.

@markshannonmarkshannon merged commit 3a60bfe into python:mainDec 15, 2021
@markshannonmarkshannon deleted the specialize-calls-to-builtin-types branch September 26, 2023 12:48
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@markshannon@Fidget-Spinner@the-knights-who-say-ni@bedevere-bot