Mailing List Archive

Speeding up CPython
Hi everyone,

CPython is slow. We all know that, yet little is done to fix it.

I'd like to change that.
I have a plan to speed up CPython by a factor of five over the next few
years. But it needs funding.

I am aware that there have been several promised speed ups in the past
that have failed. You might wonder why this is different.

Here are three reasons:
1. I already have working code for the first stage.
2. I'm not promising a silver bullet. I recognize that this is a
substantial amount of work and needs funding.
3. I have extensive experience in VM implementation, not to mention a
PhD in the subject.

My ideas for possible funding, as well as the actual plan of
development, can be found here:

https://github.com/markshannon/faster-cpython

I'd love to hear your thoughts on this.

Cheers,
Mark.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/RDXLCH22T2EZDRCBM6ZYYIUTBWQVVVWH/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Tue, 20 Oct 2020 13:53:34 +0100
Mark Shannon <mark@hotpy.org> wrote:
> Hi everyone,
>
> CPython is slow. We all know that, yet little is done to fix it.
>
> I'd like to change that.
> I have a plan to speed up CPython by a factor of five over the next few
> years. But it needs funding.
>
> I am aware that there have been several promised speed ups in the past
> that have failed. You might wonder why this is different.
>
> Here are three reasons:
> 1. I already have working code for the first stage.
> 2. I'm not promising a silver bullet. I recognize that this is a
> substantial amount of work and needs funding.
> 3. I have extensive experience in VM implementation, not to mention a
> PhD in the subject.
>
> My ideas for possible funding, as well as the actual plan of
> development, can be found here:
>
> https://github.com/markshannon/faster-cpython

Do you plan to do all this in C, or would you switch to C++ (or
something else)?

Regards

Antoine.

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/N65UEJTSX35KJOSSUFZNKKJPT224CNRS/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
A very interesting proposal.

A couple of thoughts...

Can we have an executive summary of how your proposed approach differs
from those of PyPy, Unladen Swallow, and various other attempts?

You suggest that payment should be on delivery, or meeting the target,
rather than up-front. That's good for the PSF, but it also means that
the contractor not only takes all the risk of failure, but also needs an
independent source of income, or at least substantial savings (enough
for, what, eighteen months development per stage?). Doesn't that limit
the available pool of potential contractors?

I think there's always tension between community driven development and
paid work. If the PSF pays person A to develop something, might not
people B, C, D and E feel slighted that they didn't get paid?

On the other hand, I guess we already deal with that. There are devs who
are paid by their employers to work on Python for N hours a months, for
some value of N, or to develop something and then open source it. And
then there are devs who aren't.

You have suggested that the cost of each stage be split 50:50 between
development and maintenance. But development is a one-off cost;
maintenance is an forever cost, and unpredictable, and presumably some
of that maintenance will be done by people other than the contractor.

A minor point, and I realise that the costs are all in very round
figures, but they don't quite match up: $2 million split over five
stages is $400K per stage, not $500K.


> 1. I already have working code for the first stage.

I don't mean to be negative, or hostile, but this sounds like you are
saying "I have a patch for Python that will make it 1.5 times faster,
but you will never see it unless you pay me!"

I realise that is a very uncharitable way of looking at it, sorry about
that, it's nothing personal. But $500K is a lot of money.

If the PSF says "No thanks", what happens to your code?

- delete it;
- donate it to Python for free;
- fork Python and try to make a commercial, non-FOSS version that
you can sell to recoup your development time;
- something else?


If this was a closed-source proprietary project, there would be no
question in my mind. You took a bet that you could sell the code, and
you lost. You swallow your loss and move on, that's how the proprietary
world works. But this is FOSS and community driven, and I don't think
that fits well with that model.



--
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/OFQKVMU4QPKVD2NIOTZOK5H4HA2RQLHK/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
Where is your working code for the first stage?

October 20, 2020 8:53 AM, "Mark Shannon" <mark@hotpy.org> wrote:

> Hi everyone,
>
> CPython is slow. We all know that, yet little is done to fix it.
>
> I'd like to change that.
> I have a plan to speed up CPython by a factor of five over the next few years. But it needs
> funding.
>
> I am aware that there have been several promised speed ups in the past that have failed. You might
> wonder why this is different.
>
> Here are three reasons:
> 1. I already have working code for the first stage.
> 2. I'm not promising a silver bullet. I recognize that this is a substantial amount of work and
> needs funding.
> 3. I have extensive experience in VM implementation, not to mention a PhD in the subject.
>
> My ideas for possible funding, as well as the actual plan of development, can be found here:
>
> https://github.com/markshannon/faster-cpython
>
> I'd love to hear your thoughts on this.
>
> Cheers,
> Mark.
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/RDXLCH22T2EZDRCBM6ZYYIUTBWQVVVWH
> Code of Conduct: http://python.org/psf/codeofconduct
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/DXTPGPEKDJTVLEWWMD2JT7HAWD7P6K5E/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
Hi Antoine,

On 20/10/2020 2:32 pm, Antoine Pitrou wrote:
> On Tue, 20 Oct 2020 13:53:34 +0100
> Mark Shannon <mark@hotpy.org> wrote:
>> Hi everyone,
>>
>> CPython is slow. We all know that, yet little is done to fix it.
>>
>> I'd like to change that.
>> I have a plan to speed up CPython by a factor of five over the next few
>> years. But it needs funding.
>>
>> I am aware that there have been several promised speed ups in the past
>> that have failed. You might wonder why this is different.
>>
>> Here are three reasons:
>> 1. I already have working code for the first stage.
>> 2. I'm not promising a silver bullet. I recognize that this is a
>> substantial amount of work and needs funding.
>> 3. I have extensive experience in VM implementation, not to mention a
>> PhD in the subject.
>>
>> My ideas for possible funding, as well as the actual plan of
>> development, can be found here:
>>
>> https://github.com/markshannon/faster-cpython
>
> Do you plan to do all this in C, or would you switch to C++ (or
> something else)?

All C, no C++. I promise :)

Cheers,
Mark.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/DZUH4PSWAD7MFVVXS3RBYFHVTCFLC4ZA/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On 10/20/20 2:53 PM, Mark Shannon wrote:
> I'd love to hear your thoughts on this.

a VM needs a separate backend for each architecture (maybe even OS)

- which architectures do you include into your proposal?
what's your estimate for a new port?

- do you plan for a fall-back to a slow non-VM mode, e.g.
the existing one? Do you plan to support that in parallel
such that Python still can be used on architectures with
a working compiler (and a libffi port).

E.g. OpenJDK has the zero port, which is slow (interpreted),
but runs on practically all architectures.

Thanks, Matthias
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/H4O5TFWGL5SDG4NSESNGNKIZMK6W7L7V/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On 20/10/2020 2:47 pm, Steven D'Aprano wrote:
> A very interesting proposal.
>
> A couple of thoughts...
>
> Can we have an executive summary of how your proposed approach differs
> from those of PyPy, Unladen Swallow, and various other attempts?

https://github.com/markshannon/faster-cpython/blob/master/tiers.md
should cover it.

>
> You suggest that payment should be on delivery, or meeting the target,
> rather than up-front. That's good for the PSF, but it also means that
> the contractor not only takes all the risk of failure, but also needs an
> independent source of income, or at least substantial savings (enough
> for, what, eighteen months development per stage?). Doesn't that limit
> the available pool of potential contractors?

We only need one.
I don't think financial constraints are the main problem.
I think domain knowledge is probably more of a constraint.

>
> I think there's always tension between community driven development and
> paid work. If the PSF pays person A to develop something, might not
> people B, C, D and E feel slighted that they didn't get paid?

The PSF already pays people to work on PyPI

>
> On the other hand, I guess we already deal with that. There are devs who
> are paid by their employers to work on Python for N hours a months, for
> some value of N, or to develop something and then open source it. And
> then there are devs who aren't.
>
> You have suggested that the cost of each stage be split 50:50 between
> development and maintenance. But development is a one-off cost;
> maintenance is an forever cost, and unpredictable, and presumably some
> of that maintenance will be done by people other than the contractor.

Any new feature will require ongoing maintenance. I'm just suggesting
that we budget for it.
Who is going to pay for the maintenance of PEP 634?

>
> A minor point, and I realise that the costs are all in very round
> figures, but they don't quite match up: $2 million split over five
> stages is $400K per stage, not $500K.

I meant four stages. Did I write "five" somewhere?

>
>
>> 1. I already have working code for the first stage.
>
> I don't mean to be negative, or hostile, but this sounds like you are
> saying "I have a patch for Python that will make it 1.5 times faster,
> but you will never see it unless you pay me!"

I believe that's how business works ;)
I have this thing, e.g an iPhone, if you want it you must pay me.
I think that speeding CPython 50% is worth a few hundred iPhones.

>
> I realise that is a very uncharitable way of looking at it, sorry about
> that, it's nothing personal. But $500K is a lot of money.

Remember the contractor only gets roughly half of that. The rest stays
with the PSF to fund maintenance of CPython.

$250k only pays for one engineer for one year at one of the big tech firms.

Cheers,
Mark.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/NDLJBM35DCRSOGBEYRDUAELVOHZKFSWU/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Wed, Oct 21, 2020 at 12:03 AM Mark Shannon <mark@hotpy.org> wrote:
>
> Hi everyone,
>
> CPython is slow. We all know that, yet little is done to fix it.
>
> I'd like to change that.
> I have a plan to speed up CPython by a factor of five over the next few
> years. But it needs funding.
>

> The overall aim is to speed up CPython by a factor of (approximately) five. We aim to do this in four distinct stages, each stage increasing the speed of CPython by (approximately) 50%.
>

This is a very bold estimate. Particularly, you're proposing a number
of small tweaks in stage 2 and expecting that (combined) they can give
a 50% improvement in overall performance?

Do you have any details to back this up? You're not just asking for a
proposal to be accepted, you're actually asking for (quite a bit of)
money, and then hoping to find a contractor to do the actual work.
That means you're expecting that anyone would be able to achieve this,
given sufficient development time.

