Frogging-Family / wine-tkg-git

The wine-tkg build systems, to create custom Wine and Proton builds
861 stars 156 forks source link

NTsync (aka Winesync+Fastsync) - feedback topic #936

Open Iglu47 opened 1 year ago

Iglu47 commented 1 year ago

NTsync (title not approved) is more "Correctness" and "Robustness" alternative implementation of synchronization primitives in Wine from Zebediah Figura (the author of "Esync" and "Fsync").

This requires changes on the Wine side (usually patches are called - fastsync ) and corresponding changes on the kernel side (implemented as a kernel module - winesync. Unlike Fsync, the winesync functionality cannot be used anywhere except Wine).

More details about what problem NTsync solves and what is "implementation of synchronization primitives in Wine" can be found here: https://lkml.org/lkml/2021/1/17/312 and here: sync2022.pdf

Some plans and wishes for tests from @zfigura:

CALL FOR TESTS: anyone who can test games from the "breaks with esync/fsync" list, that would be quite appreciated. Note there's a lot more that break simply because of PulseEvent(), and we've had a couple tested already and they work so I'm not worried about those. All of the above break because of subtler timing problems and I'd like to see if they work with ntsync.

ALSO CALL FOR TESTS: I need good, convincing data comparing winesync vs server side sync. I don't have application names because in the 3-4 years since I wrote esync I've completely forgotten what the most important applications even are.

How to get NTsync working on TkG builds?

  1. you need set _winesync="true" in .cfg for linux-tkg, build, install and loading on it
  2. when you need set _use_fastsync="true" in .cfg for wine-tkg and build it
  3. if you did everything correctly, then when you start the game in the output of the terminal or in the logs will appear wine: using fast synchronization.
  4. to disable NTsync, set env var WINE_DISABLE_FAST_SYNC=1.
*Please don't post conflicts with other patches, versions of Wine, or other things related to building or installing kernel or Wine in THIS thread - this is a place intended for developers and other players to see other people's NTsync test results and determine if there are any significant performance deviations (both up and down) compared to wineserver-sync, esync, fsync. And any issues are saved or added compared to esync/fsync/wineserver-sync only.
ms178 commented 1 year ago

I've got some numbers for you from the in-game-benchmark in Total War: Troy in 1080p / Ultra.

With NTSync:

Scene 1: 75,2 fps Scene 2: 119,4 fps Scene 3: 102 fps

WINE_DISABLE_FAST_SYNC=1:

Scene 1: 74,0 fps (-1,6 %) Scene 2: 116,4 fps (-2,5 %) Scene 3: 101,5 fps (-0,49 %)

Analysis: Scene 2 is the most CPU-bound of the three. As you see, there is quite a pronounced impact from the change.

My test system:

❯ inxi -GSC -xx
System:
  Host: klx99 Kernel: 6.1.5-3.2-cachyos-bore-lto arch: x86_64 bits: 64
    compiler: clang v: 16.0.0 Desktop: KDE Plasma v: 5.26.80 tk: Qt v: 5.15.8
    wm: kwin_x11 dm: SDDM Distro: CachyOS
