The International Simutrans Forum

 

Author Topic: Performance problems under Linux (Xubuntu 12.10_x64)  (Read 15591 times)

0 Members and 1 Guest are viewing this topic.

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Performance problems under Linux (Xubuntu 12.10_x64)
« on: January 23, 2013, 10:00:17 PM »
My configuration: Xubuntu 12.10 (Kernel 3.5, fglrx-driver 13.1), CPU: Intel i5 2500K 3,5 Ghz, RAM: 4GB

Hello,

i've installed Simutrans from repository (Version 111.3-1) and via download from Sourceforge (Version 120.1) with pak64. Both versions are lagging when i scroll over the map. The game is nearly unplayable.

The only way to fix this bug (that i have found), is to disable all cpu energy-saving features in BIOS. I suppose that the cpu stays in nergy-saving when simutrans is running.
By the way, the windows version also works fine with wine and cpu energy-saving features enabled.

Its annoying for people with less computer skills, that there is a buggy version in the ubuntu repository. Simutrans is a great game. I hope a developer can fix this problem.

« Last Edit: January 24, 2013, 12:51:23 AM by donjuan »

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10)
« Reply #1 on: January 23, 2013, 11:31:52 PM »
Can you download and try with one nightly? Maybe that solves your problem.

http://nightly.simutrans-germany.com/

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #2 on: January 24, 2013, 12:48:05 AM »
Hi Markohs,

I've tried the nightlys - unfortunately the same behavior.  I've tested every verison: Linux/gcc 3/gcc 4 and  Linux 64/gcc 4 Version: 112.1-6296

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #3 on: January 24, 2013, 02:19:50 AM »
Can you check how many threads does simutrans create when playing? on linux I think every thread gets it's own PID, so doing "top" should show multiple simutrans, or look for the LWP ot threads column.

 You can also simulate artificial workload to see if that forces the CPU to keep high frquency, just open some tcsh and do something similar to:

> 1:
> goto 1

 or on bash I think you can do something similar to:

 while true; do echo test done

 Keeping some of those processes actives might force the CPU frequency up, just to diagnostic.

 Does /var/log/dmesg or some file in /proc/cpu or similar record CPU frequency speedstep decreases?

 You can allways have a look at simutrans.log for some strange messages, but I think it's related to your system, not to simutrans. But I can be wrong, ofc. :)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9432
  • Languages: De,EN,JP
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #4 on: January 24, 2013, 09:17:29 AM »
You can try to compile simutrans with -MULTITHREAD=1. This could remove those problems.

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #5 on: January 24, 2013, 04:24:40 PM »
Quote
Can you check how many threads does simutrans create when playing?
There is only one thread running shared to all four cpu-cores.

Quote
You can also simulate artificial workload to see if that forces the CPU to keep high frequency...
I've used prime95 and boinc to simulate highest workload on all cores with the result, that simutrans work much better, but still lagging when i zoom out to the maximum (when the cpu is stressed so much lagging is normal). Furthermore there are no entry's in /var/log/dmesg. The CPU keep on high frequency (3,5 Ghz) when prime or boinc is running, but when only simutrans is running, cpu stays on lowest frequency (1,6 Ghz- measured with xfce4-cpu-freq-plugin)

Quote
...but I think it's related to your system. But I can be wrong, ofc.
Jep, who knows  :P ? But i've found people with the same problem and amd processor (Cool&Quiet) in a german simutrans forum (www.simutrans-forum.de) the last post is from Dec. 2011. But there is no solution. And please imagine how many people use linux, how many of them play simutrans, how many of them use a multi-core-cpu and how many of them register to this forum  and post there problems  ;). I dont believe i am the only one  with this problem.

Quote
You can try to compile simutrans with -MULTITHREAD=1
@prissi
Unfortunately, i'am just a technician not a programmer. I dont know how to compile simutrans. But your reply gave me an idea. I went to the BIOS and deactivated 3 of 4 cores (energy-saving-features enabled). With my "new" singlecore system i've tested simutrans and it works as good as with prime running - maybe better. (What i haven't tested is, if the cpu keep on 1,6 Ghz)

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #6 on: January 24, 2013, 05:14:04 PM »
 So looks like the problem comes from ubuntu shipping a single-threaded version of simutrans, looks like ubuntu Kernel does not consider one of their cores being used 100% of the time enough reason to not stepping down the CPU. Looks this is more a Ubuntu kernel problem than simutrans one, and will happen on all singre threaded processes/games.

 Said this, Ubuntu should ship a multi-threaded version of simutrans, I'd say 4 threads since all modern CPU's nowadays have a minimum of 4 cores.

 Maybe there is a way to tweak the Lunux kernel to have a less agressive underclocking strategy, since Windows looks like treats this better. I'm not a linux expert so I got no idea how. :)

 Does anybody in this forum knows how to notify Debian/Ubuntu of this problem so they ship threaded version of simutrans on its system?

 If you want to compile a simutrans with threads to confirm our theory, you just need to (saying from mind, some details can be wrong):

sudo apt-get install g++
sudo apt-get install libsdl1.2-dev
sudo apt-get install subversion
svn checkout --username anon svn://tron.homeunix.org/simutrans/simutrans/trunk
cd trunk
cp config.template config.default
--- Edit config.default
This options need to be uncommented
BACKEND = posix
COLOUR_DEPTH = 16
OSTYPE = linux
MULTI_THREAD = 4
OPTIMISE = 1 # Add umpteen optimisation flags
SDL_CONFIG     = sdl-config
---
make -j4

 This should generate a working binary, test it out.

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #7 on: January 24, 2013, 06:26:20 PM »
Hi Markohs,

if i open the activity log of simutrans in synaptic, this name appears: Ansgar Burchardt <ansgar@debian.org>.
I believe it could actually be a debian based problem (ubuntu is totally debian based with light modified kernel) but i am no expert.
By the way, do you know why there are no multi-threaded linux version on sourceforge?

 
Quote
If you want to compile a simutrans with threads to confirm our theory, you just need to (saying from mind, some details can be wrong):

I will try to compile it with your "bulding-manual".

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5453
  • Languages: EN, NO
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #8 on: January 24, 2013, 06:44:21 PM »
In my experience, you need to push Simutrans hard in order for it to use significant CPU. I haven't bothered building Simutrans with multithreading, because it uses at most a third of one of my eight 2.3 GHz cores. (My map might not be as big, relatively speaking, as it was when I started it years ago.) Spreading it across multiple cores wouldn't help, it would still be the same amount of work, except for thread synchronization overhead, which should be small. Reducing the number of cores would however increase proportional CPU use.

Could it be that low CPU usage throttles down other things like bus speed or graphics, without noticing that those are (possibly) more heavily used than the CPU?

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #9 on: January 24, 2013, 06:58:57 PM »
That makes sense.

That Frequency of the CPU might be reducing the bus speed too, memory included and PCI to write the frame to the VGA. And simutrans uses quite a lot of bus bandwith, since the whole frame is redrawn.

But Ters, do you play with trees on? That uses to cause lots of CPU use, with trees hidden CPU usage is not high.

Offline Vonjo

  • *
  • Posts: 273
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #10 on: January 24, 2013, 07:45:11 PM »
The weird thing is that the Windows version, running under Wine, runs fine. This make me wonder if something like LLVM version of Simutrans can make some differences. I still have LLVM version of Simutrans from a few months ago if you want to test it, multi thread is not enabled though.
---
It is true that the debian version doesn't have multi thread enabled.
« Last Edit: January 30, 2013, 07:17:28 AM by Vonjo »

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5453
  • Languages: EN, NO
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #11 on: January 24, 2013, 09:37:19 PM »
But Ters, do you play with trees on? That uses to cause lots of CPU use, with trees hidden CPU usage is not high.

I had transparent trees, which shouldn't have mattered much or maybe made it slower, but I was running on laptop monitor only. Now I hooked up my HD monitor, switched trees fully on and panned through a forrest. Total CPU usage on computer peaks at 10%, Simutrans only about 4%. It's "only" a 1024x1024 map. I'm not sure about the number of vehicles. Tried turning on pedestrians, which brought Simutrans up to 5-6%. That's still only about one half core.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #12 on: January 24, 2013, 09:47:46 PM »
max zoom out?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9432
  • Languages: De,EN,JP
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #13 on: January 24, 2013, 10:24:27 PM »
Actually, that single core helped indicates rather that Linux does something right, i.e. used deeper sleep states on inactive cores. Unfortunately this has the downside, that these take longer to wake up. That mean with the update routine starting four thread each of them will take longer to wake up. As a result, four threads will take much longer than a more or less constantly runningsingle thread.

The nightly is built with four threads, as far as I know. Thus building a singlecore binary should rather help (thus -MULTI_THREADs=1)

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #14 on: January 25, 2013, 12:27:23 AM »
A desktop kernel, when not running on power saving restrictions, should minimize latency on the process run queue, so going deeper sleep makes no sense at all imho. I guess this is one of the reasons Windows is the prefered OS for gamers.

 A desktop kernel should give big priority to interactive applications, specially games. Makes no sense to downgrade frequency to save power. Servers in certain circunstances and laptops/mobile devices are another thing.

 Imho this is a problem in how Ubuntu customized the kernel.

 But this is just my oppinion. ;)

 Maybe tweaking on the pthreads parameters or hinting the system somehow of our desired low-latency high-frequency requirements could help on this problem. I guess this is possible, if someone has any details we can have it a look. I know it was possible in solaris, don't know linux in depth.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #15 on: January 25, 2013, 01:31:26 AM »