BIG BIG concern: You're basically assuming that all this definition of
performance is measured for repeated executions of code. That's how
PyPy already works, and it most often suffers quite badly in startup
performance to make this happen. Will your proposed changes mean that
CPython has to pay the same startup costs that PyPy does?

What would happen if $2M were spent on improving PyPy3 instead?

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/3NBP3KLTMXNDJ2ME4QPSATW2ZIMKVICG/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Wed, Oct 21, 2020 at 12:55 AM Steven D'Aprano <steve@pearwood.info> wrote:
> A minor point, and I realise that the costs are all in very round
> figures, but they don't quite match up: $2 million split over five
> stages is $400K per stage, not $500K.

The proposal is for four stages.

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/DFFCUKWRBR557SWJEQPUFV6WEKWLFKKR/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
Hi Chris,

On 20/10/2020 4:37 pm, Chris Angelico wrote:
> On Wed, Oct 21, 2020 at 12:03 AM Mark Shannon <mark@hotpy.org> wrote:
>>
>> Hi everyone,
>>
>> CPython is slow. We all know that, yet little is done to fix it.
>>
>> I'd like to change that.
>> I have a plan to speed up CPython by a factor of five over the next few
>> years. But it needs funding.
>>
>
>> The overall aim is to speed up CPython by a factor of (approximately) five. We aim to do this in four distinct stages, each stage increasing the speed of CPython by (approximately) 50%.
>>
>
> This is a very bold estimate. Particularly, you're proposing a number
> of small tweaks in stage 2 and expecting that (combined) they can give
> a 50% improvement in overall performance?

20 tweaks each providing a 2% is a 49% speedup.
Stage 1 will open up optimizations that are currently worthwhile.

>
> Do you have any details to back this up? You're not just asking for a
> proposal to be accepted, you're actually asking for (quite a bit of)
> money, and then hoping to find a contractor to do the actual work.

I am offering to do the work.

> That means you're expecting that anyone would be able to achieve this,
> given sufficient development time.
No, I can (with paid help) achieve this.
What matters is that someone can, not that anyone can.

>
> BIG BIG concern: You're basically assuming that all this definition of
> performance is measured for repeated executions of code. That's how
> PyPy already works, and it most often suffers quite badly in startup
> performance to make this happen. Will your proposed changes mean that
> CPython has to pay the same startup costs that PyPy does?

Could you clarify what you think I'm assuming?

When you say start up, do you mean this?

$ time python3 -S -c ""

real 0m0.010s

$ time pypy -S -c ""

real 0m0.017s

No, there would be no slower startup. In fact the tier 0 interpreter
should start a fraction faster than 3.9.

>
> What would happen if $2M were spent on improving PyPy3 instead?

The PSF loses $1M to spend on CPython maintenance, to start with.

What would happen to PyPy? I have no idea.

Partial success of speeding up CPython is very valuable.
Partial success in getting PyPy to support C extensions well and perform
well when it currently does, is much less valuable.

CPython that is "only" 2 or 3 times faster is a major improvement, but a
PyPy that supports 80% of the C extensions that it currently does not is
still not a replacement for CPython.


Cheers,
Mark.

>
> ChrisA
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/3NBP3KLTMXNDJ2ME4QPSATW2ZIMKVICG/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/575BK2RBWDGXL4DNRJO5AM3GLXRCH45Q/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Wed, Oct 21, 2020 at 02:37:02AM +1100, Chris Angelico wrote:

> Do you have any details to back this up? You're not just asking for a
> proposal to be accepted, you're actually asking for (quite a bit of)
> money, and then hoping to find a contractor to do the actual work.

Payment is on delivery. At each stage, if the contractor fails to
deliver the promised gains, they get nothing.

(I believe that Mark is being polite by referring to a generic
contractor. I think he is referring to himself.)


> That means you're expecting that anyone would be able to achieve this,
> given sufficient development time.

With sufficient time, maybe the horse will learn to sing.

https://everything2.com/title/And+maybe+the+horse+will+learn+how+to+sing

But I don't think Mark believes *anyone* will be able to improve
performance. If it were that easy that anyone could do it, Python would
already be blazingly fast.


> BIG BIG concern: You're basically assuming that all this definition of
> performance is measured for repeated executions of code.

That's not what the proposal says.

"Performance should improve for all code, not just loop-heavy and
numeric code."

In fact Mark goes further: he says that he's willing to allow some
performance degradation on loop heavy code, if the overall performance
increases.

But why are we nitpicking Stage Two? The beauty of Mark's proposal is:

1. there is no committment to any stage until the previous stage is
complete;

2. there is no committment to pay for any stage unless the contractor
actually delivers the goods.


If you don't think that Mark, or the contractor, will be able to deliver
a 50% speed up in Stage 2, what have you got to lose? If he fails to
deliver, you pay nothing and don't commit to Stage 3. If he does
deliver, you get the desired result.

