Slow performance
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
42 posts
• Page 1 of 3 • 1, 2, 3
Slow performance
by 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.

Anyway, any suggestions on how to fix this? I'll set it to a high number for now...
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);

Anyway, any suggestions on how to fix this? I'll set it to a high number for now...
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Slow performance
by 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!
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
by 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".
-
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
by DennisBergkamp » 17 Feb 2010, 17:26
Heh, well I certainly hope so, Huggy 
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.

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.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Slow performance
by 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.
Probably you allocate images in rapid succession due to 'cache' not really doing anything other than prune itself all the time.
Re: Slow performance
by Huggybaby » 17 Feb 2010, 21:34
Is there a way to fix the unnecessary looking-up?
-
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
by 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!
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
by juzamjedi » 18 Feb 2010, 14:21
Re: Slow performance
by DennisBergkamp » 18 Feb 2010, 17:07
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Slow performance
by DennisBergkamp » 18 Feb 2010, 18:06
Wow, this is quite the update, impressive! I noticed two things though: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.
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.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Slow performance
by 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?
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!
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
by DennisBergkamp » 18 Feb 2010, 18:27
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.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?
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.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Slow performance
by 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.
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.
Re: Slow performance
by 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!
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
by 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.
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.
42 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 21 guests