Found something related to this:

http://embraceubuntu.com/2005/11/04/enabling-cpu-frequency-scaling/

 comment 5 menctions about "governors", you can maybe try to set it to "performance" and see if it makes a difference. Looks like there is no way for programs giving hints to the kernel about their computing needs in linux.

 More info:

http://wiki.debian.org/HowTo/CpuFrequencyScaling
http://ubuntuforums.org/showthread.php?t=248867

 Might be related to a bug cited here (even it's from 2009, but well, xubuntu is a fork, maybe the bug remains there):

https://bugs.launchpad.net/ubuntu/+source/cpufreqd/+bug/344252

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5453
  • Languages: EN, NO
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #16 on: January 25, 2013, 05:57:44 AM »
A desktop kernel, when not running on power saving restrictions, should minimize latency on the process run queue, so going deeper sleep makes no sense at all imho. I guess this is one of the reasons Windows is the prefered OS for gamers.

 A desktop kernel should give big priority to interactive applications, specially games. Makes no sense to downgrade frequency to save power. Servers in certain circunstances and laptops/mobile devices are another thing.

Unless you're doing heavy processing 24/7, computers today have such a high peak performance compared to average use that power saving makes sense on desktop also. Save the planet and all that stuff. And how should a kernal know that something is a game? Simutrans doesn't call any markProcessAsGame() function. The kernel just sees a process that doesn't use all the CPU available.

What puzzles me is that the Windows version works under Wine. Is the Windows version single-threaded, or does Wine add just enough overhead to go above the throttling threshold?

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #17 on: January 25, 2013, 07:47:43 AM »
yep, i know its because of the cpu usage pattern I know. But it's doing a horrible job recognising it.

yea, i'm quite sure wine adds that extra bit that's enough for the kernel to switch ghz

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #18 on: January 25, 2013, 08:32:43 AM »
Can you please run:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

And post the result here?

 If it doesn't output "Performance", do:

echo "Performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

 And test the game again to see if we get any difference?

 You might need to do this for cpu0, cpu1,... all your cpu's:

EDIT: Extra reflexion:

 Could it be that given the inherent tendency simutrans has to not force the CPU higher than it can give, all the logic in karte_t::update_frame_sleep_time (that tries to not force the CPU to draw more frames than it can handle), goes in precisely the opposite direction than Ubuntu's CPU frequency scaling?

 See, Simutrans tries to save CPU => Kernel downgrades CPU speed => Simutrans detects low FPS again and uppers frame time to save CPU => Kernel downgrades CPU speed again => Simutrans uses high frame times seeing he has very little CPU available.

 Might it be possible we should instruct simutrans to push the CPU harder?
« Last Edit: January 25, 2013, 11:08:32 AM by Markohs »

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #19 on: January 25, 2013, 12:59:50 PM »
Quote
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Output: ondemand

The correct command to change the governor in xbuntu and his forks (as root in debian without "sudo") was :
Code: [Select]
echo performance | sudo tee /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
I've done this for all cores (cpu0-cpu3) with the result  that simutrans now runs as good as under wine, until the next reboot.
We can bury the multithreading theory.

Okay, I even found a way to permanently change the governor to "performance". (By adding 8 rows of code to  /etc/sysfs.conf ),
but what about other people who want to try out simutrans and what about my electricity bill :-) . I hope there is a clever solution to fix this problem, by adding some rows of code to simutrans.

