Synapse is the epitome of this

2 years ago by Lena to c/programmer_humor

lime 146 points 2 years ago

all programs are single threaded unless otherwise specified.

path: 0 16035119, hotness: undefined, score: 146, children: 32
firelizzard 46 points 2 years ago

It’s safe to assume that any non-trivial program written in Go is multithreaded

path: 0 16035119 16035480, hotness: undefined, score: 46, children: 11
Scoopta 18 points 2 years ago

But it's still not a guarantee

path: 0 16035119 16035480 16040165, hotness: undefined, score: 18, children: 1
firelizzard 1 point 2 years ago

Definitely not a guarantee, bad devs will still write bad code (and junior devs might want to let their seniors handle concurrency).

path: 0 16035119 16035480 16040165 16092830, hotness: undefined, score: 1, children: 0
kbotc 15 points 2 years ago

And yet: You’ll still be limited to two simultaneous calls to your REST API because the default HTTP client was built in the dumbest way possible.

path: 0 16035119 16035480 16045382, hotness: undefined, score: 15, children: 3
firelizzard 2 points 2 years ago

Really? Huh, TIL. I guess I've just never run into a situation where that was the bottleneck.

path: 0 16035119 16035480 16045382 16092879, hotness: undefined, score: 2, children: 0
LodeMike 1 point a year ago

The client object or the library?

path: 0 16035119 16035480 16045382 17107722, hotness: undefined, score: 1, children: 1
kbotc 1 point a year ago

… Is this a trick question? The object, provided by the library (net/http which is about as default as they come) sets “DefaultMaxIdleConnsPerHost” to 2. This is significant because if you finish a connection and you’ve got more than 2 idles, it slams that connection close. If you have a lot of simultaneous fast lived requests to the same IP (say a load balanced IP), your go programs will exhaust the ephemeral port list quickly. It’s one of the most common “gotchas” I see where Go programs work great in dev and blow themselves apart in prod.

https://dev.to/... is a fairly decent write up.

path: 0 16035119 16035480 16045382 17107722 17130088, hotness: undefined, score: 1, children: 0
Opisek 6 points 2 years ago

I absolutely love how easy multi threading and communication between threads is made in Go. Easily one of the biggest selling points.

path: 0 16035119 16035480 16050415, hotness: undefined, score: 6, children: 4
firelizzard 1 point 2 years ago

Key point: they're not threads, at least not in the traditional sense. That makes a huge difference under the hood.

path: 0 16035119 16035480 16050415 16092909, hotness: undefined, score: 1, children: 3
Opisek 1 point 2 years ago

Well, they're userspace threads. That's still concurrency just like kernel threads.

Also, it still uses kernel threads, just not for every single goroutine.

path: 0 16035119 16035480 16050415 16092909 16097640, hotness: undefined, score: 1, children: 2
Successful_Try543 22 points 2 years ago

Does Python have the ability to specify loops that should be executed in parallel, as e.g. Matlab uses parfor instead of for?

path: 0 16035119 16035391, hotness: undefined, score: 22, children: 18
lime 51 points 2 years ago

python has way too many ways to do that. asyncio, future, thread, multiprocessing...

path: 0 16035119 16035391 16036248, hotness: undefined, score: 51, children: 10
WolfLink 41 points 2 years ago

Of the ways you listed the only one that will actually take advantage of a multi core CPU is multiprocessing

path: 0 16035119 16035391 16036248 16040644, hotness: undefined, score: 41, children: 3
lime 10 points 2 years ago

yup, that's true. most meaningful tasks are io-bound so "parallel" basically qualifies as "whatever allows multiple threads of execution to keep going". if you're doing numbercrunching in pythen without a proper library like pandas, that can parallelize your calculations, you're doing it wrong.

path: 0 16035119 16035391 16036248 16040644 16042432, hotness: undefined, score: 10, children: 2
danhab99 9 points 2 years ago

I've always hated object oriented multi threading. Goroutines (green threads) are just the best way 90% of the time. If I need to control where threads go I'll write it in rust.

