Skip to content

Wine NSPA: Environment Variables && Feature Setup

jrdnjhnstn edited this page Jul 29, 2024 · 28 revisions

Setting up your environment for Wine-NSPA:

/etc/Environment (aka: enabling Wine-NSPA's features)

Most of Wine-NSPA's features are enabled or setup via Environment Variables, so in order to make use of them; you are required to have them set up, before running Wine-NSPA / your apps. Generally, the best way to do this is to simply setup Wine-NSPA's Environment globally / system-wide.

Why? because in order to have ease-of-use and desktop integration, you don't want to manually have to set them up every time you launch an app. ~ This is especially true when using .desktop files / launchers. The process is very simple. On my system, I set all of my desired Environment Variables in /etc/environment.

Here is what that looks like;

#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#

# Wine-NSPA
#
# Set the Wine-Prefix
# WINEPREFIX=/home/ninez/Winebox/winebox-master
# Set wine path
WINEPATH="/usr/lib"
# Wine User & Wiseserver Threads
SRV_RT_POLICY=RR
WINE_RT_PRIO=80
WINE_RT_POLICY="RR"
# Special case: NTDLL_RT_POLICT: Makes almost al threads SCHED_RR
# You may want to use "TS", which is SCHED_OTHER. 
NTDLL_RT_POLICY="RR"
NTDLL_RT_PRIO=5
# Esync/Fsync
WINEESYNC=1
WINEFSYNC=1
WINEFSYNC_SPINCOUNT=128
# Proton's Logical cpus override
WINE_LOGICAL_CPUS_AS_CORES=1
# Large Address Awareness
WINE_LARGE_ADDRESS_AWARE=1
# From Staging/Disable
STAGING_WRITECOPY=0
# don't use with staging writecopy
WINE_DISABLE_KERNEL_WRITEWATCH=1
# Preloader Remap Stack
WINEPRELOADREMAPSTACK='on-conflict'
# disable debugging/spam
WINEDEBUG=-all

this ensures that Wine-NSPA will run exactly how I want, regardless of how the app is started.

In my case, jackd is running with an RT priority of 90, and the highest wine-related jackd thread will be 86. Followed by the highest wine thread priorities being 80 (wineserver), and so on.

NOTE: In some cases, you may choose/need to Override an env variable. This can be done at the commandline, via scripts or by customizing .desktop files / launchers. Your override will take precedence over the globally set env variable... For example, sometimes you may need to run an application's installer with SCHED_OTHER policy, rather than the default SCHED_RR that was setup above (or the installer may fail to work correctly). This is very simple to do, simply do the following:

$ WINE_RT_POLICY=TS wine /path/to/your/installer

( TS (Time Sharing) = SCHED_OTHER )

note: by default, you want to be using either SCHED_RR or possibly SCHED_FF... but having TS as an available override is important, in cases like the above, as a workaround.

Systemd vs. Process Management

Due to most distributions default systemd configurations, you will likely need to modify your settings. Wine-NSPA may not start up correctly without doing so (for example mmap failing or hitting open file / fd limits). This applies to both /etc/systemd/user.conf and /etc/systemd/system.conf

DefaultLimitNOFILE=1024:16777216
DefaultLimitNPROC=500000
DefaultLimitMEMLOCK=infinity
DefaultLimitSIGPENDING=infinity
DefaultLimitRTPRIO=98

Note: You likely will also need to have properly setup your user's ability to have realtime process management. This varies slightly between distributions, but here is Archlinux' wiki on the topic: https://wiki.archlinux.org/title/realtime_process_management.

TODO: Add Large/Huge Pages setup information - Must be done on the host-Linux system, not in Wine-NSPA!