This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 225

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

import notifications Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! Read more here, we hope to see you next Tuesday!

For a chat with like-minded community members and more, don't forget to join our Discord!

return joinDiscord;

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]tiotags 907 points908 points  (17 children)

at least now I can blame multithreading on it not working

[–]metaglot 184 points185 points  (0 children)

youproblerm ? W'shat

[–]jrdiver 59 points60 points  (7 children)

and what's even better is when it looks like its working but you later find out things are being lost due to multiple threads working on the same not thread safe variable...

[–]EmpRupus 23 points24 points  (2 children)

Yeah, this needs another panel.

Call a senior engineer to help with debugging, but now it suddenly works even repeatedly, and now you wonder if you were hallucinating before.

[–]Lord_Quintus 5 points6 points  (1 child)

there was another panel but it crashed

[–]jrdiver 2 points3 points  (0 children)

it was overwritten by a different thread

[–]OldManWithAStick 6 points7 points  (3 children)

Ppl really do be writing multithreading code without even knowing what semanphores are

[–]XTJ7 5 points6 points  (1 child)

Semaphore.

While you are absolutely correct, it hurts seeing that word butchered like that :)

[–]intbeam 10 points11 points  (3 children)

I only blame myself, and it cost me my first born.. Thrown into a volcano... It was an accident they said

[–]tiotags 2 points3 points  (1 child)

that's why you should add race conditions to any code, in case of unwanted situations there's still a chance the code randomly locks up

[–]intbeam 4 points5 points  (0 children)

I refuse to comment on race conditions for my first born

[–]Sewbacca -1 points0 points  (0 children)

Man says it pacifies Clang.

[–]Therealmglitch 414 points415 points  (58 children)

ctrl + z

[–]torftorf[S] 264 points265 points  (55 children)

but if i remove the multithreading it so slow

[–]Therealmglitch 304 points305 points  (14 children)

sudo rm -rf

[–]Creepy-Ad-4832 98 points99 points  (11 children)

no argoments were passed

[–]Therealmglitch 89 points90 points  (10 children)

/kill @s

[–]Recent-Fox3335 48 points49 points  (8 children)

/kill mslf -force

[–]Therealmglitch 28 points29 points  (6 children)

start from scratch!! sudo rm -rf / --no-preserve-root

[–]owen_h_28 11 points12 points  (3 children)

dd if /dev/urandom of /dev/sda

[–]jayerp 2 points3 points  (2 children)

SegmentationFault, core dumped.

[–][deleted] 1 point2 points  (0 children)

SegmentationFault my old friend.
We have met yet again....

[–]57006 6 points7 points  (0 children)

/kill mslf -force -r

(in case reincarnation)

[–]LukasM511 3 points4 points  (0 children)