CPU:
  Info: 18-core model: Intel Xeon E5-2696 v3 bits: 64 type: MT MCP
    arch: Haswell rev: 2 cache: L1: 1.1 MiB L2: 4.5 MiB L3: 45 MiB
  Speed (MHz): avg: 2312 high: 3790 min/max: 1200/2301 boost: enabled cores:
    1: 2301 2: 2301 3: 2301 4: 2301 5: 2301 6: 2301 7: 2301 8: 2301 9: 2301
    10: 2301 11: 2301 12: 2301 13: 1241 14: 2301 15: 2301 16: 2301 17: 2301
    18: 2301 19: 2301 20: 2301 21: 2301 22: 2301 23: 3790 24: 2301 25: 2301
    26: 2301 27: 2301 28: 2301 29: 2301 30: 2301 31: 2301 32: 2301 33: 2301
    34: 2301 35: 2301 36: 2301 bogomips: 165744
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
  Device-1: AMD Vega 10 XL/XT [Radeon RX 56/64] vendor: Micro-Star MSI
    driver: amdgpu v: kernel arch: GCN-5 pcie: speed: 8 GT/s lanes: 16 ports:
    active: DP-3 empty: DP-1,DP-2,HDMI-A-1 bus-ID: 05:00.0 chip-ID: 1002:687f
  Display: x11 server: X.Org v: 21.1.99 with: Xwayland v: 22.1.7
    compositor: kwin_x11 driver: X: loaded: amdgpu unloaded: modesetting
    alternate: fbdev,vesa dri: radeonsi gpu: amdgpu display-ID: :0 screens: 1
  Screen-1: 0 s-res: 2560x1440 s-dpi: 96
  Monitor-1: DP-3 mapped: DisplayPort-2 model: HP X27q res: 2560x1440
    dpi: 109 diag: 685mm (27")
  API: OpenGL v: 4.6 Mesa 23.1.0-devel (git-267dd1f4d5) renderer: AMD
    Radeon RX Vega (vega10 LLVM 16.0.0 DRM 3.49 6.1.5-3.2-cachyos-bore-lto)
    direct render: Yes
ms178 commented 1 year ago

Company of Heroes 2 - WQHD, Higher preset

With NTSync (2nd run):

Min: 56,00 fps Avg: 79,84 fps Max: 127,87 fps

WINE_DISABLE_FAST_SYNC=1:

Min: 56,99 fps (+1,7 %) Avg: 80,44 fps (+0,75 %) Max: 129,22 fps (+1,06 %)

Notes: There is a performance regression with NTSync in this older game. The first run with NTSync showed even worse numbers (77 fps avg) - but that might have been due to the shader compilation, hence I took the numbers from the second run which did show some improvements. I wouldn't read too much into this result as it is still in the range of normal deviation in this benchmark. Maybe still something worth to investigate?

Tk-Glitch commented 1 year ago

Maybe still something worth to investigate?

With only 2 runs it's hard to say if it's more than margin of error considering such minuscule differences. If the average on 10 runs leads to a similar gap, then that could be considered as an actual perf drop.

Now and that being said, if the WINE_DISABLE_FAST_SYNC=1 runs are with server-side sync, the difference should be much higher if you're CPU bound (>20% is quite common). If that's with fsync it's in line with what is to be expected from winesync, which is pretty much equal perf to fsync.

Iglu47 commented 1 year ago

thanks for trying to look into this. I have access to the EGS-version of A Total War Saga: Troy so I did a couple of tests with "campaign_benchmark" at Ultra preset settings - there seems to be a difference between regular wineserver-sync and ntsync at least.

screenshots of the in-game "campaign_benchmark" result

server-side sync: ![total_war_saga_troy_serverside_sync](https://user-images.githubusercontent.com/25866099/212484006-795a1aaf-aeef-4bd0-9e50-0caf44faa693.png) ntsync: ![total_war_saga_troy_ntsync](https://user-images.githubusercontent.com/25866099/212484028-501c8455-71bb-4375-af64-de00869be710.png)

UPD. another run I made mangolog https://flightlessmango.com/games/26979/logs/3576

please make sure the terminal output or log show wine: using fast synchronization. before posting resault here (we want the test results to be valid)

Tk-Glitch commented 1 year ago

Those results are making much more sense @Iglu47 . Thanks.

ms178 commented 1 year ago

I have no control over the build process, I simply used the proton-winesync binary packages ptr1337 provided in CachyOS for testers. That means by deduction that my numbers are highly likely just as valid as Iglu47's, as I've used the defaults even if they look different. Our hardware and software setup is very different after all.

I will leave more testing to others as I spend enough of my time with this experimental version that has other issues - even if Tk-Glitch considers these expected behavior. .

Tk-Glitch commented 1 year ago

@ms178 The proton build isn't enough for NTsync to work. Unless @ptr1337 added similar patches and handling to what we're doing in linux-tkg, you would need both winesync-dkms and winesync-udev-rule packages to begin with, and then either manually loading the module or adding it to your modules-load.d for it to be loaded on boot.

You didn't confirm you were seeing wine: using fast synchronization. in your wine output which would tell us if your results are indeed valid and everything was done correctly (either by you or the CachyOS maintainers), or not. You are talking with devs here, please try to understand we're expecting you to follow our guidelines if you participate in testing.

ms178 commented 1 year ago

Please have mercy with me, I am not a programmer and just wanted to help you guys. :) Admittedly I had missed that crucial part of the process. winesync-dkms / winesync-udev-rule were also installed. I assume ptr1337 handled all the neccesary patches, as he has seen NTSync working correctly with his binaries on other machines. The modules-load.d info is new to me though, I am deferring to prt1337 if that was handled automatically with his packages. If not, that could be a source for the deviation in the numbers. On the other hand, with a 1080Ti, the better result from Iglu47 with 140+ fps is also not too distant from mine with 119,4 fps and my Vega 56.

FuzzyQuils commented 1 year ago

Hello, your resident Overwatch player reporting in!

Soon as I have time I can get performance numbers vs server sync but I am glad to report Battle.net crashing wineserver in some cases with fsync doesn’t happen with winesync. (A reliable repro for the fsync issue is to also run Battle.net via Feral’s Gamemode with fsync enabled, such thing doesn’t happen using Winesync!)

Iglu47 commented 1 year ago

[20155] Ubisoft launcher hangs on "looking for patches"

Still present with NTsync for me. Using "wineserver sync" helps as workaround.

LethalManBoob commented 1 year ago

i get hangs on ea's new game app

csutcliff commented 1 year ago

Battle.net client struggles with fsync (fails to launch 1/2 the time). So far it hasn't had an issue starting with winesync. In-game performance (WoW) appears to be the same or better than fsync but being an MMO it is fairly subjective.

csutcliff commented 1 year ago

Again not a perfect comparison as it's protonified vanilla wine vs actual proton with valve wine but Hogwarts Legacies is running better (10-15 fps at 4k ultra no RT) with fastsync than fsync and hasn't crashed on me yet which was frequently happening on load screens.

ptr1337 commented 1 year ago

Again not a perfect comparison as it's protonified vanilla wine vs actual proton with valve wine but Hogwarts Legacies is running better (10-15 fps at 4k ultra no RT) with fastsync than fsync and hasn't crashed on me yet which was frequently happening on load screens.

You can also compile a fsync protonfied vanilla wine, then you would have a better comparison. Also you can disable NTsync/Winesync with your current running wine/proton with: WINE_DISABLE_FAST_SYNC=1

LethalManBoob commented 1 year ago

winesync tkg is gone from aur

csutcliff commented 1 year ago

winesync tkg is gone from aur

https://aur.archlinux.org/packages/winesync-dkms & https://aur.archlinux.org/packages/winesync-udev-rule

works fine

LethalManBoob commented 1 year ago

There was a specific prebuild protonified wine version of tkg that supported winesync edit: spoke to ptr 1337 this was due to tkg making changes that made the cachyos prebuilds unusable

shmerl commented 1 year ago

Is there some instruction how to build and test winesync? And what's the current status of it?

A side question, I recently encountered huge performance improvement in the Witcher 3 (DX12 mode) and Cyberpunk 2077 when Wine-esync is used. I wanted to compare it to Wine+fsync.

What is a good way to apply fsync patches to upstream Wine? I didn't find it in Wine-staging and it's not clear how to apply them from other sources.

rlees85 commented 1 year ago

Another report for Battle.net working nicely with winesync. On both esync and fsync it would not launch half the time or cause wineserver to coredump sometimes taking the whole system with it.

I've been playing StarCraft 2 and Overwatch 2 - both used to work with fsync anyway - with winesync. No problems.

Performance in StarCraft 2 is better but it could be any number of reasons since wine-tkg (my custom build of)/wine-ge-custom are very different things.

An-Eagle commented 1 year ago

[20155] Ubisoft launcher hangs on "looking for patches"

Still present with NTsync for me. Using "wineserver sync" helps as workaround.

Not completely related to this thread, but the crypt32 dll isntalled through winetricks allows to get through this error in my experience, and has for a few other users I have helped in the past.

shmerl commented 1 year ago

Just a follow up. Any recommended way to use Winesync now over upstream kernel and wine? Various repos are quite outdated to apply things.

FuzzyQuils commented 1 year ago

Just a follow up. Any recommended way to use Winesync now over upstream kernel and wine? Various repos are quite outdated to apply things.

The winesync-dkms module + a recent build of wine-tkg with fastsync enabled in the config. That's generally what I do.

For Proton, it's a bit trickier, I've been working on a valve tree patchset for that.

shmerl commented 1 year ago

Recent build of wine-tkg with fastsync enabled in the config

I tried playing around with that, but couldn't figure out how to apply only that on top of upstream Wine. wine-tgk has a ton of stuff and is a bit cumbersome to configure. No matter what I tried, it seemed to pull some extra stuff that I didn't want.

It would be nice to have something like wine-staging patchset for it that is easy to apply to upstream Wine.

And which repo has an up to date dkms module for winesync?

shmerl commented 1 year ago

What's the current state of this in general? I.e. is it close to getting upstream or more data is needed? Are there any blockers? Not sure where / how to check the status, so asking here.

Iglu47 commented 1 year ago

@shmerl the status has not changed. Important Information: Reports are needed to ensure that NTsync/Winesync does not introduce any new issues compared to Esync.

ptr1337 commented 1 year ago

@shmerl the status has not changed. Important Information: Reports are needed to ensure that NTsync/Winesync does not introduce any new issues compared to Esync.

Generally a rebase against proton 8 would be very interesting for many users, i think.

Iglu47 commented 1 year ago

Generally a rebase against proton 8 would be very interesting for many users, i think.

porting to wine-valve tree and availability of wenesync module. I'll try to find the time and do something about it

csutcliff commented 1 year ago

Is there anyone working on or planning on re-basing against the current wine master since it broke?

daktras420 commented 1 year ago

thank you Iglu47 i was planning on doing wine build this week using your patchset and the wine-valve tree as well as proton for steam with the ntsync patches if its doable what reversion or current tree version are your patches compatible with ei. wine-protonified, or wine-protontified bleeding edge, same for steams proton which build is most compatible? for now since i have dxvk gasync installed via aur with arch will try it using system dxvk and see if it all works till and if the developer of the new dxvk patch files work is included into the frogging family of patches.

BarackOBusiness commented 9 months ago

In some most likely outlier games and non scientific testing whatsoever, winesync can vary from doubling fps to significant gains (>25%) to being within margin of error in some indie unity games I've tested (compared to fsync on an identical proton build barring fastsync being the variable tested). On my system which consists of ryzen 9 7950x3d + rx 7900 xt using only radv, Getting Over It with Bennett Foddy goes from ~250->500 fps consistently. Second case (significant gains) games like risk of rain 2, rain world, and ultrakill see ~230->300-460 fps, 400-500 fps uplift, and 200 fps uplift for those respectively, it seems like generally winesync may be largely beneficial for a number of seemingly low end games that end up quite cpu limited as a result of the framework they're built on, a few others I've tested like phasmophobia or muck get a small margin of error fps uplift. And despite this some are still notably below windows performance (I believe getting over it performs closer to the 700-800 fps ballpark on my system). I've conducted this testing rather quickly using only dxvk's fps hud and would be interested in some simple profiling or testing methodology I can use to get empirical results across my library and also compare to esync as well to help contribute to winesync's development here

ptr1337 commented 9 months ago

@Iglu47

It would be really cool, if you could rebase this patchset against the proton-experimental branch. I would roll it out to some of our users.

Maybe it would be also worth, that GE provides a Version with winesync to have a bigger testing and feedback.

FuzzyQuils commented 9 months ago

@Iglu47

It would be really cool, if you could rebase this patchset against the proton-experimental branch. I would roll it out to some of our users.

Maybe it would be also worth, that GE provides a Version with winesync to have a bigger testing and feedback.

I've rebased onto Proton-tkg before, I'll rebase against experimental BE again when I have time. Currently using an earlier patchset with Overwatch 2 on Steam, which has improved minimum framerates when uncapped.

ptr1337 commented 9 months ago

@Iglu47 It would be really cool, if you could rebase this patchset against the proton-experimental branch. I would roll it out to some of our users. Maybe it would be also worth, that GE provides a Version with winesync to have a bigger testing and feedback.

I've rebased onto Proton-tkg before, I'll rebase against experimental BE again when I have time. Currently using an earlier patchset with Overwatch 2 on Steam, which has improved minimum framerates when uncapped.

If you have a rebase against proton-experimental, feel free to share it to me. I would add it to our proton fork

LethalManBoob commented 9 months ago

Would test.

shmerl commented 9 months ago

It would be nice to add it to wine-staging to test and provide the kernel part as an easy to use dkms module too until it's upstreamed.

I didn't get to testing it since there is no easy to way to build Wine just with these patches, unlike wine+esync.

rlees85 commented 9 months ago

@shmerl https://aur.archlinux.org/packages/winesync obviously thats arch but you should be able to follow the links to find the scripts to easily build your own DKMS module no matter what distro you are on. If you are on Arch, even better

shmerl commented 9 months ago

Thanks, I'll take a look. Is there some instruction how to build Wine itself with just winesync applied?

Riesi commented 9 months ago

just look into the customization.cfg I think you can figure the settings out ;) And then its just a matter of building the right flavor of wine

# NTsync - Disable with WINE_DISABLE_FAST_SYNC=1 envvar - Set to true to enable NTsync support - https://repo.or.cz/wine/zf.git/shortlog/refs/heads/fastsync4
# more info about NTsync and feedback topic - https://github.com/Frogging-Family/wine-tkg-git/issues/936
# !! For building and using requires special linux-tkg build with winesync module and header (or https://aur.archlinux.org/packages/winesync-dkms/) !!
# !! Not compatible with Valve trees and some other patches. On Staging depends on fsync patches !!
# !! For plain Wine required disabling esync and fsync patches applying !!
_use_fastsync="false"
shmerl commented 9 months ago

I think I tried that, but it always ends up adding more than just winesync related patches. I guess I gave up since it felt too convoluted.

May be I'll give it another try. It would be nice to simply add these to wine staging.

Riesi commented 9 months ago

If you want plain wine with it, then you should just enable it there and select mainline in the wine flavor section. That only applied fastsync for me when looking into the prepare.log.

FuzzyQuils commented 8 months ago

Reporting in; I've tested patching a pure Proton tree with my port of Fastsync and on the relevant wine subproject, it applies on the latest Experimental 8.0 - now I'm making a non-tkg build for testing purposes and will report back with my results.

UPDATE: In regards to how this patchset works; I authored it in a manner where esync and fsync are the default if fastsync is disabled:

shmerl commented 8 months ago

@FuzzyQuills: Is your version of fastsync different from upstream? What do you mean by your port? And how does it perform in comparison to fsync/esync in practice?

LethalManBoob commented 8 months ago

I hope we can get winesync into some official repos. Like cachy-proton or proton-ge.

shmerl commented 8 months ago

Would be nice to have it in Wine-staging patches too so it wouldn't be so hard to apply it to upstream Wine.

FuzzyQuils commented 8 months ago

wineserver coredumped on generating the default prefix, investigating. Probably changes in Valve's upstream that need to be taken into account now.

FuzzyQuils commented 8 months ago

@FuzzyQuills: Is your version of fastsync different from upstream? What do you mean by your port? And how does it perform in comparison to fsync/esync in practice?

Upstream normally applies to mainline wine tree, which lacks esync/fsync. The staging version requires fsync, which points to fast_sync ops structures needing fsync's function pointers present for proper interoperability.

Aside from proton-specific quirks, my port is otherwise 1:1 with zf's mainline commits.

FuzzyQuils commented 8 months ago

Fixed the coredumping issue; it was a mistake in completion.c (again) on my side. Testing the build now.

FuzzyQuils commented 8 months ago

So it appears testing NTSync in a pure Proton build is currently impossible, due to HAVE_LINUX_WINESYNC_H not being defined. This is due to the Steam Runtime container not having the files so all the fastsync functions get stubbed on build.

