It is currently 08 Sep 2025, 05:01
   
Text Size

Flirting with parallel programming

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Re: Flirting with parallel programming

Postby myk » 21 Mar 2013, 15:10

Max mtg wrote:That's going to serve as an introduction to concurrent programming for me :)
Concurrent processing can certainly speed up some tasks, especially I/O. Just remember that anything coded with threads must be tested ten times as many times as single-threaded code to check for race conditions, deadlock, livelock, and starvation. Keep all concurrency within a single class or file, if you can. Use asserts liberally to check your assumptions. Most importantly, this kind of development belongs in a branch until it is well tested across many different types of systems. Trunk is not the place for experiments. I say this not because I am afraid of threads. I say this because concurrent programming is my professional expertise, and I have already made the mistakes of using them where they should not be used.

That said, it does sound like doing threaded loads is probably a good idea, at least for SSD hard drives. I'm not sure how spindles would react. For the people that are seeing slowdowns, what kind of hard drives are you using?
myk
 
Posts: 439
Joined: 17 Jan 2013, 02:39
Location: California
Has thanked: 38 times
Been thanked: 57 times

Re: Flirting with parallel programming

Postby friarsol » 21 Mar 2013, 15:19

myk wrote:That said, it does sound like doing threaded loads is probably a good idea, at least for SSD hard drives. I'm not sure how spindles would react. For the people that are seeing slowdowns, what kind of hard drives are you using?
It's just a simple laptop so I'm fairly positive its a 5400 rpm HDD.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Flirting with parallel programming

Postby Max mtg » 21 Mar 2013, 16:04

Sol, I have made a code path for single-core systems, try the loading time now.
Last edited by Max mtg on 21 Mar 2013, 16:07, edited 1 time in total.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Flirting with parallel programming

Postby Max mtg » 21 Mar 2013, 16:05

Myk, thanks for warnings.
I'll move to a branch with Input synchronization task.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Flirting with parallel programming

Postby Max mtg » 21 Mar 2013, 19:50

myk, I understand now why the loading time increases in some cases. Due to sequental read being faster than random access one. And it looks like there is no way to detect if an SSD is used or cardfolder is already cached by OS.

So, what do you think, if cardfolder is processed in a different way, will it be faster?
Like read all files' contents in a single thread and then distubute List<List<String>> (that will hold read lines) between threads?
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Flirting with parallel programming

Postby myk » 21 Mar 2013, 22:48

With performance optimization-related questions, the only real answer is to try and test, and then get some volunteers with different types of systems, and have them test it too. Splitting the I/O from the processing might speed things up, but the processing we do is really minimal -- just parsing -- and the gains from separating I/O from processing might be erased by the overhead of just having the thread at all. It's impossible to know before you try and measure, though.

For what it's worth, the sharded loading algorithm in place right now makes forge load on my systems (Macbook Pro, with flash-based HDD and a Linux workstation with an SSD cache drive) in the blink of an eye, and I'd miss it if it were changed back : ) Perhaps a user-selectable preference for "parallel loading" with explanatory text in the tooltip, and let the user decide which algorithm to use?
myk
 
Posts: 439
Joined: 17 Jan 2013, 02:39
Location: California
Has thanked: 38 times
Been thanked: 57 times

Re: Flirting with parallel programming

Postby Max mtg » 23 Mar 2013, 05:58

decks loader needs a similiar optimization, single threaded loader is not fast enough:
Read decks (1517 ms): 7658 constructed, 0 sealed, 0 draft, 23 cubes, 0 scheme, 0 planar.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 44 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 44 users online :: 0 registered, 0 hidden and 44 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 44 guests

Login Form