Author Topic: Performance improvement for Glest multiplayer... 4 player is now practical  (Read 53003 times)

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
I've spend a little while looking at the performance problem behind the standard glest 3.2.1 codebase. After trying a lot of different things voila, I found out why the server slowed down gameplay for 4 player multiplayer. Thus far I have tested on Linux but I am using regular sockets so win32 shouldn't be a problem. I tested this evening with Elimnator, Tiger and an un-named other along with myself and the results were good.

At this point what should I do to get this code into svn for regular glest 3.2.1 (I had problems compiling gae so I reverted back to normal glest).

Thanks


update (by titi):
Its all in megaglest now: https://forum.megaglest.org/index.php?topic=4930.0
« Last Edit: 10 May 2010, 08:27:49 by titi »

Yggdrasil

  • GAE Team
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
You should make a patch against svn trunk and post it. And also send the glest team a mail, see front page of glest.org for address.

If you had problems with gae we are happy to here about it. Please post any problems in our subforum or make a ticket at http://sourceforge.net/apps/trac/glestae/.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
or you decide to go with this:
https://forum.megaglest.org/index.php?topic=4930.0
and  send me a patch for it. I think I will setup my own svn soon.
« Last Edit: 16 January 2010, 13:47:01 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Attached is an svn diff of some network improvements to make 4 player work better (no longer choppy).

seems like ioctlsocket (ioctl in linux) is evil as it creates a bug performance hit. I essentially made more use of select() on the server side of things BEFORE calling ioctl to see if there is anything to read before calling any other socket functions and it seems to have helped.

Thanks

P.S. Titi, I ported my network changes to your beta 3 code and created a tar with the name beta4

To get the diff file for glest 3.2.1 or to get the modified code for Titi's beta3 (called beta4) goto:

http://www.soft-haus.com/glest/code/

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
If I have some time over the next few weeks I'll be looking into adding the following features for glest:

1. Adding a check for clients that connect to a server to see if they have the selected map,tile and factions for a network game.
2. If clients do not match exactly what the server has (even if an xml file has a small change) then the client will be given the option to auto download the new contents from the server.

This should make sharing new factions, maps etc.. easier and less problems with crashing on installations with different data.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
cool! :)

I try to create a final megaglest now which is based on the beta4. We start testing beta4 on all platforms now and if there are no big issues this will be version megaglest 3.2.3 . If  there are still bugs I make a beta5, but this is definitly the feature freeze now for this version.

Some more ideas for multiplayer improvement:
- Playernames! In the connect menu you should be able to give a player name!
- Chat possibility inside the connect menu.
- Better error handling/messages when you get a conflict based on different platforms/builds which will get out of sync after a while.

« Last Edit: 17 January 2010, 15:25:41 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Just for your info:
I will not put the multiplayer patch in megaglest 3.2.3 now but this multiplayer fix will be the main feature for 3.2.4.
I think version 3.2.3 is stable now and i want to release something stable and finished before we start something else.
I wait some days to see if someone has serious problems with 3.2.3_beta3 and if not it will be released.
3.2.4 with this fix will follow instantly after the release!
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Yggdrasil

  • GAE Team
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
2. If clients do not match exactly what the server has (even if an xml file has a small change) then the client will be given the option to auto download the new contents from the server.
This could be quite difficult because you need write access to the data directory. You don't have this normally on linux. That's why i'am currently looking into integrating PhysFS in GAE which helps us handling more directories. It basically creates a new merged virtual directory. Can even read from compressed archives like zip and 7z.
Haven't uploaded anything yet. Will do till end of week.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Have a look at other games. They often download to their own directories in the homedir like
".glest/cache" for example. If you compress the data or not is another question but something you should
really think about especially for downloading. But one step after another....
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Feedback for the Linux multiplayer fix:

Its much mcuh much better than before! We only played with 2 players today, but we had hunderts of units and huge battles with the new mega CPU and it was nearly not choppy! Thats very very good now, thanks a lot for this patch!

I must try this online soon, I hope this will increase multiplayer stability dramatically!
( for all those who read this, please test the megaglest 3.2.3 beta3 and give me feedback so we can create a stable release. If this is done we can go on with this feature! https://forum.megaglest.org/index.php?topic=4930.0)
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Yggdrasil

  • GAE Team
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Have a look at other games. They often download to their own directories in the homedir like
".glest/cache" for example. If you compress the data or not is another question but something you should
really think about especially for downloading. But one step after another....

That's more or less planned. We thought more about configs and mods in the homedir, not about autodownloading. But another directory can be easily added.

btw, the branch is up, called physfs. Be aware, this is still playground. Nevertheless i was able to play a game with a zipped megapack in ~/.glestadv/addons. Need to repack it, so that only maps, scenarios, techs and tilesets folders are in it at toplevel.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
ah ok.

More feedback for the new multiplayer:
Its still very choppy in the game configuration on the server but when the game starts the game itself runs very smooth and without any problems!
Much better than before. We made a game with 4 players adn lots of units today, all  worked fine and nothing was choppy ( all players in local LAN ).
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Glad to hear that the multi-player fix is working well. The slowness on the server during game config is due to needing to handle new possible client connections. I may look at tweaking that a bit to make it less choppy at some point. On another note I have roughed in the main chunk of code to handle checking and downloading of missing content. Now I need to test and refine it (taking one step at a time).

Eventually I have a good solution in mind to separate the reliance of the network communication from the video rendering (this is the main cause of synch errors and choppy video play) but that will not come for a while (and someone else may beat me to it). For now this multiplayer fix makes it much more useful than it was in the past at least in a short period of time.

Thanks

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Bad news :( . We have problems now with 4 players !

Our computers:  3 fast enough Desktop computers 1 slow Laptop.
We start gaming and everything looks fine, then suddenly the laptop player cannot give any more commands! He can select the units but they don't do what he say. I think no more commands are send ( or received) by the server.
The game continues on all 4 computers without any error messages but the user can't play. ( pressing n on the server told us the client is still connected )

After a while the laptop decided to leave the game. Back in the menu still everything is fine ( and he is still marked as connected on the server )
but when he closes glest completly suddenly everything crashes ( on all 3 other computers!! ).
The errormessages we saw in the logfile are the following:

on the 2 remaining clients which showed no problems before we had something like this:
Code: [Select]
#2 Error connecting socket for IP: 172.20.100.101 for Port: 61357 err = -1 errno = 115 [Operation now in progress]EINPROGRESS in connect() - selecting
Apparent recovery for connection sock = 15, err = 1, errno = 0
Valid recovery for connection sock = 15, err = 1, errno = 0
#2 Error connecting socket for IP: 172.20.100.101 for Port: 61357 err = -1 errno = 115 [Operation now in progress]EINPROGRESS in connect() - selecting

server logfile was lost, because my son started glest again ....

laptop logfile:
Code: [Select]
#2 Error connecting socket for IP: 172.20.100.103 for Port: 61357 err = -1 errno = 115 [Operation now in progress]EINPROGRESS in connect() - selecting
Apparent recovery for connection sock = 11, err = 1, errno = 0
Valid recovery for connection sock = 11, err = 1, errno = 0

This happened two times!
Last successful test with 4 players was made by only 2 players both playing on 2 computrs simultaniosly, but when we play with 4 real players we get these problems.

« Last Edit: 22 January 2010, 18:44:05 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Ok I'll take a closer look at the code to see where the problem lies. I  didn't really change the principle by which the network code was based on, so its likely there is a check missing somewhere that is causing this.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Ok I believe the problem is an existing oversight in the networking code (in otherwords there are cases where clients / servers would have major problems if the network connection was sluggish).

I will send another patch perhaps tonight where the socket code checks for EGAIN when sending / receiving socket data AND also checks for a disconnect. The existing code doesn't properly check to see if a socket has disconnected in some cases, so I'll add that in too. This update will ALSO include code for doing file synch checks and downloading content..BUT the file synch etc.. code won't be enabled since its not ready yet and I cannot back out those changes at this point since I have made lots of infrastructure changes.

Once I have sent the patch you will see in the console and/or log output info messages when/if the suspected EAGAIN socket state is detected and the code will try to cover by re-trying the socket send or receive action for a max of 5 seconds.

Thanks

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
No hurry!
Can you modify megaglest with this? I still didn't merged your changes in the official sourcecode yet, but I made no changes up to now in megaglest 3.2.3_beta3 code so everything will fit. The only thing I will change is the version number to make my release. From then its "your code" to do the network changes and make things stable, so we will have a stable 3.2.4 one day. I will work more game content related for a while :) and I will see if I can make a full release with installers for the first official megaglest release containing my megapack V5 as the only techtree.

If you need any help with testing or anything please contact me!

 

Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
By the way when I said "existing oversight" I meant that the code in glest all along did not properly handle return codes from socket send and receive operations and thus that might explain some random weird behaviour within glest over the years (especially related to one or more slow clients or network congestion).

So hopefully we'll get things moving along shortly, and yes I'll patch both regular glest and mega glest.

Thanks

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
One more info for the error:
We tried it again today because I wanted to test something:

- this time one of the fast client computers got into trouble
- It looks like he couldn't send any more commands to the server, but he receives commands from the server! Another player was able to navigate through the map and it was shown on the client with the bug too!
« Last Edit: 23 January 2010, 17:02:26 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Super Tom

  • Draco Rider
  • *****
  • Posts: 311
    • View Profile
titi, I do not think so the question of computer or network configuration problem, but is not a game to set the problem. Today, I and my brother and my two friends tested this game on-line Versus function. Their machine configurations very good. we have four individuals LAN Battle, found that the error message is indeed there, and we had 4 hours of the Battle.

The four of us take turns playing the role of the server computers, but also take turns playing the role of the client!

By the way: In this four hours in the game will suddenly quit, abruptly quit the game about five times the number reached about it makes us feel very unhappy, one of my friend said: "Why it is so, my God! "

titi, please solve this problem, please?
« Last Edit: 23 January 2010, 12:15:35 by tom123 »

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Ok, tightened up the network code, and also have added the ability to chat while waiting in the lobby (both server and clients).

As usual the patch for regular glest 3.2.X and the whole archive for megaglest are waiting at my website:

http://soft-haus.com/glest/code/

The patch for regular glest is called: glest_patch_2010_jan_23.diff.txt
The archive for mega glest is called:   megaglest-source-3.2.3-beta4-2.7z

Let me know how this goes.

P.S. if you want loads of debug info in the console (which is helpful is we encounter issues) compile with:

bool Socket::enableDebugText = true;

in socket.cpp

Remember there is one socket.cpp for posix (linux) and another for windows.
« Last Edit: 23 January 2010, 15:20:55 by softcoder »

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Ok found a few glitches related to when you manually disconnect the server in the lobby, and choppiness when changing settings on the server in lobby mode, all have been fixed but I won't publish updates until we have done more thorough testing. In general game play seems fine though with multi-player.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,239
    • View Profile
    • http://www.titusgames.de
Hi
please call next megaglest version 3.2.4_beta1 megaglest 3.2.3 is released now.
We didn't test anything yet because the kids should not play computer the whole day  ;).
I hope tomorrow we can test it.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Super Tom

  • Draco Rider
  • *****
  • Posts: 311
    • View Profile
I'm looking forward to the next version of titi in version 3.2.4_beta1 able to solve the network connectivity issue, I am looking forward to the version without this error occurred!

Thanks!

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Ok whoever is able to test, the updated glest patch and the mega-glest 3.2.4-beta1 are available at:

http://www.soft-haus.com/glest/code/

Glest patch is called:        glest_patch_2010_jan_23-2.diff
Mega Glest update called: megaglest-source-3.2.4-beta1.7z

This update:

- improves network play stability and performance
- allows chatting once connected in the lobby when preparing to start a new game (once you are connected)
- sends a text message to all players if a player purposefully quits a game in the middle of play.
- Tells both server and clients whether or not the selected Map, Tile, Tech and FogOFWar settings all match

That is it. Please test and give feedback so that we can get a rock solid release of multiplayer.

I have stubbed in code for auto-download of mis-matched content, but that is currently disabled until some quality time can be spent getting feedback and coding it to be solid.

Thanks