Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tier 2 - is it worth it?

Author
Message
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 6th Oct 2019 16:03 Edited at: 6th Oct 2019 16:05
So I've been playing with Tier 2 to see how worth it it is, and found some odd results. Using a direct IF...THEN loop to just add to a number X many thosands of times, T1 was faster that it's T2 equivolent. When using a FOR...NEXT loop, T2 was faster, but only by a factor of 3 (not the 60 times faster I've seen observed somewhere else being mentioned).

So, I made a simple program to generate 1500 sphere's, randomly place them, then have them drop like snow, looping round to a new random start location once off the bottom of the "zone". I tested this on two machines:

8 core AMD PC, 32GB RAM, Nvidia GeForce 1080GTX 8GB:
in T1 this run at about 300 fps, when rendering in 1920*1080
in T2 this hits about 400 fps, which is a 25% increase.....but only on a VERY simple FOR NEXT loop that I know was already going to be faster

duel core intel I3 laptop, integrated Nvidia graphics:

in T1 it gets about 60-100 fps (this seems to randomly vary substantially for no reason I can see)
in T2 it gets a fairly consistent 110 fps....so the benefit is far lessened on a smaller machine

My GPU is only hitting about 30% utilisation on the desktop, about 50% on the laptop - so I accept this is a very basic test.

So my question is, for PC code, is the investment of converting T1 to T2 (I'm at about 20k lines of code) actually really worth it if it's being done solely for performance and no other reason. Has anyone found any other examples where T2 was really that much afaster than T1 that it made sense, becuase for a 10%-25% increase I'm not thinking it;s really worth the bother....T1 is surprisingly efficient.

Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 7th Oct 2019 19:03 Edited at: 7th Oct 2019 19:29
Using Teir 2 doesnt improve the speed of any of the precompiled AppGameKit functions. So for an example, a function like LoadImage() called in teir1 will take the same time as in teir 2 as its the exact same code that is being run to load the image in and set it up in memory on the GPU. The only real difference is for the interpreter (the player app) to read the bytecode for 'loadimage' and its string argument and then call the pre compiled function, which is minimal overhead.

However, if you do a large amount of logic or complex calculations then you can get a huge increase in speed. Writing a loop to check every pixel of a large image in AppGameKit teir 1 is slow but do it in C (teir 2) and it will be much much quicker in a tight C loop operating on a c array. Test how long it takes to count to a million in increments of 1 in agk then do it in C and you will get 100+ times the speed as there is no interpreter burning cpu cycles! Of course you will have to be able to write C in an optimal way and ensure the compiler itself has optimisations turned on and debug mode is off as they can slow C down depending on your compiler.

If your expecting objects to be drawn quicker or sprites to be updated quicker, they wont be. Sync() runs the same code in teir 2 as it does in teir1. Its only faster if your app is getting slowed down by actual basic computations and calculations or if the overhead of the bytecode interpreter is large compared with what your doing. Just setting up a scene then calling sync() in a loop will not really see any improvement at all by moving to teir 2 as the vast majority of the time your sat waiting for the sync() function to complete. If your doing lots of logic calculations then you will see a bigger improvement.

Its worth it IF you want to do something you cant currently do in Teir 1 (adding libraries of additional low level code) or its worth it if you want high speed logic/computational code. But it wont make the actually AppGameKit built in functions any faster really. Well, only a tiny bit as you dont have the overhead of an interpreter converting bytecode to function calls.


EDIT:
I forgot to add.....A really nice middle ground is to put any complex logic or calculations into a plugin!
Its like having some inline C in your basic app - best of both worlds. If AppGameKit plugins would work on android (they dont) then id probably never bother with teir 2.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 8th Oct 2019 14:04
@Bengismo

did you looked into LoadImage() in Tier 2? I am trying to figure out, how to be able to write a plugIn or another C++ command, to be able to load other types of images or compressed textures. But I guess, my C++ skills are not as high, to find the right spot where and which variables and *pointers I would have to use for that.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 9th Oct 2019 11:47
Bengismo,

That's interesting....bacues when I was literally doing an increimental count to 50,000 as I stated, using a FOR loop C was faster, but only by a factor of about 3. Using an IF check (IF VARIABLE IS LESS THAN 50,000 ADD 1 etc), C was MUCH slower than AGK. It could well be that Visual Studio for some reason isn't optimising the code welll, but that loop is literally all it did...there's almost no scope for any kind of optimisation. And that was a final build.

I am not expecting things such as loading to be faster....or any AppGameKit commands really...my interest lay in your previous post about loops being 60+ times faster, and using that to improve performance in game when cycles through object / units checks for AI etc....but for a speed factor increase of 3 in something which uses a tiny percentage of each frame time anyway I wasn;t sure it was worth the bother.

If you've got an example showing massive imporvements lying around can you share? I did notice that the speed incease in the demo I attached was far less on slower hardware. My PC isn't exactly slow, but the processor is quite old now.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 9th Oct 2019 14:54 Edited at: 9th Oct 2019 15:02
Firstly? Who stated that its 60 times faster? Only you did that and Ive no idea where you got that number from. Ive no idea how you have compiled your C or what exactly you have measured exactly? I dont know if you have debug on or have something else causing slow execution.

Interpreted basic is never going to be as fast as compiled basic or compiled C. The fact that there is an interpreter working out what to make the processor do from the byte code slows it up hugely.

Simple example using this AppGameKit code:



The c code does the same loop using a while loop

while (i<1000000)
{
i++;
c+=i;
}

Gives results something like this:



0.06s vs 0.0003 Id say thats a lot faster. Thast just pure calculations in C....No UI code...no waiting for sync or anything else not related to the actual processing operation.

So to put it simply....it takes Teir 1 agk 197 times longer (197x) to increment and add the same code that can be done in C.

So yeah...its a lot faster. lol...that said....neither of those 2 figures is importantn if your Sync() call takes 400mS... Like I said...its only the logic processing that gets sped up...not the AGK::function calls.

Im not saying AppGameKit teir 1 is slow by anymeans!! The bytecode format and the interpreter are VERY optimal and im often suprised by its speed but it just cant compete with truly compiled code.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 10th Oct 2019 07:54 Edited at: 10th Oct 2019 07:54
Please have a look into this presentation about performance testing

GaborD
6
Years of Service
User Offline
Joined: 3rd Dec 2017
Location:
Posted: 11th Oct 2019 01:02
Agree to what Bengismo said.
If you are doing heavy simulations or pure calculations and want to do them CPU side, sure, definitely worth it.
On the other hand, for typical indie games (especially 3D), probably not worth it. The speed will likely depend on rendering and the GPU.
Unless you are CPU bottlenecked, executing your game logic faster will not improve your overall speed.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 11th Oct 2019 18:35
@GaborD,

how to compile the App Game Kit Tier 1 Basic to the Nintendo Switch, Playstation 4, XBox 360, Xbox One / UWP? Or export them to SNES classic mini, Playstation Classic, MegaDrive / Genesis mini. These micro-consoles, that don't run Raspberian or Android, but capable of running App Game Kit games from the hardware side.
With Tier 2 C++, I guess, it would be possible to compile the game for these machines, if the SDK or Linux provides the underlaying libs, I guess.
EdzUp
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 12th Oct 2019 08:19
There are to many factors to accurately determine if one is faster than the other. Examples would be;
1) drivers - these can affect performance on certain hardware

2)Windows updates or updating in the background

