motivewave and linux performance improvements

alexjp

Member
Joined
Apr 7, 2021
Posts
22
Likes
16
Hi,

Just registered to say this about motivewave running in linux:

I am testing motivewave ( on trial for about a week ), both in linux and windows. I noticed that on windows it ran much better, especially with the Volume Imprint study in "ladder" style.

After much reading on the web and testing, now I have a much better performance on motivewave on linux, with what was before a very "jerky and slow" movement, into as smooth as in windows. As a bonus, the "mouse wheel" problem in linux is fixed ( i can use mouse wheel to increase and decrease bar width size, before it would not decrease ) !

What is needed is editing the run.sh file and adding these parameters:

-Djdk.gtk.version=2 -Dprism.forceGPU=true -Dsun.java2d.opengl=true -Dprism.order=es2,es1,sw,j2d -Dsun.java2d.pmoffscreen=false -Dprism.vsync=false -Dprism.lcdtext=false -Dawt.useSystemAAFontSettings=false


Notes:
* In my case, prism.forceGPU is necessary because with an amd card (rx580 in my case) it switches to sw rendering mode.

* prism.vsync=false and -Dsun.java2d.pmoffscreen=false seems to make things much smoother in general.

* -Djdk.gtk.version=2, -Dprism.lcdtext=false and -Dawt.useSystemAAFontSettings=false really help in making volume imprint "ladder mode" really smooth.
 
Hi there @alexjp and thank you for joining the MW-forums to tell us about your findings 😄

I have been struggling with that mouse-issue as well, for quite some time now.
I have also looked for a solution, but came up empty after hours of googling & testing stuff.

You are without a doubt more skilled ;)

I tried to implement your solution, but it does not seem to work.

Can you please be a little more specific ?
Where in that run.sh file should we past those lines ?
Which part is responsible for the weird mouse behavior ? (or is this interwoven with the GPU-stuff ?)

(I'm running Debian 10 with gdm3 by the way)


Thank you for your contribution ! (y)
 
Thanks @Spin !

Sorry, i should have been cleared:

in the script, the last line:
Code:
# Start the JVM.  For convenience java has been renamed to motivewave so that is easier to identify in the System Monitor
$SCRIPTDIR/jre/bin/motivewave $MAX_HEAP -Djdk.gtk.version=2 -Dprism.forceGPU=true -Dsun.java2d.opengl=true -Dprism.order=es2,es1,sw,j2d -Dsun.java2d.pmoffscreen=false -Dprism.vsync=false -Dprism.lcdtext=false -Dawt.useSystemAAFontSettings=false -Dprism.cacheshapes=all -Dprism.occlusion.culling=true -Dprism.scrollcacheopt=true -javaagent:"$SCRIPTDIR/jar/MotiveWave.jar" -Dname="MotiveWave"  -Djava.library.path="$SCRIPTDIR/lib" -DUserHome="$HOME" -Duser.dir="$HOME" -DappDir="$SCRIPTDIR" -DLibraryDirectory="$HOME/Library" -DDocumentsDirectory="$HOME/Documents" -DCachesDirectory="$HOME/Library/Caches" -DDesktopDirectory="$HOME/Desktop" -DDownloadsDirectory="$HOME/Downloads" -DSharedPublicDirectory="$HOME/Public" -Dprism.verbose=true -Dprism.maxvram=2048M -Dglass.gtk.uiScale=$SCALE -Dsun.java2d.uiScale=$SCALE -p "$SCRIPTDIR/javafx" --add-modules=javafx.controls,javafx.base,javafx.graphics,javafx.media,javafx.web,javafx.swing --add-exports javafx.web/com.sun.webkit.network=ALL-UNNAMED -classpath "$CP" $VM_ARGS MotiveWave

The specific parameter that fixes the mouse, is -Djdk.gtk.version=2, if i am not mistaken. ( yep confirmed, just tested it, and without it mouse doesn't work properly again ).

I didn't find on google a reference to the gtk2 mouse fix, but i saw some people having problems with java's gtk3 and wayland ( which i am using ), and some bugs on it, so decided to try with gtk2. it was just luck !
 
I confirm the mouse issue is resolved by @alexjp 's fix. What a relief !!! And my trading has already improved by 25% ;)

Thanks again @alexjp (y)(y)
 
FYI: the file /usr/share/motivewave/run.sh gets overwritten each time you update MW.

So you would have to make the changes after every update :)
 
FYI: the file /usr/share/motivewave/run.sh gets overwritten each time you update MW.

So you would have to make the changes after every update :)

