Store sequence numbers more compactly

Store them and ef_type in bit-fields.

Allocate eight bits for ef_type.  Values range from 0 to EF_GAME
(currently 16), so this is plenty.

Allocate twelve bits for sequence numbers.  Sequence number mismatches
are now missed when the numbers are equal modulo 2^12.  Still
sufficiently improbable.

Common machines store the bit-fields in a 32 bit word.  There are
twelve bits left in that word for future use.  Total savings 16 bits,
which is exactly what the previous commit spent on wider uids on
common machines.
This commit is contained in:
Markus Armbruster 2009-12-31 10:30:54 +01:00
parent ba2044be18
commit 358aee203e
15 changed files with 33 additions and 34 deletions

View file

@ -55,9 +55,9 @@ struct empobj {
* initial part must match struct emptypedstr
* valid if EFF_TYPED is set in table's flags
*/
short ef_type;
signed ef_type: 8;
unsigned seqno: 12;
int uid;
unsigned seqno;
time_t timestamp;
/* end of part matching struct emptypedstr */
natid own; /* valid if EFF_OWNER is in table's flags */
@ -76,7 +76,6 @@ struct empobj {
};
union empobj_storage {
short ef_type;
struct empobj gen;
struct comstr comm;
struct gamestr game;