(The details allow for some slack: if the speed up is only 49%, the
contractor still gets paid. Presumably it will be on some sort of
sliding scale.)


> That's how
> PyPy already works, and it most often suffers quite badly in startup
> performance to make this happen. Will your proposed changes mean that
> CPython has to pay the same startup costs that PyPy does?

Good question.


> What would happen if $2M were spent on improving PyPy3 instead?

Then both of the PyPy3 users will be very happy *wink*

(I know, that's a terrible, horrible, inaccurate slight on the PyPy
community, which is very probably thriving, and I would delete it if I
hadn't already hit Send.)

I think this isn't a matter of just throwing money at a project. Mark
knows the CPython architecture. I don't know if he knows the PyPy
architecture, and unless a PyPy expert comes up with a counter proposal,
we don't know that spending $2M on PyPy will see any sort of comparable
gains.


--
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/WVVDCZ34LY5UD6LEZBH33GFP7BSMFTRL/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Wed, Oct 21, 2020 at 02:38:25AM +1100, Chris Angelico wrote:
> On Wed, Oct 21, 2020 at 12:55 AM Steven D'Aprano <steve@pearwood.info> wrote:
> > A minor point, and I realise that the costs are all in very round
> > figures, but they don't quite match up: $2 million split over five
> > stages is $400K per stage, not $500K.
>
> The proposal is for four stages.

D'oh!

I mean, I knew that, I was just checking to see if others were paying
attention. Well done, you pass!

--
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/UZFNJK636NJQOSURFW5ANZJS5F76LITU/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Wed, Oct 21, 2020 at 3:31 AM Mark Shannon <mark@hotpy.org> wrote:
>
> Hi Chris,
>
> On 20/10/2020 4:37 pm, Chris Angelico wrote:
> > On Wed, Oct 21, 2020 at 12:03 AM Mark Shannon <mark@hotpy.org> wrote:
> >>
> >> Hi everyone,
> >>
> >> CPython is slow. We all know that, yet little is done to fix it.
> >>
> >> I'd like to change that.
> >> I have a plan to speed up CPython by a factor of five over the next few
> >> years. But it needs funding.
> >>
> >
> >> The overall aim is to speed up CPython by a factor of (approximately) five. We aim to do this in four distinct stages, each stage increasing the speed of CPython by (approximately) 50%.
> >>
> >
> > This is a very bold estimate. Particularly, you're proposing a number
> > of small tweaks in stage 2 and expecting that (combined) they can give
> > a 50% improvement in overall performance?
>
> 20 tweaks each providing a 2% is a 49% speedup.
> Stage 1 will open up optimizations that are currently worthwhile.

Yes, I understand mathematics. Do you have evidence that shows that
each of the twenty tweaks can give a two percent speedup though?

> > Do you have any details to back this up? You're not just asking for a
> > proposal to be accepted, you're actually asking for (quite a bit of)
> > money, and then hoping to find a contractor to do the actual work.
>
> I am offering to do the work.

Sure, that takes away some of the uncertainty, but you're still asking
for a considerable amount of money sight-unseen.

> > BIG BIG concern: You're basically assuming that all this definition of
> > performance is measured for repeated executions of code. That's how
> > PyPy already works, and it most often suffers quite badly in startup
> > performance to make this happen. Will your proposed changes mean that
> > CPython has to pay the same startup costs that PyPy does?
>
> Could you clarify what you think I'm assuming?
>
> When you say start up, do you mean this?
>
> $ time python3 -S -c ""
>
> real 0m0.010s
>
> $ time pypy -S -c ""
>
> real 0m0.017s
>
> No, there would be no slower startup. In fact the tier 0 interpreter
> should start a fraction faster than 3.9.

That's a microbenchmark, but yes, that's the kind of thing I'm talking
about. For short scripts, will "python3.13 script.py" be slower than
"python3.9 script.py"?

> > What would happen if $2M were spent on improving PyPy3 instead?
>
> The PSF loses $1M to spend on CPython maintenance, to start with.
>
> What would happen to PyPy? I have no idea.
>
> Partial success of speeding up CPython is very valuable.
> Partial success in getting PyPy to support C extensions well and perform
> well when it currently does, is much less valuable.
>
> CPython that is "only" 2 or 3 times faster is a major improvement, but a
> PyPy that supports 80% of the C extensions that it currently does not is
> still not a replacement for CPython.
>

True, but it does sound like you're pushing for the sorts of changes
that PyPy already has. Not sure whether your proposed changes would be
better done to PyPy or to CPython.

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/I4XKZNAZBLPWCRS5EQ4UY6DMV3LDMJPN/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Wed, Oct 21, 2020 at 3:38 AM Steven D'Aprano <steve@pearwood.info> wrote:
>
> On Wed, Oct 21, 2020 at 02:37:02AM +1100, Chris Angelico wrote:
>
> > Do you have any details to back this up? You're not just asking for a
> > proposal to be accepted, you're actually asking for (quite a bit of)
> > money, and then hoping to find a contractor to do the actual work.
>
> Payment is on delivery. At each stage, if the contractor fails to
> deliver the promised gains, they get nothing.
>
> (I believe that Mark is being polite by referring to a generic
> contractor. I think he is referring to himself.)

It's a little unclear from the proposal, as there was something about
whether a suitable contractor could be found, but sure. TBH I'd be
happier with this proposal as a direct offer/request for money than as
"hey let's go look for potential coders", but it sounds like that's
the plan anyway?

> > That means you're expecting that anyone would be able to achieve this,
> > given sufficient development time.
>
> With sufficient time, maybe the horse will learn to sing.
>
> https://everything2.com/title/And+maybe+the+horse+will+learn+how+to+sing
>
> But I don't think Mark believes *anyone* will be able to improve
> performance. If it were that easy that anyone could do it, Python would
> already be blazingly fast.

Yeah. And the "anyone" part is the concern I had - that the proposal
was asking for funding and then for a search for a contractor. But if
it's "pay me and I'll write this", then it's a bit more concrete.

> > BIG BIG concern: You're basically assuming that all this definition of
> > performance is measured for repeated executions of code.
>
> That's not what the proposal says.
>
> "Performance should improve for all code, not just loop-heavy and
> numeric code."
>
> In fact Mark goes further: he says that he's willing to allow some
> performance degradation on loop heavy code, if the overall performance
> increases.

"Overall performance" is a myth, and there's no way that CPython will
magically be able to execute any code with the exact same performance
improvement. So my question is: what happens to startup performance,
what happens to short scripts, what happens to the interpreter's load
times, etc, etc, etc? It could be that all code becomes faster, but
only after it's been run a few times. That would be great for, say, a
web app - it handles a request, goes back and waits for another, and
then handles the next one a bit faster - but not for a command-line
script.

(And yes, I'm aware that it'd theoretically be possible to dump the
compiler state to disk, but that has its own risks.)

> > What would happen if $2M were spent on improving PyPy3 instead?
>
> Then both of the PyPy3 users will be very happy *wink*
>
> (I know, that's a terrible, horrible, inaccurate slight on the PyPy
> community, which is very probably thriving, and I would delete it if I
> hadn't already hit Send.)

Yes, you're being horribly insulting to the third user of PyPy3, who
is probably right now warming up his interpreter so he can send you an
angry response :)

I guess my biggest concern with this proposal is that it's heavy on
mathematically pure boasts and light on actual performance metrics,
and I'm talking here about the part where (so we're told) the code is
all done and it just takes a swipe of a credit card to unlock it. And
without the ability to run it myself, I can't be sure that it'd
actually give *any* performance improvement on my code or use-cases.
So there's a lot that has to be taken on faith, and I guess I'm just a
bit dubious of how well it'd fulfil that.

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/4N4SSXNDAP2GZQSL7F2JBC2RJVZ3WEL6/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Tue, 20 Oct 2020 at 14:01, Mark Shannon <mark@hotpy.org> wrote:
>
> Hi everyone,
>
> CPython is slow. We all know that, yet little is done to fix it.
>
> I'd like to change that.
> I have a plan to speed up CPython by a factor of five over the next few
> years. But it needs funding.
>
> I am aware that there have been several promised speed ups in the past
> that have failed. You might wonder why this is different.
>
> Here are three reasons:
> 1. I already have working code for the first stage.
> 2. I'm not promising a silver bullet. I recognize that this is a
> substantial amount of work and needs funding.
> 3. I have extensive experience in VM implementation, not to mention a
> PhD in the subject.
>
> My ideas for possible funding, as well as the actual plan of
> development, can be found here:
>
> https://github.com/markshannon/faster-cpython
>
> I'd love to hear your thoughts on this.

