Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
tef
May 30, 2004

-> some l-system crap ->

hobbesmaster posted:

isn’t this what ldxr/stxr are for on ARM?

kinda, i was more referring to things like memory ordering

https://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync

like SeqCst (every load or store happens in order and atomically, globally) vs stuff like Release/Acquire (loads and stores can be subtly reordered in some cases, and the synchronization is less heavyweight)

and memory fences, too

Adbot
ADBOT LOVES YOU

hbag
Feb 13, 2021

god i hope i never have to do this for real

hobbesmaster
Jan 28, 2008

it’s more I thought armv8 was equivalent to x86 on all that because of the explicit, formal memory model and introduction of instructions for barriers, fences and acquire/release?

Beeftweeter
Jun 28, 2005

OFFICIAL #1 GNOME FAN

hbag posted:

god i hope i never have to do this for real

depends on what you want to do

Cybernetic Vermin
Apr 18, 2005

tef posted:

honestly? not as much as you'd hope. the problem with concurrency lessons is that they teach it in terms of the solutions "here's a mutex, here's a semaphore" and then go "now draw the loving owl".

the better way to learn about concurrency is to learn about the different types of race condition, and then understanding what steps you need to take to avoid them.

this is why of all the things people pick up "lock and unlock in the same order" is the only one that sticks. it's not they remember the dining philosophers, it's that they remember how easy it is to deadlock otherwise. or, learning about the ABA problem, and understanding that you need to version your updates such that other writers/readers can reliably detect changes

you won't get taught "why you need to use a logical clock and not a timestamp" though. it's not just that clocks can drift forwards or backwards, it's things like "you cannot detect missing updates between two timestamps, but you can between two version numbers"

and similarly, even though you might know of the dining philosophers algorithm, you won't get taught "you can't always immediately unlock things when you're done, because something else may have started before you, and may get an inconsistent picture of the application state"

this is why i made a wry comment about "only database engineers will learn how to do this correctly"

i mean, this all depends on hbags school, our programs here are pretty good on this stuff. best to listen at any rate, because if it's a good treatment it is the kind of stuff that is hard to pick up naturally.

endlessmonotony
Nov 4, 2009

by Fritz the Horse

hbag posted:

god i hope i never have to do this for real

Being able to do the horrid boring poo poo is a great way to get your foot in the door for the cushy jobs. They're not likely to come up often even then, but they might be necessary.

Cybernetic Vermin
Apr 18, 2005

hbag posted:

god i hope i never have to do this for real

naaaah, these are the fun bits when you get into it

Asleep Style
Oct 20, 2010

ime there are plenty of jobs where you will never or almost never have to deal with concurrency, but basically no jobs where you won't have to deal with race conditions. it's good to learn about this stuff because identifying and troubleshooting them can be really hard

Cybernetic Vermin
Apr 18, 2005

cjs: somehow got the funding to hire my favorite student to do a phd, hype as hell, they are way better than me at the thing i want to do

Archduke Frantz Fanon
Sep 7, 2004

tef posted:

they're all hard, they all suck

yospos bicth

Archduke Frantz Fanon
Sep 7, 2004

cjs: i think im just gonna gently caress around today since i'm blocked by apple, who seems to take a week to do anything

tef
May 30, 2004

-> some l-system crap ->

Asleep Style posted:

ime there are plenty of jobs where you will never or almost never have to deal with concurrency, but basically no jobs where you won't have to deal with race conditions. it's good to learn about this stuff because identifying and troubleshooting them can be really hard

if you're feeling fancy, you can learn about rw-conflicts and ww-conflicts

but yeah, after a while you realise that, well, you're just learning about garbage collection. not just the termination detection bits (did all my workers finish), but the bit where deadlocks detection means cycle collection :2bong:

tef
May 30, 2004

-> some l-system crap ->

hobbesmaster posted:

it’s more I thought armv8 was equivalent to x86 on all that because of the explicit, formal memory model and introduction of instructions for barriers, fences and acquire/release?

iirc, x86 really only does SeqCst, and it's arm where the weak barrier whacky town frolics happen

hobbesmaster
Jan 28, 2008

Asleep Style posted:

ime there are plenty of jobs where you will never or almost never have to deal with concurrency, but basically no jobs where you won't have to deal with race conditions. it's good to learn about this stuff because identifying and troubleshooting them can be really hard

come to embedded land, we have such sights to show you

tef
May 30, 2004

-> some l-system crap ->

Asleep Style posted:

ime there are plenty of jobs where you will never or almost never have to deal with concurrency, but basically no jobs where you won't have to deal with race conditions. it's good to learn about this stuff because identifying and troubleshooting them can be really hard

fixing them is harder, because no-one will believe you that it works. devs end up being real superstitious about it. i recall having to wait until one boss went on holiday to sneak in a mutex, and suddenly a whole class of errors just vanished. devs also do things like "put unbounded while loops in critical sections", so even if you do get it right, it's an uphill challenge to keep it that way

that, and, well, you don't really troubleshoot race conditions, that just ends up in a game of whack a mole. you gotta just write something that enforces determinism from the outset

tef
May 30, 2004

-> some l-system crap ->
like, a fun concurrency algorithm is keirs multiple compare and swap. for when you have an array of pointers to items in the heap, and want to cas multiple entries atomically. it's kinda ridiculously simple, especially if you use pointer tagging.

1. create a descriptor table in memory, which lists all the old and new values for each pointer
2. for each entry, swap in a pointer to the descriptor table in ascending order of address
3. once complete, swap in the new pointers, in descending order

with a reader, if you see a descriptor table, you race the other threads to complete the algorithm, and continue on your way. the only real problem with this algorithm comes down to "do you care if your reads are synchronized" and "do you want a consistent snapshot to work from"

if you want to do that, well, you end up having to have some global write epoch, incremented each time a write happens. when you start a read, you store the epoch, when you end it, you check it hasn't changed, and then you know no fuckery has occurred. if it has changed, you give up and try again.

which, well, introduces a new problem: reads can be aborted/restarted constantly, and it's possible to lock up any progress if one writer is misbehaving.

so you change your writer epoch protocol: increment before you swap in the table, increment afterwards. now writes happen exclusively, and if a reader wants to stop activity, it can just use the epoch as a global lock over the table to halt writes. which almost but not quite solves the problem: a reader that locks can stall other readers.

so maybe you end up storing the descriptor table in a ring buffer, indexed by the write epoch used. that way, when a read aborts, you can check to see if any of the values you looked at changed, and either pick the new or the old values to continue on with your work.

concurrency! :2bong:

Sagebrush
Feb 26, 2012

hobbesmaster posted:

come to embedded land, we have such sights to show you

:unsmigghh:

Truman Peyote
Oct 11, 2006



cjs: love to go into a meeting with product and be told the estimate they came up with for my work and all the people they've told it to before me

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


i've been playing race condition whack-a-mole on this 20 year old codebase for over three years. i wish i had the time - and skill - to do otherwise

(this is the same codebase where clock_nanosleep() would outright ignore the absolute-sleep-time flag some 1/100k calls and break everything so it's kinda fundamentally accursed imo)

Ciaphas fucked around with this message at 17:03 on Mar 30, 2023

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


born to race
pthread is a gently caress
lock em all 1989
i am sad dev man
410,757,864,530 deadlocks threads busywaiting

Ciaphas fucked around with this message at 17:14 on Mar 30, 2023

FAT32 SHAMER
Aug 16, 2012



I do a lot of concurrency in mobile development, which apparently isn’t common outside of mobile gaming

it’s fun as hell except when poo poo breaks and then it’s the worst thing in the world

Cybernetic Vermin
Apr 18, 2005

kind of want "410,757,864,530 threads busywaiting" for realism

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Cybernetic Vermin posted:

kind of want "410,757,864,530 threads busywaiting" for realism
lol this is better because it's true (more like 100 threads in this code all busywaiting, but still) :negative:

Archduke Frantz Fanon
Sep 7, 2004

Truman Peyote posted:

cjs: love to go into a meeting with product and be told the estimate they came up with for my work and all the people they've told it to before me

points aren't real and can mean whatever you want!

Asleep Style
Oct 20, 2010

tef posted:

fixing them is harder, because no-one will believe you that it works. devs end up being real superstitious about it. i recall having to wait until one boss went on holiday to sneak in a mutex, and suddenly a whole class of errors just vanished. devs also do things like "put unbounded while loops in critical sections", so even if you do get it right, it's an uphill challenge to keep it that way

that, and, well, you don't really troubleshoot race conditions, that just ends up in a game of whack a mole. you gotta just write something that enforces determinism from the outset

I would love to work somewhere with devs skilled enough to manage that last part

the first race condition I ever dealt with was in an integration test suite that took 12 hours to run. we would write the results of a 15 minute calculation to a file, then immediately try to open the file and compare it to a known good result. some tests started failing intermittently one day. it turns out that whatever C# writefile method we were using didn't wait til the file was completely written before returning, so we were comparing incomplete output data. iirc we fixed it by adding a step that check that the output file size hadn't changed within a certain interval before trying to read it

unless you were really familiar with that writefile method ahead of time, this was code that looked like it was completely synchronous. I've run into similar things at every job since, where someone didn't realize that something that appeared synchronous was actually not

thanks for the interesting concurrency posts, this is very much outside my wheelhouse

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
theres also stm and big rear end non mutex poo poo and agentic poo poo. and greenthreads which are still threading bullshit but Different

Truman Peyote
Oct 11, 2006



Archduke Frantz Fanon posted:

points aren't real and can mean whatever you want!

oh don't worry, they were using dates

Cat Face Joe
Feb 20, 2005

goth vegan crossfit mom who vapes



cjs: guy who is retiring next week just sent out his farewell email with over 100 people on it, intercompany, vendors, customers. the reply alls have already started to roll in

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost

tef posted:


that, and, well, you don't really troubleshoot race conditions, that just ends up in a game of whack a mole. you gotta just write something that enforces determinism from the outset

if you want a spearhead of determinism in a giant roiling mess of bullshit one successful thing ive seen was enforcing an associativity and commutativity property w property tests

dioxazine
Oct 14, 2004

cls: crushed a finger on a doorjamb. ow

PokeJoe
Aug 24, 2004

hail cgatan


Cat Face Joe posted:

cjs: guy who is retiring next week just sent out his farewell email with over 100 people on it, intercompany, vendors, customers. the reply alls have already started to roll in

He knew what he was doing lol

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


cjs: struggling to learn gcloud stuff :ignorance:

HamAdams
Jun 29, 2018

yospos
cjs: didn't do poo poo today, probs will do the same tomorrow

Armitag3
Mar 15, 2020

Forget it Jake, it's cybertown.


HamAdams posted:

cjs: didn't do poo poo today, probs will do the same tomorrow

if it weren’t for standup this would be everyday

hbag
Feb 13, 2021

Cybernetic Vermin posted:

cjs: somehow got the funding to hire my favorite student to do a phd, hype as hell, they are way better than me at the thing i want to do

i got to class a little early today and in the class that was there before me the professor had a slide up about how he needs people to... play video games for an hour+ and then answer a questionaire for his phd
like their assignment was literally "play video games lol"

Cybernetic Vermin
Apr 18, 2005

hbag posted:

i got to class a little early today and in the class that was there before me the professor had a slide up about how he needs people to... play video games for an hour+ and then answer a questionaire for his phd
like their assignment was literally "play video games lol"

this student actually knows group theory and will be tasked with doing group theory though. which might honestly be a better deal as far as committing five years of your life goes.

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
was it a specific game or

hbag
Feb 13, 2021

Jonny 290 posted:

was it a specific game or

no but i think there was an emphasis on "multiplayer"

dioxazine
Oct 14, 2004

space station 13 counts, right?

Adbot
ADBOT LOVES YOU

dioxazine
Oct 14, 2004

njs: don't even start until next week and my future boss is already asking me about going to conferences

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply