Live data from Hacker News

A green threading library with true concurrency for Python

github.com

31–40 of 40 posts

Re: A green threading library with true concurrency for Python

#32

> Conpig threads still can only run on one core of a processor. The disillusionment caused by having so many options for non-parallel "concurrency" in Python is, I believe, feeding the high defection rate from Python to Go.

And the numpy/scipy/ipython notebook/scikit-learn axis is driving a lot of python adoption these days. Look in any blog about beginning data mining/machine learning, odds are it'll say learn python or R.

Different kind of user, but... just sayin

Re: A green threading library with true concurrency for Python

#33
post #23
post #21

Earlier quoted context omitted.

- here actually negates the ordering of the numbers in the list. -1.0.0 === 0.0.1.

> - here actually negates the ordering of the numbers in the list. -1.0.0 === 0.0.1. Well, I've certainly never seen that before.

It should be written 0.0.1[::-1]

Re: A green threading library with true concurrency for Python

#34
post #25

Earlier quoted context omitted.

With a cooperative scheduler, you will , sooner or later, experience some form of starvation. The most obvious is the process that just infinitely loops, but less obvious situations will end up popping up too; calls that you thought were handled by the event loop but turn out to be blocking and add up when you start calling them at scale, strange behavior when you have a set of processes that turn out to yield far le…

It sounds like this sort of problem comes from using a cooperative scheduler to implement concurrency of arbitrary routines rather than control flow. I haven't been in a situation in which it would even be possible for something to yield less often than I expect, because I expect it to run until it yields. Similarly I don't often find that subroutines return too infrequently because I expect them to run until they re…

You will eventually, at scale, be wrong about that. To have full and correct knowledge of exactly how long your code takes to run sufficient to do this sort of scheduling correctly, by hand, in advance of running it, is basically equivalent to claiming that you never need to profile code because you already know exactly how long it takes. And it is well known and established to my satisfaction that even absolute, total experts in a field will still often be surprised about what actually comes out of a profiler, even in code strictly in their domains. You may well be right most of the time... but that is all you can hope for.

Re: A green threading library with true concurrency for Python

#35
post #34

Earlier quoted context omitted.

It sounds like this sort of problem comes from using a cooperative scheduler to implement concurrency of arbitrary routines rather than control flow. I haven't been in a situation in which it would even be possible for something to yield less often than I expect, because I expect it to run until it yields. Similarly I don't often find that subroutines return too infrequently because I expect them to run until they re…

You will eventually, at scale, be wrong about that. To have full and correct knowledge of exactly how long your code takes to run sufficient to do this sort of scheduling correctly, by hand, in advance of running it, is basically equivalent to claiming that you never need to profile code because you already know exactly how long it takes. And it is well known and established to my satisfaction that even absolute, tot…

If it takes more than 16.67ms to run a frame's worth of update-and-draw, then it does, and replacing "wake up every in-game entity that asked to wake up this frame" with "let a preemptive scheduler manage ~10,000 threads that want to wake up, do almost nothing, and then sleep for k frames, while some master thread waits on a latch until they're all done" seems unlikely to make it any faster. If the logic my server must perform to handle a request is expensive, then it is, and replacing an event loop with a single-threaded preemptive scheduler will not increase throughput.

I'm not sure why it is difficult to do this sort of thing correctly. The scheduler does next to nothing in the "server with connections managed in coroutines" case and probably makes matters worse in the "storing game state in execution states" case. It could have a positive impact in the server application if one routine is secretly going to crash or run forever, in the sense that the other routines will continue running while the problematic feature is fenced off or fixed.

Re: A green threading library with true concurrency for Python

#36

Earlier quoted context omitted.

This may help explain the difference: http://blog.golang.org/concurrency-is-not-parallelism

Should I have thrown a literally in there? Literally Concurrent means at the same time. Parallel literally means non intersecting. I understand some dumbass has\is trying to co opt the language it doesn't mean I have to like it. If one of them should mean one thing and the other the other why not have the one that literally means at the same time for the term that means at the same time. And have the one that means n…

> I understand some dumbass has\is trying to co opt the language it doesn't mean I have to like it.

That's called a lingo or a jargon (in this case, programmer lingo), and it involves making up words or having a different definition for a given word in the correct context.

Re: A green threading library with true concurrency for Python

#37
post #32

> Conpig threads still can only run on one core of a processor. The disillusionment caused by having so many options for non-parallel "concurrency" in Python is, I believe, feeding the high defection rate from Python to Go.

And the numpy/scipy/ipython notebook/scikit-learn axis is driving a lot of python adoption these days. Look in any blog about beginning data mining/machine learning, odds are it'll say learn python or R. Different kind of user, but... just sayin

That's true, and not incompatible with what I'm saying. I'm saying that the majority of defection from Python I hear about is defection to Go. A lot of that seems to be taking the form of loud and proud blogging, so we hear about it here. The defection rate from Python is almost certainly much lower than its overall growth rate, or it would be dying (Perl). I'm just saying, it's not an accident that people are leaving Python for Go. They want cheap and easy parallelism and concurrency. Python is great at many things, maybe even most things, but the state of affairs with parallelism is very weak. Python can expect to continue to lose people to Go until this is addressed in a real, tangible way that doesn't sound like excuse-making. I don't really expect the situation to change, because Python doesn't need it to, but the excuse-making is annoying.

Re: A green threading library with true concurrency for Python

#38
post #29
post #3

I don't really get what advantage this gives me beyond using gevent. There's still no parallelism. The readme describes it as "A solution to concurrency," but I already get that using gevent. Is it just to improve communication between green threads?

It basically is 50 lines of code that implement some stuff from gevent... So yes, it's more of a joke I guess.

So number of lines of code makes a library a joke? One of the most commonly used Haskell libraries is only 25.

http://hackage.haskell.org/packages/archive/forkable-monad/0...

Also, this doesn't implement some stuff from gevent, it implements some stuff over and using gevent.

Re: A green threading library with true concurrency for Python

#39
post #38
post #29

Earlier quoted context omitted.

It basically is 50 lines of code that implement some stuff from gevent... So yes, it's more of a joke I guess.

So number of lines of code makes a library a joke? One of the most commonly used Haskell libraries is only 25. http://hackage.haskell.org/packages/archive/forkable-monad/0... Also, this doesn't implement some stuff from gevent, it implements some stuff over and using gevent.

Yes that's exactly what I'm saying. If external code is less then some hundred lines of code, it would be better suited as a tutorial and people would be better at implementing those lines themselves. And yes, that's only my opinion.

Re: A green threading library with true concurrency for Python

#40
post #39
post #38

Earlier quoted context omitted.

So number of lines of code makes a library a joke? One of the most commonly used Haskell libraries is only 25. http://hackage.haskell.org/packages/archive/forkable-monad/0... Also, this doesn't implement some stuff from gevent, it implements some stuff over and using gevent.

Yes that's exactly what I'm saying. If external code is less then some hundred lines of code, it would be better suited as a tutorial and people would be better at implementing those lines themselves. And yes, that's only my opinion.

Do you have any reasoning behind that opinion, or is it just unfounded religious zeal?

Why should somebody who wants to use threading have to know how to write a preemptive scheduler? If you want a tutorial in addition to the library thats fine, but many good tutorials also release their code as libraries. In open source world, releasing code as a library does not mean having to keep people from understanding the workings of that code. Why should people HAVE to learn how the code works to use it though?

Post reply on HN