A very blunt (apologies if it's too blunt) restatement of this
proposal (at least stage 1) seems to me to be

"Give me $250k, and donate $250k to the PSF for ongoing support, and
I'll let you have code that I've already written that gives CPython a
50% speedup. If my code doesn't deliver a 50% speedup, I'll give the
money back. No money, no code. We can also discuss 3 more incremental
steps of the same sort of magnitude, but I don't have code already
written for them".

Honestly, if someone's able to get together $500k, that sounds like a
fairly good deal (no risk). If you're asking for a commitment to the
full $2M, even if stages 2-4 are contingent on delivery, that's a bit
of a harder ask (because the cashflow implication of committing that
sort of money becomes relevant). But maybe someone can do it.

I'm fine with this, I guess. I don't have $500k to offer myself, so
all my agreement is worth is that I don't have a problem with this
much work being funded/provided via one big donation. I assume that
part of "delivery" would involve code review, etc. - we wouldn't be
bypassing normal development workflow. So there's still work to be
done in putting the code through review, responding to review
comments, etc, and ensuring that the code is delivered in a form that
the core devs are happy to maintain (PSF donation for support
notwithstanding). Actually, a chunk of that support allocation to the
PSF might be needed to pay for reviewers, if (as I suspect) this is a
large and complex PR.

What I don't see is where the money's coming from. It's fine to ask,
but will anyone come up with that sort of funding?

Paul
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/DNM27AX7Z3VULDY7XNJPVZYFX6Z5FTRZ/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On 20/10/2020 5:48 pm, Chris Angelico wrote:
> On Wed, Oct 21, 2020 at 3:31 AM Mark Shannon <mark@hotpy.org> wrote:
>>
>> Hi Chris,
>>
>> On 20/10/2020 4:37 pm, Chris Angelico wrote:
>>> On Wed, Oct 21, 2020 at 12:03 AM Mark Shannon <mark@hotpy.org> wrote:
>>>>
>>>> Hi everyone,
>>>>
>>>> CPython is slow. We all know that, yet little is done to fix it.
>>>>
>>>> I'd like to change that.
>>>> I have a plan to speed up CPython by a factor of five over the next few
>>>> years. But it needs funding.
>>>>
>>>
>>>> The overall aim is to speed up CPython by a factor of (approximately) five. We aim to do this in four distinct stages, each stage increasing the speed of CPython by (approximately) 50%.
>>>>
>>>
>>> This is a very bold estimate. Particularly, you're proposing a number
>>> of small tweaks in stage 2 and expecting that (combined) they can give
>>> a 50% improvement in overall performance?
>>
>> 20 tweaks each providing a 2% is a 49% speedup.
>> Stage 1 will open up optimizations that are currently worthwhile.
>
> Yes, I understand mathematics. Do you have evidence that shows that
> each of the twenty tweaks can give a two percent speedup though?

My point was that small changes can easily add up to a large change.
And yes, I have a long list of possible small optimizations.

>
>>> Do you have any details to back this up? You're not just asking for a
>>> proposal to be accepted, you're actually asking for (quite a bit of)
>>> money, and then hoping to find a contractor to do the actual work.
>>
>> I am offering to do the work.
>
> Sure, that takes away some of the uncertainty, but you're still asking
> for a considerable amount of money sight-unseen.

I'm not asking for money up front. I'm asking for some promise of
payment, once the work is done. If I fail, only I suffer a loss.

>
>>> BIG BIG concern: You're basically assuming that all this definition of
>>> performance is measured for repeated executions of code. That's how
>>> PyPy already works, and it most often suffers quite badly in startup
>>> performance to make this happen. Will your proposed changes mean that
>>> CPython has to pay the same startup costs that PyPy does?
>>
>> Could you clarify what you think I'm assuming?
>>
>> When you say start up, do you mean this?
>>
>> $ time python3 -S -c ""
>>
>> real 0m0.010s
>>
>> $ time pypy -S -c ""
>>
>> real 0m0.017s
>>
>> No, there would be no slower startup. In fact the tier 0 interpreter
>> should start a fraction faster than 3.9.
>
> That's a microbenchmark, but yes, that's the kind of thing I'm talking
> about. For short scripts, will "python3.13 script.py" be slower than
> "python3.9 script.py"?

Tiered execution means that 3.10+ should be no slower than 3.9 for any
program, and faster for all but really short ones. Tier 0 would be a bit
slower than 3.9, but will start faster. Tier 1 should kick in before 3.9
would catch up.

Cheers,
Mark.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/HTFM5SREGCL3E232WSRXPTBP4S3DGVKO/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Tue, Oct 20, 2020 at 9:33 AM Steven D'Aprano <steve@pearwood.info> wrote:

> > What would happen if $2M were spent on improving PyPy3 instead?
>
> Then both of the PyPy3 users will be very happy *wink*
>

Wow, I didn't know I was 50% of Pypy3 users :)

Anyway, Pypy3 is already pretty great. I'm sure it can be improved, but I
suspect what it needs most is HPY work, which could benefit a lot of Python
language implementations in the long term:
https://github.com/hpyproject/hpy

$2e6 spent on HPY could be pretty amazing.
Re: Speeding up CPython [ In reply to ]
I'd love to hear more about what workloads you're targeting and how you
came up with the anticipated numbers for the improvements. For comparison,
our new jit provides a single-digit-percentage speedup on our django and
flask benchmarks.

On Tue, Oct 20, 2020 at 9:03 AM Mark Shannon <mark@hotpy.org> wrote:

> Hi everyone,
>
> CPython is slow. We all know that, yet little is done to fix it.
>
> I'd like to change that.
> I have a plan to speed up CPython by a factor of five over the next few
> years. But it needs funding.
>
> I am aware that there have been several promised speed ups in the past
> that have failed. You might wonder why this is different.
>
> Here are three reasons:
> 1. I already have working code for the first stage.
> 2. I'm not promising a silver bullet. I recognize that this is a
> substantial amount of work and needs funding.
> 3. I have extensive experience in VM implementation, not to mention a
> PhD in the subject.
>
> My ideas for possible funding, as well as the actual plan of
> development, can be found here:
>
> https://github.com/markshannon/faster-cpython
>
> I'd love to hear your thoughts on this.
>
> Cheers,
> Mark.
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/RDXLCH22T2EZDRCBM6ZYYIUTBWQVVVWH/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
Re: Speeding up CPython [ In reply to ]
Since HPy was mentioned, hello from the HPy team!

If anyone is thinking about Python performance or new Python VMs, we'd
love them to take a look at HPy and come and talk to us. HPy is meant
to provide a new C API layer that any Python VM could implement in
order to efficiently support Python extensions written on top of HPy.
Amazingly, such extensions would also be backwards compatible (i.e.
they would also run on CPython as it exists today).

If you'd like to talk to us (and we would like to talk to you) you can
find us at:

* Mailing list: hpy-dev@python.org
* IRC: hpy-dev@python.org

If you would like to contribute as a developer (or any other way),
we're here to help (and at the moment I am prioritising landing other
people's contributions pretty much full-time).

If someone has money to donate, they can donate to the project at
https://opencollective.com/hpy/contribute. We have quite a few
contributors who could contribute more time than they do in exchange
for money.

HPy is currently in quite an early stage of development (we can
already run some simple Python C extensions without any performance
penalties on CPython). The upside is that right now we can consider
almost any suggestion for improving HPy because none of the design is
set in stone. In a few months it might be helpful to have people try
porting some (many) C extensions to HPy to see how that goes.

Yours happily,
Simon Cross (random person working on HPy)
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/ARSII7KMZZ5W6UMKR7LIQDIWFSWWYQLZ/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Tue, Oct 20, 2020 at 06:04:37PM +0100, Paul Moore wrote:

> What I don't see is where the money's coming from. It's fine to ask,
> but will anyone come up with that sort of funding?

I don't think Mark is asking for you or I to fund the exercise. He's
asking for the PSF to fund it.

I think that Mark's asking price is perhaps a bit optimistic. With the
Covid-19 pandemic, lock downs and shutting down of international travel,
I expect that PSF conference income will be way down. And income in the
previous financial year was not exactly at Facebook levels:

Revenue: $3.1 million
Expences: $2.6 million

Nett income: $520000

https://www.python.org/psf/annual-report/2019/

Mark is asking for half of that, justified that this is the going rate
for a full-time developer at one of the top tier tech firms.



--
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/IZGFSDJMVO7UWWPD2WEHUPIVN6SATEJB/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Tue, Oct 20, 2020 at 5:59 AM Mark Shannon <mark@hotpy.org> wrote:

> Hi everyone,
>
> CPython is slow. We all know that, yet little is done to fix it.
>
> I'd like to change that.
> I have a plan to speed up CPython by a factor of five over the next few
> years. But it needs funding.
>
> I am aware that there have been several promised speed ups in the past
> that have failed. You might wonder why this is different.
>
> Here are three reasons:
> 1. I already have working code for the first stage.
> 2. I'm not promising a silver bullet. I recognize that this is a
> substantial amount of work and needs funding.
> 3. I have extensive experience in VM implementation, not to mention a
> PhD in the subject.
>
> My ideas for possible funding, as well as the actual plan of
> development, can be found here:
>
> https://github.com/markshannon/faster-cpython
>
> I'd love to hear your thoughts on this.
>
> Cheers,
> Mark.
>

+1

Overall I think you are making quite a reasonable proposal. It sounds
like effectively bringing your hotpy2 concepts into the CPython interpreter
with an intent to help maintain them over the long term.

People worried that you are doing this out of self interest may not know
who you are. Sure, you want to be paid to do work that you appear to love
and have been mulling over for a decade+. There is nothing wrong with
that. Payment is proposed as on delivery per phase. I like the sound of
that, nice!

Challenges I expect we'll face, that seem tractable to me, are mostly
around what potential roadblocks we, us existing python-committers and our
ultimate decider steering council might introduce intentionally or not that
prevents landing such work. Payment on delivery helps that a lot, if we
opt out of some work, it is both our losses. One potential outcome is that
you'd burn out and go away if we didn't accept something meaning payment
wasn't going to happen. That already happens amongst all core devs today
so I don't have a problem with this even though it isn't what we'd
rightfully want to happen. Middle grounds are quite reasonable
renegotiations. The deciders on this would be the PSF (because money) and
the PSF would presumably involve the Steering Council in decisions of terms
and judgements.

Some background materials for those who don't already know Mark's past work
along these lines that is where this proposal comes from:
https://sites.google.com/site/makingcpythonfast/ (hotpy)
and the associated presentation in 2012:
https://www.youtube.com/watch?v=c6PYnZUMF7o

The amount of money seems entirely reasonable to me. Were it to be taken
on, part of the PSF's job is to drum up the money. This would be a contract
with outcomes that could effectively be sold to funders in order to do so.
There are many companies who use CPython a lot that we could solicit
funding from, many of whom have employees among our core devs already. Will
they bite? It doesn't even have to be from a single source or be all
proposed phases up front, that is what the PSF exists to decide and
coordinate on.

We've been discussing on and off in the past many years how to pay people
for focused work on CPython and the ecosystem and balance that with being
an open source community project. We've got some people employed along
these lines already, this would become more of that and in many ways just
makes sense to me.

Summarizing some responses to points others have brought up:

Performance estimates:
* Don't fret about claimed speedups of each phase. We're all going to
doubt different things or expect others to be better. The proof is
ultimately in the future pudding.

JIT topics:
* JITs rarely stand alone. The phase 1+2 improved interpreter will always
exist. It is normal to start with an interpreter for fast startup and
initial tracing before performing JIT compilations, and as a fallback
mechanism when the JIT isn't appropriate or available. (my background:
Transmeta. We had an Interpreter and at least two levels of Translators
behind our x86 compatible CPUs, all were necessary)
* Sometimes you simply want to turn tracing and jit stuff off to save
memory. That knob always winds up existing. If nothing else it is normal to
run our test suite with such a knob in multiple positions for proper
coverage.
* It is safe to assume any later phase actual JIT would target at least
one important platform (ex: amd64 or aarch64) and if successful should
easily elicit contributions supporting others either as work or as funding
to create it.