I have written that Mr. Burchardt is responsible for the repository. That's not totally correct, there seems to be a "Debian Games Team" and he belogs to this team. Link is: http://packages.debian.org/wheezy/simutrans  (ubuntu and forks are using debian repositories)
« Last Edit: January 25, 2013, 01:22:42 PM by donjuan »

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #20 on: January 25, 2013, 01:09:00 PM »
mmm.... yep, we need to do something in simutrans so this setting is not necessary, there is certainly something not working good here.

 Trying to fix it but I'm afraid of touching that code because has some relation with network mode and I might break something. The idea is adding a minimum allowed FPS to simutrans, so even if we are not reaching let's say 25 fps, simutrans keeps using CPU to reach those 25, and not renounce to them and start targeting lower FPS/higher frame times.

 If Dwachs/prissi could have a look into this it whould be better, it will take me time to fully understand that part of the code.

 I think replacing in simintr.cc

bool increase_frame_time()
{
   if(frame_time < 255*FRAME_TIME_MULTI) {
      frame_time ++;
      return true;
   } else {
      return false;
   }
}

 with something like

if(frame_time < 2*FRAME_TIME_MULTI) {

 can maybe force the game to 15 fps max, but didn'ttried and I'm prolly  wrong. :)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9432
  • Languages: De,EN,JP
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #21 on: January 25, 2013, 01:18:41 PM »
Simutrans tries to reach 25 fps. If it can achieve it, it will pause, otherwise it will not pause at all. Thus the power mangement will not kick in, if it cannot do 25 fps.

You can take out the pause instruction by a polling loop and simutrans will run with 1000% single core CPU. But honestly, this is an error of Ubuntu rather than simutrans. The kernel should find out quickly, that it has 100% load for some time resp. a lot of latency due to waking up sleeping cores and then just go less to sleep.

Especially with power management, extra threads may be a problem. The only actve core runs fine; but waking those other core every 50ms may take a lot of time (on Intel). Wine may run a lot on a second core, which quite effectively avoids very deep sleep state of the processor, and thus a fast wakeup of other cores for the multithreading.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #22 on: January 25, 2013, 01:43:52 PM »
Are you sure we can't avoid this situation in simutrans code? donjuan, do you know if other games in ubuntu are affected by this?

I suspect the problem is also in simutrans code, but you know the code better than I do.

BTW it not so much about deep sleep on cores than the kernel lowering the frequency of the cores.

Isn't this part of the code lowering the CPU requirements of simutrans? I think might be causeing the problem

Code: [Select]
void karte_t::update_frame_sleep_time(long /*delta*/)
...
        // way too slow => try to increase time ...
        if(  last_ms-last_interaction > 100  ) {
            if(  last_ms-last_interaction > 500  ) {
                set_frame_time( 1+get_frame_time() );
            }
            else {
                increase_frame_time();
                increase_frame_time();
                increase_frame_time();
                increase_frame_time();
            }
        }
« Last Edit: January 25, 2013, 01:58:51 PM by Markohs »

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #23 on: January 25, 2013, 02:19:08 PM »
Quote
...do you know if other games in ubuntu are affected by this?

yes. I've  tried diffrent games which are similar to simutrans (not gpu-accelerated and maps). For example LincityNG, Micopolis, NetPanzer, OpenTTD and Unkonwn Horizons.

Every game runs smooth on my machine (with governor ondemand of course). Only Simutrans is in trouble.
« Last Edit: January 25, 2013, 02:28:35 PM by donjuan »

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5453
  • Languages: EN, NO
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #24 on: January 25, 2013, 04:23:03 PM »
Are you sure we can't avoid this situation in simutrans code?

Simutrans could start a thread that just does while(true) {++i;}, but that seems like a terrible hack.

Does anyone know if those other games are threaded?

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #25 on: January 25, 2013, 04:30:43 PM »
The version ububtu ships it's not threaded, so that's not the problem, according what donjuan said.

Yea, that's a horrible hack, makes no sense to include that kind of code, there has to be a problem somewere.

Offline sdog

  • Devotee
  • *
  • Posts: 2039
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #26 on: January 25, 2013, 04:41:30 PM »
i thought in ubuntu the cpufreq-daemon queries acpi to check if a power supply is connected and set the governor to performance mode. There used to be a problem that this deamon overrides conservative user settings, by doing this and setting the system to performance mode since the desktop is always connected to power supply. I remember i stumbled upon something like that last autumn.

Having ondemand as setting, might be either they fixed above behaviour and broke something else, or some problems with ACPI not detecting it is powered.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9432
  • Languages: De,EN,JP
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #27 on: January 25, 2013, 04:58:51 PM »
OpenTTD is single threaded (but for autosave), but revisits 1/7 of all tiles during a frame update. Due to the calculation possible with GRFs and the way data is stored, it is even more CPU intensive with large screens; but it runs with a fixed frame rate of 15 (if memory serves me right) and really enforces it. Thus it might seem more responsive.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #28 on: January 25, 2013, 05:24:33 PM »
What's the CPU usage % simutrans gives when running in ondemand mode, donjuan?

If it's not 100%, it's not just a problem in ubuntu, imho.

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #29 on: January 25, 2013, 06:41:56 PM »
Quote
What's the CPU usage % simutrans gives when running in ondemand mode, donjuan?

Low. The average usage of each core is 7-14%.
« Last Edit: January 25, 2013, 06:47:55 PM by donjuan »

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #30 on: January 28, 2013, 05:22:47 PM »
donjuan, do you mind trying a fix?

You have to open simintr.cc, and in line 67 change the line:

Code: [Select]
   frame_time = clamp( time, 10, 250)*FRAME_TIME_MULTI;

To:


Code: [Select]
   frame_time = clamp( time, 10, 40)*FRAME_TIME_MULTI;


 And recompile.

 Test it in ondemand mode, please.

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #31 on: January 28, 2013, 10:32:00 PM »
Hi Markohs,

sure. I've changed the code. And tried to compile it, unfortunately i got an "fatal error" message. It seems there is a header file missing.
 
Code: [Select]
bzlib.h: Can't find file or directory
compling aborted.
make: *** [build/default/dataobj/loadsave.o] Error 1

What can i do ?

Offline sdog

  • Devotee
  • *
  • Posts: 2039
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #32 on: January 28, 2013, 10:54:09 PM »
it's related to the external library for bzip2, used to compress savegames. In Ubuntu (you're using it, aren't you?) it's easily fixed. Just get the package with either software centre or directly on the shell with:

sudo apt-get install libbz2-dev

(not 100% sure it's really in that package, you might want to try other libbz2 or bzip2 packages if above doesn't work.)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9432
  • Languages: De,EN,JP
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #33 on: January 28, 2013, 11:26:03 PM »
The change Makohs suggested is just a very ugly hack. if you does this clamp, do it at least between 20 and 100. Networkgames run often 15 fps. However, seen in the other thread that the CPU sep down happens with idle=0ms I hardly doubt that this will help.

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #34 on: January 29, 2013, 03:26:06 PM »
The code has been compiled succesfully - thanks to sdog for the advice to install libbz2-dev.