you can copy the file to somewhere else, like you home folder and run it from there. As long as the "SCRIPTDIR" variable is correct, there will be no issues.
 
Alex,

good finding! the graphics redraw is faster and the system monitor shows less CPU consumption.

cheers.
 
Cheers for that. One can only hope that one day MW will wake up and give the startup script some much needed time, love and tender care.

It's been a while coming now, innit.
 
Thanks @Spin !

Sorry, i should have been cleared:

in the script, the last line:
Code:
# Start the JVM.  For convenience java has been renamed to motivewave so that is easier to identify in the System Monitor
$SCRIPTDIR/jre/bin/motivewave $MAX_HEAP -Djdk.gtk.version=2 -Dprism.forceGPU=true -Dsun.java2d.opengl=true -Dprism.order=es2,es1,sw,j2d -Dsun.java2d.pmoffscreen=false -Dprism.vsync=false -Dprism.lcdtext=false -Dawt.useSystemAAFontSettings=false -Dprism.cacheshapes=all -Dprism.occlusion.culling=true -Dprism.scrollcacheopt=true -javaagent:"$SCRIPTDIR/jar/MotiveWave.jar" -Dname="MotiveWave"  -Djava.library.path="$SCRIPTDIR/lib" -DUserHome="$HOME" -Duser.dir="$HOME" -DappDir="$SCRIPTDIR" -DLibraryDirectory="$HOME/Library" -DDocumentsDirectory="$HOME/Documents" -DCachesDirectory="$HOME/Library/Caches" -DDesktopDirectory="$HOME/Desktop" -DDownloadsDirectory="$HOME/Downloads" -DSharedPublicDirectory="$HOME/Public" -Dprism.verbose=true -Dprism.maxvram=2048M -Dglass.gtk.uiScale=$SCALE -Dsun.java2d.uiScale=$SCALE -p "$SCRIPTDIR/javafx" --add-modules=javafx.controls,javafx.base,javafx.graphics,javafx.media,javafx.web,javafx.swing --add-exports javafx.web/com.sun.webkit.network=ALL-UNNAMED -classpath "$CP" $VM_ARGS MotiveWave

The specific parameter that fixes the mouse, is -Djdk.gtk.version=2, if i am not mistaken. ( yep confirmed, just tested it, and without it mouse doesn't work properly again ).

I didn't find on google a reference to the gtk2 mouse fix, but i saw some people having problems with java's gtk3 and wayland ( which i am using ), and some bugs on it, so decided to try with gtk2. it was just luck !
Great thanks!
I struggled if i want Motivewave because of the mouse wheel bug.
You saved my day! It is clearly visible that MW runs much smoother and faster with the added parameters.
Great bugfix and boost for the linux version!
 
It looks like the most recent version of Motivewave have adopted the settings suggested here.

However, they still have the defective scripting dealing with the VM Args settings file in place.

If you are interested in dabbling with VM settings then you need to apply the attached patch. I do this by making a copy of the motivewave startup script in my personal bin directory and then use that going forward (including updating the desktop icon target).

If you update motivewave you'll have to keep updating this as the original launcher cannot deal with multiple VM setting arguments.

That's because the original script cannot extract multiple arguments correctly.

So in summary:

$ mkdir ~/bin
$ cp /usr/bin/motivewave ~/bin/motivewave
$ patch -p0 < motivewave.txt

After that you can modify the VM args as you wish using the launcher, but it must be quoted:

1648394897701.png
 

Attachments

  • motivewave.txt
    1.4 KB · Views: 56
Almost 2 years later and I'm afraid I have to resuscitate this thread: it seems that 'very annoying mouse issue' is back from the dead. ☠️
I tested with 6.8.8 and 6.9.0 on Debian 12, both with and without "-Djdk.gtk.version=2" and 3 and it persists.

Anyone else seeing this ?
Did someone find a solution already ?

Thx, fellow Linux-lovers ! ❤️

EDIT:
just saw that from 6.8.8 onwards MW started using Java / JavaFX 21. Maybe this is the culprit ?
1710499560560.png

SECOND EDIT:
I should have known: "it's not a bug, it's a feature" :sneaky:
My hunch seems to have been correct. According to this (very old) thread this is a limitation of the X12-protocol.
I added this line to the top of my 'run.sh':
1710500531187.png
and away is the demon !!
🥳
 
Last edited:
Almost 2 years later and I'm afraid I have to resuscitate this thread: it seems that 'very annoying mouse issue' is back from the dead. ☠️
I tested with 6.8.8 and 6.9.0 on Debian 12, both with and without "-Djdk.gtk.version=2" and 3 and it persists.

Anyone else seeing this ?
Did someone find a solution already ?

Thx, fellow Linux-lovers ! ❤️

EDIT:
just saw that from 6.8.8 onwards MW started using Java / JavaFX 21. Maybe this is the culprit ?
View attachment 2259

SECOND EDIT:
I should have known: "it's not a bug, it's a feature" :sneaky:
My hunch seems to have been correct. According to this (very old) thread this is a limitation of the X12-protocol.
I added this line to the top of my 'run.sh':
View attachment 2260
and away is the demon !!
🥳
Thank you so much @Spin !
This solved the issue!
 
Thanks a lot for posting that fix @Spin !, I've had the same issue since 6.8.8 and now it works again.
 
It seems gtk2 was removed in recent JavaFX.

Seems all good for Motivewave and Linux! thanks @Spin !!

I have been using "bleeding edge" versions of Xwayland, and there was an issue where Motivewave would start using all the RAM until killed. This is now fixed: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1664
Some serious testing & debugging in that thread.

R.E.S.P.E.C.T. @alexjp (The IT-world and all of the IT in the world runs on people like you !)

🙏
 
Some serious testing & debugging in that thread.

R.E.S.P.E.C.T. @alexjp (The IT-world and all of the IT in the world runs on people like you !)

🙏

Thanks :) But the merit is all of those developers. They did great work !!!
 
The startup.ini file must not contain undefined values for the follwing performance optimisation to work, so after you use advanced options you must clean the startup.ini of such lines because using advanced options in the menu overrides startup.ini with your values and gives some lines with undifined values that prevent the motivewave file to do its job in that issues:

Example for a clean startup.ini:
#
# This file contains startup parameters that are passed to the JVM when MotiveWave is started
#
MAX_HEAP=16G
MAX_VRAM=8192M

After you have a clean startup.ini set the value of it to read only. Otherwise startup.ini will get the wrong values again from advanced option if you restart Motivewave, so you can prevent the advanced options menu to change the startup.ini file.


The problems with multiple chart loading much too long can be solved with multiple vm_args in the starter java motivewave
Summary of Arguments and Benefits

  1. -XX:+UseG1GC (Garbage Collector) - Placement: VM_ARGS_1
    Improves memory efficiency and reduces pause times during garbage collection.
  2. -XX:parallelGCThreads=4 (Parallel Garbage Collection) - Placement: VM_ARGS_2
    Utilizes multiple threads for garbage collection, enhancing performance on multi-core processors.
  3. -Dsun.java2d.opengl=true (Graphics Acceleration) - Placement: VM_ARGS_3
    Enables hardware acceleration via OpenGL, which is especially beneficial for smooth chart rendering.
  4. -XX:+AlwaysPreTouch (Memory Optimization) - Placement: VM_ARGS_4
    Optimizes memory access and improves performance during the startup of Motivewave.