"*Why this, why not fund XyZ?*" whataboutism:
* This conversation is separate from other projects. The way attracting
funding for a project works can involve spelling out what it is for. It
isn't my decision, but I'd be amazed if anything beyond maybe phase 1 came
solely out of a PSF general no obligation fund. CPython is the most used
Python VM in the world. A small amount of funding is not going to get
maintainers and users to switch to PyPy. There is unlikely to be a major
this or that situation here.

Unladen Swallow
* That was a fixed time one year attempt at speeding up CPython by Google.
IIRC CPython's computed goto support came out of that(?), as did a ton of
improvements to the LLVM internals that we don't see in python-dev land as
that project was not yet anywhere near ready to take on dynamic language
VMs at the time. At the end the llvm backed side was not something that was
deemed maintainable or necessarily a win, so it was not accepted by us and
was shelved. It wasn't a clear win and carried a very complicated cross
project maintenance burden. I still work with many of the people involved
in that project, at least one of whom works full time on LLVM today. Nobody
involved that I'm aware of is bitter about it. It was a fixed time
experiment, a few projects got some good out of it. Another reason that did
continue: The motivating internal application we attempted Unladen Swallow
for ultimately found they were more Memory than CPU constrained in terms of
their compute resources planning... 5-6 years ago an attempt at getting the
same internal application up and running on PyPy (which led to many
contributions to PyPy's cpyext) ran in part into the memory constraint. (*there
were more issues with pypy - cpyext vs performance being but one; this
isn't the place for that and I'm not the right person to ask*)

