Possibly way to significantly decrease UI crashes and RAM usage: 2.6GB -> 1GB

Discussion in 'Mac and Linux' started by SXX, August 17, 2014.

  1. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    I'm finally finished some project I was busy on and now I'm able to test PA more again.
    I trying to investigate well known UI crashes bug so I started to test my ideas all over again.

    Few months ago I'm already tested many Chromium flags on Coherent and once of them was "--single-process" mode. When I tried it's back then it's caused extreme performance loss and nearly freezing UI. Today I checked it once again and find out that game remain playable and there was no visible UI lag. It's might be result of changes within Coherent or improvements that @jorgenpt implemented recently (Coherent no longer create own GL context within PA process).

    As far as I can tell with "--single-process" memory usage will be less than 1GB RAM instead of current 2.5-2.7GB. To enable it do this:
    1. In "host" directory rename "CoherentUI_Host" to "CoherentUI_Host.bin"
    2. Save this script as "CoherentUI_Host":
      Code:
      #!/bin/bash
      ARGS="--single-process"
      exec -a "$0" "./CoherentUI_Host.bin" $ARGS "$@"

    This can be also done on Mac (should be easy) and Windows, but I have no idea how to create wrapper script there. It's not tested well (due to UI crashes) and lt's likely will require beefy CPU. I decide to make this topic anyway so everyone else can test it and report about changes.

    PS: No, this not going to fix or even affect UI crash. :(
    shootall and wondible like this.
  2. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    Playing more or less "proper" game at moment. Coherent only using ~600MB RAM. :D
  3. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    Ok looks like I was wrong. This option does decreased UI crashes possibility at least for me on Intel HD4600. E.g it's no longer possible to cause crash by using cursor selection, but still possible to do that with extremely fast Window resize.

    Other random idea about the problem: I have feeling that crash rate (without --single-process) does increase after I played a bit. So it's good idea to remove contents of this cache directory:
    Code:
    ~/.local/Uber Entertainment/Planetary Annihilation/localstore/GPUCache
    I didn't tested it enough, but it's might be related to the problem and this is why:
    • When you join game this cache is changes once and then don't change as long as Coherent work properly.
      Checked with
      Code:
      md5sum ~/.local/Uber Entertainment/Planetary Annihilation/localstore/GPUCache/*
    • Once Coherent crashed this content does change.
    • Few times after removal of this directory content I get UI not crash on load
      Though this can be just coincidence.
    I'll appreciate if other Linux users will test it and report... :)
  4. n00n

    n00n Active Member

    Messages:
    345
    Likes Received:
    210
    Didn't fix the issue here on nvidia.

    I can crash the UI at the start of the match every time: Tell commander to build a line of factories and then repetitively draw a selection box over the commander and factory. Clearing the cache doesn't help.

    Thanks for looking into the issue @SXX and let us know if you have any more ideas.
    Last edited: August 17, 2014
  5. n00n

    n00n Active Member

    Messages:
    345
    Likes Received:
    210
    Ok after a bit more testing, I'm now in a match I can't seem to crash. I am using "--single-process" and removed following:
    Code:
    rm /dev/shm/* ~/.local/Uber\ Entertainment/Planetary\ Annihilation/localstore/GPUCache/*
    Continuing to test more... will report back.

    Edit/update: Must have been a fluke, can't reproduce it.
    Last edited: August 17, 2014
    SXX likes this.
  6. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    (OS X) Superficially (CoherentUI_Host process) memory works as advertised. However, at least on my computer, the in-game UI takes noticeably longer load, (e.g. the "Start Annihilation" button) so I definitely won't be using it during mod development. Also reset my firewall filters since the process filename changed ;^)
  7. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
  8. gerii

    gerii Member

    Messages:
    90
    Likes Received:
    32
    Didn't help with the crashes here on Nvidia.
    SXX likes this.
  9. thelordofthenoobs

    thelordofthenoobs Well-Known Member

    Messages:
    368
    Likes Received:
    356
    It still crashed for me (and I noticed some performance issues, obviously) but it might be true that it reduces the likelyhood of crashes (reconnected to the game and could finish playing it without another crash).
  10. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    Yes I have same behaviour. Loading is actually slow, but it's only drawback I noticed so far.

    PS: Though I mostly sure there is way to decrease this loading time by pre-load/cache all panels before game started.
    Last edited: August 17, 2014
  11. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Depends on whether you were start the entire program or just going in and out of the game.

    ..meanwhile, *smack-head* I actually looked and the reload page call takes a page id, so after months of superscene total refreshes, it's possible to refresh only a target scene without destroying and recreating it (and changing it's debugger url)

    Code:
    api.game.debug.reloadScene(api.Panel.pageId);
  12. WaylanderPK

    WaylanderPK Member

    Messages:
    72
    Likes Received:
    51
    Hi, just tried the fix and it worked, ui took a little longer to load on the start of game but didn't crash. I'm running an amd video card on Mint 13. I'll try a few more games and see what happens. Thanks :)
  13. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    Which drivers you using at moment?

    PS: Though I suppose it's AMD blob, but what version?
  14. WaylanderPK

    WaylanderPK Member

    Messages:
    72
    Likes Received:
    51
    Its the latest beta from amd -
    Driver Packaging Version 14.20-140529a-173820E
    2d - Driver Version 14.20.7
    Code:
    peter@Mandrake ~/Desktop $ fglrxinfo
    display: :0.0  screen: 0
    OpenGL vendor string: Advanced Micro Devices, Inc.
    OpenGL renderer string: AMD Radeon HD 8600M Series
    OpenGL version string: 4.4.12967 Compatibility Profile Context 14.20
    
    SXX likes this.
  15. MCXplode

    MCXplode Active Member

    Messages:
    196
    Likes Received:
    28
    Memory usage is less and coherent has only 3 threads when --single-thread command is used but still crashes after too many build commands queued. Using AMD catalyst 14.4, radeon 7750
    SXX likes this.
  16. classic1977

    classic1977 Member

    Messages:
    37
    Likes Received:
    14
    If I try to run the wrapper script, the game starts, but CoherentUI crashes immediately if I attempt to start a game, or even the Galactic War menu. Commenting out the line assigning a value to $ARGS allows the game to work again, so it's not my script... I also cleared out /dev/shm and the GPU cache directories.

    It seems like running CoherentUI as a single process on my system is simply a no-go...

    nVidia 660, Arch Linux, Steam version of PA.
    Last edited: August 18, 2014
  17. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    So I trying to reproduce this on Windows, might be somebody can help me there?
    I'm done simple Go tool that should work as wrapper. When toyed with @UberWilliam launcher I'm find out that Go provide easy way to build for Windows on Linux so I using it for such tools now, but I met a problem... :(

    Here is code:
    Code:
    package main
    
    import "bufio"
    import "os"
    import "os/exec"
    import "path/filepath"
    
    func panicIf(err error) {
        if err != nil {
            panic(err)
        }
    }
    
    func main() {
        os.Exit(run())
    }
    
    func run() int {
    
        var err error
    
        var args = make([]string,0,5)
     
        dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
    
        file, err := os.Open(filepath.Join(dir, "flags.list"))
        if err == nil {
           scanner := bufio.NewScanner(file)
           for scanner.Scan() {
            var arg = scanner.Text()
            args = append(args, arg)
           }
        }
        defer file.Close()
    
        for index,element := range os.Args {
           if index != 0 {
            args = append(args, element)
           }
        }
    
        cmd := exec.Command(filepath.Join(dir, "CoherentUI_Host_Real.exe"), args...)
        cmd.Stdout = os.Stdout
        cmd.Stderr = os.Stderr
        if err = cmd.Start(); err != nil {
            return 1
        }
    
        return 0
    }
    
    It's can be compiled for Windows on Ubuntu this way:
    Code:
    apt-get install golang-go golang-go-windows-386
    GOOS=windows GOARCH=386 go build -o CoherentUI_Host.exe run.go
    This tool work on Linux fine. On Windows does run Coherent with flags set, but unfortunately I only get black screen (with audio, hotkeys working so only rendering broken) . :(

    It's doesn't related to "--single-process" because even without any additional flags Coherent still fail to show UI. In "Process Explorer" I'm find out that normally CoherentUI_Host.exe processes should work as PA.exe childs, but it's not happen with my wrapper.

    On Linux wrapper does use "exec" command which is use execve syscall. Is anyone have idea how I get same behavior on Windows? :oops:
    Last edited: August 18, 2014
  18. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    So here is other interesting finding about Coherent memory usage control:
    Code:
    --renderer-process-limit=3
    This Chromium option does work for Coherent host.

    With 3 rendered processes in-game UI using 1GB RAM which is a bit more than 600MB, but still a lot less than default 2.7GB. :D

    PS: Also this doesn't increase loading time a lot.
    Last edited: August 18, 2014
  19. n00n

    n00n Active Member

    Messages:
    345
    Likes Received:
    210
    Last edited: August 19, 2014
    SXX likes this.
  20. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812

Share This Page