Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 11:05

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



multithreading vs events

Discussion on multithreading vs events within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old 07/06/2014, 00:08   #16
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
Quote:
Originally Posted by Korvacs View Post
And even then none of those are problems if you design your threading correctly.
Pretty much and when you use languages that are designed for concurrency and thread synchronization such as D, Go etc.
Super Aids is offline  
Thanks
1 User
Old 07/06/2014, 00:13   #17


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
Also, this might be a retarded idea but it added to my performance - measure each task (function that is needed to be passed to these worker threads which at me are 4*NR_CORES), and give "points" to that task. Then, when assigning it to a thread, assign it to the thread which has the minimal "points" (of course add, subtract). This can be used best if you can keep the tasks as close in time to each other as much as possible.
KraHen is offline  
Old 07/06/2014, 00:14   #18
 
elite*gold: 0
Join Date: Jun 2014
Posts: 24
Received Thanks: 14
Quote:
Originally Posted by Korvacs View Post
And even then none of those are problems if you design your threading correctly.
That's probably easier said than done ... a lot easier said than done
EpvpIsAJoke is offline  
Thanks
3 Users
Old 07/06/2014, 08:38   #19


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
Quote:
Originally Posted by EpvpIsAJoke View Post
That's probably easier said than done ... a lot easier said than done
Its very easily done, concurrent collections and the Parallel features in C# mean that all the work is basically done for you, just use them when access collections which multiple threads will work on (if only 1 thread will work on a collection you don't need the concurrency). And use a lock object for things like loading files to ensure you don't load the same thing twice if multiple threads have the potential to do that at the same time.

So no it's not hard.
Korvacs is offline  
Old 07/06/2014, 10:29   #20
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,211
Received Thanks: 4,114
Sorry guys, Jack is correct. I don't know why you all are whining about multithreading being so difficult. That's kind of the reason .NET had an entire update or two dedicated to safe multithreading and concurrency. Even before that though, multithreading wasn't challenging. All it required was a bit of Googling.
Spirited is offline  
Old 07/06/2014, 14:10   #21
 
elite*gold: 0
Join Date: Jun 2014
Posts: 24
Received Thanks: 14
Quote:
Originally Posted by Korvacs View Post
Its very easily done, concurrent collections and the Parallel features in C# mean that all the work is basically done for you, just use them when access collections which multiple threads will work on (if only 1 thread will work on a collection you don't need the concurrency). And use a lock object for things like loading files to ensure you don't load the same thing twice if multiple threads have the potential to do that at the same time.

So no it's not hard.
Oh, well since we were talking about performance, I read what you said as "It's easy to design a multi-threaded program that doesn't use locking".
Plastering locks all over your code is easy, sure, but it hurts performance. That's where it gets more tricky, in my opinion - designing your multi-threaded program to use as little locking (mutexes, semaphores, etc.) as possible.
EpvpIsAJoke is offline  
Old 07/06/2014, 15:03   #22


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
Its fairly easy to implement multi-threading without locks, there's only one lock in my source. Concurrency and Parallel is where its at, and its not very difficult to make use of those.
Korvacs is offline  
Old 07/06/2014, 16:25   #23
 
elite*gold: 0
Join Date: Jun 2014
Posts: 24
Received Thanks: 14
Quote:
Originally Posted by Korvacs View Post
Its fairly easy to implement multi-threading without locks, there's only one lock in my source. Concurrency and Parallel is where its at, and its not very difficult to make use of those.
Yeah, sure, you can use the concurrent collections that people from Microsoft with decades of experience in writing lock-free algorithms/data structures made for you, but that's not to say that your program doesn't use locks. Even some of the concurrent collections (ConcurrentBag and ConcurrentDictionary for example) use locking, which means you're still using locking even if you didn't explicitly write the lock statements in your code yourself.
EpvpIsAJoke is offline  
Old 07/06/2014, 17:06   #24


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
Quote:
Originally Posted by EpvpIsAJoke View Post
Yeah, sure, you can use the concurrent collections that people from Microsoft with decades of experience in writing lock-free algorithms/data structures made for you, but that's not to say that your program doesn't use locks. Even some of the concurrent collections (ConcurrentBag and ConcurrentDictionary for example) use locking, which means you're still using locking even if you didn't explicitly write the lock statements in your code yourself.
Sure, and if you bother to read up on how specific classes work you can minimise lock statements if they are causing issues. Of course when your using Parallel in conjunction with Concurrent collections your likely not going to find a better combination in terms of performance unless you take it to the extremes and work at extremely low levels.

But like I said its all about your design, Concurrent collections are slower than their regular counterparts so its a trade off as with most design choices. Is it quicker to use the slower collection which scales better across multiple threads, or use the faster collection which isn't thread safe unless you put a bunch of wrapping around it and in turn trade more performance for safety.

Typically if your going to be using alot of multi-threading then Concurrent collections are the way to go, if you know the collection will only ever be accessed by one thread at a time then always pick the standard collection, that's as complicated as it needs to be.
Korvacs is offline  
Reply


Similar Threads Similar Threads
Pirates of Altis 3.1.3 stellt sich vor | WM AKTION | Events | WL Cops&Medics | Events
06/28/2014 - Private Server Advertising - 0 Replies
Hallo Community! Wir, die Pirates of Altis, bestehend aus 10 aktiven Spielern, haben uns entschlossen, einen eigenen Altis Life Server in Betrieb zu nehmen. Entsprechend ist der Server noch sehr jung, und unterbevölkert, dennoch haben wir schon mehrere Stammspieler gewonnen. Da wir uns fest vorgenommen haben, mehr zu spielen als zu regieren, können wir sehr schnell Änderungen vornehmen, Fehler finden und beseitigen, sowie die Sicht des Spielers in Problemfällen erkennen. So sollte es,...
Multithreading
10/08/2012 - C/C++ - 25 Replies
Guten Tag Leute, Ich befasse mich seid ca 2 monaten immer mal wd mit c++ und probiere mich dran einfache Programme zu schreiben . Nun aber wollte ich mich mal am multithreading versuchen da ich eine Schleife programmieren will die solange läuft bis der Benutzer einen button drückt oder Bei der konsole per eingabe die schleife stoppt. Mir wurde gesagt ich soll eine globale Variable definieren was ich getan habe und dann die schleife in einen Threat packen soll .Mein Problem ist nun aber das...
[Free Giveaway] Twink Accs Rdy For All Events / Secret Events / Returned Warrior
01/11/2012 - Freebies - 3 Replies
like title says nothing special some low twink accs rdy for all events secrets events and returned warrior too just pm me if you need
[C++] D3D Multithreading
08/24/2011 - C/C++ - 0 Replies
Sry kann closed werde. MfG



All times are GMT +2. The time now is 11:05.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.