meta: i've written too many words and edited so often i can't see my own
typos and misedits anymore. i'll stop now. :)

-gps


> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/RDXLCH22T2EZDRCBM6ZYYIUTBWQVVVWH/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
Re: Speeding up CPython [ In reply to ]
On 10/20/2020 2:49 PM, Dan Stromberg wrote:

> I suspect what it needs most is HPY work, which could benefit a lot of
> Python language implementations in the long term:
> https://github.com/hpyproject/hpy
>
> $2e6 spent on HPY could be pretty amazing.

I don't think the two projects are mutually exclusive. I would like to
see the PSF raise and spend a few million a year on improvements.


--
Terry Jan Reedy
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/QXYIROIWMSZ4ZHF23C5TCHO2DFLQVZAZ/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Wed, Oct 21, 2020 at 3:51 AM Gregory P. Smith <greg@krypto.org> wrote:
>
> meta: i've written too many words and edited so often i can't see my own typos and misedits anymore. i'll stop now. :)

Haha! Very interesting background, thank you for writing down all of this!
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/CFC4XSS5AR2MBEDSQTNTL4GKH63RKVRZ/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On 21/10/2020 00.14, Steven D'Aprano wrote:
> On Tue, Oct 20, 2020 at 06:04:37PM +0100, Paul Moore wrote:
>
>> What I don't see is where the money's coming from. It's fine to ask,
>> but will anyone come up with that sort of funding?
>
> I don't think Mark is asking for you or I to fund the exercise. He's
> asking for the PSF to fund it.

No, he is not. Mark is asking the PSF to organize a fund raiser and keep
half the money.

Christian
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/TOKFADEIOASTU3KMAIMYA226TIJ6IM3T/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Speeding up CPython [ In reply to ]
On Wed, 21 Oct 2020 at 08:14, Christian Heimes <christian@python.org> wrote:
>
> On 21/10/2020 00.14, Steven D'Aprano wrote:
> > On Tue, Oct 20, 2020 at 06:04:37PM +0100, Paul Moore wrote:
> >
> >> What I don't see is where the money's coming from. It's fine to ask,
> >> but will anyone come up with that sort of funding?
> >
> > I don't think Mark is asking for you or I to fund the exercise. He's
> > asking for the PSF to fund it.
>
> No, he is not. Mark is asking the PSF to organize a fund raiser and keep
> half the money.

Right. I'd misinterpreted the fact that the PSF was to get half the
money as meaning they weren't doing the fundraising. My
misunderstanding, thanks for the clarification.

Paul
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/N6PBKMDETBSZURV6KOKCARHRJBZCMVDW/
Code of Conduct: http://python.org/psf/codeofconduct/

1 2 3 4  View All