Re: Ip::Address performance

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Sat, 20 Nov 2010 13:51:48 +1300

On 20/11/10 09:04, Pieter De Wit wrote:
> Hey Guys,
>
> I am joining the thread a bit late and I might miss a few things, but
> wouldn't this be a simple solution:
>
> (From memory, this is pretty close to the "union" one Alex suggested)
>
> NB : There is a very very small chance that an IPv6 address can be
> converted into an IPv4 address, from memory, it's the 2001:: addresses,
> but we can google that to confirm.

Yes there are localhost, v4-mapped, teredo, DS-LITE and some other
cone-NAT addressing syntax which can convert between protocols from the
IP alone.

However, localhost is the only one Squid needs to touch on, and that rarely.
  The others are only ever touched when copying/cloning the address from
one place to another. So we do not have to store two simultaneously.

>
> * We have a struct that contains both the IPv4 and IPv6 struct
> * When an IPv4 address is needed, it's stored in the IPv4 struct (same
> with IPv6)
> * If we have an IPv4 address and we need to return an IPv6 address the
> conversion is done once, then the result is stored in the struct (IMO, a
> simple 'if (struct.we_have_ipv6==1) ...' should do the trick
>
> The other side of this is that we have 3 methods for returning the address:
>
> * Get_IPv6 ();
> * Get_IPv4 ();
> * Get_IP ();
>
> The purpose of 'Get_IP ()' is so that we can retrieve what we need, with
> a simple command and not really care about what is stored. As an example:
>
> * if we only have an IPv6 address for someone, Get_IP will return that,
> otherwise IPv4, or an error if we have nothing.
> * if we have both IPv4 and 6, and we can use both, then for the time, we
> "prefer" IPv4, and we return that
> * Get_IPv4 will return an error if the IPv6 address can't be converted
> (but really, I can't see the need for this, just covering bases)
>
> IPv6 is gaining speed, but it's not as well connected as we would have
> like to see. The point is that squid, imho, should still default to the
> IPv4 address. There can be factors that change this (config file/checks
> at startup - like no ipv4 address ?/etc), but these will only effect
> 'Get_IP' and the checks are 'light' or limited startup/config re-read code.

We have this all Get stuff now in the form of parameter-typed Get*()
methods. The v4/v6 structure types being requested determines the output
or error.
The problem is the inefficient implementations. The current v4-mapped
storage format is effectively but sub-optimally storing both v6 and v4
addresses simultaneously for all possible addresses. Permitting
cost-free updates and alterations (expenditure is all in output conversion).

Amos

-- 
Please be using
   Current Stable Squid 2.7.STABLE9 or 3.1.9
   Beta testers wanted for 3.2.0.3
Received on Sat Nov 20 2010 - 00:51:56 MST

This archive was generated by hypermail 2.2.0 : Sat Nov 20 2010 - 12:00:05 MST