Removing Network support?
by Ecliptic · in iTorque 2D · 07/07/2009 (2:08 pm) · 26 replies
I was curious if anyone seen a noticeable increase in loading performance by removing network support. I am currently running the latest iTGB and only utuillizing it's script features and gui. All objects being called through datablocks and I only have about 1mb of images. I am trying to cut down my initial load times because it is starting to self terminating for taking too long.
I have been reading a lot of the suggestions on the forum but I have not had too much success lowering the loading time. I have removed almost everything in the common directory of my game. I am geussing all that is left is going into the source.
Also, when using images that aren't squared, does this increase load time for iTGB to auto correct them? (I would think so).
Thanks guys
Ecliptic
I have been reading a lot of the suggestions on the forum but I have not had too much success lowering the loading time. I have removed almost everything in the common directory of my game. I am geussing all that is left is going into the source.
Also, when using images that aren't squared, does this increase load time for iTGB to auto correct them? (I would think so).
Thanks guys
Ecliptic
#2
07/07/2009 (3:27 pm)
In my defaultpref.cs I got the use network set to false. Should I remove the extra script there though? Or it should be good like this? I am also using the datablocks per level code as well. I need to go back and double check everything then because it just seems like I shouldn't be having this long of a load time. Also do you know if it is increasing load time by not having square images?/// /// Network /// $pref::iPhone::UsesNetwork = false; $pref::Net::LagThreshold = 400; $pref::Net::Port = 28000;
#3
07/07/2009 (5:48 pm)
Check your datablocks.cs in the managed directory. It will frequently get written to by the TGB editor if you ever add/remove an image asset, create a new sprite animation etc.
#4
it will tell the engine to shut down the network again, which as I pointed out above is not working.
It will still be running and still block the cpu with its mutex.
The only way to really shut it is go into the sources and ensure that the network is never initialized.
07/07/2009 (8:56 pm)
Forget the setting, its of no use.it will tell the engine to shut down the network again, which as I pointed out above is not working.
It will still be running and still block the cpu with its mutex.
The only way to really shut it is go into the sources and ensure that the network is never initialized.
#5
My game seems to work perfectly without any of those extra scripts and shaved a few seconds off loading time.
I just use a boolean value based on whether or not it's running on an iPhone device.
07/08/2009 (5:40 am)
What about remarking out all those lines in the common.cs file that someone posted before?//---------------------------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//---------------------------------------------------------------------------------------------
...
// GlobalActionMap doesn't get preference anymore so need special sequence to toggle console.
// This also allows ~ to be used in the console now ;p
if ($runTheExtraStuff) {
GlobalActionMap.bind(keyboard, $Game::ConsoleBind, toggleConsole);
GlobalActionMap.bind(keyboard, $Game::ScreenshotBind, doScreenShot);
GlobalActionMap.bindcmd(keyboard, $Game::FullscreenBind, "toggleFullScreen();","");
}
...
// Common Guis.
if ($runTheExtraStuff) {
exec("~/gui/messageBoxOk.gui");
exec("~/gui/messageBoxYesNo.gui");
exec("~/gui/messageBoxYesNoCancel.gui");
exec("~/gui/messageBoxOKCancel.gui");
exec("~/gui/messageBoxOKCancelDetailsDlg.gui");
exec("~/gui/messagePopup.gui");
exec("~/gui/options.gui");
exec("~/gui/remap.gui");
exec("~/gui/console.gui");
exec("~/gui/NetworkMenu.gui");
exec("~/gui/startServer.gui");
exec("~/gui/joinServer.gui");
exec("~/gui/waitingForServer.gui");
exec("~/gui/helpDlg.gui");
...
// Random Scripts.
exec("./screenshot.cs");
}
exec("./metrics.cs");
if ($runTheExtraStuff) {
exec("./scriptDoc.cs");
exec("./keybindings.cs");
}
exec("./options.cs");
exec("./levelManagement.cs");
exec("./projectManagement.cs");
exec("./projectResources.cs");
exec("./align.cs");
...
//---------------------------------------------------------------------------------------------
// initBaseClient
// Initializes necessary client functionality.
//---------------------------------------------------------------------------------------------
function initBaseClient()
{
// Base client scripts.
if ($runTheExtraStuff) {
exec("./client/client.cs");
exec("./client/message.cs");
exec("./client/serverConnection.cs");
exec("./client/chatClient.cs");
}
}
//---------------------------------------------------------------------------------------------
// initBaseServer
// Initializes necessary server functionality.
//---------------------------------------------------------------------------------------------
function initBaseServer()
{
// Base server scripts.
if ($runTheExtraStuff) {
exec("./server/server.cs");
exec("./server/message.cs");
exec("./server/clientConnection.cs");
exec("./server/kickban.cs");
exec("./server/chatServer.cs");
}
}
...My game seems to work perfectly without any of those extra scripts and shaved a few seconds off loading time.
I just use a boolean value based on whether or not it's running on an iPhone device.
if ($platform $= "iphone") $runTheExtraStuff=false; else $runTheExtraStuff=true;
#6
I've already created a bug report on that. Until then your only option is to alter the sources and really cut it as the network init is done before the console space is initiated which means that at the time the network is initialized right now you don't have any access to any of the config settings.
and instead of the extra stuff you can just use
if( $platform !$= "iphone" )
07/08/2009 (7:51 am)
Start your game with the cpu instruments and you will see that one of the major time consumers is netasyncmutex lock and unlock, although you have disabled network.I've already created a bug report on that. Until then your only option is to alter the sources and really cut it as the network init is done before the console space is initiated which means that at the time the network is initialized right now you don't have any access to any of the config settings.
and instead of the extra stuff you can just use
if( $platform !$= "iphone" )
#7
The gain was AMAZING! I went from a 18second load time (looking in the organizer log) to a 5 second load time.... That is some nice trimming in my opinion :). Well now that I fixed that speed bump I can finally add more content! YEAH!
-Ecliptic
07/08/2009 (3:30 pm)
Wow it is a real shame there is not a way to remove some of the network code quickly and efficiently. I just manually went through and pulled out all the Network code I could find along with the audio streaming stuff that went along with it...The gain was AMAZING! I went from a 18second load time (looking in the organizer log) to a 5 second load time.... That is some nice trimming in my opinion :). Well now that I fixed that speed bump I can finally add more content! YEAH!
-Ecliptic
#8
The audio is a good point.
One thing I would love to see happen is having it either fully replaced with audio sessions or at least having the openal made an optional alternative as it does not make much sense in a 2D environment and that at higher costs than audio sessions from what I recall.
07/08/2009 (4:31 pm)
The network code actually requires a single comment block as you only need to prevent the async net from beeing initialized.The audio is a good point.
One thing I would love to see happen is having it either fully replaced with audio sessions or at least having the openal made an optional alternative as it does not make much sense in a 2D environment and that at higher costs than audio sessions from what I recall.
#9
I'm not sure if OpenAL is a huge drain on resources (it's using the same layer audio sessions are built on, I think), but it would also be something worth investigating.
07/08/2009 (10:35 pm)
Wow,, quadruple speed? That's pretty drastic. I want that to be a part of a real release.I'm not sure if OpenAL is a huge drain on resources (it's using the same layer audio sessions are built on, I think), but it would also be something worth investigating.
#10
If I wanted 3d sound btw I still wouldn't use OpenCrap (that best describes it and the common problem users, including myself, are having with that thing) but license FMod for the iPhone instead.
07/09/2009 (2:11 am)
Possible that it uses the sessions but using sessions directly gives me more control over what and when. Especially I safe the cpu time to calculate 3d positions I don't even need for example.If I wanted 3d sound btw I still wouldn't use OpenCrap (that best describes it and the common problem users, including myself, are having with that thing) but license FMod for the iPhone instead.
#11
Also, what in the source do I comment out to test this for myself?
Thanks.
07/09/2009 (8:48 am)
Just wondering, did this change also affect your frame rate in any way?Also, what in the source do I comment out to test this for myself?
Thanks.
#12
Pretty at the top in initLibraries, just comment out
Additionally I commented out
in the same file in void DemoGame::mainLoop()
Also, if you don't use the accelerometer I would recommend to disable it as well (thats done in the - (id)initWithFrame method in iPhoneOGLVideo.mm )
Even if you would only gain little performance from it, I highly recommend to do them, as they will reduce the energy aside from direct performance benefits.
07/09/2009 (10:48 am)
To disable networking (which gave me a boost of over 15% on the itouch 1st gen), open main.cc in engine/sourcePretty at the top in initLibraries, just comment out
if(!Net::init())
{
Platform::AlertOK("Network Error", "Unable to initialize the network... aborting.");
return false;
}Additionally I commented out
PROFILE_START(NetProcessMain);
Net::process(); // read in all events
PROFILE_END();in the same file in void DemoGame::mainLoop()
Also, if you don't use the accelerometer I would recommend to disable it as well (thats done in the - (id)initWithFrame method in iPhoneOGLVideo.mm )
Even if you would only gain little performance from it, I highly recommend to do them, as they will reduce the energy aside from direct performance benefits.
#13
The accelerometer is in use or I would definitely try that as well.
What exactly is the audio streaming code, could that relate to the difference in load decrease?
07/09/2009 (12:13 pm)
Thanks, I have now commented out the network init code. I did notice a slight load time decrease (15 seconds down to 12 seconds), but nothing as drastic as Ecliptic's 18 seconds into 5 seconds.The accelerometer is in use or I would definitely try that as well.
What exactly is the audio streaming code, could that relate to the difference in load decrease?
#14
I don't use the accelerometer so will comment that one out to!
07/09/2009 (12:18 pm)
Thanks Marc. I'd found the first one and commented it out but not the Net::process() one.I don't use the accelerometer so will comment that one out to!
#15
Also I went into the Common folder of the game project and removed all the extra fonts not being used, cleaned up all datablocks, cleaned all level files, removed all server stuff again, and removed all the editor code that I didn't feel like I needed like the alignment stuff. I think this shaves about 2-3 seconds on its own.
Right now I have added some more images to my game and I am still under 7 seconds. From the moment I hit the app and the console recognizes the game is trying to launch it takes anywhere from 6-7 seconds to get into my game. Before I was above the 20 mark which caused timeout errors and I had less images.
So if you want to do this... I recommend backing up your original build and then do finds on all the things mentioned and slowly trim what you think you need and don't need.
Good luck!
Ecliptic
07/09/2009 (9:28 pm)
I didn't comment anything out. I actually went into the source and removed everything that had to deal with TelDebugger, Net::process, TCP, and server code. I started by doing a find in project search on what Marc said (netasyncmutex) and started from there. There was a handful of files you can remove completely from the whole source and the rest I just removed what ever I could find then build to see what errors I got. I think I had almost 200 errors at first but I just manually went through them and cleaned up the loose ends. Along the way you are bound to start recognizing stuff and see more code that might not be needed for your project like the audio streaming code.Also I went into the Common folder of the game project and removed all the extra fonts not being used, cleaned up all datablocks, cleaned all level files, removed all server stuff again, and removed all the editor code that I didn't feel like I needed like the alignment stuff. I think this shaves about 2-3 seconds on its own.
Right now I have added some more images to my game and I am still under 7 seconds. From the moment I hit the app and the console recognizes the game is trying to launch it takes anywhere from 6-7 seconds to get into my game. Before I was above the 20 mark which caused timeout errors and I had less images.
So if you want to do this... I recommend backing up your original build and then do finds on all the things mentioned and slowly trim what you think you need and don't need.
Good luck!
Ecliptic
#16
I've not completely cut it as I actually plan to use networking at a later point in one or more ways.
Although I'm not sure if this will be torque rpc networking, I actually tend more towards SmartFox as I had a good time in the past with writting extensions for it.
But might be that I will require it for http requests and alike in case I don't find a better solution
07/10/2009 (2:57 am)
Ecliptic, the brute force killer :-)I've not completely cut it as I actually plan to use networking at a later point in one or more ways.
Although I'm not sure if this will be torque rpc networking, I actually tend more towards SmartFox as I had a good time in the past with writting extensions for it.
But might be that I will require it for http requests and alike in case I don't find a better solution
#17
The next best thing is to create a lean iTGB game template. Basically, find the minimum requirements to load your game, and go from there.
07/10/2009 (4:18 am)
I would also go through and cut out as many of the GUI objects you don't need. Every class registered as a ConsoleObject will go through some initialisation when the game starts up, things like linking namespaces, initialising console methods, etc. These all take up time and memory and the GUI is a really good place to start cleaning!The next best thing is to create a lean iTGB game template. Basically, find the minimum requirements to load your game, and go from there.
#18
-Ecliptic
07/10/2009 (9:00 am)
I figured since I have the backup source I could make this client lean for this particular project. I think after I release this game (which should be soon hopefully) I will go through the original client and really plan out what I need for future projects. Right now, networking on the iphone is not something I am capable of or looking to get into. Thus it made a lot of sense for me to go in there and remove anything dealing with it.-Ecliptic
#19
I have a project depending copy, as each project likely will require project specific modifications.
@Phillip: Thanks for the idea. Didn't think about ripping down the GUI.
Its something that I will definitely look into at a later stage when I can for sure which GUI elements aren't used, otherwise its just the fastest way to crash.
Its a good general idea actually as there are many console registered classes that are likely not needed
07/11/2009 (8:15 am)
Oh I have a fully clean iTGB install anyway.I have a project depending copy, as each project likely will require project specific modifications.
@Phillip: Thanks for the idea. Didn't think about ripping down the GUI.
Its something that I will definitely look into at a later stage when I can for sure which GUI elements aren't used, otherwise its just the fastest way to crash.
Its a good general idea actually as there are many console registered classes that are likely not needed
#20
Your advice (-> see above www.garagegames.com/community/forums/viewthread/96437/1#comment-648769) decreased my loading time from 8 down to 3 seconds.
09/25/2009 (9:58 am)
Thank you, Marc :)Your advice (-> see above www.garagegames.com/community/forums/viewthread/96437/1#comment-648769) decreased my loading time from 8 down to 3 seconds.
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
This is especially a problem with the initial loading as it loads all datablocks.
There are threads on how to take appart the initial loading and also a working script to replace 1 global datablock repository with level based datablocks, which will help quite a bit with the initial load time.
Removing network does not help in the load time. But you can get better framerates if you ensure that the network is never initialized (there seems to be a bug at the time that prevents it from closing correctly again), at least I did