More Multithreading?

Discussion in 'Ideas and Suggestions' started by Again_Dejavu, Sep 17, 2014.

  1. Again_Dejavu

    Again_Dejavu
    Expand Collapse

    Joined:
    Dec 26, 2013
    Messages:
    717
    We already have a thread for each vehicle, why not take it to the limit? A thread for every part would create a performance boost on many systems. If it's possible to do, doing it should be a high priority.
     
  2. n0ah1897

    n0ah1897
    Expand Collapse

    Joined:
    Jan 31, 2013
    Messages:
    625
    That wouldn't make any sense. There are too many parts to allow them to each have their own thread. Plus what happens when you start adding vehicles? This would just create more problems than it's worth.
     
  3. BaronRedStorm

    BaronRedStorm
    Expand Collapse

    Joined:
    Jul 12, 2014
    Messages:
    817
    Maybe certian parts can have their own threads maybe.
     
  4. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,958
    While I agree it would create problems (syncing that many threads on some vehicles will be a PITA), it wouldnt particularly impact the number of vehicles that can be simulated.
    Windows is already managing a massive amount of threads at one time already, just open task manager to the processes tab, each of those is a thread. There is a little timer in the CPU which triggers windows to manage threads periodically. Windows just decides which thread(or threads if you have multiple cores) is running at one time and which core to run it on, it can even decide that if the current threads are low priority enough that you don't need core 3 and because there is a load on core 2 it may be easier to shut down the also unneeded core 1 leaving 0 and 2 running, 1 and 3 shut down to save power.

    All windows will do is spread the various threads out as it sees fit. Shouldnt be a problem besides syncing them all. Considering the homepage mentions OpenCL support, I think just waiting for that is a better idea than majorly restructuring the physics core right now.
     
  5. Stormdrain

    Stormdrain
    Expand Collapse

    Joined:
    Jun 18, 2013
    Messages:
    480
    *coughT75wheelscough*
     
  6. randomshortguy

    randomshortguy
    Expand Collapse

    Joined:
    Aug 9, 2013
    Messages:
    1,562
    Totally agree. This could also help AMD users fully utilize 8 core CPUs

    But single-core performance would still be an issue
     
  7. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,958
    not as much as 1 vehicle would be spread across all 8 cores

    AMD's low BeamNG performance I think comes from shared floating point units, that is 1 major difference architecturally between Intel and AMD, in an AMD Module (2 cores) there is only 1 floating point unit, an intel CPU has 1 floating point unit per core.
     
  8. Again_Dejavu

    Again_Dejavu
    Expand Collapse

    Joined:
    Dec 26, 2013
    Messages:
    717
    I don't think syncing would be an issue, cars on different threads collide just fine already.
     
  9. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,958
    Cars on different threads aren't attached to each other. What happens when the thread for the wheel executes just fine but a system level interrupt gains CPU access at a higher level than the axle causing the axle thread to lag behind momentarily.
     
  10. Again_Dejavu

    Again_Dejavu
    Expand Collapse

    Joined:
    Dec 26, 2013
    Messages:
    717
    I apologize for bumping the thread, but a Dev never commented on it.
     
  11. Cira

    Cira
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    282
    From your standpoint just adding threads maybe sounds like a good idea but from a technical standpoint things are way more complicated.

    The main problem with threads is their overhead and mainly syncronization between them. More threads mean more RAM usage because 1 thread cannot use easily the resources of another thread. With resources i don't mean resources like a texture or a model but just the basic physic data, movement and position, velocity, etc. This stuff still has to be collected in a mainthread per part per vehicle, making this the ultimative bottleneck of your 100s of threads per vehicle.

    You can't just make a new thread for a fender and one for a shock and one for a door etc. Without a mainthread syncronizing each part they wouldn't even know that the car is moving. So instead of having the overhead of 100s of threads and 1 mainthread syncronizing them we now got what probably is the best approach.

    A single thread per vehicle that already does the job the mainthread-job, without the overhead of syncronizing 100s of threads. With this you're having a single thread that already has all the data it needs, it iterates over each part of the vehicle, syncronized their movement, shape,... and done.

    Not even speaking of the limits of the Operating System, you can't just throw 100 threads on a CPU and hope the software will go faster.
     
  12. theshark

    theshark
    Expand Collapse

    Joined:
    Aug 5, 2012
    Messages:
    137
    The physicsengine knows nothing about parts. After you select parts and spawn the car, beamNG generates a big jbeam out of all the selected parts and throws it at the physics.
     
  13. Again_Dejavu

    Again_Dejavu
    Expand Collapse

    Joined:
    Dec 26, 2013
    Messages:
    717
    Huh. That's a neat way of doing it.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice