Author Topic: [done] Making the Options menu load faster  (Read 1937 times)

Cygal

  • Guest
[done] Making the Options menu load faster
« on: 15 November 2012, 12:09:29 »
Clicking on the Options menu makes the game feel slow here: 0.61s are spent building the menu before displaying it, which results in a very noticeable lag.

I profiled it, and the issue is in the MenuStateOptions constructor. The constructor is very long, but all time is spent retrieving the language list in Lang::getDiscoveredLanguageList(). This is called twice, once directly in the constructor, and once indirectly through Lang::getNavtiveNameFromLanguageName() (typo not mine). This means that about 500K of text is loaded twice, simply to read the NativeLanguageName property.

I can think of two real fixes:
  • put the language names in another file,
  • or move NativeLanguageName to the top of the language file, and add lazy-loading to Properties. This way, only one or two lines of text would be read, thus eliminating the lag.
I'm not really asking for help, just stating what I found so far since I don't know when I'll be able to contribute the fix. Real developers should spend their time on adding features. I'll scratch my itches myself!

Thanks for MegaGlest.
« Last Edit: 9 January 2013, 19:23:20 by softcoder »

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Options menu is slow to load
« Reply #1 on: 15 November 2012, 20:45:54 »
Well you are right but why should it be changed? You said for you it's 0.61s which is indeed very slow ( for me its faster )but who cares ? Its fast enough. Or do you think we also have problems ingame with something similar to this ?
If not its more something to fix if smeone is bored  ;).  I think there are several other more important things.  :D
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Cygal

  • Guest
Re: Options menu is slow to load
« Reply #2 on: 16 November 2012, 10:27:23 »
MegaGlest's focus from the start was to make things work. It's also quite nicely polished as it is. For example, the original developers didn't have to add the rain effect, but they did, and the result is great. A lot of others small things make the game feel nice and fast or not, *especially* when they go unnoticed. In my opinion, there's still some work left to make MegaGlest feel more polished. This issue makes the menu transition animation stutter on my fairly old laptop (which is still way above the minimum requirements), and I think that it makes the game feel slow even when it's not. It's also possible to make an analogy with the broken window theory: with less small issues, the small issues that are left won't be left unnoticed. This is also why I take such lists so seriously. By the way, more important things take more time to work on, but I can't predict the amount of time I can spend on MegaGlest, so I prefer to work in small chunks and let the main developers to the interesting work.

It's simply attention to detail. I'm looking at all the small issues that bother me and try to fix them without taking too much of your time. I certainly agree that such issues are not worth discussing, which is why I've been explaining more the reasoning behind my choices than the actual choices themselves.

Thank you for MegaGlest.

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Making the Options menu load faster
« Reply #3 on: 16 November 2012, 21:34:44 »
I think it's great that Cygal is planning to contribute by improving existing features, and while I don't have the say on this, I think this approach should be welcomed and I personally appreciate it, as well as Cygals recent patches.

Since this very issue is not considered a bug but an existing feature which could be improved upon (I agree there with Titi), I've moved this thread to the feature requests forum. I think it's better placed there even though Cygal plans to come up with those improvements on his own (for now).
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

GunChleoc

  • Horseman
  • ****
  • Posts: 202
    • View Profile
    • Fòram na Gàidhlig
Re: Making the Options menu load faster
« Reply #4 on: 16 November 2012, 23:07:40 »
I think it's a good idea tweaking it if you have the time. On my computer, it freezes long enough that you might start to wonder if the game has crashed, and my computer is less than 2 years old.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Making the Options menu load faster
« Reply #5 on: 16 November 2012, 23:12:16 »
Oh I did not get that you want to work on this cygal! You are VERY much welcome to do so! Sorry if I got you wrong here.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Cygal

  • Guest
Re: Making the Options menu load faster
« Reply #6 on: 8 December 2012, 22:37:01 »
http://paste.debian.net/215153/ contains a patch that moves language names to a file: data/langs/langs.lng. The menu construction is now instantaneous. The drawbacks are that translators cannot change the language name using Transifex.

(I first tried implementhing this by putting the language name at the top of the file and implement lazy loading in a static class function, but it changed a lot of code since I wanted to make common code static. It was also fragile since it relied on having the language name at the top of the file for good performance. I believe my patch is a better compromise.)

GunChleoc

  • Horseman
  • ****
  • Posts: 202
    • View Profile
    • Fòram na Gàidhlig
Re: Making the Options menu load faster
« Reply #7 on: 8 December 2012, 23:33:01 »
Maybe you could work with ISO language codes instead of the language names? I remember having a discussion about changing the names of the lng files to ISO codes somwhere in this forum. http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

Common practice is to go with ISO 639-1: two-letter codes plus an optional two-letter country code, e.g. en_US or gd.

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Making the Options menu load faster
« Reply #8 on: 19 December 2012, 06:33:58 »
ISO 639-1 is already used within the language files to map files to locales, but we should also use this standard for file names in the future, this would make mapping language files with Transifex much easier, too (currently we need to manually maintain a list of mappings).

I'm not sure whether this would break Cygal's patch, though.
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

Cygal

  • Guest
Re: Making the Options menu load faster
« Reply #9 on: 20 December 2012, 08:24:33 »
It would be easy to change the patch once the names are changed, or change the names after the patch has been applied. I could do it myself, but I'd still need someone to commit that.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: Making the Options menu load faster
« Reply #10 on: 28 December 2012, 01:03:07 »
svn rev#: 3965 implements a cache and a thread to offer better performance. Let me know what you think?

Cygal

  • Guest
Re: Making the Options menu load faster
« Reply #11 on: 2 January 2013, 05:53:55 »
Sounds good, many thanks! Not tested yet.