EA/Maxis Simcity is single threaded.

Discussion in 'PC Gaming' started by Acanthus, Jan 30, 2013.

  1. Acanthus

    Acanthus Lifer

    Joined:
    Aug 28, 2001
    Messages:
    19,916
    Likes Received:
    0
    Wow. Just wow.

    If there is one style of game that could benefit from multithreading...

    Their programmers must have a tough time with shared states..

    https://twitter.com/moskow23/status/296355832998801408

    It will utilize dual core, because the rendering is done on its own thread... but the "game" itself runs on a single thread.

    This explains the small city sizes and their lack of interest in making it a 64bit app to support more memory.
     
  2. BrightCandle

    BrightCandle Diamond Member

    Joined:
    Mar 15, 2007
    Messages:
    4,763
    Likes Received:
    0
    I know it seems ridiculous but this is how the grand majority of games are written at the moment. Its very hard to go from where the industry is to utilizing more cores efficiently. Don't get me wrong I want bigger cities and better simulations, and maybe this could mean a city 3x the size on a quad core, but its still mighty hard to program this adjustment.
     
    #2 BrightCandle, Jan 30, 2013
    Last edited: Jan 30, 2013
  3. SunnyD

    SunnyD Belgian Waffler

    Joined:
    Jan 2, 2001
    Messages:
    32,543
    Likes Received:
    4
    Okay... so?

    A casual game dev that's designing for greatest common denominator. Big deal.

    For the record, MOST games are designed this way. Gameloop/logic in one thread, sound/physics/other in additional threads.
     
  4. Annisman*

    Annisman* Golden Member

    Joined:
    Aug 20, 2010
    Messages:
    1,659
    Likes Received:
    3
    Some other games that never should have been single threaded still work just fine, Sins of a Solar Empire for example. Thousands of units on screen, and somehow even with a restricted engine it's not hard to get respectable frames. Don't sweat it.
     
  5. lupi

    lupi Lifer

    Joined:
    Apr 8, 2001
    Messages:
    30,469
    Likes Received:
    20
  6. BrightCandle

    BrightCandle Diamond Member

    Joined:
    Mar 15, 2007
    Messages:
    4,763
    Likes Received:
    0
    I think if the worlds weren't so small and the developer hadn't blamed performance on the reason this would be easier to swallow. It might be normal for games to have only two threads and having more might not increase the world size. But Its still not exactly pleasant to find out that a game marketed as a deeper simulation turns out to run just as well on the lowest end of CPUs that match performance of machines made 7 years ago.

    Also goes to show you can make a great looking game and otherwise impressive simulation without remotely using the full capabilities of a modern PC.
     
  7. Bateluer

    Bateluer Lifer

    Joined:
    Jun 23, 2001
    Messages:
    27,733
    Likes Received:
    1
    Its EA. Did you expect them to make smart moves?
     
  8. Genx87

    Genx87 Lifer

    Joined:
    Apr 8, 2002
    Messages:
    39,497
    Likes Received:
    12
    Is it really that difficult to multi-thread these games these days? Shouldnt tools and newer compilers help with this now? It isnt like multi-core CPUs are something new. We are coming up on nearly a decade since they showed up for consumers.
     
  9. darkewaffle

    darkewaffle Diamond Member

    Joined:
    Oct 7, 2005
    Messages:
    8,154
    Likes Received:
    0
    It's got more to do with the underlying logic and design of the software than tools and tech. You can't really just flip a switch and say "ok it's multi-threaded now", kind of like how you can't just take code and run it off a GPU instead of a CPU.

    Interesting overview at the difficulties that lie in multicore programming.
     
  10. Olikan

    Olikan Golden Member

    Joined:
    Sep 23, 2011
    Messages:
    1,829
    Likes Received:
    0
    woot... not even the very popular, separated core for the sound
     
  11. PowerYoga

    PowerYoga Diamond Member

    Joined:
    Nov 6, 2001
    Messages:
    4,603
    Likes Received:
    0
    Multi-threaded programming is difficult in general. The technology is there but the logical concept is difficult, and it's very hard to get the core code on 2 different threads executing and playing nicely with each other.

    This is why most games typically offload components to other threads like graphics rendering, sound, etc. Stuff that doesn't affect core logic much. Core logic is typically all on a single thread because its easier to do and debug, especially for huge projects.
     
  12. Acanthus

    Acanthus Lifer

    Joined:
    Aug 28, 2001
    Messages:
    19,916
    Likes Received:
    0
    It has crippled the ability for the cities to be large.

    Maxis has been fighting complaints about city size, citing performance.

    And they've only had 10 years to develop it...
     
    #12 Acanthus, Jan 30, 2013
    Last edited: Jan 30, 2013
  13. OVerLoRDI

    OVerLoRDI Diamond Member

    Joined:
    Jan 22, 2006
    Messages:
    5,471
    Likes Received:
    1
    I could understand why this game would be really difficult to multi-thread, but I also see a definite need for more CPU power for this type of simulation. With city simulations the level of complexity is huge because there is so much overlapping dependencies. Because of those dependencies it makes multi-threading operations difficult.
     
  14. BrightCandle

    BrightCandle Diamond Member

    Joined:
    Mar 15, 2007
    Messages:
    4,763
    Likes Received:
    0
    The way they have designed the simulation suggests they should be be able to use Agents to get a lot of parallel computation for much of the simulation and the hard stuff (The A* searches). However any updates that have to happen to the game world, like taking a job would need to be synchronised or also based on agents. So you could have 10's of thousands of agents at the core, one for every building, road tile, job and sim. It would potentially scale quite well but it would be a massively more complicated implementation.

    Other strategies like Mirrors and immutable data structures wouldn't really be all that efficient for this sort of structure as its quite deep and wide in places, and the rate of update is frighteningly high per frame. When almost every data point is changing an immutable data structure is going to be inefficient for individual updates accumulated. Nice and easy to test but not good for getting parallel behavior in this case. You could also potentially split the world into 4 quadrants and deal with the synchronisation on the edges but the quadrants don't help much as anything that could cross the boundary needs locks.

    Unfortunately I can't think of an obvious strategy they doesn't involve a lot of fine grained synchronisation points, which means it would be a nightmare to code this game with multiple threads. Its not a trivial problem as I think it through.

    I have a simpler world simulation in development (lots of bouncing balls) and I can tell you its very difficult to multithread that reliably due to the interactions between them and I Simcity is much more complicated.

    I am disappointed with the world size but as a programmer I can't see an obvious way to make this better with fine grained task or agent development nor immutable data structures. If I were in the dev team I would have thought hard about it and maybe I would work out a strategy but on the surface its not immediately obvious how you would do it. No general strategy would work across the entire game world, nor is there an obvious boundary for course grained threads.

    To say concurrency and parallel computation is a challenge is an understatement, its basically impossible to get right but all the simplest of problems right now. The tools are just so primitive, most people have no idea how error prone it is to write software that uses many threads. I have seen a lot of bad multithreaded code and none that was good, literally zero lines. I suspect in the general case we will never find a solution, I suspect its impossible although I can't yet prove it.
     
  15. dagamer34

    dagamer34 Platinum Member

    Joined:
    Aug 15, 2005
    Messages:
    2,592
    Likes Received:
    0
    That denominator doesn't exist anymore. I don't think any system has shipped with a single core CPU in years.
     
  16. ViRGE

    ViRGE Elite Member, Moderator Emeritus

    Joined:
    Oct 9, 1999
    Messages:
    31,108
    Likes Received:
    16
    Keep in mind however that this is essentially a server-side game. It becomes a performance issue when they need to keep resource usage down so that users' simulations don't overwhelm their servers.
     
  17. BrightCandle

    BrightCandle Diamond Member

    Joined:
    Mar 15, 2007
    Messages:
    4,763
    Likes Received:
    0
    It is not. The grand majority of the simulation is happening on the client, the only server side element appears to be the intercity very course attributes (rubbish in/out, power in/out) etc. That is only there to facilitate the always online DRM and to give the game some minor amount of multiplayer capabilities.
     
  18. DaveSimmons

    DaveSimmons Elite Member

    Joined:
    Aug 12, 2001
    Messages:
    38,737
    Likes Received:
    33
    Most PCs shipped now are only dual-core, since laptops only get quad-core with an i7 and i3/pentium desktops are dual.

    Writing a casual game with 1 thread for logic and others for sound, UI, etc. makes sense if you're targeting the masses instead of enthusiasts,

    Even with perfect scaling you're only looking at less than a doubling of performance (because of other work for sound, graphics, etc.) not some 20x speedup.
     
  19. Kalmah

    Kalmah Diamond Member

    Joined:
    Oct 2, 2003
    Messages:
    3,684
    Likes Received:
    1
    The reason Cities XL is unplayable is because you can have a large city and it's single threaded.
     
  20. blastingcap

    blastingcap Diamond Member

    Joined:
    Sep 16, 2010
    Messages:
    6,653
    Likes Received:
    1
    If you don't like it, vote with your wallet.
     
    #20 blastingcap, Jan 30, 2013
    Last edited: Jan 30, 2013
  21. HarvardAce

    HarvardAce Senior member

    Joined:
    Mar 3, 2005
    Messages:
    233
    Likes Received:
    0
    I'll be the first to admit that I'm a novice when it comes to multi-threading, but there are easier ways to multi-thread and there are harder ways. The easiest ways are to split things into threads that are either fully independent of each other or are dependent only in specific and infrequent ways, or are unidirectional/asynchronous when it comes to information flow between threads.

    Now, the question is whether anything actually fits one of those conditions that makes multi-tasking easier. While looking at two systems in isolation may make you think so (e.g. power agents and water agents), I can see how those each can affect other agents/entities that would end up affecting the other. For example, if the power agents stop feeding the water pump, now the water agents are affected. That said, it could be that the overlap or eventual child dependency is either well enclosed and can be properly synchronized, or judged to be of minimal significance and can therefore allowed to have a known race condition whose effect one way or the other doesn't have a large enough impact in the larger picture. In the example I gave, you could determine that if one or two more water agents get out the door from the water pump before the power agent affects the status of the pump, it's not the end of the world.

    In short, I think the problem is more difficult than people expect (you can't just say "each agent is its own thread" and be done with it), but I also think you can simplify it in certain circumstances to gain some multi-threading capabilities without many of the common pitfalls associated with doing so. At that point, however, are the potential gains from a limited multi-threaded solution worth the additional effort?

    Despite what everyone thinks about EA, I would imagine that they have some good software engineers working there who have evaluated this very thing and determined the answer is "no."