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
abraham linksys
Sep 6, 2010

:darksouls:

Soricidus posted:

fibers

there’s a reason java is moving towards reintroducing something like green threads, rather than jumping on the async/await bandwagon

it’s all equivalent deep down ofc

this is like my least favorite thing about leaving the safe single-threaded confines of js

async/await on a single-threaded event loop meant it was extremely easy to reason about concurrency because you knew, if you were in a sync function accessing some poo poo, that within that function it was absolutely impossible for it to change out from under you. the await breakpoints then told you "on the other side of this, something might have changed." it was nice! sure you had "colored functions" or whatever that stupid blog post is about, but in practice js has been async by default for i/o for years, it's other languages who are having trouble catching up (see: kotlin coroutines are kinda pointless because none of the jvm db libraries and only a handful of http servers/clients support them)

now everyone suddenly wants this green thread stuff which i thought were thoroughly argued against here in a compelling way. when you have threads (green or non-green), you suddenly find yourself having to do poo poo like create awkward-to-use queues to prevent unwanted concurrency, and i hate this! threads are totally fine for cpu-intensive poo poo, but in your normal i/o-bound web context just give me one drat thread and an event loop with async/await or yield or whatever

i don't really know where .NET async/await lands with all this? i assume given it's a non-plang you have all sorts of threading options, but i'm unclear if, for example, asp.net gets a (pooled) thread per request or if it single-threads everything synchronous

i still haven't managed to figure out erlang, i dunno, maybe it'd make me see the light on this poo poo, but i'm skeptical. i assume they have like... patterns for abstracting over state so you never actually want shared state and thus it doesn't matter, or something

Adbot
ADBOT LOVES YOU

Nomnom Cookie
Aug 30, 2009



redleader posted:

now all the jvm has to reinvent is supervisor trees and its convergence towards erlang will be complete

erlang PLUS seconds-long STW GCs :eng101:

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.
Erlang is very very deep in "don't communicate by sharing state, share state by communicating" territory.

e: also all GC is very local

Nomnom Cookie
Aug 30, 2009



abraham linksys posted:

this is like my least favorite thing about leaving the safe single-threaded confines of js

async/await on a single-threaded event loop meant it was extremely easy to reason about concurrency because you knew, if you were in a sync function accessing some poo poo, that within that function it was absolutely impossible for it to change out from under you. the await breakpoints then told you "on the other side of this, something might have changed." it was nice! sure you had "colored functions" or whatever that stupid blog post is about, but in practice js has been async by default for i/o for years, it's other languages who are having trouble catching up (see: kotlin coroutines are kinda pointless because none of the jvm db libraries and only a handful of http servers/clients support them)

now everyone suddenly wants this green thread stuff which i thought were thoroughly argued against here in a compelling way. when you have threads (green or non-green), you suddenly find yourself having to do poo poo like create awkward-to-use queues to prevent unwanted concurrency, and i hate this! threads are totally fine for cpu-intensive poo poo, but in your normal i/o-bound web context just give me one drat thread and an event loop with async/await or yield or whatever

i don't really know where .NET async/await lands with all this? i assume given it's a non-plang you have all sorts of threading options, but i'm unclear if, for example, asp.net gets a (pooled) thread per request or if it single-threads everything synchronous

i still haven't managed to figure out erlang, i dunno, maybe it'd make me see the light on this poo poo, but i'm skeptical. i assume they have like... patterns for abstracting over state so you never actually want shared state and thus it doesn't matter, or something

seriously, just create 3000 threads and do thread-per-request, it’s not 1999 anymore. your app can’t handle 3000 concurrent anyway

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

abraham linksys posted:

this is like my least favorite thing about leaving the safe single-threaded confines of js

async/await on a single-threaded event loop meant it was extremely easy to reason about concurrency because you knew, if you were in a sync function accessing some poo poo, that within that function it was absolutely impossible for it to change out from under you. the await breakpoints then told you "on the other side of this, something might have changed." it was nice! sure you had "colored functions" or whatever that stupid blog post is about, but in practice js has been async by default for i/o for years, it's other languages who are having trouble catching up (see: kotlin coroutines are kinda pointless because none of the jvm db libraries and only a handful of http servers/clients support them)

now everyone suddenly wants this green thread stuff which i thought were thoroughly argued against here in a compelling way. when you have threads (green or non-green), you suddenly find yourself having to do poo poo like create awkward-to-use queues to prevent unwanted concurrency, and i hate this! threads are totally fine for cpu-intensive poo poo, but in your normal i/o-bound web context just give me one drat thread and an event loop with async/await or yield or whatever

i don't really know where .NET async/await lands with all this? i assume given it's a non-plang you have all sorts of threading options, but i'm unclear if, for example, asp.net gets a (pooled) thread per request or if it single-threads everything synchronous

i still haven't managed to figure out erlang, i dunno, maybe it'd make me see the light on this poo poo, but i'm skeptical. i assume they have like... patterns for abstracting over state so you never actually want shared state and thus it doesn't matter, or something

Just hold the state in its own thread. Then communicate between threads by dropping messages in thread safe queues. Easy.

Nomnom Cookie
Aug 30, 2009



node devs are so stockholmed they convinced the rest of the world that being able to use multiple cores is bad, actually. it’s very frustrating

abraham linksys
Sep 6, 2010

:darksouls:

leper khan posted:

Just hold the state in its own thread. Then communicate between threads by dropping messages in thread safe queues. Easy.

yeah i should probably be better at figuring out how to structure things like this

i built a lil websocket chat server in kotlin and just threw a bunch of ConcurrentHashMaps at it and hoped for the best, i dunno. like, i use them to store "which rooms exist, and which users are in that room," which has to be saved somewhere. i dunno how you make something like that into thread-local state

in javascript, i would be able to hold state like that in a singleton or whatever and never have to worry about it being concurrently accessed

Beamed
Nov 26, 2010

Then you have a responsibility that no man has ever faced. You have your fear which could become reality, and you have Godzilla, which is reality.


Nomnom Cookie posted:

node devs are so stockholmed they convinced the rest of the world that being able to use multiple cores is bad, actually. it’s very frustrating

i dont know if it's relevant to the current discussion but this is very true, one of the dudes who worked on spotify spent ages soapboxing about how node.js was way more efficient than every other language, because you didnt have to worry about anything

Bloody
Mar 3, 2013

blindly throwing threads around is basically the same as using goto for flow control. maybe worse

Asleep Style
Oct 20, 2010

Bloody posted:

blindly throwing threads around is basically the same as using goto for flow control. maybe worse

it's rude to be talking about my posting like that

Shaggar
Apr 26, 2006

abraham linksys posted:

this is like my least favorite thing about leaving the safe single-threaded confines of js

async/await on a single-threaded event loop meant it was extremely easy to reason about concurrency because you knew, if you were in a sync function accessing some poo poo, that within that function it was absolutely impossible for it to change out from under you. the await breakpoints then told you "on the other side of this, something might have changed." it was nice! sure you had "colored functions" or whatever that stupid blog post is about, but in practice js has been async by default for i/o for years, it's other languages who are having trouble catching up (see: kotlin coroutines are kinda pointless because none of the jvm db libraries and only a handful of http servers/clients support them)

now everyone suddenly wants this green thread stuff which i thought were thoroughly argued against here in a compelling way. when you have threads (green or non-green), you suddenly find yourself having to do poo poo like create awkward-to-use queues to prevent unwanted concurrency, and i hate this! threads are totally fine for cpu-intensive poo poo, but in your normal i/o-bound web context just give me one drat thread and an event loop with async/await or yield or whatever

i don't really know where .NET async/await lands with all this? i assume given it's a non-plang you have all sorts of threading options, but i'm unclear if, for example, asp.net gets a (pooled) thread per request or if it single-threads everything synchronous

i still haven't managed to figure out erlang, i dunno, maybe it'd make me see the light on this poo poo, but i'm skeptical. i assume they have like... patterns for abstracting over state so you never actually want shared state and thus it doesn't matter, or something

