High CPU usage with RakNet
Hi, I''m just wondering what cpu usage you get when using RakNet. For me, the examples included in the zip takes about 0-2% cpu before RakNet is initialized and after that it goes up to 99%. So I''m wondering if you have the same problem? I''ve asked around, both on the RakNet forum and other gamedev sites but no one seems to know what might be wrong. Do you have any tips on what might cause it? I''m not using high priority threads, and I''ve tried to put a few Sleep()s in there, but it doesn''t take care of the problem.
Any tips are welcomed!
Super Sportmatchen - A retro multiplayer competitive sports game project!
You''d be better posting this on the RakNet forums. The guy who developed RakNet should be able to help.
---------------------http://www.stodge.net
As I wrote I already tried that, you can find the post here. He gave some tips but none of them really helped. I didn''t bother with this before because my game is fullscreen etc so it didn''t really matter if it took 99%. But now I''ve created a dedicated server which should use as little cpu as possible.
I''m just wondering if someone is experiencing the same thing or has any tips on what might cause it (like different build settings, windows settings etc). I''m not asking you to be the RakNet support.
I''m just wondering if someone is experiencing the same thing or has any tips on what might cause it (like different build settings, windows settings etc). I''m not asking you to be the RakNet support.

Super Sportmatchen - A retro multiplayer competitive sports game project!
In my server I have it running at a 30fps currently, in my main loop I do this one time:
Sleep( 1000 / server.FramesPerSecond);
This will wait until it''s time for the next frame. It''s setup to do frameskipping, but I will add a system that tracks how long the current frame took, and if I should sleep or not.
Anyhow the admin on that Rak website told you to sleep for 15 - 100, and I thought it would be important to say.
Sleep( 1000 / server.FramesPerSecond);
This will wait until it''s time for the next frame. It''s setup to do frameskipping, but I will add a system that tracks how long the current frame took, and if I should sleep or not.
Anyhow the admin on that Rak website told you to sleep for 15 - 100, and I thought it would be important to say.
Yea I know... but he also said that 15 (which is default) should be good for an action-oriented game. I''ve tried to Sleep() for everything between 0 and 100 but it doesn''t help. The thing is also that other people are not getting this problem, so I''m starting to believe that it''s my computer/Windows that''s borked.
Super Sportmatchen - A retro multiplayer competitive sports game project!
If you are using low priority threads (priority 0) and you have Sleep(30) and it doesn''t help then try putting a Sleep in RecvFromNetworkLoop. That is the only other thread running, as long as you are not using IO completion ports. It''s also important to note if the thread usage is affecting your game or not. It could be your OS is counting Sleep time as CPU usage. If that is the case, then you would have 100% usage no matter how long the Sleep time was yet your performance would not be affected at all.
Are you running on a single CPU machine ? Maybe your main thread is starving the network one ? Another possibility is that you''re running your client and server programs on the same machine, in which case if the client is the "active" window, it can starve the server, or vice-versa. I''ve seen weird things with multi-processes or multi-threads under Win2K and WinXP.
Y.
Y.
my guess is that you aren''t sleeping in another thread that you should be...
put a sleep in both the raknet thread and the actual game thred.
Kent
put a sleep in both the raknet thread and the actual game thred.
Kent
--------------------Kent's Amazing Cross Compilable Hello World Program!
#include #define print printf #define caller void main(){ #define ref } caller ; print ("Hello World!n"); ref;
quote:
Original post by Kent767
my guess is that you aren''t sleeping in another thread that you should be...
put a sleep in both the raknet thread and the actual game thred.
Kent
Second that.
--
You''re Welcome,
Rick Wong
- Google | Google for GameDev.net | GameDev.net''s DirectX FAQ. (not as cool as the Graphics and Theory FAQ)
Hi again, sorry for the wait but I was away on vacation.
Thanks for all tips I''ll try to answer them all, though I might miss out on something.
The main thing is that I''m not only getting high cpu usage with my game but also with all the examples that come with RakNet. I''ve tried both my game and the RakNet examples on two other computers, getting the same result. However I''ve heard from other RakNet users that they are not getting high cpu usage. So the idea about putting Sleep()s here and there would do no good right?
As for if the high cpu usage harms the performance I''m not really sure, though I believe it is. I have to test this a bit though.
I''m running on a hyperthreaded Pentium 4 machine. And it doesn''t matter if I run both the client and server on the same machine, I get high cpu usages anyway.
In my game I have a simple main menu screen that meets the user when she starts the game. Now, if I don''t initialize RakNet the game running in menu mode takes 0% cpu time. Though if I initialize RakNet it takes lots more cpu (~99%), even if I''m not connected nor sending any messages. This is using low priority threads.. It''s just weird.
I''m wondering if the problem might be in the .dll that I''m using? Would switching .dll/.lib make any difference? I haven''t created my own .dll as is suggested by the manual, I just took the one that came with the hangman example. Anyway, thanks for all the help and I hope you got some more tips for me, as I''m totally clueless.
Thanks for all tips I''ll try to answer them all, though I might miss out on something.
The main thing is that I''m not only getting high cpu usage with my game but also with all the examples that come with RakNet. I''ve tried both my game and the RakNet examples on two other computers, getting the same result. However I''ve heard from other RakNet users that they are not getting high cpu usage. So the idea about putting Sleep()s here and there would do no good right?
As for if the high cpu usage harms the performance I''m not really sure, though I believe it is. I have to test this a bit though.
I''m running on a hyperthreaded Pentium 4 machine. And it doesn''t matter if I run both the client and server on the same machine, I get high cpu usages anyway.
In my game I have a simple main menu screen that meets the user when she starts the game. Now, if I don''t initialize RakNet the game running in menu mode takes 0% cpu time. Though if I initialize RakNet it takes lots more cpu (~99%), even if I''m not connected nor sending any messages. This is using low priority threads.. It''s just weird.
I''m wondering if the problem might be in the .dll that I''m using? Would switching .dll/.lib make any difference? I haven''t created my own .dll as is suggested by the manual, I just took the one that came with the hangman example. Anyway, thanks for all the help and I hope you got some more tips for me, as I''m totally clueless.
Super Sportmatchen - A retro multiplayer competitive sports game project!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement