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.

DarkBASIC Professional Discussion / DBP random fps drops?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Oct 2012 23:36
Hey guys

This is something that's really starting to annoy me. At random times, DarkBASIC Pro will decide to start taking really long to render everything. In the following screen shot you will see the sync timer (marked with a red arrow).

The program was running with 40 units at 90 fps in my machine, and the sync timer was never over 4000.

Then suddenly, out of nowhere, it jumps up to over 20'000 and stays there, dropping the fps to 30. The code for this measurement is as follows:



Here is the screen shot : http://0xff.avxc.net/stuff/fuuu.png

Can anyone tell me why DBP does this? Is it doing some buffering of some kind in the background?

TheComet

"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Oct 2012 02:56
Are you using animated models that are "in step" with each other? I believe DBPro uses a rather crude way of finding out which animation frame it should be using each sync for each animated object.

If the objects are animating out of step then you might not have a noticeable problem since some will be in a slow part of the animation and others will be in a fast part (in terms of processing speed not object movement).
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 6th Oct 2012 05:04 Edited at: 6th Oct 2012 05:19
1. You need to take a hard look at everything happening inside of that sync timer.

2. You also might have some problems outside of the timer, such as culling being completely disabled everywhere on extremely rare scenarios due to possible bugs, so check all culling routines. The fact that a "world timer" is also high seems to imply the problem could be related to culled objects.

3. You might be using a 2D graphic function somewhere, even in an extremely rare scenario. This can produce rapid reduction in frame rate.

4. The sound system is linked to sync in some small ways. I am aware that things like listener position changes seem to update only when sync is called not when the actual movement command is used. There could be more to this.

5. You may be having issues with texture memory. If the game needed to move a lot of texture memory on the hardware level, this can produce a noticeable lag. Some of the textures being used may be sitting in RAM and not VRAM. This may be caused by having too little VRAM on the video card. Try reducing textures, or to debug, tie everything to the same texture. Also check your shaders, to see if you are doing anything periodically that causes a massive reload of some kind.

6. Some other process on your computer might be taking to many resources on rare instances, causing bottlenecks in performance. An excellent example would be an Anti-Virus intercepting file access of your program, and taking too much time.

7. I see you have the beginnings of one of those fancy 3D map/radar hud things. The additional camera, or radar/map itself might be in some way causing this. Try completely disabling this feature, including the extra camera, and any and all supporting code.

david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 6th Oct 2012 07:59
It sounds to me like you need to do some code profiling. Put timers around code blocks and see were your real performance issues are.
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 6th Oct 2012 10:24
Are you using vsync per-chance? If the frame rate dropped even a little below 60 it would then be locked down to 30 (my understanding at least) which sounds like it could be very easily your issue as it is the sync command which would then be 'waiting' behind the scenes before allowing the program to continue.


Previously TEH_CODERER.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Oct 2012 00:19 Edited at: 7th Oct 2012 00:20
Quote: "Are you using animated models that are "in step" with each other? I believe DBPro uses a rather crude way of finding out which animation frame it should be using each sync for each animated object."


I'm not entirely sure if I understand what you are saying. I wrote my own functions to handle the animations so I had more control over their timings. I never use the commands play object or stop object, instead I use a variable called frame# which increments and decrements manually, and I update the unit's frames with set object frame frame#.

Also note that the units are all using a fastbone shader.

Quote: "1. You need to take a hard look at everything happening inside of that sync timer."


There's not much to look "inside" of the sync timer, because this is the code:



Quote: "2. You also might have some problems outside of the timer, such as culling being completely disabled everywhere on extremely rare scenarios due to possible bugs, so check all culling routines. The fact that a "world timer" is also high seems to imply the problem could be related to culled objects."


The world timer is high because it controls the Fog of War updates. More technical information on that can be found here : http://www.youtube.com/watch?v=43AmR6XiV80

Quote: "3. You might be using a 2D graphic function somewhere, even in an extremely rare scenario. This can produce rapid reduction in frame rate."


I'm using image kit to render 2D images. Again, even if images would be the problem, it doesn't explain why the frame rate suddenly drops.

Quote: "4. The sound system is linked to sync in some small ways. I am aware that things like listener position changes seem to update only when sync is called not when the actual movement command is used. There could be more to this."


Currently no sounds in PonyCraft yet.

Quote: "5. You may be having issues with texture memory. If the game needed to move a lot of texture memory on the hardware level, this can produce a noticeable lag. Some of the textures being used may be sitting in RAM and not VRAM. This may be caused by having too little VRAM on the video card. Try reducing textures, or to debug, tie everything to the same texture. Also check your shaders, to see if you are doing anything periodically that causes a massive reload of some kind.

6. Some other process on your computer might be taking to many resources on rare instances, causing bottlenecks in performance. An excellent example would be an Anti-Virus intercepting file access of your program, and taking too much time."


I ran this on a nVidia GTX 580 (1500 MB VRAM) so I doubt that's the problem, but I'll check into that.