With these settings, you should notice a significant improvement in terms of performance, startup time, and graphical rendering.
This kicks in especially if you load multiple charts at the same time under heavy use.
The new mouse scroll bug was solved by spin so big Thanks to him for that!

the smily in my motivewavre starter example file is : P without the blank space between in the forum it is by default a laughing smile. Hope you can get the correct value.
Here is the example of the usage in my starter motivewave:

#!/bin/bash
export GDK_CORE_DEVICE_EVENTS=1
# MotiveWave should be installed under the following directory
SCRIPTDIR=/usr/share/motivewave

# Classpath: dynamically load all jar files in the "jar" directory
CP=""
for entry in "$SCRIPTDIR/jar/"*.jar
do
CP+=":$entry"
done
# trim the first ':'
CP=$(echo $CP | cut -c 2-)

# Maximum Heap. By default, this will be one quarter of the system memory. Optionally, this can be hardcoded (see below)
MAX_HEAP="-Xmx16G" # 16 GB für die JVM
# Maximum VRAM. By default, this will be 8192 MB. Optionally, this can be hardcoded (see below)
MAX_VRAM="8192M" # 8 GB für den Video RAM
# Additional VM arguments (in deiner aktuellen Version wird nur ein Argument gesetzt, das überschreiben wird)
VM_ARGS=""

# Scaling does not seem to be picked up automatically and defaults to 100% (at least on the desktops that we tested)
# Try to get the scale setting for the gnome desktop, but typically this seems to return 0...
gsettings get org.gnome.desktop.interface scaling-factor
SCALE=`gsettings get org.gnome.desktop.interface scaling-factor | awk '{print $2}'`

# If this is 0, then try to guess from the screen resolution
if [[ $SCALE == 0 || $SCALE == "" || !($SCALE =~ ^[0-9]*[.]?[0-9]*$) ]]; then
xrandr --query | grep -A 1 "connected primary" | grep -v connected
H=`xrandr --query | grep -A 1 "connected primary" | grep -v connected | awk '{print $1}' | awk -Fx '{print $2}'`
echo "Resolution: $H"
SCALE=1
if [[ $H -gt 1800 ]]; then SCALE=2; fi
if [[ $H -gt 4000 ]]; then SCALE=3; fi
fi

# Convert this to a percentage
SCALE=$(echo "$SCALE*100" | bc)
SCALE=${SCALE%.*}
SCALE+="%"

# Pull information from the .settings file in the motivewave directory
SETTINGS_FILE=~/.motivewave/startup.ini

if [ -f ${SETTINGS_FILE} ]
then
source ${SETTINGS_FILE}

# Setzen von MAX_HEAP aus startup.ini
[[ -n "${MAX_HEAP}" ]] && MAX_HEAP="-Xmx${MAX_HEAP}"

# Setzen von MAX_VRAM aus startup.ini
[[ -n "${MAX_VRAM}" ]] && MAX_VRAM="-Dprism.maxvram=${MAX_VRAM}"

# Einzeln aufgesetzte VM-Argumente für bessere Flexibilität
[[ -n "${VM_ARGS_1}" ]] && VM_ARGS_1="-XX:+UseG1GC"
[[ -n "${VM_ARGS_2}" ]] && VM_ARGS_2="-XX:parallelGCThreads=4"
[[ -n "${VM_ARGS_3}" ]] && VM_ARGS_3="-Dsun.java2d.opengl=true"
[[ -n "${VM_ARGS_4}" ]] && VM_ARGS_4="-XX:+AlwaysPreTouch"
fi

