lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [lwip-users] IP Address Display Functions


From: Bill Auerbach
Subject: RE: [lwip-users] IP Address Display Functions
Date: Thu, 3 Sep 2009 11:41:14 -0400

>I find it interesting that this makes a difference.

Me too. Only from studying the compiler output from much of lwIP was able to
see inefficient patterns that I thought I could try to improve upon.

GCC (for the NIOS II) was taking ip_addr and using 4 byte reads with 3
shifts and 4 ANDs and 4 Ors to get the ip_addr.  Packing by 2 used 2 loads,
1 shift and one OR.  As much as ip_addr is used, it made a big improvement
on TCP sending.  There are no byte fields in TCP headers we don't manually
handle in code, so I saw no place where packing by 2 was going to be a
problem.  I would think if it were the stack would die hard.

>If both work, then
>the structures must be suitably packed in both cases.  If there is a
>performance difference then the compiler must be accessing the fields
>differently I suppose.  I.e. it sounds to me like your compiler is
>reading more into packed directives than it needs to (perhaps to make
>things simpler for it): it is affecting both the packing of the
>structure and the way it accesses the fields in that structure.

I don't know about that - pack 1 means the item could be on any byte
boundary.  When used as a local variable, it will be properly aligned (all
compilers align stack-variables), and when used in an IP header it is never
not u16-aligned (by definition of the IP header itself).

Bill






reply via email to

[Prev in Thread] Current Thread [Next in Thread]