path: 0 16035119 16035391 16036248 16038778, hotness: undefined, score: 9, children: 5
lime 7 points 2 years ago

nothing about any of those libraries dictates an OO approach.

path: 0 16035119 16035391 16036248 16038778 16042451, hotness: undefined, score: 7, children: 4
enemenemu 7 points 2 years ago

Are you still using matlab? Why? Seriously

path: 0 16035119 16035391 16035926, hotness: undefined, score: 7, children: 6
Successful_Try543 18 points 2 years ago

No, I'm not at university anymore.

path: 0 16035119 16035391 16035926 16036402, hotness: undefined, score: 18, children: 3
enemenemu 4 points 2 years ago

Good for you

Poor prof

path: 0 16035119 16035391 16035926 16036402 16036947, hotness: undefined, score: 4, children: 2
Panties 7 points 2 years ago

I was telling a colleague about how my department started using Rust for some parts of our projects lately. (normally Python was good enough for almost everything but we wanted to try it out)

They asked me why we're not using MATLAB. They were not joking. So, I can at least tell you their reasoning. It was their first programming language in university, it's safer and faster than Python, and it's quite challenging to use.

path: 0 16035119 16035391 16035926 16041068, hotness: undefined, score: 7, children: 1
twice_hatch 4 points 2 years ago

"Just use MATLAB" - Someone with a kind heart who has never deployed anything to anything

path: 0 16035119 16035391 16035926 16041068 16046620, hotness: undefined, score: 4, children: 0
groknull 5 points 2 years ago

I initially read this as “all programmers are single-threaded” and thought to myself, “yeah, that tracks”

path: 0 16035119 16070593, hotness: undefined, score: 5, children: 0
nickwitha_k 25 points 2 years ago path: 0 16047465, hotness: undefined, score: 25, children: 4
lena 4 points 2 years ago

Oooooh this is really cool, thanks for sharing. How could I install it on Linux (Ubuntu)? I assume I would have to compile CPython. Also, would the source of the programs I run need any modifications?

path: 0 16047465 16050192, hotness: undefined, score: 4, children: 3
computergeek125 5 points 2 years ago

From memory I can only answer one of those: The way I understand it (and I could be wrong), your programs theoretically should only need modifications if they have a concurrency related bug. The global interlock is designed to take a sledgehammer at "fixing" a concurrency data race. If you have a bug that the GIL fixed, you'll need to solve that data race using a different control structure once free threading is enabled.

I know it's kind of a vague answer, but every program that supports true concurrency will do it slightly differently. Your average script with just a few libraries may not benefit, unless a library itself uses threads. Some libraries that use native compiled components may already be able to utilize the full power of you computer even on standard Python builds because threads spawned directly in the native code are less beholden to the GIL (depending on how often they'd need to communicate with native python code)

path: 0 16047465 16050192 16053543, hotness: undefined, score: 5, children: 1
lena 2 points 2 years ago

Thanks for the answer, I really hope Synapse will be able to work with concurrency enabled.

path: 0 16047465 16050192 16053543 16054716, hotness: undefined, score: 2, children: 0
nickwitha_k 4 points 2 years ago

In this case, it's a feature of the language that enables developers to implement greater amounts of parallelism. So, the developers of the Python-based application will need to refactor to take advantage of it.

path: 0 16047465 16050192 16065929, hotness: undefined, score: 4, children: 0
SaharaMaleikuhm 22 points 2 years ago

Oh wow, a programming language that is not supposed to be used for every single software in the world. Unlike Javascript for example which should absolutely be used for making everything (horrible). Nodejs was a mistake.

path: 0 16054888, hotness: undefined, score: 22, children: 5
lena 0 points 2 years ago

Nodejs was a mistake.

More choice is always better

path: 0 16054888 16055054, hotness: undefined, score: 0, children: 4
_stranger_ 18 points 2 years ago

And some of those choices are mistakes.

path: 0 16054888 16055054 16055252, hotness: undefined, score: 18, children: 2
lena 5 points 2 years ago

I like Typescript >:3