# Startaufruf der JVM mit den neuen Argumenten
$SCRIPTDIR/jre/bin/motivewave $MAX_HEAP $VM_ARGS_1 $VM_ARGS_2 $VM_ARGS_3 $VM_ARGS_4 -Djdk.gtk.version=2 -Dprism.forceGPU=true -Dsun.java2d.opengl=true -Dprism.order=es2,es1,sw,j2d -Dsun.java2d.pmoffscreen=false -Dprism.vsync=false -Dprism.lcdtext=false -Dawt.useSystemAAFontSettings=false -javaagent:"$SCRIPTDIR/jar/MotiveWave.jar" -Dname="MotiveWave" -Djava.library.path="$SCRIPTDIR/lib" -DUserHome="$HOME" -Duser.dir="$HOME" -DappDir="$SCRIPTDIR" -DLibraryDirectory="$HOME/Library" -DDocumentsDirectory="$HOME/Documents" -DCachesDirectory="$HOME/Library/Caches" -DDesktopDirectory="$HOME/Desktop" -DDownloadsDirectory="$HOME/Downloads" -DSharedPublicDirectory="$HOME/Public" -Dprism.verbose=true -Dglass.gtk.uiScale=$SCALE -Dsun.java2d.uiScale=$SCALE -p "$SCRIPTDIR/javafx" --add-modules=javafx.controls,javafx.base,javafx.graphics,javafx.media,javafx.web,javafx.swing --add-exports javafx.web/com.sun.webkit.network=ALL-UNNAMED -classpath "$CP" MotiveWave
 
Last edited:
Hope this makes it clearer:
startup.ini:
#
# This file contains startup parameters that are passed to the JVM when MotiveWave is started
#
MAX_HEAP=16G
MAX_VRAM=8192M


This is all that is left in my startup.ini
Specify Max Heap and Vram with the graphical interface advanced options so that it matches your system requirements.
After that restart motivewave. At start the values will be written in the startup.ini
But this will write some lines in the startup.ini that do not contain values.
That lines without values in startup.ini must be deleted otherwise override the values in run.sh at start of motvewave.

After your startup.ini looks like mine perhaps with diffrent values of max heap and max vram you close the file and set it on read only. Otherwise next time you start motivewave the starting process will add the lines again in startup.ini .

Motivewave support gave my tips to product development for implementation, but until that is done, this is the way to work with multiple Vm values i fear.

To sum it up. In startup.ini nothing to add. only deleting some lines to clean it and set it on read only after that. System will start without failure notice.

All adds are in the motivewave run.sh.
The path to motivewave file is your home directory /bin

Example of a working motivewave file (run.sh) with working mouse and faster loading charts is:
#!/bin/bash
export GDK_CORE_DEVICE_EVENTS=1
# MotiveWave should be installed under the following directory
SCRIPTDIR=/usr/share/motivewave

# Classpath: dynamically load all jar files in the "jar" directory
CP=""
for entry in "$SCRIPTDIR/jar/"*.jar
do
CP+=":$entry"
done
# trim the first ':'
CP=$(echo $CP | cut -c 2-)

# Maximum Heap. By default, this will be one quarter of the system memory. Optionally, this can be hardcoded (see below)
MAX_HEAP="-Xmx16G" # 16 GB für die JVM
# Maximum VRAM. By default, this will be 8192 MB. Optionally, this can be hardcoded (see below)
MAX_VRAM="8192M" # 8 GB für den Video RAM
# Additional VM arguments (in deiner aktuellen Version wird nur ein Argument gesetzt, das überschreiben wird)
VM_ARGS=""

# Scaling does not seem to be picked up automatically and defaults to 100% (at least on the desktops that we tested)
# Try to get the scale setting for the gnome desktop, but typically this seems to return 0...
gsettings get org.gnome.desktop.interface scaling-factor
SCALE=`gsettings get org.gnome.desktop.interface scaling-factor | awk '{print $2}'`

