[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - sizeof Mystery

sizeof Mystery

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

sizeof Mystery

Postby Baker » Fri May 25, 2012 8:38 am

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: sizeof Mystery

Postby Baker » Fri May 25, 2012 8:45 am

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: sizeof Mystery

Postby taniwha » Fri May 25, 2012 10:48 am

Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: sizeof Mystery

Postby Spike » Fri May 25, 2012 10:50 am

endian is another reason to load byte-by-byte. :P
also, bitfields are far far worse. :P

consider switching the shorts to something like unsigned char colormap_index_lo,colormap_index_hi; and you'll get the verbosity from decent names, as well as a fix for endian issues. If everything in the struct is a char then it'll not be padded to anything bigger than a byte.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: sizeof Mystery

Postby WickedShell » Sat May 26, 2012 12:20 am

Generally struct's should be organized from largest to smallest size of member elements to minimize the amount of trailing/wrapping.

Quake2World gets a ~5 fps boost for 64 bit clients (from 85 to 90 on my machine) by rearranging the order of elements in r_bsp_surface_t to save about 8 bytes total (I forget the before and after sizes, that infos on a different machine), But 32 bit clients see no difference. The FPS gain comes almost completely from reducing cache miss as far as I can tell. (Saved about 500KB of memory total on the worst case map I had on hand.) If someone has a better explanation for why saving 8 bytes created such a difference I'd love to hear it :)

Caveat: Be careful about rearranging all of your structs to minimize memory used. You can do dumb stuff and mess up the copying of common members between structs :) (node and leaf in the Q2 setting for example) Ofc if that screws up your code that badly it might be an indication that you have some really messy code that would benefit from some more love :)

@Spike: Any dislike for going all the way to uint32_t rather then just unsigned int for example? I've been going and using all the stdint.h types since it was pointed out to me that there is only a minimum size associated with unsigned int's and that implementation/platform/compiler specific they could easily be 64 or 128 bit's long on me. (Which would be very surprising in file formats :) ) Alternatively anyone played with the fast types and seen any noticeable differences? IE uint_fast32_t
WickedShell
 
Posts: 24
Joined: Mon Feb 14, 2011 5:16 am

Re: sizeof Mystery

Postby taniwha » Sat May 26, 2012 12:51 am

WickedShell: More than cache, overall memory bandwidth might be the explanation. IIRC, memory controllers always read whole cache lines, so wasted space in a struct will always be read from memory. No wasted space = no wasted reads = faster reading overall.

(u)int32_t etc: I've done a lot of such conversion in QF. Particularly, any new file-format stuff uses it (eg, I modified the iqm structs to use uint32_t etc when I implemented iqm in qf). I haven't played with the fast versions, and don't see much point: int is supposed to be the fastest size for integers, so if speed is needed, use (unsigned) int.
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: sizeof Mystery

Postby Spike » Sat May 26, 2012 7:02 am

the fast stdint types are for machines which do not have 8-bit bytes etc. you won't see a difference on x86+amd64+arm.
there are also machines that only support 32bit bus access (alpha chips), in which case using a 32bit type and masking it to 16bits will often be faster.

stdint.h is a c99 feature, that does not exist on (freshly-installed) msvc, so you'd be making custom typedefs there anyway.
its a useful feature, but personally I'm generally not keen on adding dependancies purely for karma reasons.

tbh, the biggest win with int32_t is that its just a single letter to make it unsigned, instead of an entire extra word. otherwise its just 4 extra letters of verbosity.
I'll probably fix up fte's int specifiers when I try to port it to a machine where it makes a difference, otherwise I'm just gonna stay consistant with what its already using.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 2 guests