so wrt ASP.net specifically, afaik its all single threaded per request with threads taken from the pool. Long running tasks and spawning additional threads from within a request thread are definitely possible, but are strongly discouraged because the application might get nuked at any time and your task/thread will lose all its state. java servlets work the same way afaik

When writing asp.net you treat the code as if each request is totally independent of any other request (because it mostly is) and you dont really need to worry about them interacting beyond normal things like dont leak resources or dont create long running tasks.

Nomnom Cookie
Aug 30, 2009



Beamed posted:

i dont know if it's relevant to the current discussion but this is very true, one of the dudes who worked on spotify spent ages soapboxing about how node.js was way more efficient than every other language, because you didnt have to worry about anything

check out the top post of this page

Nomnom Cookie
Aug 30, 2009



Shaggar posted:

so wrt ASP.net specifically, afaik its all single threaded per request with threads taken from the pool. Long running tasks and spawning additional threads from within a request thread are definitely possible, but are strongly discouraged because the application might get nuked at any time and your task/thread will lose all its state. java servlets work the same way afaik

When writing asp.net you treat the code as if each request is totally independent of any other request (because it mostly is) and you dont really need to worry about them interacting beyond normal things like dont leak resources or dont create long running tasks.

the obvious objection here being what about shared state? because thats what its about, doing some terrible poo poo with shared mutable state. ofc you know, but for the benefit of anyone who's not aware, big boy languages provide facilities to access databases, and that is where the shared mutable state goes. not in a blob squatting inside your process

Shaggar
Apr 26, 2006
depends on how the state is partitioned. If its chat data in a test app having it live in memory on your server is totally fine cause u aren't hosting multiple instances and you dont care if the data is lost when the process restarts.

I did a chat app to try out websockets in signalr forever ago and I did litterrally the exact same thing, rpetty much just using a ConcurrentQueue for a chat buffer and ConcurrentDictionary for user state. It was one chat room and it all disappeared if the thing recycled, but it worked fine. Authentication was done w/ twitter so I didn't really need to worry about user account persistence.

if I was gonna persist it across multiple instances i'd use some kind of db.

but the bigger point is that the storage really shouldn't matter to the actual application code because you can always swap it to something else later if things are designed right. the application code (controller/hub) should just be getting some interface injected into it and then ur code is agnostic to the implementation. Your application code should not be worrying about resource contention because it should be handled in the storage implementation.

idk how things work in node or w/e.

Nomnom Cookie
Aug 30, 2009



thats true. i forgot about abstraction, current job is python and its damaged me

Bloody
Mar 3, 2013

asp.net is basically perfect

Beamed
Nov 26, 2010

Then you have a responsibility that no man has ever faced. You have your fear which could become reality, and you have Godzilla, which is reality.


Bloody posted:

asp.net core is basically perfect

PIZZA.BAT
Nov 12, 2016


:cheers:


Bloody posted:

asp.net is basically perfect

shame about the whole microsoft thing but yeah

redleader
Aug 18, 2005

Engage according to operational parameters

Bloody posted:

asp.net is basically perfect

it's ok i guess

redleader
Aug 18, 2005

Engage according to operational parameters
the js concurrency model is unironically the best thing in the language. if js had been created with a more traditional concurrency model (all threads all the time, molest shared and ui state as you will) then i'd probably have taken a long walk off a short pier by now

abraham linksys
Sep 6, 2010

:darksouls:

redleader posted:

the js concurrency model is unironically the best thing in the language. if js had been created with a more traditional concurrency model (all threads all the time, molest shared and ui state as you will) then i'd probably have taken a long walk off a short pier by now

y'know, i suppose this is a big difference, the model makes way more sense in a client side environment where you're mutating ui state than in a backend where your mutable state is likely going to be in some kind of database

this is also true of anything with a "ui thread" i guess; don't most ios apps just use a single thread by default except for background services (i know i've seen a lot of articles like "how to move your slow poo poo off the ui thread" which makes me think it's all there by default atl east)

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Yeah, most ui frameworks involve a single thread responsible for both changing the state of ui components and handing input messages on those components from the os. This is very convenient if you're writing ui components, because it means those components are essentially always single-threaded.