# If this is 0, then try to guess from the screen resolution
if [[ $SCALE == 0 || $SCALE == "" || !($SCALE =~ ^[0-9]*[.]?[0-9]*$) ]]; then
xrandr --query | grep -A 1 "connected primary" | grep -v connected
H=`xrandr --query | grep -A 1 "connected primary" | grep -v connected | awk '{print $1}' | awk -Fx '{print $2}'`
echo "Resolution: $H"
SCALE=1
if [[ $H -gt 1800 ]]; then SCALE=2; fi
if [[ $H -gt 4000 ]]; then SCALE=3; fi
fi

# Convert this to a percentage
SCALE=$(echo "$SCALE*100" | bc)
SCALE=${SCALE%.*}
SCALE+="%"

# Pull information from the .settings file in the motivewave directory
SETTINGS_FILE=~/.motivewave/startup.ini

if [ -f ${SETTINGS_FILE} ]
then
source ${SETTINGS_FILE}

# Setzen von MAX_HEAP aus startup.ini
[[ -n "${MAX_HEAP}" ]] && MAX_HEAP="-Xmx${MAX_HEAP}"

# Setzen von MAX_VRAM aus startup.ini
[[ -n "${MAX_VRAM}" ]] && MAX_VRAM="-Dprism.maxvram=${MAX_VRAM}"

# Einzeln aufgesetzte VM-Argumente für bessere Flexibilität
[[ -n "${VM_ARGS_1}" ]] && VM_ARGS_1="-XX:+UseG1GC"
[[ -n "${VM_ARGS_2}" ]] && VM_ARGS_2="-XX:parallelGCThreads=4"
[[ -n "${VM_ARGS_3}" ]] && VM_ARGS_3="-Dsun.java2d.opengl=true"
[[ -n "${VM_ARGS_4}" ]] && VM_ARGS_4="-XX:+AlwaysPreTouch"
fi

#
Startaufruf der JVM mit den neuen Argumenten
$SCRIPTDIR/jre/bin/motivewave $MAX_HEAP $VM_ARGS_1 $VM_ARGS_2 $VM_ARGS_3 $VM_ARGS_4 -Djdk.gtk.version=2 -Dprism.forceGPU=true -Dsun.java2d.opengl=true -Dprism.order=es2,es1,sw,j2d -Dsun.java2d.pmoffscreen=false -Dprism.vsync=false -Dprism.lcdtext=false -Dawt.useSystemAAFontSettings=false -javaagent:"$SCRIPTDIR/jar/MotiveWave.jar" -Dname="MotiveWave" -Djava.library.path="$SCRIPTDIR/lib" -DUserHome="$HOME" -Duser.dir="$HOME" -DappDir="$SCRIPTDIR" -DLibraryDirectory="$HOME/Library" -DDocumentsDirectory="$HOME/Documents" -DCachesDirectory="$HOME/Library/Caches" -DDesktopDirectory="$HOME/Desktop" -DDownloadsDirectory="$HOME/Downloads" -DSharedPublicDirectory="$HOME/Public" -Dprism.verbose=true -Dglass.gtk.uiScale=$SCALE -Dsun.java2d.uiScale=$SCALE -p "$SCRIPTDIR/javafx" --add-modules=javafx.controls,javafx.base,javafx.graphics,javafx.media,javafx.web,javafx.swing --add-exports javafx.web/com.sun.webkit.network=ALL-UNNAMED -classpath "$CP" MotiveWave

Hope i can help you with that :cool:
 
I must say, @Hermann, that is some bad-ass 'Deutsche Gründligkeit' 🇩🇪🇩🇪(y)(y)

Thank you for being so thorough and transmitting your solutions / suggestions to the MW-Dev-Team !
Many other will benefit from this !
 
Top