Strongly Recommanded Modification to GG about GhostInfo.updateMask
by Huan Li · in Torque 3D Professional · 06/13/2009 (2:41 am) · 9 replies
For optimizting net transitions, Torque use MaskBits, they are appears in NetObject::mDirtyMaskBits and GhostInfo::updateMask.
Then the GhostInfo's updateMask will be passed to the following method as param "mask":
An U32 type of mask only has 32bits, it's inadequate for huge complicated data structure to be efficiently transmited over net.
Make the mask a flexible structure or class will be good to suit the situation above. But this will effect a lot of mess in current Torque's net transmition.
So I strongely recommand GG to do this modification for us GG's customers.
I think this modification won't change the engine architecture, so i think it's better to let GG to do this:)
Then the GhostInfo's updateMask will be passed to the following method as param "mask":
SubClassOfNetObject::packUpdate(NetConnection* conn, U32 mask, BitStream* stream)
An U32 type of mask only has 32bits, it's inadequate for huge complicated data structure to be efficiently transmited over net.
Make the mask a flexible structure or class will be good to suit the situation above. But this will effect a lot of mess in current Torque's net transmition.
So I strongely recommand GG to do this modification for us GG's customers.
I think this modification won't change the engine architecture, so i think it's better to let GG to do this:)
#2
Are you profiling your network usage to make sure you are being as efficient as possible? A lot of the time you can group uncommon things into one big mask - you waste a little bandwidth when they need to update but since they change so rarely, it doesn't matter.
edit: It would be nice of GG to typedef that U32, though, so you can easily change to a U64 or a structure, though.
06/13/2009 (10:56 am)
If you have 64 masks, you're raising the base size of your object updates by quite a bit. IE 64bits minimum unless you are doing something clever like Picasso says.Are you profiling your network usage to make sure you are being as efficient as possible? A lot of the time you can group uncommon things into one big mask - you waste a little bandwidth when they need to update but since they change so rarely, it doesn't matter.
edit: It would be nice of GG to typedef that U32, though, so you can easily change to a U64 or a structure, though.
#3
06/13/2009 (11:06 am)
Also of note as I have this in our tracker as we have hit that 32 limit is that most of the child classes will start their flags at the end of the previous classes's flags. While there might only be 4 or 5 flags in a single class, once you add them all up hitting 32 isn't all that difficult.
#4
Actually the updated infos is something like a tree structure, So is it better to have a tree structure-like maskbits?
06/14/2009 (8:07 am)
I still insist on my point!Actually the updated infos is something like a tree structure, So is it better to have a tree structure-like maskbits?
#5
06/14/2009 (8:20 am)
I like Ben's idea of making a typedef for the net mask. it should default to U32, but then it woud be easy to change to a U64 if necessary.
#6
To this day, without going in and writing pure assembly code, a bitmask test is still one of the fasted operations you can do at the C++ source code level--and the entire networking system is based on being able to apply dozens to low hundreds of updates to client side objects per tick--which is only 32 milliseconds.
Stipulating that more bitmask values are needed for expandability reasons (I've run into this myself in the past on personal projects), a move to a non-maximally performant test is still not the best solution.
Also stipulating Ben Garney's observation that moving from 32 bit to 64 bit increases the general size of objects significantly, it's still a better option than implementing a system that is based on a different big O for update applications.
06/14/2009 (12:50 pm)
To bring up history, this has been debated in the past--and even with the increase in general computing power for the mass market, blithely changing from a bitmask to a more complex structure has a significant (and I mean very large) performance impact.To this day, without going in and writing pure assembly code, a bitmask test is still one of the fasted operations you can do at the C++ source code level--and the entire networking system is based on being able to apply dozens to low hundreds of updates to client side objects per tick--which is only 32 milliseconds.
Stipulating that more bitmask values are needed for expandability reasons (I've run into this myself in the past on personal projects), a move to a non-maximally performant test is still not the best solution.
Also stipulating Ben Garney's observation that moving from 32 bit to 64 bit increases the general size of objects significantly, it's still a better option than implementing a system that is based on a different big O for update applications.
#7
06/14/2009 (12:53 pm)
One more observation--bitmask availability is reduced heavily by deriving classes from ShapeBase, or even worse, Player. Unless your target class simply must have everything that both ShapeBase and Player provide functionality wise, you should strongly consider inheriting from GameBase directly.
#8
If you reached the bitmask limit, this means you surpassed the intended purpose of the example classes (aka: anything below GameBase), and thus it is time to roll your own classes (deriving from GameBase or even from SceneObject directly). You're only hurting your game by having all the ShapeBase and Player stuff hogging your network.
I feel obligated to remind Torque is a game engine, not a game maker. The major difference between the two being that in game engines are meant to be modified to suit your game.
If you really need to have a whole lot of flags for your object, I think you can use a BitVector to store them and send them using stream->writeBits().
06/15/2009 (6:06 am)
I agree with Stephen. If you reached the bitmask limit, this means you surpassed the intended purpose of the example classes (aka: anything below GameBase), and thus it is time to roll your own classes (deriving from GameBase or even from SceneObject directly). You're only hurting your game by having all the ShapeBase and Player stuff hogging your network.
I feel obligated to remind Torque is a game engine, not a game maker. The major difference between the two being that in game engines are meant to be modified to suit your game.
If you really need to have a whole lot of flags for your object, I think you can use a BitVector to store them and send them using stream->writeBits().
#9
06/15/2009 (2:02 pm)
I know that internally we've taken care not to derive from ShapeBase or GameBase unless its a clear win. You'll notice alot of the new classes derive directly from SceneObject to avoid the overhead.
Torque Owner Ivan Mandzhukov
Liman3D
You can combine a few masks in a single mask.
You can check for unused masks in parent classes.
I can't believe you reached the limit, your object should be huge.
I think there is a resource for 64 bit mask.