path: 0 16054888 16055054 16055252 16055640, hotness: undefined, score: 5, children: 1
_stranger_ 13 points 2 years ago

I appreciate Typescript for addressing the sins of its predecessor.

path: 0 16054888 16055054 16055252 16055640 16057285, hotness: undefined, score: 13, children: 0
driving_crooner 4 points 2 years ago

Citations Needed: Episode 95: The Hollow Vanity of Libertarian "Choice" Rhetoric

Episode webpage: https://dts.podtrac.com/...


Fucking Citations Needed, every time I finish an episode, someone comment something related to it.

path: 0 16054888 16055054 16070370, hotness: undefined, score: 4, children: 0
twice_hatch 16 points 2 years ago

don't worry it'll use all the RAM anyway

path: 0 16046605, hotness: undefined, score: 16, children: 3
SatouKazuma 7 points 2 years ago

I paid for all the memory. I'll use all the memory.

path: 0 16046605 16050768, hotness: undefined, score: 7, children: 1
goodbible 2 points 2 years ago

JG Memoryworth

path: 0 16046605 16050768 16070533, hotness: undefined, score: 2, children: 0
lena 6 points 2 years ago

No RAM gets wasted!

path: 0 16046605 16050202, hotness: undefined, score: 6, children: 0
kSPvhmTOlwvMd7Y7E 15 points 2 years ago

let's be honest here, he actually means 0.01 core performance

path: 0 16050240, hotness: undefined, score: 15, children: 0
tetris11 11 points 2 years ago

I prefer this default. Im sick of having to rein in Numba cores or OpenBlas threads or other out of control software that immediately tries to bottleneck my stack.

CGroups (Docker/LXC) is the obvious solution, but it shouldn't have to be

path: 0 16036401, hotness: undefined, score: 11, children: 0
dan 11 points 2 years ago

Do you mean Synapse the Matrix server? In my experience, Conduit is much more efficient.

path: 0 16040316, hotness: undefined, score: 11, children: 4
jimmy90 5 points 2 years ago

i wish they would switch the reference implementation to conduit

there is core components on the client side in rust so maybe that's the way for the future

path: 0 16040316 16049450, hotness: undefined, score: 5, children: 0
lena 4 points 2 years ago

Yep, I mean as in matrix. There is currently no was to migrate to conduit/conduwuit. Btw from what I've seen conduwuit is more full-featured.

path: 0 16040316 16050214, hotness: undefined, score: 4, children: 0
fmstrat 2 points 2 years ago

I may have something to read up on.

path: 0 16040316 16045798, hotness: undefined, score: 2, children: 1
dan 2 points 2 years ago

The documentation is kinda lacking, but if you could figure out how to set up Synapse then you can probably figure out Conduit too. https://conduit.rs/

path: 0 16040316 16045798 16046456, hotness: undefined, score: 2, children: 0
driving_crooner 10 points 2 years ago

I tough this was about excel and was like yeah haha!

But is about Python, so I'm officially offended.

path: 0 16057614, hotness: undefined, score: 10, children: 0
TropicalDingdong 9 points 2 years ago

Python

..so.. so you made it single threaded?

path: 0 16035505, hotness: undefined, score: 9, children: 0
h4x0r 8 points 2 years ago path: 0 16047032, hotness: undefined, score: 8, children: 0
Gonzako 7 points 2 years ago

I'll be honest, this only matters when running single services that are very expensive. it's fine if your program can't be pararlelized if the OS does its job and spreads the love around the cpus

path: 0 16037969, hotness: undefined, score: 7, children: 0
alcasa 5 points 2 years ago

It only took us how many years?

path: 0 16050042, hotness: undefined, score: 5, children: 0
Fortatech 2 points 2 years ago

!lemmySilver

path: 0 16219747, hotness: undefined, score: 2, children: 0
programmer_humor
programmer_humor

@programming.dev

login for more options
33583
2551
7101

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
    • If the mod doesn't find it funny, you're banned. Ha-ha!... For real: do not use the community for "statements". There are other places for such content. Keep it chill and funny.

go to feed...