Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 25

Thread: Mafia Slowness

  1. #1

    Default Mafia Slowness

    Over the last few weeks I've noticed Mafia getting slower and have had a few lockups. (Ubuntu 16.04, latest mafia version from Jenkins)

    Today it is VERY bad, I ran `top` and I see java using 100% of the CPU and 9GB of virtual memory.

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    10752 rugrat 20 0 9639444 1.063g 30724 S 100.0 6.8 21:05.65 java

    Is there a memory leak or is this resource hog natural?
    Last edited by Boondoggle; 07-31-2019 at 12:16 PM.

  2. #2
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,314

    Default

    Over the last few weeks I've noticed Mafia getting slower and have had a few lockups. (Ubuntu 16.04, latest mafia version from Jenkins)
    Originally Posted by Boondoggle View Post
    What did you change on your system a few weeks ago?
    Did you upgrade your Java, say?
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  3. #3

    Default

    The only thing I have been updating is Mafia. This is my work laptop, updates are shut down it hasn't been updated for 3 months.

    Correction, I updated libxerces-c28 on monday.
    Last edited by Boondoggle; 07-31-2019 at 06:24 PM.

  4. #4
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,314

    Default

    Literally every time something like this has been reported:

    - It's been on a Linux system
    - It's been an issue with the Java version that is installed.

    What Java version do you have?
    Is there anyone else - anyone - who has noticed an issue like this in the last month?
    What else have you changed - regarding your use of KoLmafia? New scripts?

    Looking at all the changes in the last month - easy to see if you look at the Version 19.7 announcement - nothing has changed that could cause an infinite loop or a memory leak, that I can see.

  5. #5
    Developer
    Join Date
    Aug 2009
    Posts
    2,974

    Default

    9G of virtual memory is essentially meaningless, though... it's only actually using 1G of RAM (per the RES column from top).

    Are you running any scripts?

    For what it's worth, I have had no problems running Mafia on Linux, even with a relatively new version of Java --
    $ java -version
    openjdk version "10.0.2" 2018-07-17
    OpenJDK Runtime Environment (build 10.0.2+13)
    OpenJDK 64-Bit Server VM (build 10.0.2+13, mixed mode)
    (I also have OpenJDK 12 installed, but I can't build for Java 6 with it.)

  6. #6
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,314

    Default

    (Off topic, but I would like to move to Java 7, at least. How many people can’t run that?)

  7. #7
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,862

    Default

    (Off topic, but I would like to move to Java 7, at least. How many people can’t run that?)
    Originally Posted by Veracity View Post
    (do java 7 releases even get current truststore? I think I had to update java recently because some certificates it trusts expired and I could not connect to zachbardon.com)

  8. #8
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,314

    Default

    (do java 7 releases even get current truststore? I think I had to update java recently because some certificates it trusts expired and I could not connect to zachbardon.com)
    Originally Posted by xKiv View Post
    When I say "move to Java 7", I mean "use an up-to-date Java but allow Java 7 syntax" rather than only allowing Java 6 syntax.

    Code:
    $ java -version
    java version "1.8.0_172"
    Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
    I can write and run Java 8 code, but KoLmafia is restricted to Java 6 features.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  9. #9

    Default

    OOkay, conferred with my IT guys that my computer wasn't silly itself.

    I explained to them the problem and they told me I should look into minecraft optimization for linux, since this problem is similar to what that community experiences.

    So that being said I read, I tinkered, and I made a little launcher script over my lunch break, and have been testing it. It is showing a lot of promise. I probably went overkill on the upper limit of java's memory allocation, but screw it, go big or go home.

    I'm going to continue testing over the next few weeks, if it all is good I'll have a script to help others.

    Code:
    #!/bin/bash
    ## This script optimizes the CPU and sets java's memory usage for Linux
    ## This script MUST be located in the same directory as the KoLmafia .jar file
    
    ## Set our variables
    MyKoLM=`ls -t KoLmafia*.jar | head -n 1`
    MyCPU=`which cpufreq-set`
    
    ## Fail if no KoLmafia found
    if [[ -z $MyKoLM ]]; then
            echo "Could not find a valid KoLmafia .jar file in `pwd`"
            echo "This script MUST be located in the same file where the .jar is located"
            exit 1
    fi
    
    ## Make sure we can run KoLmafia in the event of a fresh download
    echo "Ensuring KoLmafia is executable"
    chmod 777 "$MyKoLM"
    
    ## Get Free Memory Data
    echo "Getting Memory Stats"
    Mem=`free -mh | grep Mem | awk '{print $4}'`
    Round=`echo $Mem | sed -e 's/[a-zA-Z]//g' | awk -F "." '{print $1}'`
    HRA=`echo $Mem | sed -e 's/[0-9\.]//g'`
    
    ## Fail if Free memory is too small, otherwise optimize
    echo "We have $Mem free memory"
    if [[ "$HRA" != "G" ]] && [[ "$HRA" != "T" ]]; then
            echo "This script only allocates Gigabytes or Terabytes."
            exit 1
    elif [[ "$Round" == "1" ]] && [[ "$HRA" == "G" ]]; then
            OptMem="512M"
    elif [[ "$Round" == "2" ]] && [[ "$HRA" == "G" ]]; then
            OptMem="1024M"
    elif [[ "$Round" -ge "3" ]] && [[ "$Round" -lt "8" ]]; then
            OptMem="2048M"
    elif [[ "$Round" -ge "8" ]]; then
            OptMem="4096M"
    fi
    echo "Optimising to use $OptMem memory"
    
    ## Try to optimize the CPU if we have the required utility
    if [[ -z $MyCPU ]]; then
            echo "Would prefer to maximize CPU consider installing optimizer."
            echo -e "\tRun: sudo apt-get install cpufrequtils"
            sleep 3
    else
            echo "Setting CPU to Performance mode"
            sudo $MyCPU -g performance
    fi
    
    ## Run java with our optimized memory (Xmx and Xms should be equal to prevent mid process resizing)
    echo "Starting KoLMafia"
    java -Dsun.java3d.opengl=true -Xmx$OptMem -Xms$OptMem -jar ./$MyKoLM
    Last edited by Boondoggle; 08-01-2019 at 06:11 PM.

  10. #10
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,862

    Default

    sudo $MyCPU -g performance
    Originally Posted by Boondoggle View Post
    Oh, so you were running at 100% *underclocked* cpu? That makes some sense ...

    -Dsun.java3d.opengl=true
    This is interesting. It should probably do absolutely nothing with kolmafia, though. Unless java now uses 3D when doing 2D operations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •