News for hackers. Stuff that matters.
Re:Python’s Multiprocessing Performance Problem by mlyle on Wednesday March 01, 2023 @04:29PM (#34988612)
You're still kinda stuck with concurrency of the python code itself though. It sure would be nice to be able to just throw cores at problems for awhile.

Computers are cheap, and people are expensive.

Re:Python’s Multiprocessing Performance Problem by bb88 on Wednesday March 01, 2023 @09:27PM (#34991154)
I think the question is how much more cost does it take to move the code from python to C/C++/Rust/whatever? That's a human problem until ChatGPT can solve that problem for you.
Re:Python’s Multiprocessing Performance Problem by KptMarchewa on Thursday March 02, 2023 @06:40AM (#34994589)
You can spawn threads as much as you want from native language.
Re:Python’s Multiprocessing Performance Problem by mlyle on Thursday March 02, 2023 @11:13AM (#34997584)
Sure, and if you can't get stuff in and out of Python objects with concurrency, it doesn't help you much a lot of the time. Plus, again, computing is cheap: it'd be nice to use all my cores before I spend a lot of effort optimizing and rewriting things in native code.
Re:Python’s Multiprocessing Performance Problem by VHRanger on Thursday March 02, 2023 @02:58PM (#35001089)
That's a data layout problem largely, though.

If your data is fragmented across a bunch of small containers/classes, passing it around will be expensive whichever the method (either passing to C++, or just in terms of cache efficiency).

If you just pass an array of data back and forth it's cheap.

Re:Python’s Multiprocessing Performance Problem by mlyle on Thursday March 02, 2023 @03:31PM (#35001598)
> If you just pass an array of data back and forth it's cheap.

Yes, and numpy is great, and all. Python works great as glue to marshal things to and from native code and do inexpensive (but possibly complicated) bits of control logic.

But if I'm trying to deal with large numbers of client requests, say... the lack of concurrency in python itself really hurts. Sure, I can punt almost everything to native code, but what's the point in having Python at all, then?

Not all problems have state that can be shared well across Multiprocessing or completely externalized to large lumps that travel to native code in a few calls-- I'd actually say these are special case exceptions than the rule.

Re:Python’s Multiprocessing Performance Problem by VHRanger on Thursday March 02, 2023 @03:48PM (#35001820)
Right, if your issue is that you're getting a ton of small, individual API calls, python will suffer.

At that point you'd look to Go or another language, and also carefully choose the REST API framework you're setting up.

Note that having a solution setup where the end result is "a ton of small, individual API calls" could possibly indicate a bad system architecture.

Re:Python’s Multiprocessing Performance Problem by mlyle on Thursday March 02, 2023 @04:31PM (#35002371)
> Note that having a solution setup where the end result is "a ton of small, individual API calls" could possibly indicate a bad system architecture.

Or just a lot of clients with a fair bit of shared state which is best kept resident, which is a pretty common use case.

It's a bummer to write python code that works well, and then gets up to 130% CPU load when you grow your use case... and not have any obvious path to scale upwards despite you having 32 threads of execution around.