Commit Graph
17 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 56148606e5 Headless: Keep ad hoc test instances in step in emulated time
Each instance paced itself against the wall clock, so on a busy machine
the one that got less CPU fell behind, and anything a test times across
instances (a peer leaving, a matching timeout) came out differently with
the load: pair/vanish and pair/matching3 failed on macOS CI.

With --sync-file and --sync-count, instances on one machine share a file
of one slot per instance. CoreTiming ends a slice at every emulated
millisecond, publishes it there, and waits until every other instance
has reached it too, so they're never more than a millisecond apart. It
works for any number of instances. One that stops moving (a debugger
pause, a crash) is waited for 2 s and then left out until it moves
again, and one that blocks the CPU thread in real time on something the
others must do (the relay PTP connect) stands aside meanwhile.

Tools/adhoc_multi.py and adhoc_session.py use it (--no-sync turns it
off). The host's 1 s head start is gone: they wait for the server's
port instead. adhoc_multi writes each instance's output to a file, as a
full pipe would now stop the other instances too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 09:04:00 +01:00
Henrik Rydgård 85efe6ba7c Instance: lock the shared counter for real, and don't hand out ID 0
The POSIX path used mlock() as though it were a mutex. mlock only pins pages in
RAM - it provides no mutual exclusion at all, so the read-modify-write of the
cross-process instance counter was unsynchronized. Two instances launched at the
same moment could both come away with PPSSPP_ID == 1, at which point both pass
IsFirstInstance() and write ppsspp.ini over each other, and both compute the same
adhoc local IP. Take an advisory lock on the shm fd instead. (The Windows path was
already fine - it uses a named mutex.)

Also, next/total are uint8_t in a segment that outlives the processes using it, so
next climbs across runs and wraps. Landing on 0 is worse than it looks: it isn't a
valid instance id, IsFirstInstance() fails, and config saving is silently disabled
from then on. Skip past it on wrap.
2026-08-31 12:53:34 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Jan Beich e6b84efc55 Instance: add missing include after 1bace55583
Core/Instance.cpp:148:55: error: use of undeclared identifier 'S_IRUSR'
        hIDMapFile = shm_open(ID_SHM_NAME, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
                                                             ^
Core/Instance.cpp:148:65: error: use of undeclared identifier 'S_IWUSR'
        hIDMapFile = shm_open(ID_SHM_NAME, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
                                                                       ^
2021-09-24 01:18:53 +00:00
iota97 1bace55583 Add permission to shm_open 2021-09-21 16:08:38 +02:00
Unknown W. Brackets af5618705c http: Remove timeoutless requests.
Let's always have timeouts.  This timeout is reset even when a single byte
is sent, so it's pretty generous.
2021-05-01 11:20:05 -07:00
M4xw 76051ac9b5 Switch: Disable multi-instance tracking. 2021-03-04 21:07:13 -08:00
Unknown W. Brackets 13ec384dbe Build: Explicitly include ppsspp_config.h.
This adds it to all files that use it.  Not all our builds include the
file.
2021-03-02 21:04:03 -08:00
Unknown W. Brackets da2e722794 Windows: Fix some format warnings. 2021-02-14 10:30:10 -08:00
Jan Beich 901c3c53de Instance: add missing headers more POSIX systems
Core/Instance.cpp:90:56: error: use of undeclared identifier 'PROT_READ'
        InstanceInfo *buf = (InstanceInfo *)mmap(0, BUF_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, hIDMapFile, 0);
                                                              ^
Core/Instance.cpp:90:68: error: use of undeclared identifier 'PROT_WRITE'
        InstanceInfo *buf = (InstanceInfo *)mmap(0, BUF_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, hIDMapFile, 0);
                                                                          ^
Core/Instance.cpp:90:80: error: use of undeclared identifier 'MAP_SHARED'
        InstanceInfo *buf = (InstanceInfo *)mmap(0, BUF_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, hIDMapFile, 0);
                                                                                      ^
Core/Instance.cpp:91:13: error: use of undeclared identifier 'MAP_FAILED'
        if (buf == MAP_FAILED) {
                   ^
Core/Instance.cpp:147:37: error: use of undeclared identifier 'O_CREAT'
        hIDMapFile = shm_open(ID_SHM_NAME, O_CREAT | O_RDWR, 0);
                                           ^
Core/Instance.cpp:147:47: error: use of undeclared identifier 'O_RDWR'
        hIDMapFile = shm_open(ID_SHM_NAME, O_CREAT | O_RDWR, 0);
                                                     ^
Core/Instance.cpp:185:3: error: use of undeclared identifier 'shm_unlink'
                shm_unlink(ID_SHM_NAME);     // If program exited or crashed before unlinked the shared memory object and it's contents will persist.
                ^
2020-12-27 05:25:05 +00:00
Unknown W. Brackets b0ca635414 Windows: Show instance counter only with peers. 2020-08-18 06:59:49 -07:00
Unknown W. Brackets 09a3d1f7cb Net: Use locking consistently for instance counter. 2020-08-18 06:59:49 -07:00
Henrik Rydgård f617bfce29 Disable the instance counter in libretro builds.
Dunno if it might help #13271...
2020-08-11 22:32:41 +02:00
Henrik Rydgård f9a1a0eee5 Fix issue where after a backend change restart, the new instance was considered secondary. 2020-08-06 10:19:58 +02:00
Henrik Rydgård fb0b3b3351 Another buildfix 2020-07-20 14:09:08 +02:00
Henrik Rydgård 7858980cbf Buildfix 2020-07-20 13:11:11 +02:00
Henrik Rydgård fa0b9dc1bc Make the instance counter global and initialized at startup.
Turn off config saving for secondary instances.
2020-07-20 11:40:54 +02:00