3) the code itself - sometimes the same code can give drastically different results

Whilst C++ is faster most of the time this is also dependent on the compiler, library versions etc
-EdzUp
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 20th Oct 2019 14:13
Bengismo.....apologies, it cant have been you, but theres only a couple of users who generally have that level of knowledge, and someone posted a memblock example and cited the loop ran 60 times faster. I'll try you demo and see what I get.

That's a fascinating video.....but my guess is they are dealing largely with marginal gains, which is why I asked. Rendering speed is good just now but that's all because there is very little game logic so far....past tiles using 100 units with path mapping became ridiculously slow, even with 2d. Its these recursive loops I was interested in seeing speed up - the more I can do per frame CPU side, being limited to a single thread, the more complex I can let the AI be.

But it's also things like swapping out high res models for low res models etc on the fly that need a large amount of objects cycled through quickly that I thought might benefit from T2 speed.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 20th Oct 2019 15:08
SO I ran the two deoms....AGK took 0.113606 seconds (so much slower than your system anyway), and T2 took 0.003894....so T2 was quicker by a factor of 29 times.

Clearly I have some odd visual studio settings (it;s a fresh 2017 download), or your system is just particularly quick.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 20th Oct 2019 17:38 Edited at: 20th Oct 2019 17:43
No worries mate. Id expect to see some difference between systems but was not really expecting that much to be honest as my i5 pc was built in 2014 so is not exactly fast by any shot.

Anyways, the only point I was making was AGK's functions dont increase in speed when used in teir 2. Its really just the C code bits that a user writes that improves dues to not being interpreted. You hit the nail on the head that most speed gains come from simply processing smaller sized resources and not sitting in recursive loops in interpreted basic.

xaby wrote: " did you looked into LoadImage() in Tier 2? I am trying to figure out, how to be able to write a plugIn or another C++ command, to be able to load other types of images or compressed textures. But I guess, my C++ skills are not as high, to find the right spot where and which variables and *pointers I would have to use for that."


I have an AppGameKit plugin that can load a number of image formats. (psd, dds, bmp, jp2, tiff, gif, and a load more...it even has the basis transcoder in it)


But the plugin version just loads the image format and AppGameKit still stores it as 32Bit RGBA data internally (AGK does not pass the image to the GPU as a compressed format)

You would need a modified interpreter (player) to do properly we means recompiling teir 2 and adding a lot of platform specific image handling. Getting the file fomat loaded is fairly easy. You were correct that the cImage class is mainly where to do it, but its also the platform files (windows core) you would have to change as its in there where the data is put in to a gl texture in a compressed format rather than just as completely uncompressed. Its completely doable of course but isnt a small amount of work really and would need a fair bit of testing. Im still not sure why .bmp was removed as a supported format as its one of my faves 9if you dont need small files) and loads fast too.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 20th Oct 2019 20:16
I dont think theres much of a size difference between memblock and bump files though, and they load much faster, especially for larger images. Maybe that's why? Or a licence issue? Either way, I mix images and memblcoks for that very reason. Objects also load about twice as fast from memblocks.

That's a huge difference we get....I have an 8 core AMD processor and 3.5ghz. It's fairly old (2014 or 2015)....but oddly runs most modern games fine. I may try another compiler to check if theres an Intel bias with visual studio. Lol.

I was going to upgrade, but bought a PS4 pro instead for gaming. I think consoles finally have the cost vs performance edge but quite a margin these days, and the next gen will just widen it further of the PS5 is only £500.

Login to post a reply

Server time is: 2024-04-26 23:01:37
Your offset time is: 2024-04-26 23:01:37