Quote: "7. I see you have the beginnings of one of those fancy 3D map/radar hud things. The additional camera, or radar/map itself might be in some way causing this. Try completely disabling this feature, including the extra camera, and any and all supporting code."


The minimap is just an image, no extra camera used.

Quote: "It sounds to me like you need to do some code profiling. Put timers around code blocks and see were your real performance issues are. "


Screen shot does just that.

Quote: "Are you using vsync per-chance? If the frame rate dropped even a little below 60 it would then be locked down to 30 (my understanding at least) which sounds like it could be very easily your issue as it is the sync command which would then be 'waiting' behind the scenes before allowing the program to continue."


Nope, vsync is disabled and sync rate is uncapped. Everything in the game is handled with timer based movement.

TheComet

"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 7th Oct 2012 01:40
I'm more going with what Green Gandalf is saying about the animations. If you have multiple animations on the characters 'all in sync', then the tweening between the frames (calculating the new meshes per object) can cause a bottle-neck. I'm wondering if it's possible to 'instance' the objects to maybe speed things up a little, however even that wouldn't do much to cut the bottle-neck down.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Oct 2012 17:18
So if I make sure that no models have the same frame at any point in time, that should be able to determine if it is the issue?

TheComet

"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Oct 2012 20:53
Hopefully.

This problem with animated models was raised a while back and it seems that, in certain circumstances, DBPro does a linear search through the model's frames each sync till it finds the right ones for interpolation. If that is indeed what happens then it would have the effect that the animation gradually slows down as it works through the frames. You then get a sudden speedup when a looping animation returns to the beginning. I guess that for simple models with only a few frames then this effect wouldn't be noticeable but it might with a more complex object or animation or many copies of a simple object animating in unison. If you can spread out the frames over the objects then each sync you'll be getting a more stable average effect. This assumes I've remembered the issue correctly.

I'll try to find the original discussion and post the link here.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Oct 2012 21:00
And this is the case, even when you're using a fastbone shader?

TheComet

"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Oct 2012 21:12
Here's the thread:

progressive lag in animated models

The relevant discussion is given by IanM some way down the thread. IanM said he wasn't familiar with all the details going on behind the scenes - but he has a much clearer idea than I do.

Quote: "And this is the case, even when you're using a fastbone shader?"


I assume so. The bone shader is just a fast way of manipulating the bone matrices - your present issue is caused I suspect by the way DBPro calculates the matrices in the first place before passing them to the shader. As IanM notes, there should be a faster way of doing the search.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 8th Oct 2012 05:41
Just to throw something into the discussion:

Enhanced Animations

Perhaps this might fix the issue?

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 8th Oct 2012 22:06
Well, after some extensive tests on multiple computers I have come to a conclusion.

It is not DBP's fault, it is my laptop's fault. All desktop computers run it fine with no random slowdowns, so I'm assuming my laptop decreases the clock frequency of the GPU when it starts getting too hot.

Sure enough, MSI Afterburner reveals just that.

So thanks everyone for your help! I would never have thought this could be the cause... Oh well, you live and learn!

TheComet

"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Oct 2012 23:08
Sounds like you've stolen my old laptop. If you have you can keep it.

Glad you identified the problem. Sounds like the other issues were not that important.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 8th Oct 2012 23:11
Thanks for posting a followup.

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 9th Oct 2012 06:09
Could also be a program in the background using the CPU or accessing the hard drive at intervals.

Chenak
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 9th Oct 2012 18:04
I would buy enhanced animations, it's a huge performance saver especially for multiple animated objects
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 9th Oct 2012 23:56 Edited at: 10th Oct 2012 00:10
Here's a solution, if it's a heat issue:

Frame Limiter:
Limit your frame rate with a frame rate limiter to say 30fps (you said you were normally at 90fps). Heat levels should drop around 40-60%.



Having a frame limiter can suck if you don't need it, so build in a global variable that can turn it off or on (for a possible options menu) like this:



I see you are using a high precision timer plugin, so you will want to adjust this code to use that timer instead. What I posted above is crude but it gets the job done. A high precision timer will make it easier to avoid over and under shooting the desired frame rate. I would also recommend digging up that "nicer sleep" method that lets the CPU go completely idle also.

Why:
Sync will take the same time to execute as your usual 90fps, but will effectively happen less often. This will increase the time the card is idle. The GPU is almost only working during sync. This gives it way more time to idle and cool off. This will almost certainly have an immediate and massive effect in reducing heat. Therefore, you won't overheat causing the computer to slow itself down to compensate.

This is only effective if your frame rate is higher than 30, and yours is you said 90fps.

Edit: I would favor this method over setting a sync rate of 30. I would also favor more complicated methods like combining the frame limiter with decoupling the screen drawing from the main/game loop as this allows you to process game-play instead of sleep/wait.

Login to post a reply

Server time is: 2026-07-07 19:10:56
Your offset time is: 2026-07-07 19:10:56