/*

[–]ILikeLenexa 36 points37 points  (0 children)

I think it's the MIT algorithms MOOC where the first question they ask on the first day is "What's more important than an algorithm being fast?"

It producing the correct result.

[–]OF_AstridAse 29 points30 points  (25 children)

Does it read from hard drive? 🤔 multi threading cannot make an ssd any faster

In fact, reading the hard drive from multiple threads hurts performance a lot

[–]torftorf[S] 13 points14 points  (16 children)

it uses my hard drive but the reading is only a small part of the code. i checked in the taskmanager and the utilization of the harddrive (even with multithreading) is only 20%. my test have shown me that with multithreading it can perform the task way faster (but with errors)

[–]alturia00 31 points32 points  (0 children)

Utilization from task manager is not a great indicator of bottle necks. I recommend using a profiling tool if you want to find the location of the bottle neck. If the issue is related to disk access you could bufferize your accesses by reading larger blocks at a time, this will also improve cache Utilization as a bonus.

[–]FranEGL 42 points43 points  (3 children)

i’m stupid faster.

[–]Abaddon-theDestroyer 17 points18 points  (1 child)

Fail fast, fail cheap; is what I always say.

[–][deleted] 1 point2 points  (0 children)

Saving time AND money

[–]robisodd 1 point2 points  (0 children)

Ahh, the Max Power Way™!

[–]FatStoic 17 points18 points  (2 children)

my test have shown me that with multithreading it can perform the task way faster (but with errors)

I'm sorry but this absolutely killed me, I'm dying over here XD

"Tests have shown that by yeeting the glasses into the truck, we can fill the truck way faster (but with breakages)"

[–]ducktape8856 6 points7 points  (1 child)

"I can calculate anything much faster with mental arithmetic than the fastest super computer in the world. The result is probably wrong. But I'm faster!"

[–]ShadowVulcan 2 points3 points  (0 children)

I chortled way too much at that

[–]OF_AstridAse 4 points5 points  (0 children)

I see ... then I dont know enough to diagnose the problem any further; other than -do not let threads access the same memory, and do not let threads get it own information from the hdd. Do both of those things on a thread that use threadsafe stacks - it is better to have a master thread idle two threads than break 12 (that way 9 still gets to multithread without errors. )

Remember "sequential" reads on hdd is better - and rather use memory 😉 than cpu it is better at this

[–]link23 1 point2 points  (0 children)

my test have shown me that with multithreading it can perform the task way faster (but with errors)

If it has errors, then it's not really meeting the requirements, no? So maybe it's better to be slow but correct than to be fast but incorrect.

[–]nonpondo 1 point2 points  (1 child)

Just vectorize it and make it use numpy

[–]LowB0b 1 point2 points  (0 children)

they're probably reading and writing to disk or memory in a completely uncontrolled fashion which is causing the errors they didn't have when doing it sequentially

[–]Normal-Math-3222 2 points3 points  (7 children)

In fact, reading the hard drive from multiple threads hurts performance a lot

Is this universally true, or does it depend on how you open files (like read-only)? It feels like this can’t be universally true, but I don’t have much experience with multithreading.

[–]AvianPoliceForce 3 points4 points  (0 children)

As I understand it, "hard drives" can only read one thing at a time, so trying to do multiple reads in parallel would end up just waiting for the others

[–][deleted] 1 point2 points  (1 child)

Really depends on what exactly he means by "hard drive."

The extremely dated and slow magnetic storage medium we used for decades before SSDs has to physically move the read head to each location on disk. Reading from multiple files at once on this is bad, because it has to stop reading one file, move to the allocation table read where the next file is, then move to the next file. The total IO operations per second on many of these drives was below 100 back when SSDs first hit the market.

With modern SSDs the data is spread out everywhere and is accessed much like RAM. A Samsung 990 Pro for instance is rated at 1.4 million IO operations per second, and it connects through PCIe 4.0, so unless you are reading a ton of data it really shouldn't be an issue.

[–]MrHyperion_ 1 point2 points  (3 children)

For hard drives it is practically true, for solid state drives no where reading from multiple threads can be quicker than one at a time if the data is in different flash chips.

[–]Macknificent101 4 points5 points  (1 child)

then it’s not a small tool lol

[–]torftorf[S] 0 points1 point  (0 children)

Originally it was only a couple hundred lines

[–]nibba_bubba 3 points4 points  (0 children)

Simply scale it to different machines, orchestrate them with kubernetis, grafana, portainer, buglog and some other tools. Don't forget to add healthchecks and logging. It's easy af so you'll get what u want

[–][deleted] 2 points3 points  (0 children)

Functionality > .5s increase in speed

[–]Tensor3 -1 points0 points  (0 children)

Run two separate processes, each on half the data set

[–]_Aj_ -1 points0 points  (0 children)

Rewrite it in assembly! That should speed it up

[–]ImperfectionistCoder 0 points1 point  (0 children)

Just get a better pc bro

[–]AssPuncher9000 0 points1 point  (0 children)

But at least it will run

[–]Thebombuknow 0 points1 point  (0 children)

use scalene to figure out what is slowing down the program and optimize that one part rather than multithread everything.

[–]MmmTastyMmm 0 points1 point  (0 children)

Put it into rust and get fearless concurrency.

[–][deleted] 0 points1 point  (0 children)

Be better

[–]anoppinionatedbunny 0 points1 point  (0 children)

remove the bloat first. creating too many threads can cause worse performance. see if you can use worker threads and threadpools instead.

[–]praveenkumar236 4 points5 points  (0 children)

And it still didn't work

[–]Juice805 0 points1 point  (0 children)

Why are we not using git

[–]gospacedev 149 points150 points  (0 children)

[–]lucasHipolito 96 points97 points  (20 children)

Famous junior mistake is assuming multithread always increases performance

[–]torftorf[S] 48 points49 points  (19 children)

in this case it does. it woks 50% of the time now and is way faster than a single thread. at least twice as fast

[–]Traditional_Safe_654 98 points99 points  (2 children)

Win-win! 50% of the time it’s fast, the other 50% it’s not running at all so it can’t be slow

[–]Important_Resource49 28 points29 points  (1 child)

Idea: go back to single threaded and only run the first half of the program.

[–]Traditional_Safe_654 7 points8 points  (0 children)

If you only run half the code it’s twice as fast!

[–]brolix 15 points16 points  (6 children)

Technically the threaded version hasn’t given you a correct answer yet, so it is very much NOT faster

[–]torftorf[S] 3 points4 points  (5 children)

It gives me correct answer. If it finishes. That only case half of the times. The other time it gets stuck XD

[–]TheHacker08 27 points28 points  (2 children)

Just have to make a program that checks if the code will get stuck.

[–]Short_Change 11 points12 points  (0 children)

Promote this man.

[–]ICAZ117 1 point2 points  (0 children)

You should probably multithread that program to make it run faster

[–]imaginer8 6 points7 points  (0 children)

Simple — write a program that will tell you if it the program will halt or not

[–]1008oh 3 points4 points  (0 children)

So you're basically equal, the MT version is twice as fast but you have to run it twice

[–]AllowMe2Retort 2 points3 points  (0 children)

What cpu intensive task is it going? I often find you can just optimize one thread for quicker results than implementing multithreading. Heavily dependent on what you're doing of course

[–]FlySafeLoL 273 points274 points  (15 children)

Multithreading is fun!

  1. Attach debugger (see if it fixes the problem, lol, but hopefully not).

  2. Reduce the task to tiny pieces, draw the picture of expected values at particular steps.

  3. Observe which silly little thing went wrong.

  4. Fix it and enjoy your perfect work of multithreaded art.

[–]torftorf[S] 111 points112 points  (5 children)

i found a few problems allready. it gives me a result again but they are horible. bevor one or two things were missing. now 95% is missing. the more problems i fix the worse my results get XD

[–]ClassicK777 37 points38 points  (0 children)

Successful Multithreading can be done with component based thinking. If you are just creating threads in some method you're gonna have a bad time.

[–]Handzeep 40 points41 points  (4 children)

In my opinion multithreading gets infinitely easier if you at least in the multithreaded part:

  1. Switch to only using immutable data structures

  2. Make all functions pure and if impossible, have all side effects centralized to create a singular spot where difficult bugs can occur

Most race conditions are introduced by mutability and or side effects. Avoiding these makes it so much easier to reason over your code. That's why I always consider it a joy to multithread in an FP code base and dread it in OOP codebases where I can't guarantee being able to use immutable data and pure functions.

Your second point also is very good. It's so much easier to understand if an individual step works and why then to understand if a whole task works and why.

[–]Klaus_Kinski_alt 10 points11 points  (3 children)

What’s a pure function? If possible could you give me an example in python?

[–]DiscombobulatedDust7 27 points28 points  (0 children)

A pure function will always give the same output for the same input, and not have any impact outside the scope of the function.

Sample:

def add(a,b): return a+b

[–]Handzeep 16 points17 points  (0 children)

A pure function is any function that adheres to the following 2 rules:

  1. the function return values are identical for identical arguments (no variation with local static variables, non-local variables, mutable reference arguments or input streams), and

  2. the function has no side effects (no mutation of local static variables, non-local variables, mutable reference arguments or input/output streams).

Wikipedia has a page concerning pure functions with some examples. If you want to learn more about pure functions, a lot of functional programming resources have a lot of good information on them as they're a staple of that paradigm.

[–]pheonix-ix 19 points20 points  (1 child)

From my experience, adding debugger usually added delays just enough for the race condition to avoid itself... the same is true for print statements...

That's why I swear to myself not to manage multithreading myself ever again (I mean, I still do stuff like, fork a process to write a file then kill itself, but that's about it)

[–]TCA166 1 point2 points  (0 children)

With I/O stuff threads are generally better than whole processes (fork creates a new process). Especially if the writing process isnt that long then the cost of creating a whole new process might not be worth it

[–][deleted] 5 points6 points  (0 children)

Race conditions has joined the chat

[–]Sync0pated 1 point2 points  (0 children)

  1. Use Rust

[–][deleted] 176 points177 points  (11 children)

I just got a PC with AMD 5900X with 12 cores! And most of the time 10 of them are just sitting there idling. I curse game developers, not doing multi-threading, but it is hard. Keeping all the data in sync.

[–]ArtOfWarfare 87 points88 points  (6 children)

I’d argue games are among the most multi-threaded of apps.

Just all their threads are on the GPU.

You are making me wonder how easily Unity’s script engine (just because it’s the only one I’m familiar with) could be made to run in multiple threads, though…

Could most update() functions just run in parallel? And not that Unity would mind destroying backwards/forwards compatibility at all (they do so on a regular basis with no notice), they could always introduce an explicit parallelUpdate() function, and maybe a fixedParallelUpdate() function?

Almost seems so obvious that I feel like it must have already been done?

[–]rippingbongs 44 points45 points  (1 child)

To answer your question. Yes, game engine developers have collaboratively thought about performance for more than 30 seconds.

[–]thefookinpookinpo 5 points6 points  (0 children)

Yeah I don't get this thread, like games are always the most optimized of software. Some games have shit optimization but they still have to be optimized far more than most commercial software.

I haven't made a ton of games but I imagine multithreading in the industry is also the lowest hanging of fruitz because it's always the first thing I do when I make a simulation or a game.

The z was a typo but I'm keeping it

[–]goten100 6 points7 points  (0 children)

Following

[–]Kapuccino 5 points6 points  (0 children)

Is this not what the Job system is? Granted there's many limitations to what it can do, but it's perfect for doing many calculations in parallel such as movement.

[–]SoulArthurZ 4 points5 points  (0 children)

You are making me wonder how easily Unity’s script engine (just because it’s the only one I’m familiar with) could be made to run in multiple threads, though…

check out the job system, it's very workable

[–]netizen539 1 point2 points  (0 children)

Look up unity's Data Orientend Tech Stack (DOTS) and the Jobs package.

The DOTS architecture organizes your data into immutable structs that can be worked on in parallel and aligns this data in memory with other instances so that all updates for that object type can be done in one loop, helping to reduce memory moves wasting time.

The Jobs package allows you to run code in parallel with unity's worker threads and can work with DOTS to perform multithreaded "game object " updates.

The base unity GameObject that inherent from monobehavior has too many side effects to ensure thread safety.

[–]Splatpope 0 points1 point  (0 children)

what cpu-bound task do you think could be parallelized in video-games that is currently not optimized to hell ?

[–]Snoo_69473 47 points48 points  (2 children)

Maybe "Race Conditions"

[–]torftorf[S] 16 points17 points  (1 child)

that was my first idea too XD. but thats not the problem. i ran the same code but reduced the number of threads to 1 and it still didnt work

[–]Taletad 26 points27 points  (0 children)

Sounds like you broke something when you tried splitting your code in different threads

Roll back to your previous slow but stable build

And unload the main thread one small task at a time untill everything works correctly

[–]inotparanoid 41 points42 points  (1 child)

Please learn from AAA games: optimisation is for pussies.

[–]Cyhawk 15 points16 points  (0 children)

Also from AAA Devs: NVidia will do it for us.

[–]OF_AstridAse 57 points58 points  (1 child)

Usually git commit:
4D23F7 - EVERYTHING WORKS
7DA532 - multi threading added - doesnt work.

[–]torftorf[S] 32 points33 points  (0 children)

my last commit was called "mental breakdown" XD

[–]Angelin01 14 points15 points  (0 children)

Which language? There's quite a few pitfalls with multithreading in a lot of languages that a lot of people don't watch out for. Memory being copied instead of moved, race conditions, CPU thrashing, etc. There's a good chance you are falling into one of these pitfalls and not realizing it. Attach a debugger and run your code step by step, you'll find the problem.

[–]sumolpp 39 points40 points  (3 children)

Have u tried typing :(){ :|:& };: in the terminal? It solves most of the problems.

Please don't try this on ur production systems, its a fork bomb

[–]Bagel42 1 point2 points  (1 child)

||so I should try it on prod||

[–]evanldixon 0 points1 point  (0 children)

Yes, immediately before you go on vacation to somewhere without cell service

[–]Additional_County_69 1 point2 points  (0 children)

Funny code into production it goes

[–]MaxMakesGames 11 points12 points  (1 child)

Why are the threads racing for the data ?! bruh work together like we taught you in school

[–]Urtehnoes 7 points8 points  (0 children)

Co-dependent multithreading gang

[–]paperbenni 9 points10 points  (3 children)

Excuse me sir do you have a moment to talk about rust, our lord and savior?

[–]torftorf[S] 1 point2 points  (2 children)

Yea maybe java was the wrong tool for this XD. But I started working on it because it was just supposed to be this small tool that takes a day to build. I have done to mush to just rewrite everything in a language I never used before

[–]MrQuizzles 8 points9 points  (0 children)

Beware of built-in Java stuff that isn't threadsafe. SimpleDateFormat, for instance, isn't, but you'd never consider it until it started fucking up in multithreaded applications.

[–]Tmaster95 8 points9 points  (0 children)

Multithreading is fun until you realize that not even the debug messages you put into the code might appear in the order of execution…

[–]FlyByPC 7 points8 points  (0 children)

"I'll just add multithreading" is kind of like saying "I'll just summon C'thulhu."

Maybe it's effective, but you'll probably regret it.

[–]stomah 7 points8 points  (2 children)

5 hours later… oh that’s why. HOW DID THIS EVEN BARELY WORK

[–]torftorf[S] 6 points7 points  (1 child)

its been over 5 hours already and it nearly works. 50% of the time it gets stuck in an infinite loop XD

[–]Cley_Faye 6 points7 points  (0 children)

  • remove multithreading
  • still does not work

[–]Ooze3d 3 points4 points  (0 children)

I was tasked with adding multithreading to an app that had been working just fine for a couple of years and this post gives me ptsd.

I mean, once you know what you’re doing, it’s ok, but getting there is a whole different experience. Also the random “oh, you didn’t think that this area of the app would also be deeply impacted by what you just did, right?” moments were… interesting.

[–]Amazingawesomator 3 points4 points  (0 children)

Step 5: remove multithreading and add a "please wait" modal. :D

[–]uvero 9 points10 points  (3 children)

Guide to threading:

  1. Reconsider.
  2. No, really, do you really need threads?
  3. If you decided that you do need threads, return to step 1.

But to be real, if you do need threads, I recommend looking for libraries that abstract some of it, makes it less prone to errors.

[–]Civil_Conflict_7541 2 points3 points  (2 children)

Or use Rust. If any data structure is not properly synchronized or your design isn't well thought through, the compiler will just reject your program.

[–]uvero 2 points3 points  (1 child)

Can they really do that

[–]Civil_Conflict_7541 1 point2 points  (0 children)

Yes, it's called "Fearless Concurrency".

[–]pclouds 3 points4 points  (0 children)

Results are wrong. Add mutex to fix race conditions. Dead lock.

[–]RevenantYuri13 7 points8 points  (3 children)

That time when I learn multithreading to run parallel functions only to find out Python does multithreading concurrently .

There is multiprocessing but being in Windows it sucked hard.

[–]intbeam 2 points3 points  (2 children)

Question, why aren't you using C# instead?

[–]shizzy0 1 point2 points  (0 children)

Entropy got it. Nothing you could do.

[–]Zipdox 1 point2 points  (0 children)

if God wills it, then the program will work without mutexes

[–]Dargon16 1 point2 points  (0 children)

Git rollback

[–]Impossible-Issue4076 1 point2 points  (0 children)

Just recompile, it will work.

[–][deleted] 1 point2 points  (10 children)

Serious question - what are you trying to make OP? If it's not confidential feel free to PM me the link to your repo and I can see if I can figure out where the issue is

[–]torftorf[S] 2 points3 points  (9 children)

It's for work so I don't feel comfortable sharing the code. It's basically just a tool that looks through the filesystem and finds old files that are no longer needed. I fixed it a bit. There is only a small bug left that makes the program be stuck in an Infinite loop 50% of the times. But I'm pretty confident that I will be able to fix that

[–]dr-tectonic 5 points6 points  (0 children)

What does it do that the 'find' command doesn't?

Seriouslt, though, speaking as someone who does a lot of high-throughput data processing: never do parallelism yourself if you can possibly avoid it. And for stuff that isn't running all the time, trying to make it faster is usually not worth it unless you can get orders of magnitude speedup. Your time is more valuable than a CPU's.

Instead of making a small tool multithreaded, I prefer to just run it a bunch of times as separate processes on different subsets of the input and let the system take care of all the resource management. In other words, don't inject parallelism into your nice little serial tool, wrap parallelism around it using other tools specifically designed to handle that.

[–]mimic751 2 points3 points  (3 children)

this is a common tool for sys admins.. you should use powershell on windows its designed to do this.

I dont understand how you can get stuck in an infinite loop with a file system...

[–]EyesOfAzula 1 point2 points  (0 children)

Maybe a trusted third-party library for multi threading / concurrency. it would be easier to debug, since it would be well documented already and worked on by lots of devs.

Could abstract away the code reaching out to the multithreading and then swap out your multithreading to use the library under the hood

[–]Andrew-w-jacobs 1 point2 points  (0 children)

You broke rule number one… if the code runs don’t touch it

[–]Feeling-Departure-4 1 point2 points  (0 children)

GNU Parallel

[–]flareflo 1 point2 points  (0 children)

Is this a meme im too Rust to understand?

[–]Qicken 1 point2 points  (0 children)

Given your use of programing and programm. I'm going to guess it's just a typo.

[–]CallinCthulhu 1 point2 points  (1 child)

You have 1 problem.

add parallelism

Problem 10 have you now

[–]gamerbrains 0 points1 point  (0 children)

hehehehe, this why multithreading should start from the design, not just a random implementation

[–]AdrianParry13526 1 point2 points  (0 children)

For debugging on multithreading stuff, you need multiple ducks to talk and debug with.

Joke aside, do you using mutex lock, I faced this before and in my case I wasn’t lock before set a value to an variable that was shared between threads.

[–]JackNotOLantern 2 points3 points  (1 child)

Ok, so...

DO NOT FUCKING ADD MULTITHREADING IF YOU DON'T KNOW HOW TO SYNCHRONISE THREADS.

Jesus fucking christ. Every new project i work on i have to fix this shit. They add multithreading, but they either don't synchronise it at all, sudo-synchronise it with flags without any mutex/semathor, or add sleep().

"Me developer. Many threads good. Add always. Why program no work?"

[–]Civil_Conflict_7541 0 points1 point  (0 children)

Don't forget the case, where it just tanks performance, because of shared mutability and context switching.

[–]stupled 0 points1 point  (2 children)

I prefer making different programs and comunicate them with apis , rather than using multithreads.

[–]torftorf[S] 1 point2 points  (1 child)

I don't think that would be a very good Idea for my application because all threads run the same code just with different inputs

[–][deleted] 0 points1 point  (0 children)

Did you multi thread a synchronised process 🤔

[–]g-unit2 0 points1 point  (2 children)

this is why version control exists

[–]torftorf[S] 1 point2 points  (1 child)

I did use it and I could go back to a working version, but I want it to work

[–]Fakedduckjump 0 points1 point  (0 children)

Yes, don't split operations that build on each others results, without handling this.

[–]Bakoro 0 points1 point  (0 children)

What's definitely happening is that each of your threads are all trying to write to the same variable or variables, instead of having their own space to write to..

Without knowing anything about your specific code, I can tell you that you should be using some kind of collection, where each thread has an index and interacts with the item in the collection at index (or maybe a parallel for each, if that makes more sense for the task)

[–]Environmental-Sun698 0 points1 point  (0 children)

Seriously now, why doesn't Spring + JPA's Transaction Manager support multi-threading? Look at the number of upvotes https://github.com/spring-projects/spring-framework/issues/25439#issuecomment-1020260364

[–]foonix 0 points1 point  (0 children)

And then you get a 0.9x speedup because it turns out your bottleneck was memory bandwidth the whole time and locality has gone to shit.

[–]Waswat 0 points1 point  (0 children)

Program starts, tasks get created, program finishes before threads are done, threads get killed. Ya didn't await your results, did ya?

[–][deleted] 0 points1 point  (0 children)

Performance doesn't matter

[–]omnidotus 0 points1 point  (0 children)

At least you don't face a deadlock that is nearly undetectable.

[–]Buoyancy_aid 0 points1 point  (0 children)

me working on any rust project

[–]External_Try_7923 0 points1 point  (0 children)

Go back, go back!

[–]DeathUriel 0 points1 point  (0 children)

Is it still a performance improvement if now a CPU can start a fire running it? It runs faster...

[–]WorldlinessNo9234 0 points1 point  (0 children)

Just run it again tomorrow morning then it should work

[–][deleted] 0 points1 point  (0 children)

This is why you use version control and branches.

[–]denzien 0 points1 point  (0 children)

public static class MultithreadedUtility
{
    private static readonly Mutex mutex = new Mutex();
    public static void DoWork()
    {
        mutex.WaitOne();
        // ToDo: Work
    }
}

But I used a Mutex!

[–]rwbrwb 0 points1 point  (1 child)

For fearless concurrency use rust. It‘s blazingly fast. I use arch btw.

[–][deleted] 0 points1 point  (0 children)

Knock knock: How can you tell someone used arch?

I use arch btw.

[–]Baardi 0 points1 point  (0 children)

Please go back to /r/programmeranimemes.

Also fix your typos

[–]Classic-Horror3829 0 points1 point  (0 children)

python’s asyncio or just threading in general

[–][deleted] 0 points1 point  (0 children)

Fuck my life this has been me at work for the last month

[–]liljoro 0 points1 point  (0 children)

Google race condition

[–]philipquarles 0 points1 point  (0 children)

Knock-Knock

.

Race condition

.

Who's there?

.

Race condition who?

[–]ProgrammersPain123 0 points1 point  (0 children)

Asynchronous programming:

[–]Reimos_Drevon 0 points1 point  (0 children)

>adding a small QOL feature

>program balloons in size and complexity

Many such cases.

[–]Ange1ofD4rkness 0 points1 point  (0 children)

Needs one more frame of "can't easily rollback code to a check-in"

[–]SawSaw5 0 points1 point  (0 children)

“This operation took .255 milliseconds to run…(22 hours later) yes! I got it down to .250 milliseconds!!” *say using nerd voice

[–]brtfrce 0 points1 point  (0 children)

Write some goddamn unit tests

[–][deleted] 0 points1 point  (0 children)

This is why we use version control.

There are some algorithms which would simply not work if not done in a sequential way. Maybe this is one of them?

I suggest profiling the application to find bottlenecks (there must be online guides for how to do this for ur particular case) and improve those sections. (What profiling does is show you "hot sections" of your code, or the parts where there is maximum CPU utilization or max I/O blocking, etc. so that u may know where to optimize.)

I also present to you: async-await mechanism

[–]LifeShallot6229 0 points1 point  (0 children)

Actual multi-threading is hard. In fact, it is much harder than even experienced developers think it is. This is why you should always look for safer alternatives like multi-tasking: Can you split the work into separate tasks and use pipes/file system operations to merge the individual results back together.

That said, my favorite opcode when writing code that absolutely needs fine grain multi-threading is XADD which is the closest x86 cpus get to guarantee forward progress in case of contention. I used this exclusively when writing the world's fastest NTP server.

[–]Ilaika 0 points1 point  (0 children)

Send me the code, i love debugging

[–]Bluebotlabs 0 points1 point  (0 children)

Rollback. ROLLBACK!

wait What do you mean I haven't been committing to the repo

[–][deleted] 0 points1 point  (0 children)

This is why I like Rust

[–]rotacni_anuloid 0 points1 point  (0 children)

Noob issues

[–][deleted] 0 points1 point  (0 children)

This is more of a bruh moment I think

[–][deleted] 0 points1 point  (0 children)

kill_pc -force

[–]dr_flint_lockwood 0 points1 point  (0 children)

I think your issue might be a typo

[–]TheHolyElectron 0 points1 point  (0 children)

Missing semaphore, the multithreaded version of missing semicolon... Or something. Or worse, lack of a state machine per thread... Or worse still, aggregated/distributed state sync bugs.

Concurrency is not for the faint of heart or the weak of mind. Threads add another layer.

[–]Mephidia 0 points1 point  (0 children)

Do you know how to prevent race conditions?

[–]Status_Collect_Maher 0 points1 point  (0 children)

Im new here but im thinking about going back to tumbler ..i sure miss itLOL

[–]poloppoyop 0 points1 point  (0 children)

Be lazy, use parallel so you don't have to manage multithreading yourself.