It is currently 12 Sep 2025, 19:15
   
Text Size

Slow performance

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Slow performance

Postby DennisBergkamp » 17 Feb 2010, 06:15

I've been doing some tests, and it appears the slow performance (I don't think it causes heap space problems), seems to be due to small image caching.
Anytime some kind of caching is done, the game slows down to a crawl.

Code: Select all
if (cache.size() >= 15) {
         int count = 10;
         ArrayList<String> imgNames = new ArrayList<String>(count);
         for (String imgName : cache.keySet()) {
            imgNames.add(imgName);            
            count--;
            if (count == 0)
               break;
         }
         for (String imgName : imgNames)
            cache.remove(imgName);
        }
       
        cache.put(name, resized);
I changed the cache size to 15 (was 30 before), and after a turn or two the game starts to crawl... when I set it to 100, I can keep on playing without any slowdowns for a very long time :)

Anyway, any suggestions on how to fix this? I'll set it to a high number for now...
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Slow performance

Postby silly freak » 17 Feb 2010, 08:46

i'm trying to solve the memory problems right now, but it's good we have a quick workaround. i'm somehow stuck in refactoring a lot of badly structured code.
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Slow performance

Postby Huggybaby » 17 Feb 2010, 09:10

I knew you guys would come to grips with this. Soon these problems will be a thing of the past, and you'll be saying "remember when we had those graphics problems? Ah, good times".
User avatar
Huggybaby
Administrator
 
Posts: 3228
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 753 times
Been thanked: 601 times

Re: Slow performance

Postby DennisBergkamp » 17 Feb 2010, 17:26

Heh, well I certainly hope so, Huggy :lol:

For now I'll just comment out that block where it removes stuff from cache, and make sure the map gets cleared in between games.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Slow performance

Postby Snacko » 17 Feb 2010, 21:15

What's wrong with the code above is that you make 20 hash lookups every ~10 different art cards (because after each prune you loose 10 random - not that random as it depends on the order in the internal hashmap representation).
Probably you allocate images in rapid succession due to 'cache' not really doing anything other than prune itself all the time.
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Re: Slow performance

Postby Huggybaby » 17 Feb 2010, 21:34

Is there a way to fix the unnecessary looking-up?
User avatar
Huggybaby
Administrator
 
Posts: 3228
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 753 times
Been thanked: 601 times

Re: Slow performance

Postby silly freak » 18 Feb 2010, 11:27

i have made good efforts in fixing the issue. it was rather brute - a lot of code changed - and i'm not sure that it works 100%. i will test it a little and then commit.
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Slow performance

Postby juzamjedi » 18 Feb 2010, 14:21

I have noticed that games come to a crawl when Brawn, Anger, etc. are in the graveyard. It's so bad that I draft Brawn, etc. every time I see them so that the computer cannot play them.
juzamjedi
Tester
 
Posts: 575
Joined: 13 Nov 2008, 08:35
Has thanked: 6 times
Been thanked: 8 times

Re: Slow performance

Postby DennisBergkamp » 18 Feb 2010, 17:07

Yeah, we know the Wonder / Brawn etc. cards are horribly slow. I'm still not quite sure why though...
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Slow performance

Postby DennisBergkamp » 18 Feb 2010, 18:06

silly freak wrote:i have made good efforts in fixing the issue. it was rather brute - a lot of code changed - and i'm not sure that it works 100%. i will test it a little and then commit.
Wow, this is quite the update, impressive! I noticed two things though:

1. The small card images are extremely pixelated (see screenshot below to illustrate this). I noticed Snacko made an update to make it less pixelated, but for me it still looks really bad.
2. I still had some compile errors, so I had to delete GUI_PictureHQ.
Attachments
pixels.jpg
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Slow performance

Postby silly freak » 18 Feb 2010, 18:22

i know GUI_PictureHQ is not working, see my commit message. i was able to run forge with those errors, and hoped one of you could sort this out. do you know what exactly the class was for?

I tried to use the existing resizing code to minimize such things - I guess I failed. I'll see if I can sort it out. It has to do with the arcane classes, right?
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Slow performance

Postby DennisBergkamp » 18 Feb 2010, 18:27

silly freak wrote:i know GUI_PictureHQ is not working, see my commit message. i was able to run forge with those errors, and hoped one of you could sort this out. do you know what exactly the class was for?

I tried to use the existing resizing code to minimize such things - I guess I failed. I'll see if I can sort it out. It has to do with the arcane classes, right?
As far as I know GUI_PictureHQ was used in the deck editor for a full-size zoom when hovering over the image shown on the right. Vasiliy coded this.

I'm not sure about the resize, but I don't think it has to do with the Arcane classes, I think we just use those for large images.
Then again, maybe we could use them for displaying the small images too.

EDIT: Snacko probably knows more about this.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Slow performance

Postby Snacko » 18 Feb 2010, 19:44

@silly freak
I think it was for popup panel with the full size image.

Also you do all the resizing yourself in the image cache, that means arcane sees mysize == imagesize => do nothing just present what you have.

I added a blur if you halve the scale, looks more pleasing aka less pixelated.
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Re: Slow performance

Postby silly freak » 18 Feb 2010, 20:45

so the way to go is basically to use the original-size image in the picture panel, becuase arcane scales it?
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Slow performance

Postby Snacko » 18 Feb 2010, 20:48

Yes it can scale it, but then you miss the scaled images cache.
Currently it works ok, so I don't think you need to change it. It's a bit of doubling the functionality but you get the cache.
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 41 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 41 users online :: 0 registered, 0 hidden and 41 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 41 guests

Login Form