Reputation: 3734
I am using a 64bit machine
When using the structure
typedef struct node{
unsigned int p; //4 bytes
struct node* next;//8bytes
}Node;
//sizeof(Node) is 16 bytes
I know that this is due to structure padding. If I use structure packing using
typedef struct __attribute__((__packed__))
//sizeof(Node) is 12 bytes
Should I expect any performance degradation using packing or is it system dependent?
Compiler is gcc (GCC) 4.4.7
I have tested my code with packed and unpacked structure and there doesn't seem to be any difference in the performance.
Upvotes: 1
Views: 112
Reputation: 34145
That's not a lot of information. The answer will also depends on your Node allocation strategy, on whether you embed the node in your data or store it separately, on how big your cache lines are, what kind of work you do, etc.
Measure your runtime with and without packing (in your specific application) - you'll have the answer.
Upvotes: 2