markshannon / faster-cpython

How to make CPython faster.
940 stars 19 forks source link

Requesting details #7

Open etki opened 3 years ago

etki commented 3 years ago

Hey, this is more of curiosity question rather something else.

Currently plan is a bit vague. May I ask for more details of what is meant by:

And why those things are considered slow / what's wrong with them, since i have no clue of current state of things inside CPython:

And what feature makes superior machine code superior? It would be totally OK just to explain why all those key points are currently slow if you don't want to write your concrete ideas about speeding them up.

ghost commented 3 years ago

Improved performance for integers of less than one machine word.

Python3 uses 30 bits chunks to represent an int value in 64-bit build, or 15 bits chunks in 32-bit build. The utilization of machine word is almost halved.

If an int's value does not exceed the range of one machine word, it may be use native machine word to represent it.

There was a discussion about it: https://mail.python.org/archives/list/python-ideas@python.org/thread/L6BMMETVQYFGDIG7VIFICDSYVUXQAS52/

https://discuss.python.org/t/hybrid-implementation-for-pylongobject-performance/2129

And a very primitive prototype patch: https://github.com/animalize/cpython/pull/7/files

I gave up because I thought it make the code complex, but IMHO further attempts may be worthwhile.

I guess Mark's idea is let the interpreter support native integer (outside of int class), then it's more worth to try.

stonebig commented 3 years ago

hi another small question. Is the "Step1"(adaptive, specializing interpreter):

hlovatt commented 2 years ago

Hi, Adding to the small questions list. Did the Stage 1 improvements make it into 3.10? Thanks, Howard.