aboutsummaryrefslogtreecommitdiff
path: root/src/core/core_timing.cpp
Commit message (Collapse)AuthorAgeFilesLines
* nx2: run the guest counter at 31.25 MHz for Switch 2 titlesTakoroka5 days1-1/+1
| | | | | | | | | | | | | | | | | | | | The Switch 2 counter runs at 31.25 MHz and its SDK converts ticks with that constant: Mario Kart World's sdk builds 31,250,000 in nn::os::GetSystemTickFrequency, TickManager::ConvertToTimeSpan and TickManager::ConvertToTick (19.2 MHz appears nowhere). Eglantine counted at the Switch 1 rate for every title, so every tick-based time in a Switch 2 game was off by 1.63x: elapsed times read short, and a deadline of one 60 Hz frame converted to ticks waited ~27 ms. The wall clock now has a guest counter frequency, set at boot: 31.25 MHz for Switch 2 programs, 19.2 MHz otherwise, EDEN_NX2_CNTFRQ=<Hz> to force one. CNTPCT reads, CNTFRQ_EL0, svcGetSystemTick, thread tick counts and the time services' tick conversions follow it, and the CNTPCT spin detection keeps its ~1.7 us threshold. Mario Kart World, title screen and attract demo, 180 s, same build: frame times unchanged (17-19 ms once warm), process CPU time 848 s instead of 930 s.
* core_timing: request the timer thread's stop before waking itTakoroka5 days1-1/+6
| | | | | | | | | CoreTiming::Reset set pause_event and event, and only then requested the stop. The woken timer thread could take the wake-up, still see no stop request, and go back to waiting on pause_event for good; the join that follows then hung the frontend while booting a game ("Not Responding", main thread in CoreTiming::Reset -> std::thread::join). Request the stop first, so the thread sees it whenever it wakes.
* [core, gpu, threads] Multithreading refactor (#4254)CamilleLaVey2026-08-081-3/+20
| | | | | | This insufferable work tries to cover some holes on previous threading implementation from yuzu's team, starting with Windows and Linux reordering of priorities (NICE), reworks previous Android's threading and cpu affinity with adpf, adjust emulated clocks/gpu for better "accuracy" with their work, bumps android minSDK for all flavors, legacy will now work with AP 29 to cover A10 - A12, standard will reach A13 as base and finally the optimized build will come with API 35, mostly targeted on devices with A15 support and newer, NDK and AGP wasn't upgraded yet. The performance cost efficiency have been improved based on device power configuration; preventing overheating if certain devices tended to fall into NICE0 (not allocated threads priority, all task ran with higher priority, 11 tasks running within the limited 2 - 7 threads available on the most common configuration 1x3x4 or 1x4x3). Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4254
* [core/core_timing] better MWAITX and WAITPKG delays (#3984)lizzie2026-05-301-28/+10
| | | | | | | | | | | | | This implements MWAITX and WAITPKG extensions (umonitor, mwait) for CPUs that support them. Reduces wait times and bypasses the timing stuff from the OS that is slow (windows notably). generally it should answer within 0.2 to 0.5 microsecs (since most requests wait for that long). Also does a general rework of static ctors and stuff Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3984 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: crueter <crueter@eden-emu.dev>
* [common] remove ptr indirection on WallClock (#3864)lizzie2026-05-151-88/+67
| | | | | | | | | also devirtualizes manually since compiler doesn't do it with LTO Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3864 Reviewed-by: crueter <crueter@eden-emu.dev>
* [windows] Return x86 microsleep for Windows (#3563)John2026-02-171-28/+11
| | | | | | | | | | Microsleep removal may have regressed AOC in msvc Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3563 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: Lizzie <lizzie@eden-emu.dev> Co-authored-by: John <john@eden-emu.dev> Co-committed-by: John <john@eden-emu.dev>
* [windows] return x86 microsleep for mingw only (#3544)lizzie2026-02-151-2/+44
| | | | | | | | | Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3544 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: DraVee <dravee@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [frontend] Slow and Turbo modes (#3525)crueter2026-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Closes #3344 Adds slow and turbo modes with configurable speeds that can then be toggled by the user. Behavior is: - Standard/slow limit, toggle turbo = turbo - Turbo limit, toggle turbo = standard - Standard/turbo limit, toggle slow = slow - Slow limit, toggle slow = standard Enabling the turbo/slow mode enables the frame limiter unconditionally. This has some conflicts with VSync. For example when I set my refresh rate to 60hz and enable vsync, turbo mode does nothing. Not sure how to go about fixing this, @MaranBr probably knows better the proper solution. Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3525 Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
* [core, windows] remove microSleep() and simply wait on events like on linux ↵lizzie2026-02-091-27/+2
| | | | | | | | | | | | | | | (#3498) we shall see if the original code was put there for a reason or if the microsleeps actually are horrid Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3498 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [common, core] remove uneeded memory indirection overhead at startup (#3306)lizzie2026-01-161-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for core stuff: just remove unique ptrs that dont need any pointer stability at all (afterall its an allocation within an allocation so yeah) for fibers: Main reasoning behind this is because virtualBuffer<> is stupidly fucking expensive and it also clutters my fstat view ALSO mmap is a syscall, syscalls are bad for performance or whatever ALSO std::vector<> is better suited for handling this kind of "fixed size thing where its like big but not THAT big" (512 KiB isn't going to kill your memory usage for each fiber...) for core.cpp stuff - inlines stuff into std::optional<> as opposed to std::unique_ptr<> (because yknow, we are making the Impl from an unique_ptr, allocating within an allocation is unnecessary) - reorganizes the structures a bit so padding doesnt screw us up (it's not perfect but eh saves a measly 44 bytes) - removes unused/dead code - uses std::vector<> instead of std::deque<> no perf impact expected, maybe some initialisation boost but very minimal impact nonethless lto gets rid of most calls anyways - the heavy issue is with shared_ptr and the cache coherency from the atomics... but i clumped them together because well, they kinda do not suffer from cache coherency - hopefully not a mistake this balloons the size of Impl to about 1.67 MB - which is fine because we throw it in the stack anyways REST OF INTERFACES: most of them ballooned in size as well, but overhead is ok since its an allocation within an alloc, no stack is used (when it comes to storing these i mean) Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3306 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [settings, frontend] Reorganize graphics/CPU settings, saner defaults (#3233)crueter2025-12-301-9/+10
| | | | | | | | | | | | | | - Fast GPU now defaults to 256, removed 128 since it's useless. - Completely reorganized graphics and CPU settings on both platforms. Also got rid of Eden's Veil - Merged some "use ..." settings that weren't really necessary. - Changed ExtendedDynamicState to be a combo box Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3233 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: Lizzie <lizzie@eden-emu.dev>
* [qt_common, core, audio] remove duplicate string literal definitions, inline ↵lizzie2025-11-171-2/+1
| | | | | | | | | | | | | | SystemManager::threadfunc, increase latency of audio shutdown (#3030) Very small code cleanup, also remove `[[unlikely]]` because it doesn't matter + increase latency of audio render when shutting down Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3030 Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [meta] remove MicroProfile (#185)crueter2025-08-061-5/+0
| | | | | | Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/185 Reviewed-by: Lizzie <lizzie@eden-emu.dev>
* Add cmake option to enable microprofile (#179)Gamer642025-08-021-0/+2
| | | | | | | | | | | | Backported from https://github.com/azahar-emu/azahar/commit/dd9c743041308112c8dc349c5c237c04b2c4c75f. Co-authored-by: PabloMK7 <hackyglitch2@gmail.com> Co-authored-by: Shinmegumi <shinmegumi@eden-emu.dev> Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/179 Co-authored-by: Gamer64 <gamer64@eden-emu.dev> Co-committed-by: Gamer64 <gamer64@eden-emu.dev>
* [core]: Custom CPU Ticks rewrite (#118)Gamer642025-07-261-5/+11
| | | | | | | | | For now this is for testing purposes Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/118 Co-authored-by: Gamer64 <gamer64@eden-emu.dev> Co-committed-by: Gamer64 <gamer64@eden-emu.dev>
* fix license headerscrueter2025-06-271-0/+3
| | | | Signed-off-by: crueter <swurl@swurl.xyz>
* [core, frontend] Add Custom CPU Ticks option (#217)Gamer642025-06-271-1/+3
| | | | | | Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Co-authored-by: crueter <swurl@swurl.xyz> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/217
* Fast CPU Time & Improved Fast GPU Time (#109)swurl2025-05-291-1/+6
| | | | | | | | | | | needs android setting Signed-off-by: swurl <swurl@swurl.xyz> Co-authored-by: Aleksandr Popovich <alekpopo@pm.me> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/109 Co-authored-by: swurl <swurl@swurl.xyz> Co-committed-by: swurl <swurl@swurl.xyz>
* Add sync core speedPavel Barabanov2025-04-121-2/+13
|
* Rework time service to fix time passing offline.Kelebek12024-01-241-1/+1
|
* core_timing: block advance thread while clearing and signal afterLiam2023-12-231-1/+2
|
* core_timing: handle concurrent unscheduling of looping eventsLiam2023-12-231-3/+11
|
* core_timing: use static typing for no-wait unscheduleLiam2023-12-231-2/+3
|
* core_timing: remove user data valueLiam2023-12-231-21/+11
|
* core_timing: lock event queue accessLiam2023-11-141-0/+2
|
* core_timing: Attempt to reduce heap siftingMerry2023-09-161-11/+22
|
* core_timing: Use a fibonacci heapMerry2023-09-161-27/+29
|
* Use spans over guest memory where possible instead of copying data.Kelebek12023-07-021-2/+1
|
* core_timing: Remove GetCurrentTimerResolution in CoreTiming loopMorph2023-07-021-3/+6
| | | | Other programs may change this value, but if thousands of syscalls in this loop is undesirable, then we can just set this once.
* core_timing: Fix SingleCore cycle timerMorph2023-06-071-17/+9
|
* (wall, native)_clock: Add GetGPUTickMorph2023-06-071-0/+7
| | | | Allows us to directly calculate the GPU tick without double conversion to and from the host clock tick.
* core_timing: Use CNTPCT as the guest CPU tickMorph2023-06-071-27/+8
| | | | | Previously, we were mixing the raw CPU frequency and CNTFRQ. The raw CPU frequency (1020 MHz) should've never been used as CNTPCT (whose frequency is CNTFRQ) is the only counter available.
* core_timing: Make use of MicroSleep for x64 CPUsMorph2023-03-271-0/+8
| | | | For CPUs that support tpause, this should result in significant CPU power savings over thread yield in this spin wait.
* core: Promote CPU/GPU threads to time criticalMorph2023-03-071-1/+1
| | | | And also demote Audren and CoreTiming to High thread priority.
* core_timing: Use higher precision sleeps on WindowsMorph2023-03-051-22/+33
| | | | | | The precision of sleep_for and wait_for is limited to 1-1.5ms on Windows. Using SleepForOneTick() allows us to sleep for exactly one interval of the current timer resolution. This allows us to take advantage of systems that have a timer resolution of 0.5ms to reduce CPU overhead in the event loop.
* remove static from pointer sized or smaller types for aesthetics, change ↵arades792023-02-141-1/+1
| | | | | | constexpr static to static constexpr for consistency Signed-off-by: arades79 <scravers@protonmail.com>
* add static lifetime to constexpr values to force compile time evaluation ↵arades792023-02-141-1/+1
| | | | | | where possible Signed-off-by: arades79 <scravers@protonmail.com>
* timing: wait for completion on unregisterLiam2023-01-141-24/+18
|
* core: core_timing: Re-initialize if single/multicore state changes.bunnei2022-10-181-9/+14
|
* core: Partially persist emulation state across game boots.bunnei2022-10-181-16/+13
|
* core_timing: use high-precision sleeps on non-Windows targetsLiam2022-10-081-0/+4
|
* common: remove "yuzu:" prefix from thread namesLiam2022-10-031-1/+1
|
* Merge pull request #8650 from Kelebek1/vsyncbunnei2022-09-171-16/+37
|\ | | | | [Coretiming/NVNFlinger] Improve multi-core vsync timing, and core timing accuracy
| * core_timing: Sleep in discrete intervals, yield during spinMorph2022-08-021-12/+13
| |
| * Add missing looping event schedule signalKelebek12022-08-021-5/+9
| |
| * Make coretiming waiting more accurateKelebek12022-08-021-11/+27
| |
* | Remove pause callbacks from coretimingKelebek12022-09-131-14/+0
|/
* Revert Coretiming PRs 8531 and 7454 (#8591)Maide2022-07-271-95/+56
|
* Rework CoreTimingKelebek12022-07-101-8/+67
|
* Core timing: use only one thread.Fernando Sahmkow2022-07-021-10/+2
|