17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-06 09:18:36 +01:00

perf(physics): performance.multithreading switches the work over many threads, which each job sizes by how much it has: the physics steps a thread per 128 vehicle steps, up to all logical cores

This commit is contained in:
2026-10-23 21:07:05 +02:00
parent 9f7217256b
commit 1a42009dc2
8 changed files with 170 additions and 154 deletions

View File

@@ -655,6 +655,8 @@ private:
TDynamicObject * GetFirstDynamic(int cpl_type, int cf = 1);
void ABuSetModelShake(glm::dvec3 mShake);
// place in vehicle_table::m_items, set by its update for the groups of the physics steps on many threads
std::uint32_t m_tableindex { 0 };
// McZapkie-010302
TController *Mechanik;
TController *ctOwner; // wskażnik na obiekt zarządzający składem
@@ -880,9 +882,9 @@ public:
// legacy method, checks for presence and height of traction wire for specified vehicle
void
update_traction( TDynamicObject *Vehicle );
// the steps of the physics of update() on many threads, see the definition
void
update_steps_parallel( double const Deltatime, int const Iterationcount, std::vector<std::uint8_t> const &Coarse );
// the steps of the physics of update() on up to Threads threads, see the definition. false: they can't be split, nothing done
bool
update_steps_parallel( double const Deltatime, int const Iterationcount, std::vector<std::uint8_t> const &Coarse, std::size_t const Threads );
// legacy method, sends list of vehicles over network
void
DynamicList( bool const Onlycontrolled = false ) const;
@@ -891,10 +893,9 @@ private:
// maintenance; removes from tracks consists with vehicles marked as disabled
bool
erase_disabled();
// working space of update_steps_parallel(), kept between the updates: the groups of the vehicles (joined by union find, by
// the vehicle and by its mover), the group of each root, the groups done on the threads and in the main thread
// working space of update_steps_parallel(), kept between the updates: the groups of the vehicles (joined by union find), the
// group of each root, the groups done on the threads and in the main thread
std::vector<std::uint32_t> m_groupparent;
std::unordered_map<void const *, std::uint32_t> m_grouplookup;
std::vector<std::uint32_t> m_groupof;
std::vector<std::vector<std::uint32_t>> m_groups;
std::vector<std::uint32_t> m_threadgroups;