I dont know what has happend (i've uninstalled wine for a while), but i cant start simutrans any longer. Not only the self-compiled simutrans, even the files from sourceforge are no longer starting. Only the st from repository and the 64-bit-nighly build are starting - of course, I marked all "simutrans"-files as executable.

When i try to start st in the terminal i get this message:
Code: [Select]
user@P67A-UD3-B3:~/simutrans$ ./simutrans
./simutrans: error while loading shared libraries: libbz2.so.1.0: cannot open shared object file: No such file or directory

I try to find this file with "find / libbz2.so.1.0" no match. Synaptic shows that the package libbz2-1.0 is installed.


Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #35 on: January 29, 2013, 06:49:50 PM »
Maybe you need to install 64bit version of this library?

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #36 on: January 29, 2013, 08:01:15 PM »
The solution was, to manually download the 32-Bit-Editions of  "libsdl-mixer1.2_1.2.12-3" and "libbz2-1.0_1.0.6-4" from http://packages.debian.org, just for the log. Now everything works fine, like a few days ago.

But i need help with my compiled code (remember, i am no programmer, but i want to help). Check if i do right:
1. Copy file with the name "sim" in ./trunk/build/default ,  to ./trunk/simutrans
2. Download pak64 to ./trunk/simutrans
3. Try to start it in terminal (but it doesn't start). Terminal output is:
Code: [Select]
user@P67A-UD3-B3:~/trunk/simutrans$ ./sim
Use work dir /home/user/trunk/simutrans/
Reading low level config data ...
parse_simuconf() at config/simuconf.tab: Reading simuconf.tab successful!
Preparing display ...
Loading font 'font/prop.fnt'
font/prop.fnt successfully loaded as old format prop font!
Init done.
user@P67A-UD3-B3:~/trunk/simutrans$

What do i wrong?

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #37 on: January 29, 2013, 08:26:07 PM »
execute the ../get_lang_files.sh insode the folder you copied "sim", I think will be enough. Thanks your your help donjuan!

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #38 on: January 29, 2013, 09:00:06 PM »
I've copied "get_lang_files.sh" to ./trunk/simutrans and ./trunk/simutrans/text (i guess the lang. file must be in there) and executed it. The language-files are installed, but  when i start "sim" i get the same output as before.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #39 on: January 30, 2013, 07:39:18 AM »
You have to start get_lang_files in the trunk/ directory (ie in its original location, no copying of script-file necessary)

Offline whoami

  • Devotees (Inactive)
  • *
  • Posts: 693
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #40 on: January 30, 2013, 09:46:31 AM »
Regarding performance: It seems that nobody yet mentioned the binding (Windows: affinity) of the ST process (threads) to one CPU core, which in itself may improve performance by better cache usage patterns, but also allows to set only one core to maximum performance (same for two cores, if multithreading is enabled).

Offline donjuan

  • *
  • Posts: 13
  • Languages: EN,GER
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #41 on: January 30, 2013, 03:26:36 PM »
Quote
You have to start get_lang_files in the trunk/ directory (ie in its original location, no copying of script-file necessary)
Yes, thats right (I havent read the script yesterday). All lang-files are correctly stored to "./simutrans/text" but it still doesn't work.

I even tried to place the self-compiled "sim"-file to a gcc3-nighly-build directory - with no success. I think that this have to work, because my "sim"-file and the original simutrans-file are depending on the same directory structure. Maybe this proof that the problem is my "sim"-file itself ?

An idea: To finally test the hack of Markohs, can somebody send me an e-mail with a working modified st-package, that i can test on my system? (I reveal my email-adress by pm)

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #42 on: January 30, 2013, 03:34:21 PM »
mmm... I tested the fix and it isn't working. I have to make a few modifications to the code still, when I have a solution I'll contact you. Thanks for your time, donjuan. :)

Offline captain crunch

  • *
  • Posts: 111
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #43 on: March 01, 2013, 09:27:13 PM »
Today when I noticed that simutrans 111.2 runs unreasonably slow on my 1.7GHz
Celeron M laptop under Ubuntu Precise, I found this thread when looking for
possible solutions.
  Interestingly, I tried running the win32 version with wine and I am
flabbergasted that it works very well this way.
  As far as I know the Celeron M does not support frequency scaling, at least I
could not activate it with the tools supplied by Ubuntu Precise. Also the
Celeron M has only one core (-8.
HTH

Offline whoami

  • Devotees (Inactive)
  • *
  • Posts: 693
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #44 on: March 01, 2013, 09:34:41 PM »
Did you run it with (edit:) parameters "-nomidi" and "-nosound" on Linux? This is the work-around for a well-known performance problem with sound output.
« Last Edit: March 01, 2013, 09:40:05 PM by whoami »

Offline captain crunch

  • *
  • Posts: 111
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #45 on: March 01, 2013, 10:47:46 PM »
Did you run it with (edit:) parameters "-nomidi" and "-nosound" on
Linux?
Thanks for suggesting this, but this did not help very much. I noticed in wine
the MIDI sound is disabled upon program start and it is not working later.
Here is what I found:
Code: [Select]
Simutrans version/OS      fps   idle(ms) simloops  sound midi
111.2.2-1 Ubuntu Linux    4     25       4,3       off   off
111.2.2-1 Ubuntu Linux    3     25       3,0       on    on
112.1 r6212 W32 with wine 14    25       4,7       on    off



Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #46 on: March 02, 2013, 08:21:20 AM »
You could also try a recent nightly build, which should be a little faster than the last release.

I also ask you to upload your savegame. Maybe there are some unusual patterns in there, as sometimes also the style of playing matters.

Offline captain crunch

  • *
  • Posts: 111
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #47 on: March 04, 2013, 05:23:52 PM »
You could also try a recent nightly build, which should be a little faster than the last release.
Yes, I built 112.1.1 Nightly from git for i386-linux-gnu configured with
"BACKEND=mixer_sdl". With this configuration I get 20fps and
4.1 simloops. I wonder what make the ubuntu packaged version run so much
slower, their config.default does not differ significantly.

I also ask you to upload your savegame. Maybe there are some unusual patterns in there, as sometimes also the style of playing matters.
It is only the savegame built into the pak and vanilla simconf.tab.


Offline Jando

  • *
  • Posts: 459
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #48 on: June 02, 2014, 08:33:53 PM »
Apologies for posting in an old thread but the original post describes what I see in Linux Mint (Ubuntu fork) as well. 32 bit version Linux on a 2-core AMD CPU. Performance is very bad, especially when scrolling the map. Sadly makes Simutrans unplayable for me.

Downloaded Simutrans from Sourceforge, both version 112.3 and the new version 120 release candidate. Tried with Experimental as well (Thanks, James, for the new compiled Linux version). All versions have very bad performance, with Experimental sadly showing the worst performance.

2 observations (trees and passengers/pedestrians off):

- FPS drops really fast to 4 or 5 frames per second (from about 11 or 12) when the game is paused. Pausing the game makes performance worse. :)
- Both CPU cores are at 20-40% when running Simutrans.
« Last Edit: June 02, 2014, 08:44:11 PM by Jando »

Offline Miziiik

  • *
  • Posts: 84
    • Mizíííkův Simutrans
  • Languages: CZ, EN
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #49 on: June 03, 2014, 07:12:31 AM »
What version of SDL do you use? Maybe it can be problem of SDL or another library (old version,...) I can post here my version compiled from latest SVN rep. on Ubuntu afternoon...

Odesláno z mého NEXT pomocí Tapatalk


Offline Jando

  • *
  • Posts: 459
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #50 on: June 03, 2014, 09:13:03 AM »
What version of SDL do you use? Maybe it can be problem of SDL or another library (old version,...) I can post here my version compiled from latest SVN rep. on Ubuntu afternoon...

Odesláno z mého NEXT pomocí Tapatalk

I don't even know what SDL is. :)  It's just a standard Mint installation, kept up-to-date with the Mint Update Manager.

Offline Miziiik

  • *
  • Posts: 84
    • Mizíííkův Simutrans
  • Languages: CZ, EN
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #51 on: June 03, 2014, 11:08:22 AM »
It' maybe that problem :D Wait 3 hours and I post here my binary and test it

Odesláno z mého NEXT pomocí Tapatalk


Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #52 on: June 03, 2014, 12:14:52 PM »

 I wrote  this (page one) time ago, can you try it and see if it fixes your problem?

Can you please run:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

And post the result here?

 If it doesn't output "Performance", do:

echo "Performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

 And test the game again to see if we get any difference?

 You might need to do this for cpu0, cpu1,... all your cpu's:

EDIT: Extra reflexion:

...


Offline Jando

  • *
  • Posts: 459
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #53 on: June 03, 2014, 12:42:32 PM »
I wrote  this (page one) time ago, can you try it and see if it fixes your problem?

Markohs, you're a genius. :) That completely fixes the problem.

Governor settings for both CPUs was OnDemand, after using your echo command the settings changed to Performance. Performance problem fixed for me.

Note for other people having the same problem: switch to root before using the echo command sequence, otherwise it won't let you use the command.

Edit: also my apologies for not spotting this solution on the first page of the thread. Somehow I missed it between all the other techno-speak. :)
« Last Edit: June 03, 2014, 12:52:04 PM by Jando »

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Performance problems under Linux (Xubuntu 12.10_x64)
« Reply #54 on: June 04, 2014, 12:58:47 PM »
No problem :-D  I'm glad it helped you.