Most client-app-developer's exposure to threads is "I want to do something blocking and/or cpu intensive, without having my ui lock up because the ui thread isn't doing those things any more".

Chalks
Sep 30, 2009

Shaggar posted:

so wrt ASP.net specifically, afaik its all single threaded per request with threads taken from the pool. Long running tasks and spawning additional threads from within a request thread are definitely possible, but are strongly discouraged because the application might get nuked at any time and your task/thread will lose all its state. java servlets work the same way afaik

When writing asp.net you treat the code as if each request is totally independent of any other request (because it mostly is) and you dont really need to worry about them interacting beyond normal things like dont leak resources or dont create long running tasks.

if you do need to spin up a thread in your web request you can use QueueBackgroundWorkItem which creates a thread that the application will wait for when recycling instead of nuking it like a normal thread

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


redleader posted:

bbbut how can you ~scale~ without async

hahaha threadripper go brrrr

Aramoro
Jun 1, 2012




We're having a bit of an async night mare just now. We have a system where users can save records and doing that might start a process that causes n other records to be saved. Now previously this has always been synchronous, you press save and everything gets save, easy. Now because our customers are idiots what they love to do is create processes with hundreds of stages and decision points in them. This was making things slow so we had to fix it. Now all this record saving was written in command pattern so it's actually really easy to just queue them and do it asynchronously, as long as you validate the process before you queue it then it can't really fail, so all good. This is where we made out first mistake, we added a screen for admins to see how async processing was going ,just in case anything was stuck. This might live in this queue for 20 seconds sometimes as it churns through creating everything. Then our business analysts sees this and has a brilliant idea...'I want to edit them' what do you mean edit them? 'I want to open up a queued request and change the values in it'

Everything would be so much simpler is business analysts/product managers didn't exist or at least stopped having 'good ideas'

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


preemptive :rip: for the disaster you are about to have visited upon you

this is why I hate workflow tooling. even if it starts simple ("we only need two forms") you will end up with a spiderweb disaster in no time

Aramoro
Jun 1, 2012




Powerful Two-Hander posted:

preemptive :rip: for the disaster you are about to have visited upon you

this is why I hate workflow tooling. even if it starts simple ("we only need two forms") you will end up with a spiderweb disaster in no time

As designed the workflow stuff is fine, you open the BPNM designer thingy we made and create the workflow, a process here, a decision there etc all great. When you create a record rules determine which workflow to choose. One of our resellers decided that the bit that picked the right workflow was a bit too much effort, so they create 1 workflow for all types of records for their customers (presumably using billable consultant hours). So instead of 20 workflows you have 1 workflow that reads from the record and goes through some hoops to make it work. We don't really know how they even do this as some of their workflows have thousands of stages and you cannot even open them in the editor, they must be doing it manually in SQL.

DrPossum
May 15, 2004

i am not a surgeon

Nomnom Cookie posted:

the obvious objection here being what about shared state? because thats what its about, doing some terrible poo poo with shared mutable state. ofc you know, but for the benefit of anyone who's not aware, big boy languages provide facilities to access databases, and that is where the shared mutable state goes. not in a blob squatting inside your process

yah but then you get some guy who's not done anything outside of redux just moved to your mobile team and then it's like "content providers? sounds like someone reinvented redux. watch me now throw a fit if you don't go along with my plan to implement redux in loving android"

Shaggar
Apr 26, 2006

Chalks posted:

if you do need to spin up a thread in your web request you can use QueueBackgroundWorkItem which creates a thread that the application will wait for when recycling instead of nuking it like a normal thread

I would not rely on this for anything critical but its fine for best effort stuff.

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

Powerful Two-Hander posted:

preemptive :rip: for the disaster you are about to have visited upon you

this is why I hate workflow tooling. even if it starts simple ("we only need two forms") you will end up with a spiderweb disaster in no time