I'm investigating ways I can make this work but currently it looks like only TkG Proton builds (these don't use the Steam Runtime) are the only way to use my patchset.

Given the bug I found and fixed before, I'll have to update the actual patch file before I can upload it.

UPDATE: I may have found a workaround, stay tuned.

FuzzyQuils commented 8 months ago

Okay, so I now have fastsync mostly working, sans some bugs with interoperability between esync/fsync and fastsync (namely, a stack overflow currently occurs if esync/fsync and fastsync are active at the same time, I'm narrowing down what detection mechanism to properly use so fastsync is the default setting)

UPDATE: Couldn't fix the interoperability issues so I reverted my logic to the old one. Only bug left with doing that is the fact fastsync will fail to print "wine: using server synchronisation" if it fails to load but PROTON_NO_FAST_SYNC is set to 0 (Incidentally it doesn't automatically fallback to esync/fsync when this happens. oof)

Tomorrow, I'll be redoing the patches in a way that makes them easier to maintain, with all the new tweaks done today being included.

FuzzyQuils commented 8 months ago

Some good news; I've done further testing with Forza Horizon 5 and the game in singleplayer mode with online active is stable with fastsync active. Haven't yet tested PvP in this game though.

UPDATE: Tested with Overwatch 2 as well, looking good here too