18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-03 13:35:26 +01:00
Commit Graph

4 Commits

Author SHA1 Message Date
jerrrrycho 9cc1eb48a4 perf(physics): the worker threads look out for the next job before they sleep, and wake one another
Each job of worker_pool released the semaphore of every thread it wanted from the calling thread, and the threads
slept again right after it. A frame of the test mode runs four or five jobs (the neighbours, the facts, the steps,
the hose exchange), so the main thread made some 40 wake calls a frame: 3.3 % of its time on Tomaszewo, and on
linia 107 it waited 4.8 % of its time for threads woken late.

Now a thread done with a job looks out for the next one for 50 us (spin_time), as the jobs of a frame come close
after one another, and only then sleeps. A job is a ticket (its number and the seats left for the threads of the
pool): the threads looking out take a seat each, and sleeping ones are woken for the seats left, two by the calling
thread and two more by each thread which takes a seat, so the wakes go out as a tree. A thread going to sleep sets
its flag before a last look at the ticket, and a waker takes the flag before it releases, so no job is missed and no
semaphore released twice. The calling thread closes the seats nobody took once it is done, then waits for the
threads which took one, looking out for them for a while before it sleeps on the count.

Which thread does which index never mattered for the results, so they don't change. workerpool.cpp moved into the
core library, for the new unit tests (each index once with any number of threads, jobs back to back and after the
threads slept, the threads of the pool taking part, an exception passed on).
2026-12-02 06:15:59 +01:00
Hirek 7667e5b2ec fix: the bugs and vulnerabilities SonarCloud reports on PR #216 2026-11-07 22:11:08 +01:00
Hirek 1a42009dc2 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 2026-10-23 21:07:05 +02:00
Hirek 60667588b5 perf(physics): the steps of the vehicle physics on many threads, in groups of vehicles which act on one another (performance.cpucores, 0: all cores) 2026-10-23 19:56:36 +02:00