you can nip this one in the bud by doing design iterations on paper. A colleague of mine did this for designing a system for air ticket vendors and after a week of iterating designs they had one management felt comfortable with and the people who would actually use the system felt wouild cover their bases.

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Boiled Water posted:

you can nip this one in the bud by doing design iterations on paper. A colleague of mine did this for designing a system for air ticket vendors and after a week of iterating designs they had one management felt comfortable with and the people who would actually use the system felt wouild cover their bases.

agreed. in my case, I've worked with my main business users for like 12 years now so I also have a lot of leeway with them and if I say "I know you say you want to have 25 sub statuses to provide 'MIS' but are you honestly going to populate them when you currently don't even keep the one single status you have up to date?" they usually listen

or I just ignore them and do what I think makes sense and we iterate (or just deploy anyway #yolo #agile #neverwritespecs)

Cold on a Cob
Feb 6, 2006

i've seen so much, i'm going blind
and i'm brain dead virtually

College Slice

Shaggar posted:

so wrt ASP.net specifically, afaik its all single threaded per request with threads taken from the pool. Long running tasks and spawning additional threads from within a request thread are definitely possible, but are strongly discouraged because the application might get nuked at any time and your task/thread will lose all its state. java servlets work the same way afaik

When writing asp.net you treat the code as if each request is totally independent of any other request (because it mostly is) and you dont really need to worry about them interacting beyond normal things like dont leak resources or dont create long running tasks.

yep, you just basically be careful with global state which you only encounter if you do it on purpose, like with a static cache or something registered as singleton in your di container

Aramoro posted:

This is where we made out first mistake, we added a screen for admins to see how async processing was going ,just in case anything was stuck. This might live in this queue for 20 seconds sometimes as it churns through creating everything. Then our business analysts sees this and has a brilliant idea...'I want to edit them' what do you mean edit them? 'I want to open up a queued request and change the values in it'

Everything would be so much simpler is business analysts/product managers didn't exist or at least stopped having 'good ideas'

lol literally had this happen before, so this time when i was tempted to build a screen to show the queues i changed my mind and built an email alert instead

MononcQc
May 29, 2007

abraham linksys posted:

i still haven't managed to figure out erlang, i dunno, maybe it'd make me see the light on this poo poo, but i'm skeptical. i assume they have like... patterns for abstracting over state so you never actually want shared state and thus it doesn't matter, or something

text me :wink:

Shaggar posted:

depends on how the state is partitioned. If its chat data in a test app having it live in memory on your server is totally fine cause u aren't hosting multiple instances and you dont care if the data is lost when the process restarts.

I did a chat app to try out websockets in signalr forever ago and I did litterrally the exact same thing, rpetty much just using a ConcurrentQueue for a chat buffer and ConcurrentDictionary for user state. It was one chat room and it all disappeared if the thing recycled, but it worked fine. Authentication was done w/ twitter so I didn't really need to worry about user account persistence.

if I was gonna persist it across multiple instances i'd use some kind of db.

but the bigger point is that the storage really shouldn't matter to the actual application code because you can always swap it to something else later if things are designed right. the application code (controller/hub) should just be getting some interface injected into it and then ur code is agnostic to the implementation. Your application code should not be worrying about resource contention because it should be handled in the storage implementation.

idk how things work in node or w/e.
This is like folks going "banking apps use ACID databases and transactions" as if it were an obvious truth when in fact they rely on complex distributed append-only ledgering systems.

Chat apps (after IRC and ignoring a single instance corporate XMPP thing for a few hundred employees) are one of the app styles where you can't just keep state in one node in memory at a greater scale because if you have to contend with:
- not disconnecting everyone at once when doing a rolling upgrade
- not losing all in-flight messages that were not yet delivered
- scaling things up is never always obvious: per user means your rooms/channels have to be distributed, per room/channel means you can get weird growth/scaling patterns and DMs are all distributed

regardless any of the above, the biggest challenge of chat apps is always presence, which requires consistently tracking/polling all users and distributing that result to all other users, all the time.

MononcQc
May 29, 2007

Aramoro posted:

Now all this record saving was written in command pattern so it's actually really easy to just queue them and do it asynchronously, as long as you validate the process before you queue it then it can't really fail, so all good. This is where we made out first mistake, we added a screen for admins to see how async processing was going ,just in case anything was stuck. This might live in this queue for 20 seconds sometimes as it churns through creating everything. Then our business analysts sees this and has a brilliant idea...'I want to edit them' what do you mean edit them? 'I want to open up a queued request and change the values in it'

"no"

also you gotta wonder what they see in that queue that makes them want to edit things, and whether the way that info is presented is any different from what they get elsewhere. It's possible that having them want to edit what's in the queue is just because the way it's presented triggers a use case they have but had no good way of conceptualizing before.

Cold on a Cob
Feb 6, 2006

i've seen so much, i'm going blind
and i'm brain dead virtually

College Slice

MononcQc posted:

"no"

also you gotta wonder what they see in that queue that makes them want to edit things, and whether the way that info is presented is any different from what they get elsewhere. It's possible that having them want to edit what's in the queue is just because the way it's presented triggers a use case they have but had no good way of conceptualizing before.

in my case, without getting into the business-specific details, it was more "this message failed to validate or parse due to an easily fixable error, instead of bouncing a failure message back and forcing the entire process to start again at the source, let us just tweak the message and continue the process"

when the process involves hitting external data sources at various stages you can kinda understand why they want to do this but there were obviously better solutions like applying more validations and parsing checks earlier in the process

Aramoro
Jun 1, 2012




MononcQc posted:

"no"

also you gotta wonder what they see in that queue that makes them want to edit things, and whether the way that info is presented is any different from what they get elsewhere. It's possible that having them want to edit what's in the queue is just because the way it's presented triggers a use case they have but had no good way of conceptualizing before.

A bit of both really, what Cold on a Cob said and this. Like seeing something creates the Use Case for it. We've being doing it synchronously for 15 years but now they see the opportunity to break things in a way they had not considered.

Another side is often they're tying to workaround another issue in the system. So instead of telling us the problem they'll say 'hey make this editable' or 'lets make this number field into text' without telling us why. It's almost always to workaround some behaviour in the system and this is the way they've thought of to it in the cheapest way possible, or so they think.

handle
Jan 20, 2011

little bit of a panic attack. i'm making changes in our POS system after the vendor went out of business.
  • PHP 5
  • all editable sources are decoded from ionCube files
  • fully procedural programming style
  • constant redirections through Header("Location: butt"); (was this a thing??)
  • all output:
    code:
    printf("<html><table style='all: inline;'><a onclick='window.location=\"reinventing_the_wheel.cry\"'>no $_POST, only $_GET</a></table></html>\n");
  • database queries through string concatenation, no sanitizing, all errors fatal
  • ~40 files, average 2000 lines each
like even though users can switch between development/stable/vanilla anytime, i don't even know what the gently caress to prioritize or document when AFAIK I'm the only programming-inclined person at work.

counting my blessings:
  1. my boss funds this
  2. my coworkers are endlessly patient
  3. decoded files have variable names
  4. development environment on my own machine, source control, versioning, etc.

PIZZA.BAT
Nov 12, 2016


:cheers:


why the gently caress does every single customer have that one guy who insists on using vim for everything but they absolutely suck at using it :cripes:

i've been watching this guy bungle around in a shared webex session for hours

PIZZA.BAT
Nov 12, 2016


:cheers:


don't you understand i'm so much faster because my finger motion is so EFFICIENT now!!

*watches him struggle to remember how to enter a line break for 30 seconds*

Adbot
ADBOT LOVES YOU

Cold on a Cob
Feb 6, 2006

i've seen so much, i'm going blind
and i'm brain dead virtually

College Slice

PIZZA.BAT posted:

why the gently caress does every single customer have that one guy who insists on using vim for everything but they absolutely suck at using it :cripes:

i've been watching this guy bungle around in a shared webex session for hours

cargo culting after reading thousands of articles and books about super-productive 10xers

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